Ignore:
Timestamp:
11/12/09 17:08:03 (14 years ago)
Author:
ramonb
Message:

job_monarch/overview.php,
job_monarch/index.php:

  • old code cleanup

job_monarch/index.php,
job_monarch/image.php,
job_monarch/jobstore.php

  • rewrote session handling

job_monarch/image.php:

job_monarch/templates/header.tpl:

  • add session to clusterimage
  • (temp?) disabled pie chart

job_monarch/libtoga.php:

  • wrote new SessionHandler? class to handle all sessions
  • DataSource? now uses interactive port so can retrieve only relevant XML
  • disable XML_OPTION_CASE_FOLDING to speed up xml parsing
  • use jobmond poll interval to only reload XML when useful
  • use strpos instead of strstr, should be faster xml parsing
  • dont parse XML in ClusterImage? anymore, instead supply DataGather? object


job_monarch/conf.php:

  • use interactive gmetad port now
File:
1 edited

Legend:

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

    r646 r648  
    11<?php
    22
    3 ini_set("memory_limit","200M");
     3ini_set("memory_limit","1G");
    44set_time_limit(0);
     5
     6//ini_set("xdebug.profiler_output_dir","/tmp");
     7//ini_set("xdebug.profiler_output_name","timestamp");
     8//ini_set("xdebug.profiler_enable","1");
    59
    610$c                      = $_POST['c'];
     
    5357$_GET['c']              = $c;
    5458
    55 global $c, $clustername, $cluster;
     59global $c, $clustername, $cluster, $mySession;
    5660
    5761include_once "./libtoga.php";
    5862
    59 function 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 
    70 global $session_active, $_SESSION;
    71 
    72 function 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 
    98 function 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 
    133 checkSession();
    134 
    135 global $jobs, $metrics;
    136 
    137 $data_gatherer  = new DataGatherer( $clustername );
    138 $data_gatherer->parseXML( &$_SESSION['data'] );
    139 
    140 $heartbeat      = &$data_gatherer->getHeartbeat();
    141 $jobs           = &$data_gatherer->getJobs();
    142 //$gnodes         = $data_gatherer->getNodes();
    143 $cpus           = &$data_gatherer->getCpus();
    144 $use_fqdn       = &$data_gatherer->getUsingFQDN();
     63
     64global $jobs, $metrics, $session;
     65
     66//printf( "c %s\n", $clustername );
     67
     68$mySession      = new SessionHandler( $clustername );
     69$mySession->checkSession();
     70
     71$session        = &$mySession->getSession();
     72$myXML          = $session['data'];
     73
     74//printf( "gt %s\n", $session['gather_time'] );
     75//printf( "pi %s\n", $session['poll_interval'] );
     76
     77$myData         = new DataGatherer( $clustername );
     78$myData->parseXML( $myXML );
     79
     80$mySession->updatePollInterval( $myData->getPollInterval() );
     81//printf( "pi %s\n", $myData->getPollInterval() );
     82//printf( "pi %s\n", $session['poll_interval'] );
     83$mySession->endSession();
     84
     85
     86$heartbeat      = &$myData->getHeartbeat();
     87$jobs           = &$myData->getJobs();
     88$cpus           = &$myData->getCpus();
     89$use_fqdn       = &$myData->getUsingFQDN();
     90
     91//print_r( $jobs );
     92
     93//print_r( $session );
    14594
    14695// The ext grid script will send  a task field which will specify what it wants to do
     
    518467{
    519468        global $jobs, $jobids, $clustername, $metrics, $jid, $p_metricname;
    520         global $always_timestamp, $always_constant;
     469        global $always_timestamp, $always_constant, $mySession;
    521470
    522471        $display_nodes  = array();
     
    566515                $poll_interval  = (int) $jobs[$jid]['poll_interval'];
    567516
    568                 checkSessionPollInterval( $poll_interval );
     517                //$mySession->updatePollInterval( $poll_interval );
    569518
    570519                $time           = time();
     
    636585        global $jobs, $hearbeat, $pstart, $pend;
    637586        global $sortfield, $sortorder, $query, $host;
    638         global $jid, $owner, $queue,  $status;
     587        global $jid, $owner, $queue,  $status, $mySession;
    639588
    640589        $job_count              = count( $jobs );
     
    686635                $poll_interval          = (int) $jobs[$jobid]['poll_interval'];
    687636
    688                 checkSessionPollInterval( $poll_interval );
     637                //$mySession->updatePollInterval( $poll_interval );
    689638
    690639                if( $jr['status'] == 'R' )
Note: See TracChangeset for help on using the changeset viewer.