KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVBatchSystemGUI.cpp
Go to the documentation of this file.
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 
64 
65  selected_jobs = 0;
66 
67  Refresh();
68 
69  fTimer = 0;
70  // automatic update every N second
71  if (gEnv->GetValue("KVBatchSystemGUI.AutoUpdate", kFALSE)) {
72  fTimer = new TTimer;
73  fTimer->Connect("Timeout()", "KVBatchSystemGUI", this, "Refresh()");
74  fTimer->Start(1000 * (gEnv->GetValue("KVBatchSystemGUI.RefreshInterval", 30)));
75  }
76 
82 
85 
86  MainFrame->Connect("CloseWindow()", "KVBatchSystemGUI", this, "DoClose()");
87  MainFrame->DontCallClose(); // to avoid double deletions.
88 }
89 
90 
91 
94 
96 {
97  // Destructor
98  fOpen = kFALSE;
100  if (fTimer)delete fTimer;
101  delete MainFrame;
102  SafeDelete(jobs);
103 }
104 
105 
106 
108 
110 {
111  KVDatime now;
112  Info("Refresh", "Updating... [%s]", now.AsSQLString());
115  KVList* newjobs = gBatchSystem->GetListOfJobs();
116  fLVJobs->Display(newjobs);
117  SafeDelete(jobs);
118  jobs = newjobs;
119 }
120 
121 
122 
124 
126 {
129  if (!selected_jobs->GetEntries()) return;
130  TIter next(selected_jobs);
131  KVBatchJob* job;
132  while ((job = (KVBatchJob*)next())) job->DeleteJob();
133  Refresh();
134 }
135 
136 
137 
139 
141 {
144  if (!selected_jobs->GetEntries()) return;
145 
146  //gBatchSystem->AlterJobs(MainFrame, selected_jobs);
148  TString resources = j1->GetResources();
149  Bool_t ok = kFALSE;
150  new KVInputDialog(MainFrame, "Modify the currently-set resources for theses jobs ?", &resources, &ok,
151  "Change the resources you want to modify; leave the other ones as they are");
152  if (ok) {
153  TIter next(selected_jobs);
154  KVGEBatchJob* job;
155  while ((job = (KVGEBatchJob*)next())) job->AlterResources(resources);
156  }
157 
158  Refresh();
159 }
160 
161 
162 
164 
166 {
167  TTimer::SingleShot(150, "KVBatchSystemGUI", this, "CloseWindow()");
168 }
169 
170 
171 
173 
175 {
176  delete this;
177 }
178 
179 
180 
kVerticalFrame
kHorizontalFrame
kMainFrame
KVBatchSystemManager * gBatchSystemManager
KVBatchSystem * gBatchSystem
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
const Bool_t kFALSE
bool Bool_t
const 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:15
virtual void DeleteJob()
Definition: KVBatchJob.h:123
GUI for batch system jobsGraphical interface for monitoring, altering, and deleting batch jobs....
virtual ~KVBatchSystemGUI()
Destructor.
KVBatchSystemGUI()
Default constructor.
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:32
@ kSQL
Definition: KVDatime.h:43
Job handled by Grid Engine batch system at CC-IN2P3.
Definition: KVGEBatchJob.h:15
const Char_t * GetResources() const
Definition: KVGEBatchJob.h:28
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:23
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:145
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:167
virtual void Display(const TCollection *l)
Definition: KVListView.h:172
TList * GetSelectedObjects() const
Definition: KVListView.h:244
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:27
virtual Int_t GetEntries() 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)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
virtual TGDimension GetDefaultSize() const
virtual void MapSubwindows()
virtual void Resize(TGDimension size)
virtual void MapWindow()
void DontCallClose()
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
virtual void SetName(const char *name)
virtual TObject * First() const
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)