KaliVeda
Toolkit for HIC analysis
KVBatchSystemGUI.cpp
1 //Created by KVClassFactory on Wed Apr 3 15:57:14 2013
2 //Author: John Frankland,,,
3 
4 #include "KVBatchSystemGUI.h"
5 #include "KVInputDialog.h"
6 #include <KVBatchJob.h>
7 #include <KVDatime.h>
8 #include <TEnv.h>
9 #include <KVBatchSystemManager.h>
10 #include <KVGEBatchJob.h>
11 
13 
14 
16 
17 
20 
22 {
23  // Default constructor
24  fOpen = kTRUE;
25  jobs = 0;
26 
27  MainFrame = new TGMainFrame(gClient->GetRoot(), 10, 10, kMainFrame | kVerticalFrame);
28  MainFrame->SetName("BatchSystem GUI");
30  BrefreshDir = new TGPictureButton(hf, gClient->GetPicture("refresh2.xpm"));
31  hf->AddFrame(BrefreshDir, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
32  BrefreshDir->Resize(40, 40);
33  BrefreshDir->SetToolTipText("Update");
34  BrefreshDir->Connect("Clicked()", "KVBatchSystemGUI", this, "Refresh()");
35  BalterJobs = new TGPictureButton(hf, gClient->GetPicture("bld_edit_s.png"));
36  hf->AddFrame(BalterJobs, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
37  BalterJobs->Resize(40, 40);
38  BalterJobs->SetToolTipText("Alter job(s) resources");
39  BalterJobs->Connect("Clicked()", "KVBatchSystemGUI", this, "AlterJobs()");
40  BremDir = new TGPictureButton(hf, gClient->GetPicture("mb_stop_s.xpm"));
41  hf->AddFrame(BremDir, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
42  BremDir->Resize(40, 40);
43  BremDir->SetToolTipText("Kill job(s)");
44  BremDir->Connect("Clicked()", "KVBatchSystemGUI", this, "KillJobs()");
45  MainFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2));
46  fLVJobs = new KVListView(KVBatchJob::Class(), MainFrame, 900, 400);
48  fLVJobs->SetDataColumn(0, "JobID");
49  fLVJobs->SetDataColumn(1, "Name");
50  fLVJobs->SetDataColumn(2, "Status");
51  fLVJobs->SetDataColumn(3, "Submitted");
53  fLVJobs->SetDataColumn(4, "Complete [%]", "GetPercentageComplete");
54  fLVJobs->SetDataColumn(5, "CPUusage");
55  fLVJobs->SetDataColumn(6, "CPUmax");
56  fLVJobs->SetDataColumn(7, "MemUsed");
57  fLVJobs->SetDataColumn(8, "MemMax");
58  fLVJobs->SetDataColumn(9, "DiskUsed");
59  fLVJobs->SetDataColumn(10, "DiskMax");
61 
62  if (!gBatchSystemManager) new KVBatchSystemManager;
63  if (!gBatchSystem) gBatchSystemManager->GetDefaultBatchSystem()->cd();
64 
65  Refresh();
66 
67  fTimer = 0;
68  // automatic update every N second
69  if (gEnv->GetValue("KVBatchSystemGUI.AutoUpdate", kFALSE)) {
70  fTimer = new TTimer;
71  fTimer->Connect("Timeout()", "KVBatchSystemGUI", this, "Refresh()");
72  fTimer->Start(1000 * (gEnv->GetValue("KVBatchSystemGUI.RefreshInterval", 30)));
73  }
74 
80 
83 
84  MainFrame->Connect("CloseWindow()", "KVBatchSystemGUI", this, "DoClose()");
85  MainFrame->DontCallClose(); // to avoid double deletions.
86 }
87 
88 
89 
92 
94 {
95  // Destructor
96  fOpen = kFALSE;
97  if (fTimer)delete fTimer;
98  delete MainFrame;
100 }
101 
102 
103 
105 
107 {
108  KVDatime now;
109  Info("Refresh", "Updating... [%s]", now.AsSQLString());
110  if (!gBatchSystemManager) new KVBatchSystemManager;
111  if (!gBatchSystem) gBatchSystemManager->GetDefaultBatchSystem()->cd();
112  KVList* newjobs = gBatchSystem->GetListOfJobs();
113  fLVJobs->Display(newjobs);
114  SafeDelete(jobs);
115  jobs = newjobs;
116 }
117 
118 
119 
121 
123 {
125  if (selected_jobs.IsEmpty()) return;
126  TIter next(&selected_jobs);
127  KVBatchJob* job;
128  while ((job = (KVBatchJob*)next())) job->DeleteJob();
129  Refresh();
130 }
131 
132 
133 
135 
137 {
139  if (selected_jobs.IsEmpty()) return;
140 
141  //gBatchSystem->AlterJobs(MainFrame, selected_jobs);
143  TString resources = j1->GetResources();
144  Bool_t ok = kFALSE;
145  new KVInputDialog(MainFrame, "Modify the currently-set resources for theses jobs ?", &resources, &ok,
146  "Change the resources you want to modify; leave the other ones as they are");
147  if (ok) {
148  TIter next(&selected_jobs);
149  KVGEBatchJob* job;
150  while ((job = (KVGEBatchJob*)next())) job->AlterResources(resources);
151  }
152 
153  Refresh();
154 }
155 
156 
157 
159 
161 {
162  TTimer::SingleShot(150, "KVBatchSystemGUI", this, "CloseWindow()");
163 }
164 
165 
166 
168 
170 {
171  delete this;
172 }
173 
174 
175 
kVerticalFrame
kHorizontalFrame
kMainFrame
#define SafeDelete(p)
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
#define gClient
kMWMFuncAll
kMWMDecorAll
kMWMInputModeless
kLHintsExpandY
kLHintsLeft
kLHintsTop
kLHintsExpandX
Handles jobs submitted to batch system.
Definition: KVBatchJob.h:16
virtual void DeleteJob()
Definition: KVBatchJob.h:124
GUI for batch system jobsGraphical interface for monitoring, altering, and deleting batch jobs....
virtual ~KVBatchSystemGUI()
Destructor.
KVBatchSystemGUI()
Default constructor.
KVUnownedList selected_jobs
KVListView * fLVJobs
TGMainFrame * MainFrame
static Bool_t fOpen
kTRUE if GUI is already open
TGPictureButton * BalterJobs
TGPictureButton * BremDir
TGPictureButton * BrefreshDir
Handles list of all available batch systems for processing non-interactive data analysis tasks.
KVBatchSystem * GetDefaultBatchSystem() const
void cd()
Make this the default batch system.
virtual KVList * GetListOfJobs()
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
@ kSQL
Definition: KVDatime.h:44
Job handled by Grid Engine batch system at CC-IN2P3.
Definition: KVGEBatchJob.h:16
const Char_t * GetResources() const
Definition: KVGEBatchJob.h:29
void AlterResources(TString r)
call qalter on job with given resource list
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:146
virtual void ActivateSortButtons()
Definition: KVListView.cpp:72
virtual void SetDataColumns(Int_t ncolumns)
Definition: KVListView.cpp:91
virtual KVLVColumnData * GetDataColumn(Int_t index) const
Definition: KVListView.h:168
virtual void Display(const TCollection *l)
Definition: KVListView.h:173
KVUnownedList GetSelectedObjects() const
Definition: KVListView.h:252
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
Definition: KVListView.cpp:106
Extended TList class which owns its objects by default.
Definition: KVList.h:22
TObject * First() const override
virtual Bool_t IsEmpty() const
const char * AsSQLString() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetToolTipText(const char *text, Long_t delayms=400)
TGDimension GetDefaultSize() const override
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
void MapSubwindows() override
virtual void Resize(TGDimension size)
void MapWindow() override
void DontCallClose()
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
virtual void SetName(const char *name)
static TClass * Class()
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
virtual void Start(Long_t milliSec=-1, Bool_t singleShot=kFALSE)
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
ClassImp(TPyArg)