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