TAlienMasterJobStatus.cxx

Go to the documentation of this file.
00001 // @(#)root/alien:$Id: TAlienMasterJobStatus.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Jan Fiete Grosse-Oetringhaus   06/10/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TAlienMasterJobStatus                                                //
00015 //                                                                      //
00016 // Status of a MasterJob                                                //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 
00020 #include "TAlienJobStatus.h"
00021 #include "TAlienMasterJobStatus.h"
00022 #include "TObjString.h"
00023 #include "TBrowser.h"
00024 
00025 ClassImp(TAlienMasterJobStatus)
00026 
00027 //______________________________________________________________________________
00028 TAlienMasterJobStatus::~TAlienMasterJobStatus()
00029 {
00030    // Cleanup.
00031 
00032    fJobs.DeleteAll();
00033 
00034    if (fMasterJob)
00035       delete fMasterJob;
00036 }
00037 
00038 //______________________________________________________________________________
00039 void TAlienMasterJobStatus::Browse(TBrowser* b)
00040 {
00041    // Browser interface.
00042 
00043    if (b) {
00044      //      TString status("");
00045      //      status += GetStatus();
00046      //      b->Add(new TNamed(status, TString("overall status")));
00047      //      status = "";
00048      //      status += PercentFinished();
00049      //      b->Add(new TNamed(status, TString("percentage finished")));
00050 
00051       TIterator* iter = fJobs.MakeIterator();
00052 
00053       TObject* obj = 0;
00054       while ((obj = iter->Next()) != 0) {
00055          TObjString* keyStr = dynamic_cast<TObjString*>(obj);
00056          TObject* value = fJobs.GetValue(obj);
00057 
00058          if (keyStr && value)
00059             b->Add(value, keyStr->GetString().Data());
00060       }
00061       delete iter;
00062    }
00063 }
00064 
00065 //______________________________________________________________________________
00066 TGridJobStatus::EGridJobStatus TAlienMasterJobStatus::GetStatus() const
00067 {
00068    // Returns the status of the master job reduced to the subset defined
00069    // in TGridJobStatus.
00070 
00071    if (!fMasterJob)
00072       return kUNKNOWN;
00073 
00074    return fMasterJob->GetStatus();
00075 }
00076 
00077 //______________________________________________________________________________
00078 Float_t TAlienMasterJobStatus::PercentFinished()
00079 {
00080    // Returns the percentage of finished subjobs, only DONE is considered
00081    // as finished.
00082 
00083    if (fJobs.GetSize() == 0)
00084       return 0;
00085 
00086    TIterator* iter = fJobs.MakeIterator();
00087 
00088    Int_t done = 0;
00089 
00090    TObject* obj = 0;
00091    while ((obj = iter->Next()) != 0) {
00092       TObject* value = fJobs.GetValue(obj);
00093       TAlienJobStatus* jobStatus = dynamic_cast<TAlienJobStatus*>(value);
00094 
00095       if (jobStatus) {
00096          if (jobStatus->GetStatus() == kDONE)
00097             ++done;
00098       }
00099    }
00100 
00101    delete iter;
00102 
00103    return (Float_t) done / fJobs.GetSize();
00104 }
00105 
00106 //______________________________________________________________________________
00107 void TAlienMasterJobStatus::Print(Option_t *) const
00108 {
00109    // Prints information of the master job and the sub job. Only the status is printed.
00110 
00111    if (fMasterJob) {
00112       printf("Printing information for the master job: ");
00113       fMasterJob->PrintJob(kFALSE);
00114    }
00115 
00116    TIterator* iter = fJobs.MakeIterator();
00117 
00118    TObject* obj = 0;
00119    while ((obj = iter->Next()) != 0) {
00120       TObjString* keyStr = dynamic_cast<TObjString*>(obj);
00121 
00122       TObject* value = fJobs.GetValue(obj);
00123       TAlienJobStatus* jobStatus = dynamic_cast<TAlienJobStatus*>(value);
00124 
00125       if (keyStr && jobStatus) {
00126          printf("Printing info for subjob %s: ", keyStr->GetString().Data());
00127          jobStatus->PrintJob(kFALSE);
00128       }
00129    }
00130    delete iter;
00131 }

Generated on Tue Jul 5 14:45:30 2011 for ROOT_528-00b_version by  doxygen 1.5.1