]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbRestorePanel : implemented the director modification showing jobid when a job...
authorNicolas Boichat <nicolas@boichat.ch>
Fri, 6 Aug 2004 13:00:40 +0000 (13:00 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Fri, 6 Aug 2004 13:00:40 +0000 (13:00 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1511 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/console_thread.cpp
bacula/src/wx-console/wxbrestorepanel.cpp

index d71ad8f898b54a298a48945e45381af75fd8c11a..97e4845b2ee015329b4955688f6ece7ded821e20 100644 (file)
@@ -1,3 +1,7 @@
+06-08-2004 :
+ - wxbRestorePanel : implemented the director modification showing
+     jobid when a job is started.
+
 28-07-2004 :
  - wxbRestorePanel : implemented restore before=<Date> parameter.
 
index 6271e032e865911eb7e0d6cb0e4f64529472e85b..62c076bcf8e4f58045a4d244ec8faf9b7daf91d3 100644 (file)
@@ -1,7 +1,6 @@
 general : Show nice messages boxes when errors occurs.
 
-wxbRestorePanel : Be sure of which job we just have run (not suppositions
-   as I'm doing now): implement the director modification.
+wxbRestorePanel : implement .backups client=xxx (2.1a)
    
 wxbRestorePanel : list jobs and list jobid=# will probably crash if there
    is nothing to show (db error or empty table)
@@ -46,11 +45,7 @@ wxbMainFrame : set focus to type control when clicking on console
 wxbConfigPanel : Create a dialog for selecting dates and paths.
 
 wxbMainFrame : use more often status text
-
-wxbRestorePanel : Ask Kern for a dot command which gives restore
-  dates for a client (with an interval, last 20 for example, or last
-  40 excluding last 20).
-    
+   
 wxbRestorePanel : Use ".default job=RestoreFiles" to get defaults parameters
        when changing a restore parameter fails.
 
index 146221e57f6852b3855ea0defdb9e5c5f77e391d..705033f05378de41601ad8acf94ce672c25c446a 100644 (file)
@@ -260,7 +260,7 @@ void* console_thread::Entry() {
    
    csprint(NULL, CS_CONNECTED);
    
-   Write("messages\n");
+   Write(".messages\n");
 
    int stat;
 
index 2d4e9ed35779447e89154cdc001bdc6e22805300..44f522a27a539f3b6487d00a4eedfd851af66856 100644 (file)
@@ -777,11 +777,33 @@ void wxbRestorePanel::CmdStart() {
       wxbDataTokenizer* dt;
     
       SetStatus(restoring);
-      wxbUtils::WaitForEnd("yes\n");
+      dt = wxbUtils::WaitForEnd("yes\n", true);
 
       gauge->SetValue(0);
       gauge->SetRange(totfilemessages);
 
+      int j;
+            
+      for (i = 0; i < dt->GetCount(); i++) {
+         if ((j = (*dt)[i].Find("Job started. JobId=")) > -1) {
+            jobid = (*dt)[i].Mid(j+19);
+            wxbMainFrame::GetInstance()->SetStatusText("Restore started, jobid=" + jobid);
+            break;
+         }
+
+         if ((j = (*dt)[i].Find("Job failed.")) > -1) {
+            wxbMainFrame::GetInstance()->Print("Restore failed, please look at messages.\n", CS_DEBUG);
+            wxbMainFrame::GetInstance()->SetStatusText("Restore failed, please look at messages in console.");
+            return;
+         }
+      }
+      
+      if (jobid == "") {
+         wxbMainFrame::GetInstance()->Print("Failed to retrieve jobid.\n", CS_DEBUG);
+         wxbMainFrame::GetInstance()->SetStatusText("Failed to retrieve jobid.\n");
+         return;         
+      }
+
       wxDateTime currenttime;
       
       dt = wxbUtils::WaitForEnd("time\n", true);
@@ -810,67 +832,104 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
 
-      wxString cmd = "list jobid=";
-
-      wxString jobname = restorePanel->GetRowString("Job Name");
-
-      wxStopWatch sw;
+      wxString cmd = wxString("list jobid=") + jobid;
 
       wxbTableParser* tableparser;
-
-      while (true) {
-         tableparser = wxbUtils::CreateAndWaitForParser("list jobs\n");
-         
-         wxDateTime jobtime;
-         
-         for (i = 0; i < tableparser->GetCount(); i++) {
-            if (jobname == (*tableparser)[i][1]) {
-               wxStringTokenizer jtkz((*tableparser)[i][2], " ", wxTOKEN_STRTOK);
-               if ((jobtime.ParseDate(jtkz.GetNextToken()) != NULL) && // Date
-                     (jobtime.ParseTime(jtkz.GetNextToken()) != NULL)) { // Time
-                  if (jobtime.IsLaterThan(currenttime)) {
-                     jobid = (*tableparser)[i][0];
-                     cmd << jobid << "\n";
-                     delete tableparser;
-                     tableparser = NULL;
-                     cancel->Enable(true);
-                     break;
-                  }
-               }
-            }
-         }
-   
-         if (tableparser == NULL) { //The job was found
-            break;
-         }
-         
-         delete tableparser;
-         
-         wxStopWatch sw2;
-         while (sw2.Time() < 2000) {
-            wxTheApp->Yield(true);
-            ::wxUsleep(100);
-         }
-         if (sw.Time() > 60000) {
-            wxbMainFrame::GetInstance()->Print("The restore job has not been created within one minute, wx-console will not wait for its completion anymore.\n", CS_DEBUG);
-            wxbMainFrame::GetInstance()->SetStatusText("The restore job has not been created within one minute, wx-console will not wait for its completion anymore.");
-            SetStatus(finished);
-            cancel->Enable(true);
-            return;
-         }
-      }
       
       long filemessages = 0;
+      
+      bool ended = false;
+      bool waitforever = false;
+      
+      char status = '?';
 
+      wxStopWatch sw;
+           
       while (true) {
          tableparser = wxbUtils::CreateAndWaitForParser(cmd);
-         if ((*tableparser)[0][7] != "C") {
+         ended = false;
+         status = (*tableparser)[0][7].GetChar(0);
+         switch (status) {
+         case JS_Created:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job created, but not yet running.");
+            waitforever = false;
+            break;
+         case JS_Running:
+            wxbMainFrame::GetInstance()->SetStatusText(
+               wxString("Restore job running, please wait (") << filemessages << 
+               " of " << totfilemessages << " files restored)...");
+            waitforever = true;
+            break;
+         case JS_Terminated:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job terminated successfully.");
+            wxbMainFrame::GetInstance()->Print("Restore job terminated successfully.\n", CS_DEBUG);
+            waitforever = false;
+            ended = true;
+            break;
+         case JS_ErrorTerminated:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job terminated in error, see messages in console.");
+            wxbMainFrame::GetInstance()->Print("Restore job terminated in error, see messages.\n", CS_DEBUG);
+            waitforever = false;
+            ended = true;
+            break;
+         case JS_Error:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job reported a non-fatal error.");
+            waitforever = false;
+            break;
+         case JS_FatalError:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job reported a fatal error.");
+            waitforever = false;
+            ended = true;
+            break;
+         case JS_Canceled:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job cancelled by user.");
+            wxbMainFrame::GetInstance()->Print("Restore job cancelled by user.\n", CS_DEBUG);
+            waitforever = false;
+            ended = true;
+            break;
+         case JS_WaitFD:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting on File daemon.");
+            waitforever = false;
+            break;
+         case JS_WaitMedia:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for new media.");
+            waitforever = false;
+            break;
+         case JS_WaitStoreRes:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for storage resource.");
+            waitforever = false;
+            break;
+         case JS_WaitJobRes:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for job resource.");
+            waitforever = false;
+            break;
+         case JS_WaitClientRes:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for Client resource.");
+            waitforever = false;
+            break;
+         case JS_WaitMaxJobs:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for maximum jobs.");
+            waitforever = false;
+            break;
+         case JS_WaitStartTime:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for start time.");
+            waitforever = false;
+            break;
+         case JS_WaitPriority:
+            wxbMainFrame::GetInstance()->SetStatusText("Restore job is waiting for higher priority jobs to finish.");
+            waitforever = false;
             break;
          }
          delete tableparser;
 
-         dt = wxbUtils::WaitForEnd("messages\n", true);
+         wxStopWatch sw2;
+         while (sw2.Time() < 1000) {  
+            wxTheApp->Yield(true);
+            ::wxUsleep(100);
+         }
          
+         dt = wxbUtils::WaitForEnd(".messages\n", true);
+                  
          for (unsigned int i = 0; i < dt->GetCount(); i++) {
             wxStringTokenizer tkz((*dt)[i], " ", wxTOKEN_STRTOK);
    
@@ -900,29 +959,32 @@ void wxbRestorePanel::CmdStart() {
          }
          
          delete dt;
-
-         wxbMainFrame::GetInstance()->SetStatusText(wxString("Restoring, please wait (") << filemessages << " of " << totfilemessages << " files done)...");
-
+         
          wxStopWatch sw2;
-         while (sw2.Time() < 10000) {  
+         while (sw2.Time() < 1000) {  
             wxTheApp->Yield(true);
             ::wxUsleep(100);
          }
+         
+         if (ended) {
+            break;
+         }
+         
+         if ((!waitforever) && (sw.Time() > 60000)) {
+            wxbMainFrame::GetInstance()->Print("The restore job has not been started within one minute, wx-console will not wait for its completion anymore.\n", CS_DEBUG);
+            wxbMainFrame::GetInstance()->SetStatusText("The restore job has not been started within one minute, wx-console will not wait for its completion anymore.");
+            break;
+         }
       }
 
-      wxbUtils::WaitForEnd("messages\n");
+      wxbUtils::WaitForEnd(".messages\n");
 
       gauge->SetValue(totfilemessages);
 
-      if ((*tableparser)[0][7] == "T") {
+      if (status == JS_Terminated) {
          wxbMainFrame::GetInstance()->Print("Restore done successfully.\n", CS_DEBUG);
          wxbMainFrame::GetInstance()->SetStatusText("Restore done successfully.");
       }
-      else {
-         wxbMainFrame::GetInstance()->Print("Restore failed, please look at messages.\n", CS_DEBUG);
-         wxbMainFrame::GetInstance()->SetStatusText("Restore failed, please look at messages in console.");
-      }
-      delete tableparser;
       SetStatus(finished);
    }
 }