English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Launcher: TCluster.h Source File
Uranie / Launcher v4.9.0
/* @license-end */
TCluster.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2024 CEA/DES
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as published
6// by the Free Software Foundation, either version 3 of the License, or any
7// later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
18// $Id$
19// $Author$
20// $Date$
21// $Revision$
22// $State$
24
41#ifndef TCLUSTER_H
42#define TCLUSTER_H
43
44#include <stdlib.h>
45#include <iostream>
46
47//ROOT
48#include "Rtypes.h"
49#include "TNamed.h"
50
51// Uranie
52#include "Launcher.h"
53
54#ifdef WITH_LIBSSH
55#include "TCode.h"
56#include "TInputFileFlag.h"
57#include "TAttribute.h"
58#include "TInputFileRecreate.h"
59
60//SSH
61#define LIBSSH_STATIC 1
62#include <libssh/libssh.h>
63#include <libssh/sftp.h>
64#endif
65
66namespace URANIE
67{
68namespace Launcher
69{
70class TCluster: public TNamed
71{
72public:
73 Bool_t _blog;
74#ifdef WITH_LIBSSH
75 enum EDistrib { kUnknown, kLSB, kSLURM, kMPI, kPBS, kSGE, kEc };
76 EDistrib _edistrib;
77 TString _eType;
78#endif
79
80private:
81 Int_t _nnode;
82 TString _slistOfNodes;
83public:
84 //---------------------------------------------
88
89 TCluster(const char* name, const char *nodeList, Int_t nnode);
90#ifdef WITH_LIBSSH
91 TCluster(URANIE::DataServer::TDataServer *tds, TCode *code);
92 TCluster(TCode *code);
93#endif
94
96 virtual ~TCluster();
97
99 virtual void init() = 0;
101
102#ifdef WITH_LIBSSH
104
107 void setWorkingDirectory(TString localWorkingDirectory);
108 void setRemoteWorkingDirectory();
109
110 TCode * _code;
111 URANIE::DataServer::TDataServer* _tds;
112#endif
113 //---------------------------------------------
117 void setNNodes(Int_t nnode){
118 _nnode = nnode;
119 }
120 TString getListOfNodes(){
121 return _slistOfNodes;
122 }
123 // Adds the node name
124 void addNodeName(const TString& snodename, Int_t n = -1);
125 virtual void getCommandPrefix(char *, char*) = 0;
127
128 //---------------------------------------------
132 void setLog(){
133 _blog = kTRUE;
134 }
135 void unsetLog(){
136 _blog = kFALSE;
137 }
138 void changeLog(){
139 _blog = _blog ? kFALSE : kTRUE;
140 }
141 Bool_t getLog(){
142 return _blog;
143 }
144
145 virtual void printLog(Option_t *option = "");
147
148#ifdef WITH_LIBSSH
152
156 void setClusterUserAuth(TString user ,TString authentification_method="public_key"){
157 _sClusterUser=user;
158 _sClusterUserAuthMethod=authentification_method;
159 }
161
164 virtual void setCluster(TString cluster_name){
165 _sClusterName = cluster_name;
166
167 }
168 virtual void setCluster(TCluster *cluster);
169
174 TString getClusterName() const{
175 return _sClusterName;
176 }
181 TString getClusterIP() const{
182 return _sClusterIP;
183 }
188 TString setClusterIP() const{
189 return _sClusterIP;
190 }
192
195 void setSkeleton(TString skeleton){
196 _sSkeletonHeader = skeleton;
197 }
202 TString getSkeleton() const{
203 return _sSkeletonHeader;
204 }
206
210 void setOutputHeaderName(TString oHeaderName){
211#ifdef WIN32
212 const char *tail = strrchr(oHeaderName.Data(), '/');
213 _sOutputHeader = tail ? tail + 1 : oHeaderName.Data();
214#else
215 _sOutputHeader=basename(oHeaderName);
216#endif
217 }
218 // //! Sets the path to generate header output path
219 // /*!
220 // * \param generate header (TString) output of the cluster
221 // */
222
223 // * \brief Get the path to remoteWorkingDir
224 // * \return Output Path Header Name
225 // */
226
228
232 void setJobID(TString jobid){
233 _sJobID.push_back(jobid);
234
235 }
237
241 void setNRetries(Int_t retries){
242 _sRetries = retries;
243
244 }
246
250 TString getOutputHeaderName() const{
251 return _sOutputHeader;
252 }
254
258 TString getOutputHeaderPath() const{
259 return _sOutputHeaderPath;
260 }
262
266 TString getClusterUser() const{
267 return _sClusterUser;
268 }
270
274 TString getClusterUserAuthMethod() const{
275 return _sClusterUserAuthMethod;
276 }
278
282 TString getRemotePath() const{
283 return _sRemoteWorkingDirectory;
284 }
286
290 TString getOutputSsh() const{
291 return _sSshOutput;
292 }
294
298 TString getSplitName() const{
299 return _sSplitName;
300 }
302
306 TString getJobID(Int_t index) const{
307 return _sJobID.at(index);
308 }
310
313 void setNumberOfCores(Int_t ncores){
314 _nAllocatedCores = ncores;
315 }
320 Int_t getNumberOfCores() const{
321 return _nAllocatedCores;
322 }
324 //CLUSTER CODE
326 void preTreatment(Option_t *option="");
327
329
333 void addClusterDirective(TString directive, TString value);
334
336
339 void setJobName(TString path){
340 _sJobName=path;
341 }
343
346 TString getJobName(){
347 return _sJobName;
348 }
349
351 // SSH
353
355
361 Int_t connectSSH(TString cluster_name , TString user, TString authentification_method);
363
366 Int_t verify_knownhostSSH();
368
372 Int_t openSFTPChannel();
374 Int_t sendHeader();
376
378 Int_t sendCompiledBinary(std::list<TString> filenames);
380
384 Int_t sendInputFiles(Int_t start, Int_t end);
385
387
391 Int_t retrieveInputFiles(const char * localFolder);
392
394
398 Int_t closeSFTPChannel();
399
401
404 void setRemotePath(TString remotePath){
405 if (!remotePath.EndsWith("/"))
406 {
407 remotePath.Append("/");
408 }
409 _sRemoteWorkingDirectory = remotePath;
410 }
411
413
416 void setDataServer(URANIE::DataServer::TDataServer *tds){
417 _tds =tds;
418 }
420
423 TString getGateway()
424 {
425 return _sGateWay;
426 }
427
428 Bool_t isConnected(){
429 return _sConnected;
430 }
431
432 virtual void selectHeader(TString SkeletonHeaderName="./",TString localHeaderFolderPath=gSystem->pwd() ) {UNUSED(SkeletonHeaderName,localHeaderFolderPath); cout << "base" <<endl;};
433 virtual void generateHeader(Option_t *option = "") {UNUSED(option); cout << "base" <<endl;};
434 virtual void generateHeaderSplit(Option_t *option = "") {UNUSED(option); cout << "base" <<endl;};
435 TString getJobStatusCommand(std::list<std::pair<TString, std::pair<int, int> > > JobList) {UNUSED(JobList); return "base";};
436 TString getJobStatusCommand(TString JobIDs) {UNUSED(JobIDs); return "base";};
437 TString checkJobStatus(TString JobId, TString Command) {UNUSED(JobId,Command); return "base";};
438 void substituteDirectives(TString infilePath, TString outFilePath, std::map<TString,TString> ListOfDirectives);
440
441 void execRemoteCommand(TString command);
442 virtual TString submitJob(TString command);
443
444 void replaceHeaderKey(std::string& source, const std::string& from, const std::string& to);
445#endif
446
447protected:
448
450 // SSH
452#ifdef WITH_LIBSSH
453 ssh_session _sSshSession;
458 sftp_session _sFtpSession;
459 ssh_session *_ptrsshSession;
464 sftp_session * _ptrsftp;
465
469 TString _sSshOutput;
470 Bool_t _sConnected;
471
473 // Header
475 TString _sSkeletonHeader;
479 TString _sOutputHeader;
483 TString _sSplitName;
487 TString _sWorkingDirectory;
491 TString _sOutputHeaderPath;
495 TString _sJobName;
499 TString _slocalHeaderFolderPath;
503 Int_t _nAllocatedCores;
508 Int_t _sRetries;
509
513 TString _sRemoteWorkingDirectory;
514
516 // Cluster
518
522 TString _sClusterUser;
527 TString _sClusterUserAuthMethod;
532 TString _sClusterName;
536 TString _sClusterIP;
537
541 TString _sGateWay;
545 vector<TString> _sJobID;
549 Bool_t _sUserBinary=kFALSE;
553 TString _sConnectionProtocol="ssh";
554
558 std::map<TString,TString> _sListClusterDirectives;
559#endif
560
561 Int_t getProcsPerJob(Char_t separator, const Char_t* procs) const;
562
563 ClassDef(URANIE::Launcher::TCluster, ID_LAUNCHER)
564
565};
566
567
568} // Fin du namespace Launcher
569} // Fin du namespace URANIE
570#endif
Interface of the class URANIE::Launcher::TCode.
Interface of the class URANIE::Launcher::TInputFileFlag.
Interface of the class URANIE::Launcher::TInputFileRecreate.
Description of the class TCluster.
Definition TCluster.h:71
Bool_t _blog
Boolean to edit the log.
Definition TCluster.h:73
void setNNodes(Int_t nnode)
Definition TCluster.h:117
void changeLog()
Definition TCluster.h:138
virtual ~TCluster()
Default destructor.
void setLog()
Definition TCluster.h:132
TString getListOfNodes()
Definition TCluster.h:120
virtual void printLog(Option_t *option="")
virtual void init()=0
Constructs the list of nodes.
void unsetLog()
Definition TCluster.h:135
Bool_t getLog()
Definition TCluster.h:141
Int_t _nnode
The number of nodes by proc.
Definition TCluster.h:81
virtual void getCommandPrefix(char *, char *)=0
Int_t getProcsPerJob(Char_t separator, const Char_t *procs) const
void addNodeName(const TString &snodename, Int_t n=-1)
TString _slistOfNodes
The list of nodes.
Definition TCluster.h:82
TCluster(const char *name, const char *nodeList, Int_t nnode)
Description of the class TCode.
Definition TCode.h:46
Definition TCluster.h:67