Ignore:
Timestamp:
04/24/07 00:41:54 (17 years ago)
Author:
bastiaans
Message:

web/addons/job_monarch/libtoga.php:

  • fixed per-cluster settings
  • changed node sorting algorythm to handle when only one of x or y is set
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/libtoga.php

    r337 r339  
    10611061                global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH;
    10621062                global $BIG_CLUSTERIMAGE_MAXWIDTH, $BIG_CLUSTERIMAGE_NODEWIDTH;
    1063                 global $CLUSTER_CONFS;
    1064 
    1065                 //global $SORTBY_HOSTNAME, $SORT_ORDER, $skan_str;
    1066                 global $skan_str;
     1063                global $CLUSTER_CONFS, $confcluster;
     1064
     1065                global $SORTBY_HOSTNAME, $SORT_ORDER, $skan_str;
     1066                //global $skan_str;
    10671067                global $x_first, $y_first;
    10681068
    10691069                foreach( $CLUSTER_CONFS as $confcluster => $conffile )
    10701070                {
    1071                         if( strtolower( $this->clustername ) == $confcluster )
    1072                         {
     1071                        //printf( "cf %s cc %s\n", $this->clustername, $confcluster);
     1072                        //printf( "cf %s cc %s\n", strtolower( trim($this->clustername)), trim($confcluster) );
     1073                        if( strtolower( trim($this->clustername) ) == strtolower(trim($confcluster)) )
     1074                        {
     1075                                //printf( "cf %s cc %s\n", $conffile, $confcluster);
    10731076                                include_once $conffile;
    10741077                        }
    10751078                }
    10761079
    1077                 global $SORTBY_HOSTNAME, $SORT_ORDER;
    1078                 global $SORT_XLABEL, $SORT_YLABEL;
     1080                //global $SORTBY_HOSTNAME, $SORT_ORDER;
     1081                //global $SORT_XLABEL, $SORT_YLABEL;
    10791082       
     1083                //printf( "SORTBY_HOSTNAME %s SORT_YLABEL %s\n", $SORTBY_HOSTNAME, $SORT_YLABEL );
     1084
    10801085                $mydatag = $this->dataget;
    10811086                $mydatag->parseXML( $this->data );
     
    11491154                        $y_first        = 0;
    11501155
    1151 
    1152                         if( strpos( $SORTBY_HOSTNAME, "{x}" ) < strpos( $SORTBY_HOSTNAME, "{y}" ) )
     1156                        $skan_str       = $SORTBY_HOSTNAME;
     1157
     1158                        global $x_present, $y_present;
     1159                        $x_present      = false;
     1160                        $y_present      = false;
     1161
     1162                        if(stripos( $SORTBY_HOSTNAME, "{x}" ) != false )
     1163                        {
     1164                                $x_present      = true;
     1165                        }
     1166                        if(stripos( $SORTBY_HOSTNAME, "{y}" ) != false )
     1167                        {
     1168                                $y_present      = true;
     1169                        }
     1170
     1171                        if(( strpos( $SORTBY_HOSTNAME, "{x}" ) < strpos( $SORTBY_HOSTNAME, "{y}" ) ) && ( $x_present && $y_present ))
    11531172                        {
    11541173                       
    11551174                                $x_first        = 1;
    11561175                        }
    1157                         else
     1176                        else if(( strpos( $SORTBY_HOSTNAME, "{x}" ) > strpos( $SORTBY_HOSTNAME, "{y}" ) ) && ( $x_present && $y_present ))
    11581177                        {
    11591178                                $y_first        = 1;
    11601179               
    11611180                        }
    1162 
    1163                         $skan_str       = str_replace( "{x}", "%d", $SORTBY_HOSTNAME );
    1164                         $skan_str       = str_replace( "{y}", "%d", $skan_str );
     1181                        else if( $x_present )
     1182                        {
     1183                                $x_first        = 1;
     1184                        }
     1185                        else if( $y_present )
     1186                        {
     1187                                $y_first        = 1;
     1188                        }
     1189
     1190                        if(( $x_first ) && ( $x_present && $y_present ) )
     1191                        {
     1192                                $skan_str       = str_replace( "{x}", "%d", $skan_str );
     1193                                $skan_str       = str_replace( "{y}", "%d", $skan_str );
     1194                                //printf("ppoep = %s\n", $skan_str);
     1195                        }
     1196                        else if( $x_present)
     1197                        {
     1198                                $skan_str       = str_replace( "{x}", "%d", $skan_str );
     1199                        }
     1200                        else if( $y_present)
     1201                        {
     1202                                $skan_str       = str_replace( "{y}", "%d", $skan_str );
     1203                        }
    11651204
    11661205                        $x_min          = null;
     
    11711210                        foreach( $nodes as $hostname => $node )
    11721211                        {
    1173                                 //$n    = sscanf( $hostname, $skan_str, $i, $j );
    1174                                 if( $x_first )
     1212                                $x      = 0;
     1213                                $y      = 0;
     1214
     1215                                if( $x_present && $y_present )
    11751216                                {
    1176                                         $n = sscanf( $hostname, $skan_str, $x, $y );
    1177                                 }
    1178                                 else if( $y_first )
     1217                                        //$n    = sscanf( $hostname, $skan_str, $i, $j );
     1218                                        if( $x_first )
     1219                                        {
     1220                                                $n = sscanf( $hostname, $skan_str, $x, $y );
     1221                                        }
     1222                                        else if( $y_first )
     1223                                        {
     1224                                                $n = sscanf( $hostname, $skan_str, $y, $x );
     1225                                        }
     1226                                        // Remove nodes that don't match
     1227                                        //
     1228                                        if( $n < 2 )
     1229                                        {
     1230                                                unset( $nodes[$hostname] );
     1231                                        }
     1232                                }
     1233                                else if( $x_present && !$y_present )
    11791234                                {
    1180                                         $n = sscanf( $hostname, $skan_str, $y, $x );
    1181                                 }
     1235                                        $n = sscanf( $hostname, $skan_str, $x );
     1236                                        // Remove nodes that don't match
     1237                                        //
     1238                                        if( $n < 1 )
     1239                                        {
     1240                                                unset( $nodes[$hostname] );
     1241                                        }
     1242                                        $y      = 1;
     1243                                }
     1244                                else if( $y_present && !$x_present )
     1245                                {
     1246                                        $n = sscanf( $hostname, $skan_str, $y );
     1247                                        // Remove nodes that don't match
     1248                                        //
     1249                                        if( $n < 1 )
     1250                                        {
     1251                                                unset( $nodes[$hostname] );
     1252                                        }
     1253                                        $x      = 1;
     1254                                }
     1255                                //printf( "xfirst %s yfirst %s\n", $x_first, $y_first );
    11821256
    11831257                                //printf( "n %s\n", $n );
    11841258
    1185                                 // Remove nodes that don't match
    1186                                 //
    1187                                 if( $n < 2 )
    1188                                 {
    1189                                         unset( $nodes[$hostname] );
    1190                                 }
    11911259
    11921260                                if( !$x_min )
     
    12261294                        //printf( "ss %s\n", $skan_str);
    12271295                        $sorted_nodes   = usort( $nodes, "cmp" );
     1296
     1297                        //print_r( $nodes );
    12281298
    12291299                        $cur_node       = 0;
     
    12751345                        }
    12761346
    1277                         if( $this->isBig() )
     1347                        if( $this->isBig() && ( isset( $SORT_XLABEL ) || isset( $SORT_YLABEL ) ) )
    12781348                        {
    12791349                                $colorblue      = imageColorAllocate( $image, 0, 0, 255 );
    12801350
    1281                                 imageString( $image, $font, $x_offset, $fontspaceing, $SORT_XLABEL, $colorblue );
    1282 
    1283                                 // Stupid php without imageStringDown function
    1284                                 //
    1285                                 imageStringDown( $image, $font, $fontspaceing, $y_offset, $SORT_YLABEL, $colorblue );
     1351                                if( isset( $SORT_XLABEL ) )
     1352                                {
     1353                                        imageString( $image, $font, $x_offset, $fontspaceing, $SORT_XLABEL, $colorblue );
     1354                                }
     1355
     1356                                if( isset( $SORT_YLABEL ) )
     1357                                {
     1358                                        // Stupid php without imageStringDown function
     1359                                        //
     1360                                        imageStringDown( $image, $font, $fontspaceing, $y_offset, $SORT_YLABEL, $colorblue );
     1361                                }
    12861362                        }
    12871363
     
    13031379                                                $host   = $nodes[$cur_node]->getHostname();
    13041380
    1305                                                 if( $x_first )
     1381                                                if( $x_present && $y_present )
    13061382                                                {
    1307                                                         $nn = sscanf( $host, $skan_str, $rx, $ry );
     1383                                                        if( $x_first )
     1384                                                        {
     1385                                                                $nn = sscanf( $host, $skan_str, $rx, $ry );
     1386                                                        }
     1387                                                        else if( $y_first )
     1388                                                        {
     1389                                                                $nn = sscanf( $host, $skan_str, $ry, $rx );
     1390                                                        }
     1391                                                        if ( $nn < 2 )
     1392                                                        {
     1393                                                                continue;
     1394                                                        }
     1395                                                        if( ( $rx ) > $n )
     1396                                                        {
     1397                                                                $m      = $y_max + 1;
     1398                                                                continue;
     1399                                                        }
    13081400                                                }
    1309                                                 else if( $y_first )
     1401                                                else if( $x_present )
    13101402                                                {
    1311                                                         $nn = sscanf( $host, $skan_str, $ry, $rx );
     1403                                                        $nn = sscanf( $host, $skan_str, $rx );
    13121404                                                }
    1313                                                 if ( $nn < 2 )
     1405                                                else if( $y_present )
    13141406                                                {
    1315                                                         continue;
    1316                                                 }
    1317                                                 if( ( $rx ) > $n )
    1318                                                 {
    1319                                                         $m      = $y_max + 1;
    1320                                                         continue;
     1407                                                        $nn = sscanf( $host, $skan_str, $ry );
    13211408                                                }
    13221409
     
    13361423                                        if( $this->isBig() )
    13371424                                        {
    1338                                                 if( $n == $x_min )
     1425                                                if(( $n == $x_min ) && ( isset($SORT_YLABEL) ) )
    13391426                                                {
    13401427                                                        $mfontspacing   = 1;
     
    13441431                                                        imageString( $image, $font, $ylabel_x, $ylabel_y, strval( $m ), $colorblue );
    13451432                                                }
    1346                                                 if( $m == $y_min )
     1433                                                if(( $m == $y_min ) && ( isset($SORT_XLABEL) ) )
    13471434                                                {
    13481435                                                        $mfontspacing   = 2;
     
    16451732        global $skan_str;
    16461733        global $x_first, $y_first;
    1647 
     1734        global $x_present, $y_present;
     1735
     1736        //printf("ppoep = %s\n", $skan_str);
    16481737        $a_node         = $a;
    16491738        $b_node         = $b;
     
    16531742        if( $a == $b ) return 0;
    16541743
    1655         if( $x_first )
     1744        $a_x            = 0;
     1745        $b_x            = 0;
     1746        $a_y            = 0;
     1747        $b_y            = 0;
     1748
     1749        if( $x_present && $y_present )
    16561750        {
    1657                 $n = sscanf( $a, $skan_str, $a_x, $a_y );
    1658                 $n = sscanf( $b, $skan_str, $b_x, $b_y );
    1659         }
    1660         else if( $y_first )
     1751                if( $x_first )
     1752                {
     1753                        $n = sscanf( $a, $skan_str, $a_x, $a_y );
     1754                        $n = sscanf( $b, $skan_str, $b_x, $b_y );
     1755                }
     1756                else if( $y_first )
     1757                {
     1758                        $n = sscanf( $a, $skan_str, $a_y, $a_x );
     1759                        $n = sscanf( $b, $skan_str, $b_y, $b_x );
     1760                }
     1761        }
     1762        else if( $x_present && !$y_present )
    16611763        {
    1662                 $n = sscanf( $a, $skan_str, $a_y, $a_x );
    1663                 $n = sscanf( $b, $skan_str, $b_y, $b_x );
     1764                $n = sscanf( $a, $skan_str, $a_x );
     1765                $n = sscanf( $b, $skan_str, $b_x );
     1766        }
     1767        else if( $y_present && !$x_present )
     1768        {
     1769                $n = sscanf( $a, $skan_str, $a_y );
     1770                $n = sscanf( $b, $skan_str, $b_y );
    16641771        }
    16651772
     
    16671774        {
    16681775
    1669                 // 1  = a < b
    1670                 // -1 = a > b
    1671                 //
    1672                 if ($a_x == $b_x)
     1776                if( $x_present && $y_present )
     1777                {
     1778                        // 1  = a < b
     1779                        // -1 = a > b
     1780                        //
     1781                        if ($a_x == $b_x)
     1782                        {
     1783                                if ($a_y < $b_y)
     1784                                {
     1785                                        return 1;
     1786                                }
     1787                                else if ($a_y > $b_y)
     1788                                {
     1789                                        return -1;
     1790                                }
     1791                        }
     1792                        else if ($a_x < $b_x)
     1793                        {
     1794                                return 1;
     1795                        }
     1796                        else if ($a_x > $b_x)
     1797                        {
     1798                                return -1;
     1799                        }
     1800                }
     1801                else if( $x_present && !$y_present )
     1802                {
     1803                        if ($a_x < $b_x)
     1804                        {
     1805                                return 1;
     1806                        }
     1807                        else if ($a_x > $b_x)
     1808                        {
     1809                                return -1;
     1810                        }
     1811                }
     1812                else if( $y_present && !$x_present )
    16731813                {
    16741814                        if ($a_y < $b_y)
     
    16811821                        }
    16821822                }
    1683                 else if ($a_x < $b_x)
    1684                 {
    1685                         return 1;
    1686                 }
    1687                 else if ($a_x > $b_x)
    1688                 {
    1689                         return -1;
    1690                 }
    16911823        }
    16921824        else if ( $SORT_ORDER == "asc" )
    16931825        {
    16941826
    1695                 // 1  = a > b
    1696                 // -1 = a < b
    1697                 //
    1698                 if ($a_x == $b_x)
     1827                if( $x_present && $y_present )
     1828                {
     1829                        // 1  = a > b
     1830                        // -1 = a < b
     1831                        //
     1832                        if ($a_x == $b_x)
     1833                        {
     1834                                if ($a_y > $b_y)
     1835                                {
     1836                                        return 1;
     1837                                }
     1838                                else if ($a_y < $b_y)
     1839                                {
     1840                                        return -1;
     1841                                }
     1842                        }
     1843                        else if ($a_x > $b_x)
     1844                        {
     1845                                return 1;
     1846                        }
     1847                        else if ($a_x < $b_x)
     1848                        {
     1849                                return -1;
     1850                        }
     1851                }
     1852                else if( $x_present && !$y_present )
     1853                {
     1854                        if ($a_x > $b_x)
     1855                        {
     1856                                return 1;
     1857                        }
     1858                        else if ($a_x < $b_x)
     1859                        {
     1860                                return -1;
     1861                        }
     1862                }
     1863                else if( $y_present && !$x_present )
    16991864                {
    17001865                        if ($a_y > $b_y)
     
    17061871                                return -1;
    17071872                        }
    1708                 }
    1709                 else if ($a_x > $b_x)
    1710                 {
    1711                         return 1;
    1712                 }
    1713                 else if ($a_x < $b_x)
    1714                 {
    1715                         return -1;
    17161873                }
    17171874        }
Note: See TracChangeset for help on using the changeset viewer.