Ignore:
Timestamp:
03/25/13 18:49:23 (11 years ago)
Author:
ramonb
Message:
  • more speedup attempts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/web/addons/job_monarch/libtoga.php

    r748 r749  
    609609        $this->offline_nodes    = array();
    610610        $this->clustername    = $clustername;
     611        $this->proc_cluster = null;
    611612        $this->fqdn        = 1;
    612613    }
     
    694695    function startElement( $parser, $name, $attrs )
    695696    {
    696         $jobs = $this->jobs;
    697         $nodes = $this->nodes;
    698697
    699698        if( isset( $attrs['TN'] ) )
     
    704703                if ( $attrs['TN'] > $attrs['TMAX'] * 4 )
    705704                {
    706                     return;
     705                    return null;
    707706                }
    708707            }
     
    714713        {
    715714            $this->proc_cluster = $attrs['NAME'];
    716         }
    717         else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
     715            //printf("set proc cluster to %s\n", $attrs['NAME'] );
     716            return null;
     717        }
     718        if( $this->proc_cluster != $this->clustername )
     719        {
     720            //printf("cluster does not match: %s\n", $this->clustername );
     721            return null;
     722        }
     723
     724        if( $name == 'HOST' )
    718725        {
    719726            $hostname = $attrs['NAME'];
    720727
    721             $location = $attrs['LOCATION'];
    722 
    723             if( !isset( $nodes[$hostname] ) )
    724             {
    725                 $nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname );
    726             }
    727         }
    728         else if( $name == 'METRIC' and ( strpos( $attrs['NAME'], 'zplugin_monarch' ) !== false ) and $this->proc_cluster == $this->clustername )
     728            //printf( "host %s\n", $hostname );
     729            //$location = $attrs['LOCATION'];
     730
     731            if( !isset( $this->nodes[$hostname] ) )
     732            {
     733                $this->nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname );
     734            }
     735            return null;
     736        }
     737        if( $name == 'METRIC' and ( strpos( $attrs['NAME'], 'zplugin_monarch' ) !== false ) )
    729738        {
    730739            if( strpos( $attrs['NAME'], 'zplugin_monarch_heartbeat' ) !== false )
    731740            {
    732741                $this->heartbeat['time'] = $attrs['VAL'];
     742                return;
    733743            }
    734744            else if( strpos( $attrs['NAME'], 'zplugin_monarch_down' ) !== false )
     
    767777                    }
    768778                }
     779                return;
    769780            }
    770781            else if( strpos( $attrs['NAME'], 'zplugin_monarch_offline' ) !== false )
     
    803814                    }
    804815                }
     816                return;
    805817            }
    806818            else if( strpos( $attrs['NAME'], 'zplugin_monarch_job' ) !== false )
     
    808820                sscanf( $attrs['NAME'], 'zplugin_monarch_job_%d_%s$', $monincr, $jobid );
    809821
    810                 if( !isset( $jobs[$jobid] ) )
    811                 {
    812                     $jobs[$jobid] = array();
     822                if( !isset( $this->jobs[$jobid] ) )
     823                {
     824                    $this->jobs[$jobid] = array();
    813825                }
    814826
     
    824836                    if( $toganame == 'nodes' )
    825837                    {
    826                         if( $jobs[$jobid]['status'] == 'R' )
     838                        if( $this->jobs[$jobid]['status'] == 'R' )
    827839                        {
    828                             if( !isset( $jobs[$jobid][$toganame] ) )
     840                            if( !isset( $this->jobs[$jobid][$toganame] ) )
    829841                            {
    830                                 $jobs[$jobid][$toganame] = array();
     842                                $this->jobs[$jobid][$toganame] = array();
    831843                            }
    832844
     
    835847                            foreach( $mynodes as $node )
    836848                            {
    837                                 if( !in_array( $node, $jobs[$jobid][$toganame] ) )
     849                                if( !in_array( $node, $this->jobs[$jobid][$toganame] ) )
    838850                                {
    839                                     array_push( $jobs[$jobid][$toganame], $node );
     851                                    array_push( $this->jobs[$jobid][$toganame], $node );
    840852                                }
    841853                            }
    842854
    843855                        }
    844                         else if( $jobs[$jobid]['status'] == 'Q' )
     856                        else if( $this->jobs[$jobid]['status'] == 'Q' )
    845857                        {
    846                             $jobs[$jobid][$toganame] = $togavalue;
     858                            $this->jobs[$jobid][$toganame] = $togavalue;
    847859                        }
    848860                    }
    849861                    else
    850862                    {
    851                         $jobs[$jobid][$toganame] = $togavalue;
     863                        $this->jobs[$jobid][$toganame] = $togavalue;
    852864                    }
    853865                }
    854866
    855                 if( isset( $jobs[$jobid]['nodes'] ) )
    856                 {
    857                     $nr_nodes = count( $jobs[$jobid]['nodes'] );
     867                if( isset( $this->jobs[$jobid]['nodes'] ) )
     868                {
     869                    $nr_nodes = count( $this->jobs[$jobid]['nodes'] );
    858870       
    859                     if( $jobs[$jobid]['status'] == 'R' )
     871                    if( $this->jobs[$jobid]['status'] == 'R' )
    860872                    {
    861873
    862                         if( isset( $jobs[$jobid]['domain'] ) )
     874                        if( isset( $this->jobs[$jobid]['domain'] ) )
    863875                        {
    864                             $domain        = $jobs[$jobid]['domain'];
     876                            $domain        = $this->jobs[$jobid]['domain'];
    865877                            $domain_len    = 0 - strlen( $domain );
    866878
    867                             $nodekeys     = array_keys( $nodes );
     879                            $nodekeys     = array_keys( $this->nodes );
    868880
    869881                            $first_host    = $nodekeys[0];
     
    880892                        }
    881893
    882                         foreach( $jobs[$jobid]['nodes'] as $node )
     894                        foreach( $this->jobs[$jobid]['nodes'] as $node )
    883895                        {
    884896
    885897                            // Only add domain name to the hostname if Ganglia is doing that too
    886898                            //
    887                             if( $this->fqdn && isset( $jobs[$jobid]['domain'] ) )
     899                            if( $this->fqdn && isset( $this->jobs[$jobid]['domain'] ) )
    888900                            {
    889901                                if( strpos( $node, $domain ) === false )
     
    900912                            }
    901913
    902                             if( !isset( $nodes[$host] ) )
     914                            if( !isset( $this->nodes[$host] ) )
    903915                            {
    904916                                $my_node = new NodeImage( $this->proc_cluster, $host );
     
    906918                            else
    907919                            {
    908                                 $my_node = $nodes[$host];
     920                                $my_node = $this->nodes[$host];
    909921                            }
    910922
     
    921933                            }
    922934
    923                             $nodes[$host] = $my_node;
     935                            $this->nodes[$host] = $my_node;
    924936                        }
    925937                    }
    926938                }
    927939            }
    928         }
    929         $this->jobs    = $jobs;
    930         $this->nodes    = $nodes;
     940            return;
     941        }
    931942    }
    932943
Note: See TracChangeset for help on using the changeset viewer.