Changeset 582 for trunk


Ignore:
Timestamp:
02/04/09 13:51:28 (15 years ago)
Author:
ramonb
Message:

job_monarch/libtoga.php:

  • fixed clusterimage filtering

job_monarch/image.php:

  • code cleanup
Location:
trunk/web2/addons/job_monarch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web2/addons/job_monarch/image.php

    r563 r582  
    2828include_once "./libtoga.php";
    2929
    30 if ( !empty( $_GET ) ) {
     30if ( !empty( $_GET ) )
     31{
    3132        extract( $_GET );
    3233}
    3334
    34 function checkSessionData() {
    35 
     35function checkSessionData()
     36{
    3637        global $_SESSION;
    3738
    3839        session_start();
    3940
    40         if( isset( $_SESSION["data"] ) ) {
    41                 $myxml_data     = &$_SESSION["data"];
    42         } else {
     41        if( isset( $_SESSION['data'] ) )
     42        {
     43                $myxml_data     = &$_SESSION['data'];
     44        }
     45        else
     46        {
    4347                $myxml_data     = 0;
    4448        }
     
    4852                $myxml_data     = $ds->getData();
    4953
    50                 //print_f( "%s\n", $myxml_data );
    5154        }
    5255        return $myxml_data;
     
    5457
    5558
    56 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
    57 $view = $httpvars->getHttpVar( "view" );
    58 $host = $httpvars->getHttpVar( "host" );
    59 $query = $httpvars->getHttpVar( "query" );
    60 $clustername = $httpvars->getClusterName();
     59$httpvars       = new HTTPVariables( $HTTP_GET_VARS, $_GET );
     60$view           = $httpvars->getHttpVar( "view" );
     61$host           = $httpvars->getHttpVar( "host" );
     62$query          = $httpvars->getHttpVar( "query" );
     63$clustername    = $httpvars->getClusterName();
    6164
    62 if( isset($jid) && ($jid!='')) $filter[jid]=$jid;
    63 if( isset($state) && ($state!='')) $filter[state]=$state;
    64 if( isset($owner) && ($owner!='')) $filter[owner]=$owner;
    65 if( isset($queue) && ($queue!='')) $filter[queue]=$queue;
    66 if( isset($host) && ($host!='')) $filter[host]=$host;
    67 if( isset($query) && ($query!='')) $filter[query]=$query;
    68 //printf("host = %s\n", $filter[host] );
     65if( isset($jid) && ($jid!='')) $filter['jid']=$jid;
     66if( isset($state) && ($state!='')) $filter['state']=$state;
     67if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
     68if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
     69if( isset($host) && ($host!='')) $filter['host']=$host;
     70if( isset($query) && ($query!='')) $filter['query']=$query;
    6971
    7072function drawHostImage() {
     
    8082
    8183        if( $data_gatherer->isJobmonRunning() )
     84        {
    8285                $ic = new HostImage( $data_gatherer, $clustername, $hostname );
     86        }
    8387        else
     88        {
    8489                $ic = new EmptyImage();
     90        }
    8591
    8692        $ic->draw();
     
    98104        $data_gatherer->parseXML( $myxml_data );
    99105
    100         if( $data_gatherer->isJobmonRunning() ) {
     106        if( $data_gatherer->isJobmonRunning() )
     107        {
    101108                $ic = new ClusterImage( $myxml_data, $clustername );
    102109                $ic->setSmall();
    103         } else {
     110        }
     111        else
     112        {
    104113                $ic = new EmptyImage();
    105114        }
     
    117126        $ic->setBig();
    118127
    119         if( isset( $filter ) ) {
    120                 foreach( $filter as $filtername=>$filtervalue ) {
    121                         //printf("filter %s,%s\n", $filtername, $filtervalue);
    122                         switch( $filtername ) {
    123 
    124                                 case "jid":
    125                                         $ic->setFilter( 'jobid', $filtervalue );
    126                                         break;
    127                                 case "owner":
    128                                         $ic->setFilter( 'owner', $filtervalue);
    129                                         break;
    130                                 case "queue":
    131                                         $ic->setFilter( 'queue', $filtervalue);
    132                                         break;
    133                                 case "state":
    134                                         $ic->setFilter( 'status', $filtervalue);
    135                                         break;
    136                                 case "host":
    137                                         $ic->setFilter( 'host', $filtervalue);
    138                                         break;
    139                                 case "query":
    140                                         $ic->setFilter( 'query', $filtervalue);
    141                                         break;
    142                                 default:
    143                                         break;
    144                         }
     128        if( isset( $filter ) )
     129        {
     130                foreach( $filter as $filtername=>$filtervalue )
     131                {
     132                        $ic->setFilter( $filtername, $filtervalue );
    145133                }
    146134        }
  • trunk/web2/addons/job_monarch/libtoga.php

    r578 r582  
    14021402                $filtered_nodes = array();
    14031403
     1404                $filter_checks  = array();
     1405
    14041406                foreach( $nodes as $node )
    14051407                {
    1406                         $hostname = $node->getHostname();
    1407 
    1408                         $addhost = 1;
    1409 
    1410                         if( count( $this->filters ) > 0 )
    1411                         {
    1412                                 $mynjobs = $node->getJobs();
    1413 
    1414                                 if( $filtername == 'host' && $hostname == $filtervalue )
    1415                                 {
    1416                                         $addhost        = 1;
    1417                                         $this->selected = $hostname;
    1418                                 }
    1419                                 else if( count( $mynjobs ) > 0 )
    1420                                 {
    1421                                         foreach( $mynjobs as $myjob )
    1422                                         {
    1423                                                 foreach( $this->filters as $filtername => $filtervalue )
    1424                                                 {
    1425                                                         if( $filtername!=null && $filtername!='' )
     1408                        $hostname       = $node->getHostname();
     1409                        $mynjobs        = $node->getJobs();
     1410
     1411                        foreach( $this->filters as $filtername => $filtervalue )
     1412                        {
     1413                                $filter_checks[$filtername] = false;
     1414                        }
     1415
     1416                        if( array_key_exists( 'host', $this->filters ) )
     1417                        {
     1418                                if( $hostname == $this->filters['host'] )
     1419                                {
     1420                                        $this->selected         = $hostname;
     1421                                        $filtered_nodes[] = $hostname;
     1422                                        //$filter_checks['host']        = true;
     1423                                }
     1424                        }
     1425
     1426                        if( count( $mynjobs ) == 0 )
     1427                        {
     1428                                continue;
     1429                        }
     1430
     1431                        foreach( $mynjobs as $myjob )
     1432                        {
     1433                                foreach( $this->filters as $filtername => $filtervalue )
     1434                                {
     1435                                        if( $filtername == 'jid' )
     1436                                        {
     1437                                                if( $myjob == $filtervalue )
     1438                                                {
     1439                                                        $filter_checks['jid'] = true;
     1440                                                }
     1441                                        }
     1442                                        if( $filtername == 'query' )
     1443                                        {
     1444                                                foreach( $jobs[$myjob] as $myj_attr => $myj_val )
     1445                                                {
     1446                                                        if( is_array( $myj_val ) )
    14261447                                                        {
    1427                                                                 if( $filtername == 'jobid' )
     1448                                                                foreach( $myj_val as $myj_v )
    14281449                                                                {
    1429                                                                         if ( $myjob != $filtervalue )
     1450                                                                        if( strpos( $myj_v, $filtervalue ) !== false )
    14301451                                                                        {
    1431                                                                                 $addhost = 0;
    1432                                                                                 break;
    1433                                                                         }
    1434                                                                         else
    1435                                                                         {
    1436                                                                                 $addhost = 1;
    1437                                                                                 break;
    1438                                                                         }
    1439                                                                 }
    1440                                                                 else
    1441                                                                 {
    1442                                                                         if( $jobs[$myjob][$filtername] == $filtervalue )
    1443                                                                         {
    1444                                                                                 $addhost = 1;
    1445                                                                                 continue;
    1446                                                                         }
    1447                                                                         else if( $jobs[$myjob][$filtername] != $filtervalue )
    1448                                                                         {
    1449                                                                                 $addhost = 0;
    1450                                                                         }
    1451                                                                         if( $filtername == 'query' )
    1452                                                                         {
    1453                                                                                 foreach( $jobs[$myjob] as $myj_attr => $myj_val )
    1454                                                                                 {
    1455                                                                                         if(!is_array( $myj_val ) )
    1456                                                                                         {
    1457                                                                                                 if( strpos( $myj_val, $filtervalue ) !== false )
    1458                                                                                                 {
    1459                                                                                                         $addhost = 1;
    1460                                                                                                         continue;
    1461                                                                                                 }
    1462                                                                                         }
    1463                                                                                         else
    1464                                                                                         {
    1465                                                                                                 foreach( $myj_val as $myj_v )
    1466                                                                                                 {
    1467                                                                                                         if( strpos( $myj_v, $filtervalue ) !== false )
    1468                                                                                                         {
    1469                                                                                                                 $addhost = 1;
    1470                                                                                                                 continue;
    1471                                                                                                         }
    1472                                                                                                 }
    1473                                                                                         }
    1474                                                                                         if( strpos( $myjob, $filtervalue ) !== false )
    1475                                                                                         {
    1476                                                                                                 $addhost        = 1;
    1477                                                                                                 continue;
    1478                                                                                         }
    1479                                                                                 }
     1452                                                                                $filter_checks['query'] = true;
    14801453                                                                        }
    14811454                                                                }
    14821455                                                        }
    1483                                                 }
    1484                                         }
    1485                                 }
    1486                                 else
    1487                                 {
    1488                                         $addhost = 0;
    1489                                 }
    1490                         }
    1491 
    1492                         if( $addhost )
     1456                                                        else
     1457                                                        {
     1458                                                                if( strpos( $myj_v, $filtervalue ) !== false )
     1459                                                                {
     1460                                                                        $filter_checks['query'] = true;
     1461                                                                }
     1462                                                        }
     1463                                                }
     1464                                        }
     1465                                        if( $filtername != 'host' )
     1466                                        {
     1467                                                if( $jobs[$myjob][$filtername] == $filtervalue )
     1468                                                {
     1469                                                        $filter_checks[$filtername] = true;
     1470                                                }
     1471                                        }
     1472                                }
     1473                        }
     1474
     1475                        $addhost        = true;
     1476
     1477                        foreach( $filter_checks as $c_filtername => $c_filterfound )
     1478                        {
     1479                                if( ! $c_filterfound )
     1480                                {
     1481                                        $addhost        = false;
     1482                                }
     1483                        }
     1484
     1485                        if( $addhost == true )
    14931486                        {
    14941487                                $filtered_nodes[] = $hostname;
Note: See TracChangeset for help on using the changeset viewer.