Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
getProof.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_proof
3///
4/// Attaches to a PROOF session, possibly at the indicated URL.
5/// If no existing PROOF session is found and no URL is given,
6/// try to start a local PROOF session.
7///
8/// Arguments:
9/// 'url' URL of the master where to start/attach the PROOF session;
10/// this is also the place where to force creation of a new session,
11/// if needed (use option 'N', e.g. "proof://mymaster:myport/?N")
12///
13/// The following arguments apply to xrootd responding at 'refloc' only:
14/// 'nwrks' Number of workers to be started. []
15/// 'dir' Directory to be used for the files and working areas []. When starting a new
16/// instance of the daemon this directory is cleaned with 'rm -fr'. If 'dir'
17/// is null, the default is used: `/tmp/<user>/.getproof`
18/// 'opt' Defines what to do if an existing xrootd uses the same ports; possible
19/// options are: "ask", ask the user; "force", kill the xrootd and start
20/// a new one; if any other string is specified the existing xrootd will be
21/// used ["ask"].
22/// NB: for a change in 'nwrks' to be effective you need to specify opt = "force"
23/// 'dyn' This flag can be used to switch on dynamic, per-job worker setup scheduling
24/// [kFALSE].
25/// 'tutords' This flag can be used to force a dataset dir under the tutorial dir [kFALSE]
26///
27/// It is possible to trigger the automatic valgrind setup by defining the env GETPROOF_VALGRIND.
28/// E.g. to run the master in valgrind do
29///
30/// $ export GETPROOF_VALGRIND="valgrind=master"
31///
32/// (or
33/// $ export GETPROOF_VALGRIND="valgrind=master valgrind_opts:--leak-check=full"
34///
35/// to set some options) before running getProof. Note that 'getProof' is also called by 'stressProof',
36/// so this holds for 'stressProof' runs too.
37///
38///
39/// \macro_code
40///
41/// \author Gerardo Ganis
42
43#include "Bytes.h"
44#include "Getline.h"
45#include "TEnv.h"
46#include "TProof.h"
47#include "TSocket.h"
48#include "TString.h"
49#include "TSystem.h"
50
51// Auxilliary functions
52int getDebugEnum(const char *what);
53Int_t getXrootdPid(Int_t port, const char *subdir = "xpdtut");
54Int_t checkXrootdAt(Int_t port, const char *host = "localhost");
55Int_t checkXproofdAt(Int_t port, const char *host = "localhost");
56Int_t startXrootdAt(Int_t port, const char *exportdirs = nullptr, Bool_t force = kFALSE);
57Int_t killXrootdAt(Int_t port, const char *id = nullptr);
58
59// Auxilliary structures for Xrootd/Xproofd pinging ...
60// The client request
61typedef struct {
62 int first;
63 int second;
64 int third;
65 int fourth;
66 int fifth;
67} clnt_HS_t;
68// The body received after the first handshake's header
69typedef struct {
70 int msglen;
71 int protover;
72 int msgval;
73} srv_HS_t;
74
75// By default we start a cluster on the local machine
76const char *refloc = "proof://localhost:40000";
77
78TProof *getProof(const char *url = "proof://localhost:40000", Int_t nwrks = -1, const char *dir = nullptr,
79 const char *opt = "ask", Bool_t dyn = kFALSE, Bool_t tutords = kFALSE)
80{
81
82
83 TProof *p = nullptr;
84
85 // Valgrind options, if any
86 TString vopt, vopts;
87#ifndef WIN32
88 if (gSystem->Getenv("GETPROOF_VALGRIND")) {
89 TString s(gSystem->Getenv("GETPROOF_VALGRIND")), t;
90 Int_t from = 0;
91 while (s.Tokenize(t, from , " ")) {
92 if (t.BeginsWith("valgrind_opts:"))
93 vopts = t;
94 else
95 vopt = t;
96 }
97 if (vopts.IsNull()) vopts = "valgrind_opts:--leak-check=full --track-origins=yes";
98 TProof::AddEnvVar("PROOF_WRAPPERCMD", vopts.Data());
99 Printf("getProof: valgrind run: '%s' (opts: '%s')", vopt.Data(), vopts.Data());
100 }
101#endif
102
103 // If an URL has specified get a session there
104 TUrl uu(url), uref(refloc);
105 Bool_t ext = (strcmp(uu.GetHost(), uref.GetHost()) ||
106 (uu.GetPort() != uref.GetPort())) ? kTRUE : kFALSE;
107 Bool_t lite = kFALSE;
108 if (ext && url) {
109 if (!strcmp(url, "lite://") || !url[0]) {
110 if (!url[0]) uu.SetUrl("lite://");
111 if (dir && strlen(dir) > 0) gEnv->SetValue("Proof.Sandbox", dir);
112 TString swrk("<default> workers");
113 if (nwrks > 0) {
114 uu.SetOptions(Form("workers=%d", nwrks));
115 swrk.Form("%d workers", nwrks);
116 }
117 lite = kTRUE;
118 gEnv->SetValue("Proof.MaxOldSessions", 1);
119 Printf("getProof: trying to open a PROOF-Lite session with %s", swrk.Data());
120 } else {
121 Printf("getProof: trying to open a session on the external cluster at '%s'", url);
122 }
123 p = TProof::Open(uu.GetUrl(), vopt);
124 if (p && p->IsValid()) {
125 // Check consistency
126 if (ext && !lite && nwrks > 0) {
127 Printf("getProof: WARNING: started/attached a session on external cluster (%s):"
128 " 'nwrks=%d' ignored", url, nwrks);
129 }
130 if (ext && !lite && dir && strlen(dir) > 0) {
131 Printf("getProof: WARNING: started/attached a session on external cluster (%s):"
132 " 'dir=\"%s\"' ignored", url, dir);
133 }
134 if (ext && !strcmp(opt,"force")) {
135 Printf("getProof: WARNING: started/attached a session on external cluster (%s):"
136 " 'opt=\"force\"' ignored", url);
137 }
138 if (ext && dyn) {
139 Printf("getProof: WARNING: started/attached a session on external cluster (%s):"
140 " 'dyn=kTRUE' ignored", url);
141 }
142 } else {
143 Printf("getProof: could not get/start a valid session at %s", url);
144 if (p) delete p;
145 p = nullptr;
146 }
147 // Done
148 return p;
149 }
150
151#ifdef WIN32
152 // No support for local PROOF on Win32 (yet; the optimized local Proof will work there too)
153 Printf("getProof: local PROOF not yet supported on Windows, sorry!");
154 return p;
155#else
156
157 // Temp dir for tutorial daemons
158 TString tutdir = dir;
159 if (!tutdir.IsNull()) {
160 if (gSystem->AccessPathName(tutdir)) {
161 // Directory does not exist: try to make it
162 gSystem->mkdir(tutdir.Data(), kTRUE);
164 if (gSystem->AccessPathName(tutdir)) {
165 Printf("getProof: unable to create the working area at the requested path: '%s'"
166 " - cannot continue", tutdir.Data());
167 } else {
168 Printf("getProof: working area at the requested path '%s'"
169 " created but it is not writable - cannot continue", tutdir.Data());
170 }
171 return p;
172 }
173 } else {
174 // Check if it is writable ...
176 // ... fail if not
177 Printf("getProof: working area at the requested path '%s'"
178 " exists but is not writable - cannot continue", tutdir.Data());
179 return p;
180 }
181 }
182 } else {
183 // Notify
184 Printf("getProof: working area not specified temp ");
185 // Force "/tmp/<user>" whenever possible to avoid length problems on MacOsX
186 tutdir="/tmp";
188 TString us;
190 if (!ug) {
191 Printf("getProof: could not get user info");
192 return p;
193 }
194 us.Form("/%s", ug->fUser.Data());
195 if (!tutdir.EndsWith(us.Data())) tutdir += us;
196 // Add our own subdir
197 tutdir += "/.getproof";
198 if (gSystem->AccessPathName(tutdir)) {
199 gSystem->mkdir(tutdir.Data(), kTRUE);
201 Printf("getProof: unable to get a writable working area (tried: %s)"
202 " - cannot continue", tutdir.Data());
203 return p;
204 }
205 }
206 }
207 Printf("getProof: working area (tutorial dir): %s", tutdir.Data());
208
209 // Dataset dir
210 TString datasetdir;
211 if (tutords) {
212 datasetdir = Form("%s/dataset", tutdir.Data());
213 if (gSystem->AccessPathName(datasetdir, kWritePermission)) {
214 gSystem->mkdir(datasetdir, kTRUE);
215 if (gSystem->AccessPathName(datasetdir, kWritePermission)) {
216 Printf("getProof: unable to get a writable dataset directory (tried: %s)"
217 " - cannot continue", datasetdir.Data());
218 return p;
219 }
220 Printf("getProof: dataset dir: %s", datasetdir.Data());
221 }
222 }
223
224 // Local url (use a special port to try to not disturb running daemons)
225 TUrl u(refloc);
226 u.SetProtocol("proof");
227 if (!strcmp(uu.GetHost(), uref.GetHost()) && (uu.GetPort() != uref.GetPort()))
228 u.SetPort(uu.GetPort());
229 Int_t lportp = u.GetPort();
230 Int_t lportx = lportp + 1;
231 TString lurl = u.GetUrl();
232
233 // Prepare to start the daemon
234 TString workarea = Form("%s/proof", tutdir.Data());
235 TString xpdcf(Form("%s/xpd.cf",tutdir.Data()));
236 TString xpdlog(Form("%s/xpd.log",tutdir.Data()));
237 TString xpdlogprt(Form("%s/xpdtut/xpd.log",tutdir.Data()));
238 TString xpdpid(Form("%s/xpd.pid",tutdir.Data()));
239 TString proofsessions(Form("%s/sessions",tutdir.Data()));
240 TString cmd;
241 Int_t rc = 0;
242
243 // Is there something listening already ?
244 Int_t pid = -1;
245 Bool_t restart = kTRUE;
246 if ((rc = checkXproofdAt(lportp)) == 1) {
247 Printf("getProof: something else the a XProofd service is running on"
248 " port %d - cannot continue", lportp);
249 return p;
250
251 } else if (rc == 0) {
252
253 restart = kFALSE;
254
255 pid = getXrootdPid(lportx);
256 Printf("getProof: daemon found listening on dedicated ports {%d,%d} (pid: %d)",
257 lportx, lportp, pid);
258 if (isatty(0) == 0 || isatty(1) == 0) {
259 // Cannot ask: always restart
260 restart = kTRUE;
261 } else {
262 if (!strcmp(opt,"ask")) {
263 char *answer = (char *) Getline("getProof: would you like to restart it (N,Y)? [N] ");
264 if (answer && (answer[0] == 'Y' || answer[0] == 'y'))
265 restart = kTRUE;
266 }
267 }
268 if (!strcmp(opt,"force"))
269 // Always restart
270 restart = kTRUE;
271
272 // Cleanup, if required
273 if (restart) {
274 Printf("getProof: cleaning existing instance ...");
275 // Cleaning up existing daemon
276 cmd = Form("kill -9 %d", pid);
277 if ((rc = gSystem->Exec(cmd)) != 0)
278 Printf("getProof: problems stopping xrootd process %d (%d)", pid, rc);
279 // Wait for all previous connections being cleaned
280 Printf("getProof: wait 5 secs so that previous connections are cleaned ...");
281 gSystem->Sleep(5000);
282 }
283 }
284
285 if (restart) {
286
287 // Try to start something locally; make sure that everything is there
288 char *xpd = gSystem->Which(gSystem->Getenv("PATH"), "xproofd", kExecutePermission);
289 if (!xpd) {
290 Printf("getProof: xproofd not found: please check the environment!");
291 return p;
292 }
293
294 // Cleanup the working area
295 cmd = Form("rm -fr %s/xpdtut %s %s %s %s", tutdir.Data(), workarea.Data(),
296 xpdcf.Data(), xpdpid.Data(), proofsessions.Data());
297 gSystem->Exec(cmd);
298
299 // Try to start something locally; create the xproofd config file
300 FILE *fcf = fopen(xpdcf.Data(), "w");
301 if (!fcf) {
302 Printf("getProof: could not create config file for XPD (%s)", xpdcf.Data());
303 return p;
304 }
305 fprintf(fcf,"### Use admin path at %s/admin to avoid interferences with other users\n", tutdir.Data());
306 fprintf(fcf,"xrd.adminpath %s/admin\n", tutdir.Data());
307#if defined(R__MACOSX)
308 fprintf(fcf,"### Use dedicated socket path under /tmp to avoid length problems\n");
309 fprintf(fcf,"xpd.sockpathdir /tmp/xpd-sock\n");
310#endif
311 fprintf(fcf,"### Load the XrdProofd protocol on port %d\n", lportp);
312 fprintf(fcf,"xrd.protocol xproofd libXrdProofd.so\n");
313 fprintf(fcf,"xpd.port %d\n", lportp);
314 if (nwrks > 0) {
315 fprintf(fcf,"### Force number of local workers\n");
316 fprintf(fcf,"xpd.localwrks %d\n", nwrks);
317 }
318 fprintf(fcf,"### Root path for working dir\n");
319 fprintf(fcf,"xpd.workdir %s\n", workarea.Data());
320 fprintf(fcf,"### Allow different users to connect\n");
321 fprintf(fcf,"xpd.multiuser 1\n");
322 fprintf(fcf,"### Limit the number of query results kept in the master sandbox\n");
323 fprintf(fcf,"xpd.putrc ProofServ.UserQuotas: maxquerykept=2\n");
324 fprintf(fcf,"### Limit the number of sessions kept in the sandbox\n");
325 fprintf(fcf,"xpd.putrc Proof.MaxOldSessions: 1\n");
326 if (tutords) {
327 fprintf(fcf,"### Use dataset directory under the tutorial dir\n");
328 fprintf(fcf,"xpd.datasetsrc file url:%s opt:-Cq:Av:As:\n", datasetdir.Data());
329 }
330 if (dyn) {
331 fprintf(fcf,"### Use dynamic, per-job scheduling\n");
332 fprintf(fcf,"xpd.putrc Proof.DynamicStartup 1\n");
333 }
334 fprintf(fcf,"### For internal file serving use the xrootd protocol on the same port\n");
335 fprintf(fcf,"xpd.xrootd libXrdXrootd-4.so\n");
336 fprintf(fcf,"### Set the local data server for the temporary output files accordingly\n");
337 fprintf(fcf,"xpd.putenv LOCALDATASERVER=root://%s:%d\n", gSystem->HostName(), lportp);
338 fclose(fcf);
339 Printf("getProof: xproofd config file at %s", xpdcf.Data());
340
341 // Start xrootd in the background
342 Printf("getProof: xproofd log file at %s", xpdlogprt.Data());
343 cmd = Form("%s -c %s -b -l %s -n xpdtut -p %d",
344 xpd, xpdcf.Data(), xpdlog.Data(), lportp);
345 Printf("(NB: any error line from XrdClientSock::RecvRaw and XrdClientMessage::ReadRaw should be ignored)");
346 if ((rc = gSystem->Exec(cmd)) != 0) {
347 Printf("getProof: problems starting xproofd (%d)", rc);
348 return p;
349 }
350 delete[] xpd;
351
352 // Wait a bit
353 Printf("getProof: waiting for xproofd to start ...");
354 gSystem->Sleep(2000);
355
356 pid = getXrootdPid(lportp);
357 Printf("getProof: xproofd pid: %d", pid);
358
359 // Save it in the PID file
360 FILE *fpid = fopen(xpdpid.Data(), "w");
361 if (!fpid) {
362 Printf("getProof: could not create pid file for XPD");
363 } else {
364 fprintf(fpid,"%d\n", pid);
365 fclose(fpid);
366 }
367 }
368 Printf("getProof: start / attach the PROOF session ...");
369
370 // Start / attach the session now
371 p = TProof::Open(lurl, vopt.Data());
372 if (!p || !(p->IsValid())) {
373 Printf("getProof: starting local session failed");
374 if (p) delete p;
375 p = nullptr;
376 return p;
377 }
378
379 // Return the session
380 return p;
381#endif
382}
383
384Int_t getXrootdPid(Int_t port, const char *subdir)
385{
386#ifdef WIN32
387 // No support for Xrootd/Proof on Win32 (yet; the optimized local Proof will work there too)
388 Printf("getXrootdPid: Xrootd/Proof not supported on Windows, sorry!");
389 return -1;
390#else
391 // Get the pid of the started xrootd process
392 Int_t pid = -1;
393#if defined(__sun)
394 const char *com = "-eo pid,comm";
395#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
396 const char *com = "ax -w -w";
397#else
398 const char *com = "-w -w -eo pid,command";
399#endif
400 TString cmd;
401 if (subdir && strlen(subdir) > 0) {
402 cmd.Form("ps %s | grep xrootd | grep \"\\-p %d\" | grep %s", com, port, subdir);
403 } else {
404 cmd.Form("ps %s | grep xrootd | grep \"\\-p %d\"", com, port);
405 }
406 FILE *fp = gSystem->OpenPipe(cmd.Data(), "r");
407 if (fp) {
408 char line[2048], rest[2048];
409 while (fgets(line, sizeof(line), fp)) {
410 sscanf(line,"%d %s", &pid, rest);
411 break;
412 }
413 gSystem->ClosePipe(fp);
414 }
415 // Done
416 return pid;
417#endif
418}
419
420Int_t checkXrootdAt(Int_t port, const char *host)
421{
422 // Check if a XrdXrootd service is running on 'port' at 'host'
423 // Return
424 // 0 if OK
425 // -1 if nothing is listening on the port (connection cannot be open)
426 // 1 if something is listening but not XROOTD
427
428 // Open the connection
429 TSocket s(host, port);
430 if (!(s.IsValid())) {
431 if (gDebug > 0)
432 Printf("checkXrootdAt: could not open connection to %s:%d", host, port);
433 return -1;
434 }
435 // Send the first bytes
436 clnt_HS_t initHS;
437 memset(&initHS, 0, sizeof(initHS));
438 initHS.fourth = host2net((int)4);
439 initHS.fifth = host2net((int)2012);
440 int len = sizeof(initHS);
441 s.SendRaw(&initHS, len);
442 // Read first server response
443 int type;
444 len = sizeof(type);
445 int readCount = s.RecvRaw(&type, len); // 4(2+2) bytes
446 if (readCount != len) {
447 if (gDebug > 0)
448 Printf("checkXrootdAt: 1st: wrong number of bytes read: %d (expected: %d)",
449 readCount, len);
450 return 1;
451 }
452 // to host byte order
453 type = net2host(type);
454 // Check if the server is the eXtended proofd
455 if (type == 0) {
456 srv_HS_t xbody;
457 len = sizeof(xbody);
458 readCount = s.RecvRaw(&xbody, len); // 12(4+4+4) bytes
459 if (readCount != len) {
460 if (gDebug > 0)
461 Printf("checkXrootdAt: 2nd: wrong number of bytes read: %d (expected: %d)",
462 readCount, len);
463 return 1;
464 }
465
466 } else if (type == 8) {
467 // Standard proofd
468 if (gDebug > 0)
469 Printf("checkXrootdAt: server is ROOTD");
470 return 1;
471 } else {
472 // We don't know the server type
473 if (gDebug > 0)
474 Printf("checkXrootdAt: unknown server type: %d", type);
475 return 1;
476 }
477 // Done
478 return 0;
479}
480
481Int_t checkXproofdAt(Int_t port, const char *host)
482{
483 // Check if a XrdProofd service is running on 'port' at 'host'
484 // Return
485 // 0 if OK
486 // -1 if nothing is listening on the port (connection cannot be open)
487 // 1 if something is listening but not XPROOFD
488
489 // Open the connection
490 TSocket s(host, port);
491 if (!(s.IsValid())) {
492 if (gDebug > 0)
493 Printf("checkXproofdAt: could not open connection to %s:%d", host, port);
494 return -1;
495 }
496 // Send the first bytes
497 clnt_HS_t initHS;
498 memset(&initHS, 0, sizeof(initHS));
499 initHS.third = (int)host2net((int)1);
500 int len = sizeof(initHS);
501 s.SendRaw(&initHS, len);
502 // These 8 bytes are need by 'proofd' and discarded by XPD
503 int dum[2];
504 dum[0] = (int)host2net((int)4);
505 dum[1] = (int)host2net((int)2012);
506 s.SendRaw(&dum[0], sizeof(dum));
507 // Read first server response
508 int type;
509 len = sizeof(type);
510 int readCount = s.RecvRaw(&type, len); // 4(2+2) bytes
511 if (readCount != len) {
512 if (gDebug > 0)
513 Printf("checkXproofdAt: 1st: wrong number of bytes read: %d (expected: %d)",
514 readCount, len);
515 return 1;
516 }
517 // to host byte order
518 type = net2host(type);
519 // Check if the server is the eXtended proofd
520 if (type == 0) {
521 srv_HS_t xbody;
522 len = sizeof(xbody);
523 readCount = s.RecvRaw(&xbody, len); // 12(4+4+4) bytes
524 if (readCount != len) {
525 if (gDebug > 0)
526 Printf("checkXproofdAt: 2nd: wrong number of bytes read: %d (expected: %d)",
527 readCount, len);
528 return 1;
529 }
530 xbody.protover = net2host(xbody.protover);
531 xbody.msgval = net2host(xbody.msglen);
532 xbody.msglen = net2host(xbody.msgval);
533
534 } else if (type == 8) {
535 // Standard proofd
536 if (gDebug > 0)
537 Printf("checkXproofdAt: server is PROOFD");
538 return 1;
539 } else {
540 // We don't know the server type
541 if (gDebug > 0)
542 Printf("checkXproofdAt: unknown server type: %d", type);
543 return 1;
544 }
545 // Done
546 return 0;
547}
548
549Int_t startXrootdAt(Int_t port, const char *exportdirs, Bool_t force)
550{
551 // Start a basic xrootd service on 'port' exporting the dirs in 'exportdirs'
552 // (blank separated list)
553
554#ifdef WIN32
555 // No support for Xrootd on Win32 (yet; the optimized local Proof will work there too)
556 Printf("startXrootdAt: Xrootd not supported on Windows, sorry!");
557 return -1;
558#else
559 Bool_t restart = kTRUE;
560
561 // Already there?
562 Int_t rc = 0;
563 if ((rc = checkXrootdAt(port)) == 1) {
564
565 Printf("startXrootdAt: some other service running on port %d - cannot proceed ", port);
566 return -1;
567
568 } else if (rc == 0) {
569
570 restart = kFALSE;
571
572 if (force) {
573 // Always restart
574 restart = kTRUE;
575 } else {
576 Printf("startXrootdAt: xrootd service already available on port %d: ", port);
577 char *answer = (char *) Getline("startXrootdAt: would you like to restart it (N,Y)? [N] ");
578 if (answer && (answer[0] == 'Y' || answer[0] == 'y')) {
579 restart = kTRUE;
580 }
581 }
582
583 // Cleanup, if required
584 if (restart) {
585 Printf("startXrootdAt: cleaning existing instance ...");
586
587 // Get the Pid
588 Int_t pid = getXrootdPid(port, "xrd-basic");
589
590 // Cleanimg up existing daemon
591 TString cmd = Form("kill -9 %d", pid);
592 if ((rc = gSystem->Exec(cmd)) != 0)
593 Printf("startXrootdAt: problems stopping xrootd process %d (%d)", pid, rc);
594 }
595 }
596
597 if (restart) {
598 if (gSystem->AccessPathName("/tmp/xrd-basic")) {
599 gSystem->mkdir("/tmp/xrd-basic");
600 if (gSystem->AccessPathName("/tmp/xrd-basic")) {
601 Printf("startXrootdAt: could not assert dir for log file");
602 return -1;
603 }
604 }
605 TString cmd;
606 cmd.Form("xrootd -d -p %d -b -l /tmp/xrd-basic/xrootd.log", port);
607 if (exportdirs && strlen(exportdirs) > 0) {
608 TString dirs(exportdirs), d;
609 Int_t from = 0;
610 while (dirs.Tokenize(d, from, " ")) {
611 if (!d.IsNull()) {
612 cmd += " ";
613 cmd += d;
614 }
615 }
616 }
617 Printf("cmd: %s", cmd.Data());
618 if ((rc = gSystem->Exec(cmd)) != 0) {
619 Printf("startXrootdAt: problems executing starting command (%d)", rc);
620 return -1;
621 }
622 // Wait a bit
623 Printf("startXrootdAt: waiting for xrootd to start ...");
624 gSystem->Sleep(2000);
625 // Check the result
626 if ((rc = checkXrootdAt(port)) != 0) {
627 Printf("startXrootdAt: xrootd service not available at %d (rc = %d) - startup failed",
628 port, rc);
629 return -1;
630 }
631 Printf("startXrootdAt: basic xrootd started!");
632 }
633
634 // Done
635 return 0;
636#endif
637}
638
639Int_t killXrootdAt(Int_t port, const char *id)
640{
641 // Kill running xrootd service on 'port'
642
643#ifdef WIN32
644 // No support for Xrootd on Win32 (yet; the optimized local Proof will work there too)
645 Printf("killXrootdAt: Xrootd not supported on Windows, sorry!");
646 return -1;
647#else
648
649 Int_t pid = -1, rc= 0;
650 if ((pid = getXrootdPid(port, id)) > 0) {
651
652 // Cleanimg up existing daemon
653 TString cmd = Form("kill -9 %d", pid);
654 if ((rc = gSystem->Exec(cmd)) != 0)
655 Printf("killXrootdAt: problems stopping xrootd process %d (%d)", pid, rc);
656 }
657
658 // Done
659 return rc;
660#endif
661}
662
663int getDebugEnum(const char *what)
664{
665 // Check if 'what' matches one of the TProofDebug enum and return the corresponding
666 // integer. Relies on a perfect synchronization with the content of TProofDebug.h .
667
668 TString sws(what), sw;
669 int rcmask = 0;
670 int from = 0;
671 while (sws.Tokenize(sw, from , "|")) {
672 if (sw.BeginsWith("k")) sw.Remove(0,1);
673
674 if (sw == "None") {
675 rcmask |= TProofDebug::kNone;
676 } else if (sw == "Packetizer") {
677 rcmask |= TProofDebug::kPacketizer;
678 } else if (sw == "Loop") {
679 rcmask |= TProofDebug::kLoop;
680 } else if (sw == "Selector") {
681 rcmask |= TProofDebug::kSelector;
682 } else if (sw == "Output") {
683 rcmask |= TProofDebug::kOutput;
684 } else if (sw == "Input") {
685 rcmask |= TProofDebug::kInput;
686 } else if (sw == "Global") {
687 rcmask |= TProofDebug::kGlobal;
688 } else if (sw == "Package") {
689 rcmask |= TProofDebug::kPackage;
690 } else if (sw == "Feedback") {
691 rcmask |= TProofDebug::kFeedback;
692 } else if (sw == "Condor") {
693 rcmask |= TProofDebug::kCondor;
694 } else if (sw == "Draw") {
695 rcmask |= TProofDebug::kDraw;
696 } else if (sw == "Asyn") {
697 rcmask |= TProofDebug::kAsyn;
698 } else if (sw == "Cache") {
699 rcmask |= TProofDebug::kCache;
700 } else if (sw == "Collect") {
701 rcmask |= TProofDebug::kCollect;
702 } else if (sw == "Dataset") {
703 rcmask |= TProofDebug::kDataset;
704 } else if (sw == "Submerger") {
705 rcmask |= TProofDebug::kSubmerger;
706 } else if (sw == "Monitoring") {
707 rcmask |= TProofDebug::kMonitoring;
708 } else if (sw == "All") {
709 rcmask |= TProofDebug::kAll;
710 } else if (!sw.IsNull()) {
711 Printf("WARNING: requested debug enum name '%s' does not exist: assuming 'All'", sw.Data());
712 rcmask |= TProofDebug::kAll;
713 }
714 }
715 // Done
716 return rcmask;
717}
UShort_t host2net(UShort_t x)
Definition Bytes.h:562
UShort_t net2host(UShort_t x)
Definition Bytes.h:575
#define d(i)
Definition RSha256.hxx:102
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Int_t gDebug
Definition TROOT.cxx:597
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2481
@ kExecutePermission
Definition TSystem.h:45
@ kWritePermission
Definition TSystem.h:46
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:736
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
static TProof * Open(const char *url=0, const char *conffile=0, const char *confdir=0, Int_t loglevel=0)
Start a PROOF session on a specific cluster.
Definition TProof.cxx:11583
static void AddEnvVar(const char *name, const char *value)
Add an variable to the list of environment variables passed to proofserv on the master and slaves.
Definition TProof.cxx:11760
Basic string class.
Definition TString.h:139
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2222
const char * Data() const
Definition TString.h:380
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:627
Bool_t IsNull() const
Definition TString.h:418
TString & Remove(Ssiz_t pos)
Definition TString.h:685
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2334
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1650
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
Definition TSystem.cxx:893
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:640
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
Definition TSystem.cxx:649
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1283
virtual int ClosePipe(FILE *pipe)
Close the pipe.
Definition TSystem.cxx:658
virtual const char * HostName()
Return the system's host name.
Definition TSystem.cxx:290
virtual Int_t GetUid(const char *user=nullptr)
Returns the user's id. If user = 0, returns current user's id.
Definition TSystem.cxx:1547
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:424
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1533
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition TSystem.cxx:1586
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1469
This class represents a WWW compatible URL.
Definition TUrl.h:33
TLine * line
Definition first.py:1
static const char * what
Definition stlLoader.cc:6
TString fUser
Definition TSystem.h:141
int protover
Definition TProofMgr.cxx:56