]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Fix maxwaittime to fit documentation, this time is now counted
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 10 Nov 2008 10:27:47 +0000 (10:27 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 10 Nov 2008 10:27:47 +0000 (10:27 +0000)
     from the job start and group all wait periods.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8026 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/job.c
bacula/src/jcr.h
bacula/src/lib/jcr.c
bacula/technotes-2.5

index 2fb91119be05bae87269952ddccbb501bf6c08b5..8e3f66b160d604a4eb44089b686ba7d1953ea43d 100644 (file)
@@ -545,13 +545,20 @@ static bool job_check_maxwaittime(JCR *jcr)
 {
    bool cancel = false;
    JOB *job = jcr->job;
+   utime_t current=0;
 
    if (!job_waiting(jcr)) {
       return false;
    }
-   Dmsg3(200, "check maxwaittime %u - %u >= %u\n", watchdog_time, jcr->wait_time, job->MaxWaitTime);
+
+   if (jcr->wait_time) {
+      current = watchdog_time - jcr->wait_time;
+   }
+
+   Dmsg3(200, "check maxwaittime %u >= %u\n", 
+         current + jcr->wait_time_sum, job->MaxWaitTime);
    if (job->MaxWaitTime != 0 &&
-       (watchdog_time - jcr->wait_time) >= job->MaxWaitTime) {
+       (current + jcr->wait_time_sum) >= job->MaxWaitTime) {
       cancel = true;
    }
 
index e100a26a6ad89f88ebd0627ab92aaa2f92050ce4..386335eba068e746be03b99ecd2b6352c01998a5 100644 (file)
@@ -216,7 +216,8 @@ public:
    time_t start_time;                 /* when job actually started */
    time_t run_time;                   /* used for computing speed */
    time_t end_time;                   /* job end time */
-   time_t wait_time;                  /* when job have started to wait */
+   time_t wait_time_sum;              /* cumulative wait time since job start */
+   time_t wait_time;                  /* timestamp when job have started to wait */
    POOLMEM *client_name;              /* client name */
    POOLMEM *RestoreBootstrap;         /* Bootstrap file to restore */
    POOLMEM *stime;                    /* start time for incremental/differential */
index 2bad20da40617997b556ce24d86f8c3aad582758..48d366ed490c6eb1df2b8d60bd07e253e5f0a94e 100644 (file)
@@ -738,41 +738,29 @@ static int get_status_priority(int JobStatus)
    return priority;
 }
 
-void set_jcr_job_status(JCR *jcr, int JobStatus)
+
+static void update_wait_time(JCR *jcr, int newJobStatus)
 {
-    bool set_waittime = false;
-    int oldJobStatus = jcr->JobStatus;
-    int priority, old_priority;
-
-    priority = get_status_priority(JobStatus);
-    old_priority = get_status_priority(oldJobStatus);
-
-    Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
-    /* if wait state is new, we keep current time for watchdog MaxWaitTime */
-    switch (JobStatus) {
-       case JS_WaitFD:
-       case JS_WaitSD:
-       case JS_WaitMedia:
-       case JS_WaitMount:
-       case JS_WaitStoreRes:
-       case JS_WaitJobRes:
-       case JS_WaitClientRes:
-       case JS_WaitMaxJobs:
-       case JS_WaitPriority:
-         set_waittime = true;
-       default:
-         break;
-    }
-   /*
-    * For a set of errors, ... keep the current status
-    *   so it isn't lost. For all others, set it.
-    */
-   Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
-         jcr->JobStatus, JobStatus);
-   if (priority >= old_priority) {
-      jcr->JobStatus = JobStatus;     /* replace with new priority */
+   bool enter_in_waittime;
+   int oldJobStatus = jcr->JobStatus;
+
+   switch (newJobStatus) {
+   case JS_WaitFD:
+   case JS_WaitSD:
+   case JS_WaitMedia:
+   case JS_WaitMount:
+   case JS_WaitStoreRes:
+   case JS_WaitJobRes:
+   case JS_WaitClientRes:
+   case JS_WaitMaxJobs:
+   case JS_WaitPriority:
+      enter_in_waittime = true;
+      break;
+   default:
+      enter_in_waittime = false; /* not a Wait situation */
+      break;
    }
+   
    /*
     * If we were previously waiting and are not any more
     *   we want to update the wait_time variable, which is
@@ -788,13 +776,43 @@ void set_jcr_job_status(JCR *jcr, int JobStatus)
    case JS_WaitClientRes:
    case JS_WaitMaxJobs:
    case JS_WaitPriority:
-       set_waittime = false;    /* keep old time */
+      if (!enter_in_waittime) { /* we get out the wait time */
+         jcr->wait_time_sum += (time(NULL) - jcr->wait_time);
+         jcr->wait_time = 0;
+      }
+      break;
+
+   /* if wait state is new, we keep current time for watchdog MaxWaitTime */
    default:
-      if (set_waittime) {
-         Dmsg0(800, "Setting wait_time\n");
+      if (enter_in_waittime) {
          jcr->wait_time = time(NULL);
       }
+      break;
+   }
+}
+
+void set_jcr_job_status(JCR *jcr, int JobStatus)
+{
+   int priority, old_priority;
+   int oldJobStatus = jcr->JobStatus;
+   priority = get_status_priority(JobStatus);
+   old_priority = get_status_priority(oldJobStatus);
+   
+   Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
+
+   /* Update wait_time depending on newJobStatus and oldJobStatus */
+   update_wait_time(jcr, JobStatus);
+
+   /*
+    * For a set of errors, ... keep the current status
+    *   so it isn't lost. For all others, set it.
+    */
+   Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
+         jcr->JobStatus, JobStatus);
+   if (priority >= old_priority) {
+      jcr->JobStatus = JobStatus;     /* replace with new priority */
    }
+
    if (oldJobStatus != jcr->JobStatus) {
       Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
          oldJobStatus, JobStatus);
index e33c92717d97fc0a3f44bae95a5cc3ee3329a3bc..d8af59b567293a3deb300698d67b6cb4a1b4bbb9 100644 (file)
@@ -11,6 +11,8 @@ mixed priorities
 
 General:
 10Nov08
+ebl  Fix maxwaittime to fit documentation, this time is now counted
+     from the job start and group all wait periods.
 ebl  Add tips for postgresql to improve performance when having
      multiple batch insert at the same time.
 09Nov08