Ignore:
Timestamp:
06/01/05 16:55:14 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/templates/overview.tpl:

  • Cosmetic HTML change

web/addons/toga/index.php:

  • Added Joblist filter tree text

web/addons/toga/overview.php:

  • Setup clusterimage filter

web/addons/toga/image.php:

  • Added filter handling

web/addons/toga/libtoga.php:

File:
1 edited

Legend:

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

    r117 r122  
    334334class NodeImage {
    335335
    336         var $image, $x, $y, $hostname, $jobs, $tasks;
     336        var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo;
    337337
    338338        function NodeImage( $hostname ) {
     
    345345                $this->hostname = $hostname;
    346346                $this->cpus = $this->determineCpus();
     347                $this->showinfo = 1;
    347348        }
    348349
     
    400401        }
    401402
     403        function getHostname() {
     404                return $this->hostname;
     405        }
     406
    402407        function getJobs() {
    403408                return $this->jobs;
    404409        }
    405410
     411        function setShowinfo( $showinfo ) {
     412                $this->showinfo = $showinfo;
     413        }
     414
    406415        function draw() {
    407416
    408                 global $SMALL_CLUSTERIMAGE_NODEWIDTH, $JOB_NODE_MARKING_ALLCPUS, $JOB_NODE_MARKING_SINGLECPU;
     417                $this->drawSmall();
     418        }
     419
     420        function drawBig() {
     421
     422        }
     423
     424        function drawSmall() {
     425
     426                global $SMALL_CLUSTERIMAGE_NODEWIDTH;
    409427                global $JOB_NODE_MARKING;
    410428
    411                 $this->load = $this->determineLoad();
    412 
    413                 if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) {
    414                         printf( "aborting\n" );
    415                         printf( "x %d y %d load %f\n", $this->x, $this->y, $load );
    416                         return;
    417                 }
    418 
    419429                $black_color = imageColorAllocate( $this->image, 0, 0, 0 );
    420 
    421                 // Convert Ganglias Hexadecimal load color to a Decimal one
    422                 //
    423                 $load = $this->determineLoad();
    424                 $my_loadcolor = $this->colorHex( load_color($load) );
    425 
    426430                $size = $SMALL_CLUSTERIMAGE_NODEWIDTH;
    427431
    428432                imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color );
    429                 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor );
    430 
    431                 $nr_jobs = count( $this->jobs );
    432 
    433                 $node_mark = null;
    434 
    435                 if( count( $this->jobs ) > 0 )
    436                         $node_mark = $JOB_NODE_MARKING;
    437 
    438                 //      if( $this->tasks < $this->cpus )
    439                 //              $node_mark = $JOB_NODE_MARKING_SINGLECPU;
    440 
    441                 //      else if( $this->tasks == $this->cpus )
    442                 //              $node_mark = $JOB_NODE_MARKING_ALLCPUS;
    443 
    444                 if( $node_mark )
    445                         imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $node_mark, $black_color );
     433
     434                if( $this->showinfo) {
     435               
     436                        $this->load = $this->determineLoad();
     437
     438                        if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) {
     439                                printf( "aborting\n" );
     440                                printf( "x %d y %d load %f\n", $this->x, $this->y, $load );
     441                                return;
     442                        }
     443
     444
     445                        // Convert Ganglias Hexadecimal load color to a Decimal one
     446                        //
     447                        $load = $this->determineLoad();
     448                        $usecolor = $this->colorHex( load_color($load) );
     449                        imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor );
     450                        if( count( $this->jobs ) > 0 )
     451                                imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $JOB_NODE_MARKING, $black_color );
     452
     453                } else {
     454
     455                        // White
     456                        $usecolor = imageColorAllocate( $this->image, 255, 255, 255 );
     457                        imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor );
     458                }
     459
     460
    446461        }
    447462
     
    470485
    471486        var $dataget, $image, $clustername;
    472 
    473         function ClusterImage( $clustername, $data_gather ) {
    474 
    475                 if( !isset( $data_gather ) )
    476                         $this->dataget = new DataGatherer();
    477                 else
    478                         $this->dataget = $data_gather;
    479 
     487        var $filtername, $filtervalue;
     488
     489        function ClusterImage( $clustername ) {
     490
     491                $this->dataget = new DataGatherer();
    480492                $this->clustername = $clustername;
     493                $this->filtername = null;
     494                $this->filtervalue = null;
     495        }
     496
     497        function setFilter( $filtername, $filtervalue ) {
     498
     499                //printf( "filter set to %s = %s\n", $filtername, $filtervalue );
     500                $this->filtername = $filtername;
     501                $this->filtervalue = $filtervalue;
     502        }
     503
     504        function filterNodes( $jobs, $nodes ) {
     505
     506                $filtered_nodes = array();
     507
     508                foreach( $nodes as $node ) {
     509
     510                        $mynjobs = $node->getJobs();
     511                        $hostname = $node->getHostname();
     512
     513                        if( $this->filtername ) {
     514                                foreach( $mynjobs as $myjob )
     515
     516                                        if( $this->filtername == 'jobid' && $node->hasJob( $this->filtervalue) )
     517                                                $filtered_nodes[] = $hostname;
     518                                        else if( $jobs[$myjob][$this->filtername] == $this->filtervalue  && !in_array( $hostname, $filtered_nodes  ) )
     519                                                $filtered_nodes[] = $hostname;
     520                        } else
     521                                $filtered_nodes[] = $hostname;
     522                }
     523
     524                return $filtered_nodes;
    481525        }
    482526
     
    526570                imageFill( $image, 0, 0, $colorwhite );
    527571
     572                $jobs = $mydatag->getJobs();
     573                //printf("filtername = %s\n", $filtername );
     574                $filtered_nodes = $this->filterNodes( $jobs, $nodes );
     575
     576                //print_r($filtered_nodes);
     577
    528578                for( $n = 0; $n < $node_rows; $n++ ) {
    529579                       
     
    536586                                $host = $nodes_hosts[$cur_node];
    537587
     588
    538589                                if( isset( $nodes[$host] ) ) {
    539590
    540591                                        $nodes[$host]->setCoords( $x, $y );
    541592                                        $nodes[$host]->setImage( $image );
     593
     594                                        if( !in_array( $host, $filtered_nodes ) )
     595                                                $nodes[$host]->setShowinfo( 0 );
     596
    542597                                        $nodes[$host]->draw();
    543598                                }
Note: See TracChangeset for help on using the changeset viewer.