home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / client / sysint / perf-count-timer.sm < prev    next >
Text File  |  2007-08-29  |  3KB  |  110 lines

  1. /* 
  2.  * (C) 2001 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <unistd.h>
  11. #include <fcntl.h>
  12. #include <sys/time.h>
  13.  
  14. #include "client-state-machine.h"
  15. #include "pint-perf-counter.h"
  16.  
  17. extern job_context_id pint_client_sm_context;
  18.  
  19. %%
  20.  
  21. machine pvfs2_client_perf_count_timer_sm
  22. {
  23.     state do_work 
  24.     {
  25.         run perf_count_timer_do_work;
  26.         success => do_work;
  27.         default => error;
  28.     }
  29.  
  30.     state error 
  31.     {
  32.         run perf_count_timer_error;
  33.         default => terminate;
  34.     }
  35. }
  36.  
  37. %%
  38.  
  39. /* perf_count_timer_error()
  40.  *
  41.  * cleans up any resources consumed by this state machine and ends
  42.  * execution of the machine
  43.  */
  44. static PINT_sm_action perf_count_timer_error(
  45.         struct PINT_smcb *smcb, job_status_s *js_p)
  46. {
  47.     gossip_debug(GOSSIP_CLIENT_DEBUG,
  48.                  "perf timer state: perf_count_timer_error\n");
  49.     gossip_err("Error: stopping client perf timer.\n");
  50.  
  51.     PINT_SET_OP_COMPLETE;
  52.     return SM_ACTION_DEFERRED;
  53. }
  54.  
  55. /* perf_count_timer_do_work()
  56.  *
  57.  * periodically resets performance counters
  58.  */
  59. static PINT_sm_action perf_count_timer_do_work(
  60.         struct PINT_smcb *smcb, job_status_s *js_p)
  61. {
  62.     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  63.     job_id_t tmp_id;
  64.     uint64_t current_mask = 0;
  65.     int current_debug_on = 0;
  66.     char* tmp_text;
  67.     char* ptr;
  68.     char* token;
  69.     char delim[] = "\n";
  70.  
  71. #if 0
  72.     gossip_debug(GOSSIP_CLIENT_DEBUG,
  73.                  "perf count timer state: perf_count_timer_do_work\n");
  74. #endif
  75.     
  76.     /* log current statistics if the gossip mask permits */
  77.     gossip_get_debug_mask(¤t_debug_on, ¤t_mask);
  78.     if(current_mask & GOSSIP_PERFCOUNTER_DEBUG)
  79.     {
  80.         tmp_text = PINT_perf_generate_text(sm_p->u.perf_count_timer.pc, 4096);
  81.         if(tmp_text)
  82.         {
  83.             token = strtok_r(tmp_text, delim, &ptr);
  84.             while(token)
  85.             {
  86.                 gossip_perf_log("%s\n", token);
  87.                 token = strtok_r(NULL, delim, &ptr);
  88.             }
  89.             free(tmp_text);
  90.         }
  91.     }
  92.  
  93.     PINT_perf_rollover(sm_p->u.perf_count_timer.pc);
  94.         
  95.     /* post another timer */
  96.     return job_req_sched_post_timer(
  97.         ((*sm_p->u.perf_count_timer.interval_secs)*1000), 
  98.         smcb, 0, js_p, &tmp_id, pint_client_sm_context);
  99. }
  100.  
  101. /*
  102.  * Local variables:
  103.  *  mode: c
  104.  *  c-indent-level: 4
  105.  *  c-basic-offset: 4
  106.  * End:
  107.  *
  108.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  109.  */
  110.