Changeset 646 for trunk


Ignore:
Timestamp:
08/26/09 12:15:10 (15 years ago)
Author:
ramonb
Message:

job_monarch/templates/header.tpl:

job_monarch/image.php:

  • cache XML data during jobmond's polling interval

job_monarch/jobstore.php:

  • cache XML data during jobmond's polling interval
  • set host link

job_monarch/js/monarch.js:

  • small changes to nodes popup window
Location:
trunk/web/addons/job_monarch
Files:
4 edited

Legend:

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

    r582 r646  
    3333}
    3434
    35 function checkSessionData()
    36 {
    37         global $_SESSION;
    38 
    39         session_start();
    40 
    41         if( isset( $_SESSION['data'] ) )
    42         {
    43                 $myxml_data     = &$_SESSION['data'];
    44         }
    45         else
    46         {
    47                 $myxml_data     = 0;
    48         }
    49 
    50         if( !$myxml_data ) {
    51                 $ds             = new DataSource();
    52                 $myxml_data     = $ds->getData();
    53 
    54         }
    55         return $myxml_data;
    56 }
    57 
     35function makeSession()
     36{
     37        $ds             = new DataSource();
     38        $myxml_data     = &$ds->getData();
     39
     40        unset( $_SESSION['data'] );
     41
     42        $_SESSION['data']               = &$myxml_data;
     43        $_SESSION['gather_time']        = time();
     44}
     45
     46global $session_active, $_SESSION, $myxml_data;
     47
     48function checkSessionPollInterval( $poll_interval )
     49{
     50        global $session_active, $_SESSION;
     51
     52        if( ! session_active )
     53        {
     54                return 0;
     55        }
     56
     57        if( isset( $_SESSION['poll_interval'] ) )
     58        {
     59                if( $poll_interval <> $_SESSION['poll_interval'] )
     60                {
     61                        $_SESSION['poll_interval']      = $poll_interval;
     62                }
     63        }
     64        else
     65        {
     66                $_SESSION['poll_interval']      = $poll_interval;
     67        }
     68
     69        session_write_close();
     70
     71        $session_active = false;
     72}
     73
     74function checkSession()
     75{
     76        global $session_active, $_SESSION;
     77
     78        session_start();
     79
     80        $session_active         = true;
     81
     82        // I got nothing; create session
     83        //
     84        if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
     85        {
     86                makeSession();
     87
     88                return 0;
     89        }
     90
     91        if( isset( $_SESSION['poll_interval'] ) )
     92        {
     93                $gather_time    = $_SESSION['gather_time'];
     94                $poll_interval  = $_SESSION['poll_interval'];
     95
     96                $cur_time       = time();
     97
     98                // If poll_interval time elapsed since last update; recreate session
     99                //
     100                if( ($cur_time - $gather_time) >= $poll_interval )
     101                {
     102                        makeSession();
     103
     104                        return 0;
     105                }
     106        }
     107}
     108
     109checkSession();
     110$myxml_data     = &$_SESSION['data'];
     111session_write_close();
    58112
    59113$httpvars       = new HTTPVariables( $HTTP_GET_VARS, $_GET );
     
    70124if( isset($query) && ($query!='')) $filter['query']=$query;
    71125
    72 function drawHostImage() {
    73 
     126$data_gatherer  = new DataGatherer( $clustername );
     127$data_gatherer->parseXML( &$myxml_data );
     128
     129function drawHostImage()
     130{
    74131        global $clustername, $hostname, $data_gatherer;
    75132
    76         $ds             = new DataSource();
    77         $myxml_data     = $ds->getData();
    78 
    79         $data_gatherer  = new DataGatherer( $clustername );
    80 
    81         $data_gatherer->parseXML( $myxml_data );
    82 
    83133        if( $data_gatherer->isJobmonRunning() )
    84134        {
     
    93143}
    94144
    95 function drawSmallClusterImage() {
    96 
    97         global $clustername, $data_gatherer;
    98 
    99         $ds             = new DataSource();
    100         $myxml_data     = $ds->getData();
    101 
    102         $data_gatherer  = new DataGatherer( $clustername );
    103 
    104         $data_gatherer->parseXML( $myxml_data );
     145function drawSmallClusterImage()
     146{
     147        global $clustername, $data_gatherer, $myxml_data;
    105148
    106149        if( $data_gatherer->isJobmonRunning() )
     
    117160}
    118161
    119 function drawBigClusterImage() {
    120 
    121         global $filter, $clustername;
    122 
    123         $myxml_data     = checkSessionData();
     162function drawBigClusterImage()
     163{
     164        global $filter, $clustername, $myxml_data;
    124165
    125166        $ic = new ClusterImage( $myxml_data, $clustername );
     
    136177}
    137178
    138 switch( $view ) {
    139 
     179switch( $view )
     180{
    140181        case "small-clusterimage":
    141182
  • trunk/web/addons/job_monarch/jobstore.php

    r637 r646  
    5757include_once "./libtoga.php";
    5858
    59 $ds             = new DataSource();
    60 $myxml_data     = &$ds->getData();
    61 
    62 session_start();
    63 unset( $_SESSION['data'] );
    64 $_SESSION['data']       = &$myxml_data;
     59function makeSession()
     60{
     61        $ds             = new DataSource();
     62        $myxml_data     = &$ds->getData();
     63
     64        unset( $_SESSION['data'] );
     65
     66        $_SESSION['data']               = &$myxml_data;
     67        $_SESSION['gather_time']        = time();
     68}
     69
     70global $session_active, $_SESSION;
     71
     72function checkSessionPollInterval( $poll_interval )
     73{
     74        global $session_active, $_SESSION;
     75
     76        if( ! session_active )
     77        {
     78                return 0;
     79        }
     80
     81        if( isset( $_SESSION['poll_interval'] ) )
     82        {
     83                if( $poll_interval <> $_SESSION['poll_interval'] )
     84                {
     85                        $_SESSION['poll_interval']      = $poll_interval;
     86                }
     87        }
     88        else
     89        {
     90                $_SESSION['poll_interval']      = $poll_interval;
     91        }       
     92
     93        session_write_close();
     94
     95        $session_active = false;
     96}
     97
     98function checkSession()
     99{
     100        global $session_active, $_SESSION;
     101
     102        session_start();
     103
     104        $session_active         = true;
     105
     106        // I got nothing; create session
     107        //
     108        if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
     109        {
     110                makeSession();
     111
     112                return 0;       
     113        }
     114
     115        if( isset( $_SESSION['poll_interval'] ) )
     116        {
     117                $gather_time    = $_SESSION['gather_time'];
     118                $poll_interval  = $_SESSION['poll_interval'];
     119
     120                $cur_time       = time();
     121
     122                // If poll_interval time elapsed since last update; recreate session
     123                //
     124                if( ($cur_time - $gather_time) >= $poll_interval )
     125                {
     126                        makeSession();
     127
     128                        return 0;       
     129                }
     130        }
     131}
     132
     133checkSession();
    65134
    66135global $jobs, $metrics;
    67136
    68137$data_gatherer  = new DataGatherer( $clustername );
    69 $data_gatherer->parseXML( &$myxml_data );
     138$data_gatherer->parseXML( &$_SESSION['data'] );
    70139
    71140$heartbeat      = &$data_gatherer->getHeartbeat();
     
    495564                $reported       = (int) $jobs[$jid]['reported'];
    496565
     566                $poll_interval  = (int) $jobs[$jid]['poll_interval'];
     567
     568                checkSessionPollInterval( $poll_interval );
     569
    497570                $time           = time();
    498571
     
    501574                $job_runtime    = $time - intval( $jobs[$jid]['start_timestamp'] );
    502575                //$job_runtime  = date( 'u' ) - intval( $jobs[$jid]['start_timestamp'] );
    503                 //$job_window   = intval( $job_runtime ) * 1.2;
     576                $job_window     = intval( $job_runtime ) * 1.2;
    504577
    505578                $jobrange       = -$job_window;
     
    508581
    509582                $nr['jid']      = $jid;
     583                $nr['nodename'] = $host;
    510584
    511585                $hostar         = array( $host );
     
    523597                // maybe later to popup?
    524598                //
    525                 //$host_link      = "\"../../?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&job_start=$jobstart\"";
     599                $host_link      = "../../?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&job_start=$jobstart";
     600
     601                $nr['hostlink'] = $host_link;
    526602
    527603                if ( $val["TYPE"] == "timestamp" || $always_timestamp[$metricname] )
     
    608684                $jr['requested_time']   = makeTime( timeToEpoch( $jobs[$jobid]['requested_time'] ) );
    609685
     686                $poll_interval          = (int) $jobs[$jobid]['poll_interval'];
     687
     688                checkSessionPollInterval( $poll_interval );
     689
    610690                if( $jr['status'] == 'R' )
    611691                {
  • trunk/web/addons/job_monarch/js/monarch.js

    r645 r646  
    764764JobsColumnModel = new Ext.grid.ColumnModel(
    765765{
    766         //CheckJobs,
    767766        defaults:
    768767        {
     
    773772        columns:
    774773        [
     774                CheckJobs,
    775775                {
    776776                        header:         '#',
     
    926926                        },[
    927927                                {name: 'jid', type: 'string', mapping: 'jid'},
    928                                 {name: 'ga', type: 'string', mapping: 'ga'}
     928                                {name: 'ga', type: 'string', mapping: 'ga'},
     929                                {name: 'nodename', type: 'string', mapping: 'nodename'},
     930                                {name: 'hostlink', type: 'string', mapping: 'hostlink'}
    929931                        ]),
    930932                        listeners:
     
    976978                                        '<tpl for=".">',
    977979                                        //'<div class="rrd-float"><a href="./graph.php?z=large&{ga}" border="0" rel="lightbox[{jid}.{[globalWindowCount]}]"><img src="./graph.php?z=small&{ga}" border="0"></a></div>',
    978                                         '<div class="rrd-float"><img src="./graph.php?z=small&{ga}" border="0" style="cursor:pointer" onclick="nodeWindow(\'node x\', \'{ga}\');"></a></div>',
     980                                        '<div class="rrd-float"><img src="./graph.php?z=small&{ga}" border="0" style="cursor:pointer" onclick="nodeWindow(\'{nodename}\', \'{hostlink}\');"></a></div>',
    979981                                        '</tpl>')
    980982                });
  • trunk/web/addons/job_monarch/templates/header.tpl

    r641 r646  
    3535        JobProxy.on('beforeload', function(p, params)
    3636        {
    37                 params.c        = "{cluster}";
    38                 newparams       = joinMyArray( params, myfilters );
    39                 myparams        = newparams;
    40                 params          = newparams;
     37                params['c']                     = '{cluster}';
     38                params['{session_name}']        = '{session_id}';
     39                newparams                       = joinMyArray( params, myfilters );
     40                myparams                        = newparams;
     41                params                          = newparams;
    4142        });
    4243
Note: See TracChangeset for help on using the changeset viewer.