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 / client-job-timer.sm < prev    next >
Text File  |  2007-08-29  |  2KB  |  94 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 "state-machine.h"
  15. #include "client-state-machine.h"
  16. #include "job-time-mgr.h"
  17.  
  18. extern job_context_id pint_client_sm_context;
  19.  
  20. %%
  21.  
  22. machine pvfs2_client_job_timer_sm
  23. {
  24.     state do_work 
  25.     {
  26.         run job_timer_do_work;
  27.         success => do_work;
  28.         default => error;
  29.     }
  30.  
  31.     state error 
  32.     {
  33.         run job_timer_error;
  34.         default => terminate;
  35.     }
  36. }
  37.  
  38. %%
  39.  
  40. /* job_timer_error()
  41.  *
  42.  * cleans up any resources consumed by this state machine and ends
  43.  * execution of the machine
  44.  */
  45. static PINT_sm_action job_timer_error(
  46.     struct PINT_smcb *smcb, job_status_s* js_p)
  47. {
  48.     gossip_debug(GOSSIP_CLIENT_DEBUG,
  49.                  "job timer state: job_timer_error\n");
  50.     gossip_err("Error: stopping client job timer.\n");
  51.  
  52.     PINT_SET_OP_COMPLETE;
  53.     return SM_ACTION_TERMINATE;
  54. }
  55.  
  56. /* job_timer_do_work()
  57.  *
  58.  * resets counters, updates metrices, etc- this is intended to be
  59.  * called repeatedly on a regular interval
  60.  */
  61. static PINT_sm_action job_timer_do_work(
  62.     struct PINT_smcb *smcb, job_status_s* js_p)
  63. {
  64.     int ret = -1;
  65.     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  66.  
  67. #if 0
  68.     gossip_debug(GOSSIP_CLIENT_DEBUG,
  69.                  "job timer state: job_timer_do_work\n");
  70. #endif
  71.  
  72.     /* look for expired jobs */
  73.     ret = job_time_mgr_expire();
  74.     if (ret < 0)
  75.     {
  76.         js_p->error_code = ret;
  77.         return SM_ACTION_COMPLETE;
  78.     }
  79.         
  80.     /* post another timer */
  81.     return job_req_sched_post_timer(
  82.         1000, smcb, 0, js_p, &sm_p->u.job_timer.job_id, pint_client_sm_context);
  83. }
  84.  
  85. /*
  86.  * Local variables:
  87.  *  mode: c
  88.  *  c-indent-level: 4
  89.  *  c-basic-offset: 4
  90.  * End:
  91.  *
  92.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  93.  */
  94.