KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
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"));
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"));
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()");
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 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;
103}
104
105
106
108
110{
111 KVDatime now;
112 Info("Refresh", "Updating... [%s]", now.AsSQLString());
113 if (!gBatchSystemManager) new KVBatchSystemManager;
114 if (!gBatchSystem) gBatchSystemManager->GetDefaultBatchSystem()->cd();
115 KVList* newjobs = gBatchSystem->GetListOfJobs();
116 fLVJobs->Display(newjobs);
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
#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.
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
Job handled by Grid Engine batch system at CC-IN2P3.
void AlterResources(TString r)
call qalter on job with given resource list
const Char_t * GetResources() const
General purpose dialog box asking for some input in the form of a string.
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()
virtual void SetDataColumns(Int_t ncolumns)
virtual void Display(const TCollection *l)
Definition KVListView.h:173
TList * GetSelectedObjects() const
Definition KVListView.h:245
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
virtual KVLVColumnData * GetDataColumn(Int_t index) const
Definition KVListView.h:168
Extended TList class which owns its objects by default.
Definition KVList.h:28
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)
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)
TObject * First() const override
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)