ROOT  6.06/08
Reference Guide
TXProofMgr.cxx
Go to the documentation of this file.
1 // @(#)root/proofx:$Id$
2 // Author: Gerardo Ganis 12/12/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TXProofMgr //
15 // //
16 // The PROOF manager interacts with the PROOF server coordinator to //
17 // create or destroy a PROOF session, attach to or detach from //
18 // existing one, and to monitor any client activity on the cluster. //
19 // At most one manager instance per server is allowed. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include <errno.h>
24 #include <memory>
25 #ifdef WIN32
26 #include <io.h>
27 #endif
28 
29 #include "Getline.h"
30 #include "TList.h"
31 #include "TObjArray.h"
32 #include "TObjString.h"
33 #include "TProof.h"
34 #include "TProofLog.h"
35 #include "TXProofMgr.h"
36 #include "TXSocket.h"
37 #include "TXSocketHandler.h"
38 #include "TROOT.h"
39 #include "TStopwatch.h"
40 #include "TSysEvtHandler.h"
41 #include "XProofProtocol.h"
42 
43 #include "XrdProofConn.h"
44 
46 
47 //
48 //----- ProofMgr Interrupt signal handler
49 //
50 class TProofMgrInterruptHandler : public TSignalHandler {
51 private:
52  TProofMgr *fMgr;
53 
54  TProofMgrInterruptHandler(const TProofMgrInterruptHandler&); // Not implemented
55  TProofMgrInterruptHandler& operator=(const TProofMgrInterruptHandler&); // Not implemented
56 public:
57  TProofMgrInterruptHandler(TProofMgr *mgr)
58  : TSignalHandler(kSigInterrupt, kFALSE), fMgr(mgr) { }
59  Bool_t Notify();
60 };
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// TProofMgr interrupt handler.
64 
65 Bool_t TProofMgrInterruptHandler::Notify()
66 {
67  // Only on clients
68  if (isatty(0) != 0 && isatty(1) != 0) {
69  TString u = fMgr->GetUrl();
70  Printf("Opening new connection to %s", u.Data());
71  TXSocket *s = new TXSocket(u, 'C', kPROOF_Protocol,
72  kXPROOF_Protocol, 0, -1, (TXHandler *)fMgr);
73  if (s && s->IsValid()) {
74  // Set the interrupt flag on the server
75  s->CtrlC();
76  }
77  }
78  return kTRUE;
79 }
80 
81 // Autoloading hooks.
82 // These are needed to avoid using the plugin manager which may create
83 // problems in multi-threaded environments.
84 TProofMgr *GetTXProofMgr(const char *url, Int_t l, const char *al)
85 { return ((TProofMgr *) new TXProofMgr(url, l, al)); }
86 
87 class TXProofMgrInit {
88 public:
89  TXProofMgrInit() {
91 }};
92 static TXProofMgrInit gxproofmgr_init;
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Create a PROOF manager for the standard (old) environment.
96 
97 TXProofMgr::TXProofMgr(const char *url, Int_t dbg, const char *alias)
98  : TProofMgr(url, dbg, alias)
99 {
100  // Set the correct servert type
102 
103  // Initialize
104  if (Init(dbg) != 0) {
105  // Failure: make sure the socket is deleted so that its lack of
106  // validity is correctly transmitted
108  }
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Do real initialization: open the connection and set the relevant
113 /// variables.
114 /// Login and authentication are dealt with at this level, if required.
115 /// Return 0 in case of success, 1 if the remote server is a 'proofd',
116 /// -1 in case of error.
117 
119 {
120  // Here we make sure that the port is explicitly specified in the URL,
121  // even when it matches the default value
122  TString u = fUrl.GetUrl(kTRUE);
123 
124  fSocket = 0;
125  if (!(fSocket = new TXSocket(u, 'C', kPROOF_Protocol,
126  kXPROOF_Protocol, 0, -1, this)) ||
127  !(fSocket->IsValid())) {
128  if (!fSocket || !(fSocket->IsServProofd()))
129  if (gDebug > 0)
130  Error("Init", "while opening the connection to %s - exit (error: %d)",
131  u.Data(), (fSocket ? fSocket->GetOpenError() : -1));
132  if (fSocket && fSocket->IsServProofd())
134  return -1;
135  }
136 
137  // Protocol run by remote PROOF server
139 
140  // We add the manager itself for correct destruction
142  gROOT->GetListOfSockets()->Remove(fSocket);
143  }
144 
145  // Set interrupt PROOF handler from now on
146  fIntHandler = new TProofMgrInterruptHandler(this);
147 
148  // We are done
149  return 0;
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153 /// Destructor: close the connection
154 
156 {
157  SetInvalid();
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// Invalidate this manager by closing the connection
162 
164 {
165  if (fSocket)
166  fSocket->Close("P");
168 
169  // Avoid destroying twice
171  gROOT->GetListOfSockets()->Remove(this);
172  }
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 /// Dummy version provided for completeness. Just returns a pointer to
177 /// existing session 'id' (as shown by TProof::QuerySessions) or 0 if 'id' is
178 /// not valid. The boolena 'gui' should be kTRUE when invoked from the GUI.
179 
181 {
182  if (!IsValid()) {
183  Warning("AttachSession","invalid TXProofMgr - do nothing");
184  return 0;
185  }
186  if (!d) {
187  Warning("AttachSession","invalid description object - do nothing");
188  return 0;
189  }
190 
191  if (d->GetProof())
192  // Nothing to do if already in contact with proofserv
193  return d->GetProof();
194 
195  // Re-compose url
196  TString u(Form("%s/?%d", fUrl.GetUrl(kTRUE), d->GetRemoteId()));
197 
198  // We need this to set correctly the kUsingSessionGui bit before the first
199  // feedback messages arrive
200  if (gui)
201  u += "GUI";
202 
203  // Attach
204  TProof *p = new TProof(u, 0, 0, gDebug, 0, this);
205  if (p && p->IsValid()) {
206 
207  // Set reference manager
208  p->SetManager(this);
209 
210  // Save record about this session
211  Int_t st = (p->IsIdle()) ? TProofDesc::kIdle
213  d->SetStatus(st);
214  d->SetProof(p);
215 
216  // Set session tag
217  p->SetName(d->GetName());
218 
219  } else {
220  // Session creation failed
221  Error("AttachSession", "attaching to PROOF session");
222  }
223  return p;
224 }
225 
226 ////////////////////////////////////////////////////////////////////////////////
227 /// Detach session with 'id' from its proofserv. The 'id' is the number
228 /// shown by QuerySessions. The correspondent TProof object is deleted.
229 /// If id == 0 all the known sessions are detached.
230 /// Option opt="S" or "s" forces session shutdown.
231 
233 {
234  if (!IsValid()) {
235  Warning("DetachSession","invalid TXProofMgr - do nothing");
236  return;
237  }
238 
239  if (id > 0) {
240  // Single session request
241  TProofDesc *d = GetProofDesc(id);
242  if (d) {
243  if (fSocket)
245  TProof *p = d->GetProof();
246  fSessions->Remove(d);
247  SafeDelete(p);
248  delete d;
249  }
250  } else if (id == 0) {
251 
252  // Requesto to destroy all sessions
253  if (fSocket) {
254  TString o = Form("%sA",opt);
255  fSocket->DisconnectSession(-1, o);
256  }
257  if (fSessions) {
258  // Delete PROOF sessions
259  TIter nxd(fSessions);
260  TProofDesc *d = 0;
261  while ((d = (TProofDesc *)nxd())) {
262  TProof *p = d->GetProof();
263  SafeDelete(p);
264  }
265  fSessions->Delete();
266  }
267  }
268 
269  return;
270 }
271 
272 ////////////////////////////////////////////////////////////////////////////////
273 /// Detach session 'p' from its proofserv. The instance 'p' is invalidated
274 /// and should be deleted by the caller
275 
277 {
278  if (!IsValid()) {
279  Warning("DetachSession","invalid TXProofMgr - do nothing");
280  return;
281  }
282 
283  if (p) {
284  // Single session request
285  TProofDesc *d = GetProofDesc(p);
286  if (d) {
287  if (fSocket)
289  fSessions->Remove(d);
290  p->Close(opt);
291  delete d;
292  }
293  }
294 
295  return;
296 }
297 
298 ////////////////////////////////////////////////////////////////////////////////
299 /// Checks if 'url' refers to the same 'user@host:port' entity as the URL
300 /// in memory. TProofMgr::MatchUrl cannot be used here because of the
301 /// 'double' default port, implying an additional check on the port effectively
302 /// open.
303 
304 Bool_t TXProofMgr::MatchUrl(const char *url)
305 {
306  if (!IsValid()) {
307  Warning("MatchUrl","invalid TXProofMgr - do nothing");
308  return 0;
309  }
310 
311  TUrl u(url);
312 
313  // Correct URL protocol
314  if (!strcmp(u.GetProtocol(), TUrl("a").GetProtocol()))
315  u.SetProtocol("proof");
316 
317  if (u.GetPort() == TUrl("a").GetPort()) {
318  // Set default port
319  Int_t port = gSystem->GetServiceByName("proofd");
320  if (port < 0)
321  port = 1093;
322  u.SetPort(port);
323  }
324 
325  // Now we can check
326  if (!strcmp(u.GetHostFQDN(), fUrl.GetHost()))
327  if (u.GetPort() == fUrl.GetPort() ||
328  u.GetPort() == fSocket->GetPort())
329  if (strlen(u.GetUser()) <= 0 || !strcmp(u.GetUser(),fUrl.GetUser()))
330  return kTRUE;
331 
332  // Match failed
333  return kFALSE;
334 }
335 
336 ////////////////////////////////////////////////////////////////////////////////
337 /// Show available workers
338 
340 {
341  if (!IsValid()) {
342  Warning("ShowWorkers","invalid TXProofMgr - do nothing");
343  return;
344  }
345 
346  // Send the request
348  if (os) {
349  TObjArray *oa = TString(os->GetName()).Tokenize(TString("&"));
350  if (oa) {
351  TIter nxos(oa);
352  TObjString *to = 0;
353  while ((to = (TObjString *) nxos()))
354  // Now parse them ...
355  Printf("+ %s", to->GetName());
356  }
357  }
358 }
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 /// Gets the URL to be prepended to paths when accessing the MSS associated
362 /// with the connected cluster, if any. The information is retrieved from
363 /// the cluster the first time or if retrieve is true.
364 
366 {
367  if (fMssUrl.IsNull() || retrieve) {
368  // Nothing to do if not in contact with proofserv
369  if (!IsValid()) {
370  Error("GetMssUrl", "invalid TXProofMgr - do nothing");
371  return 0;
372  }
373  // Server may not support it
374  if (fSocket->GetXrdProofdVersion() < 1007) {
375  Error("GetMssUrl", "functionality not supported by server");
376  return 0;
377  }
379  if (os) {
380  Printf("os: '%s'", os->GetName());
381  fMssUrl = os->GetName();
382  SafeDelete(os);
383  } else {
384  Error("GetMssUrl", "problems retrieving the required information");
385  return 0;
386  }
387  } else if (!IsValid()) {
388  Warning("GetMssUrl", "TXProofMgr is now invalid: information may not be valid");
389  return 0;
390  }
391 
392  // Done
393  return fMssUrl.Data();
394 }
395 
396 ////////////////////////////////////////////////////////////////////////////////
397 /// Get list of sessions accessible to this manager
398 
400 {
401  if (opt && !strncasecmp(opt,"L",1))
402  // Just return the existing list
403  return fSessions;
404 
405  // Nothing to do if not in contact with proofserv
406  if (!IsValid()) {
407  Warning("QuerySessions","invalid TXProofMgr - do nothing");
408  return 0;
409  }
410 
411  // Create list if not existing
412  if (!fSessions) {
413  fSessions = new TList();
414  fSessions->SetOwner();
415  }
416 
417  // Send the request
418  TList *ocl = new TList;
420  if (os) {
421  TObjArray *oa = TString(os->GetName()).Tokenize(TString("|"));
422  if (oa) {
423  TProofDesc *d = 0;
424  TIter nxos(oa);
425  TObjString *to = (TObjString *) nxos();
426  if (to && to->GetString().IsDigit() && !strncasecmp(opt,"S",1))
427  Printf("// +++ %s session(s) currently active +++", to->GetName());
428  while ((to = (TObjString *) nxos())) {
429  // Now parse them ...
430  Int_t id = -1, st = -1;
431  TString al, tg, tk;
432  Ssiz_t from = 0;
433  while (to->GetString()[from] == ' ') { from++; }
434  if (!to->GetString().Tokenize(tk, from, " ") || !tk.IsDigit()) continue;
435  id = tk.Atoi();
436  if (!to->GetString().Tokenize(tg, from, " ")) continue;
437  if (!to->GetString().Tokenize(al, from, " ")) continue;
438  if (!to->GetString().Tokenize(tk, from, " ") || !tk.IsDigit()) continue;
439  st = tk.Atoi();
440  // Add to the list, if not already there
441  if (!(d = (TProofDesc *) fSessions->FindObject(tg))) {
442  Int_t locid = fSessions->GetSize() + 1;
443  d = new TProofDesc(tg, al, GetUrl(), locid, id, st, 0);
444  fSessions->Add(d);
445  } else {
446  // Set missing / update info
447  d->SetStatus(st);
448  d->SetRemoteId(id);
449  d->SetTitle(al);
450  }
451  // Add to the list for final garbage collection
452  ocl->Add(new TObjString(tg));
453  }
454  SafeDelete(oa);
455  }
456  SafeDelete(os);
457  }
458 
459  // Printout and Garbage collection
460  if (fSessions->GetSize() > 0) {
461  TIter nxd(fSessions);
462  TProofDesc *d = 0;
463  while ((d = (TProofDesc *)nxd())) {
464  if (ocl->FindObject(d->GetName())) {
465  if (opt && !strncasecmp(opt,"S",1))
466  d->Print("");
467  } else {
468  fSessions->Remove(d);
469  SafeDelete(d);
470  }
471  }
472  }
473 
474  // We are done
475  return fSessions;
476 }
477 
478 ////////////////////////////////////////////////////////////////////////////////
479 /// Handle asynchronous input on the socket
480 
482 {
483  if (fSocket && fSocket->IsValid()) {
484  TMessage *mess;
485  if (fSocket->Recv(mess) >= 0) {
486  Int_t what = mess->What();
487  if (gDebug > 0)
488  Info("HandleInput", "%p: got message type: %d", this, what);
489  switch (what) {
490  case kPROOF_TOUCH:
491  fSocket->RemoteTouch();
492  break;
493  default:
494  Warning("HandleInput", "%p: got unknown message type: %d", this, what);
495  break;
496  }
497  }
498  } else {
499  Warning("HandleInput", "%p: got message but socket is invalid!", this);
500  }
501 
502  // We are done
503  return kTRUE;
504 }
505 
506 ////////////////////////////////////////////////////////////////////////////////
507 /// Handle error on the input socket
508 
510 {
511  XHandleErr_t *herr = in ? (XHandleErr_t *)in : 0;
512 
513  // Try reconnection
514  if (fSocket && herr && (herr->fOpt == 1)) {
515  fSocket->Reconnect();
516  if (fSocket && fSocket->IsValid()) {
517  if (gDebug > 0)
518  Printf("ProofMgr: connection to coordinator at %s re-established",
519  fUrl.GetUrl());
520  return kFALSE;
521  }
522  }
523  Printf("TXProofMgr::HandleError: %p: got called ...", this);
524 
525  // Interrupt any PROOF session in Collect
526  if (fSessions && fSessions->GetSize() > 0) {
527  TIter nxd(fSessions);
528  TProofDesc *d = 0;
529  while ((d = (TProofDesc *)nxd())) {
530  TProof *p = (TProof *) d->GetProof();
531  if (p)
533  }
534  }
535  if (gDebug > 0)
536  Printf("TXProofMgr::HandleError: %p: DONE ... ", this);
537 
538  // We are done
539  return kTRUE;
540 }
541 
542 ////////////////////////////////////////////////////////////////////////////////
543 /// Send a cleanup request for the sessions associated with the current user.
544 /// If 'hard' is true sessions are signalled for termination and moved to
545 /// terminate at all stages (top master, sub-master, workers). Otherwise
546 /// (default) only top-master sessions are asked to terminate, triggering
547 /// a gentle session termination. In all cases all sessions should be gone
548 /// after a few (2 or 3) session checking cycles.
549 /// A user with superuser privileges can also asks cleaning for an different
550 /// user, specified by 'usr', or for all users (usr = *)
551 /// Return 0 on success, -1 in case of error.
552 
553 Int_t TXProofMgr::Reset(Bool_t hard, const char *usr)
554 {
555  // Nothing to do if not in contact with proofserv
556  if (!IsValid()) {
557  Warning("Reset","invalid TXProofMgr - do nothing");
558  return -1;
559  }
560 
561  Int_t h = (hard) ? 1 : 0;
563 
564  return 0;
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// Get logs or log tails from last session associated with this manager
569 /// instance.
570 /// The arguments allow to specify a session different from the last one:
571 /// isess specifies a position relative to the last one, i.e. 1
572 /// for the next to last session; the absolute value is taken
573 /// so -1 and 1 are equivalent.
574 /// stag specifies the unique tag of the wanted session
575 /// The special value stag = "NR" allows to just initialize the TProofLog
576 /// object w/o retrieving the files; this may be useful when the number
577 /// of workers is large and only a subset of logs is required.
578 /// If 'stag' is specified 'isess' is ignored (unless stag = "NR").
579 /// If 'pattern' is specified only the lines containing it are retrieved
580 /// (remote grep functionality); to filter out a pattern 'pat' use
581 /// pattern = "-v pat".
582 /// If 'rescan' is TRUE, masters will rescan the worker sandboxes for the exact
583 /// paths, instead of using the save information; may be useful when the
584 /// ssave information looks wrong or incomplete.
585 /// Returns a TProofLog object (to be deleted by the caller) on success,
586 /// 0 if something wrong happened.
587 
588 TProofLog *TXProofMgr::GetSessionLogs(Int_t isess, const char *stag,
589  const char *pattern, Bool_t rescan)
590 {
591  // Nothing to do if not in contact with proofserv
592  if (!IsValid()) {
593  Warning("GetSessionLogs","invalid TXProofMgr - do nothing");
594  return 0;
595  }
596 
597  TProofLog *pl = 0;
598 
599  // The absolute value of isess counts
600  isess = (isess > 0) ? -isess : isess;
601 
602  // Special option in stag
603  bool retrieve = 1;
604  TString sesstag(stag);
605  if (sesstag == "NR") {
606  retrieve = 0;
607  sesstag = "";
608  }
609 
610  // Get the list of paths
611  Int_t xrs = (rescan) ? 1 : 0;
612  TObjString *os = fSocket->SendCoordinator(kQueryLogPaths, sesstag.Data(), isess, -1, xrs);
613 
614  // Analyse it now
615  Int_t ii = 0;
616  if (os) {
617  TString rs(os->GetName());
618  Ssiz_t from = 0;
619  // The session tag
620  TString tag;
621  if (!rs.Tokenize(tag, from, "|")) {
622  Warning("GetSessionLogs", "Session tag undefined: corruption?\n"
623  " (received string: %s)", os->GetName());
624  return (TProofLog *)0;
625  }
626  // The pool url
627  TString purl;
628  if (!rs.Tokenize(purl, from, "|")) {
629  Warning("GetSessionLogs", "Pool URL undefined: corruption?\n"
630  " (received string: %s)", os->GetName());
631  return (TProofLog *)0;
632  }
633  // Create the instance now
634  if (!pl)
635  pl = new TProofLog(tag, GetUrl(), this);
636 
637  // Per-node info
638  TString to;
639  while (rs.Tokenize(to, from, "|")) {
640  if (!to.IsNull()) {
641  TString ord(to);
642  ord.Strip(TString::kLeading, ' ');
643  TString url(ord);
644  if ((ii = ord.Index(" ")) != kNPOS)
645  ord.Remove(ii);
646  if ((ii = url.Index(" ")) != kNPOS)
647  url.Remove(0, ii + 1);
648  // Add to the list (special tag for valgrind outputs)
649  if (url.Contains(".valgrind")) ord += "-valgrind";
650  pl->Add(ord, url);
651  // Notify
652  if (gDebug > 1)
653  Info("GetSessionLogs", "ord: %s, url: %s", ord.Data(), url.Data());
654  }
655  }
656  // Cleanup
657  SafeDelete(os);
658  // Retrieve the default part if required
659  if (pl && retrieve) {
660  const char *pat = pattern ? pattern : "-v \"| SvcMsg\"";
661  if (pat && strlen(pat) > 0)
662  pl->Retrieve("*", TProofLog::kGrep, 0, pat);
663  else
664  pl->Retrieve();
665  }
666  }
667 
668  // Done
669  return pl;
670 }
671 
672 ////////////////////////////////////////////////////////////////////////////////
673 /// Read, via the coordinator, 'len' bytes from offset 'ofs' of 'file'.
674 /// Returns a TObjString with the content or 0, in case of failure
675 
676 TObjString *TXProofMgr::ReadBuffer(const char *fin, Long64_t ofs, Int_t len)
677 {
678  // Nothing to do if not in contact with proofserv
679  if (!IsValid()) {
680  Warning("ReadBuffer","invalid TXProofMgr - do nothing");
681  return (TObjString *)0;
682  }
683 
684  // Send the request
685  return fSocket->SendCoordinator(kReadBuffer, fin, len, ofs, 0);
686 }
687 
688 ////////////////////////////////////////////////////////////////////////////////
689 /// Read, via the coordinator, 'fin' filtered. If 'pattern' starts with '|',
690 /// it represents a command filtering the output. Elsewhere, it is a grep
691 /// pattern. Returns a TObjString with the content or 0 in case of failure
692 
693 TObjString *TXProofMgr::ReadBuffer(const char *fin, const char *pattern)
694 {
695  // Nothing to do if not in contact with proofserv
696  if (!IsValid()) {
697  Warning("ReadBuffer", "invalid TXProofMgr - do nothing");
698  return (TObjString *)0;
699  }
700 
701  const char *ptr;
702  Int_t type; // 1 = grep, 2 = grep -v, 3 = pipe through cmd
703  if (*pattern == '|') {
704  ptr = &pattern[1]; // strip first char if it is a command
705  type = 3;
706  }
707  else {
708  ptr = pattern;
709  type = 1;
710  }
711 
712  // Prepare the buffer
713  Int_t plen = strlen(ptr);
714  Int_t lfi = strlen(fin);
715  char *buf = new char[lfi + plen + 1];
716  memcpy(buf, fin, lfi);
717  memcpy(buf+lfi, ptr, plen);
718  buf[lfi+plen] = 0;
719 
720  // Send the request
721  return fSocket->SendCoordinator(kReadBuffer, buf, plen, 0, type);
722 }
723 
724 ////////////////////////////////////////////////////////////////////////////////
725 /// Display what ROOT versions are available on the cluster
726 
728 {
729  // Nothing to do if not in contact with proofserv
730  if (!IsValid()) {
731  Warning("ShowROOTVersions","invalid TXProofMgr - do nothing");
732  return;
733  }
734 
735  // Send the request
737  if (os) {
738  // Display it
739  Printf("----------------------------------------------------------\n");
740  Printf("Available versions (tag ROOT-vers remote-path PROOF-version):\n");
741  Printf("%s", os->GetName());
742  Printf("----------------------------------------------------------");
743  SafeDelete(os);
744  }
745 
746  // We are done
747  return;
748 }
749 
750 ////////////////////////////////////////////////////////////////////////////////
751 /// Set the default ROOT version to be used
752 
754 {
755  // Nothing to do if not in contact with proofserv
756  if (!IsValid()) {
757  Warning("SetROOTVersion","invalid TXProofMgr - do nothing");
758  return -1;
759  }
760 
761  // Send the request
763 
764  // We are done
765  return (fSocket->GetOpenError() != kXR_noErrorYet) ? -1 : 0;
766 }
767 
768 ////////////////////////////////////////////////////////////////////////////////
769 /// Send a message to connected users. Only superusers can do this.
770 /// The first argument specifies the message or the file from where to take
771 /// the message.
772 /// The second argument specifies the user to which to send the message: if
773 /// empty or null the message is send to all the connected users.
774 /// return 0 in case of success, -1 in case of error
775 
776 Int_t TXProofMgr::SendMsgToUsers(const char *msg, const char *usr)
777 {
778  Int_t rc = 0;
779 
780  // Check input
781  if (!msg || strlen(msg) <= 0) {
782  Error("SendMsgToUsers","no message to send - do nothing");
783  return -1;
784  }
785 
786  // Buffer (max 32K)
787  const Int_t kMAXBUF = 32768;
788  char buf[kMAXBUF] = {0};
789  char *p = &buf[0];
790  size_t space = kMAXBUF - 1;
791  Int_t lusr = 0;
792 
793  // A specific user?
794  if (usr && strlen(usr) > 0 && (strlen(usr) != 1 || usr[0] != '*')) {
795  lusr = (strlen(usr) + 3);
796  snprintf(buf, kMAXBUF, "u:%s ", usr);
797  p += lusr;
798  space -= lusr;
799  }
800 
801  ssize_t len = 0;
802  // Is it from file ?
803  if (!gSystem->AccessPathName(msg, kFileExists)) {
804  // From file: can we read it ?
806  Error("SendMsgToUsers","request to read message from unreadable file '%s'", msg);
807  return -1;
808  }
809  // Open the file
810  FILE *f = 0;
811  if (!(f = fopen(msg, "r"))) {
812  Error("SendMsgToUsers", "file '%s' cannot be open", msg);
813  return -1;
814  }
815  // Determine the number of bytes to be read from the file.
816  size_t left = 0;
817  off_t rcsk = lseek(fileno(f), (off_t) 0, SEEK_END);
818  if ((rcsk != (off_t)(-1))) {
819  left = (size_t) rcsk;
820  if ((lseek(fileno(f), (off_t) 0, SEEK_SET) == (off_t)(-1))) {
821  Error("SendMsgToUsers", "cannot rewind open file (seek to 0)");
822  fclose(f);
823  return -1;
824  }
825  } else {
826  Error("SendMsgToUsers", "cannot get size of open file (seek to END)");
827  fclose(f);
828  return -1;
829  }
830  // Now readout from file
831  size_t wanted = left;
832  if (wanted > space) {
833  wanted = space;
834  Warning("SendMsgToUsers",
835  "requested to send %lld bytes: max size is %lld bytes: truncating",
836  (Long64_t)left, (Long64_t)space);
837  }
838  do {
839  while ((len = read(fileno(f), p, wanted)) < 0 &&
840  TSystem::GetErrno() == EINTR)
842  if (len < 0) {
843  SysError("SendMsgToUsers", "error reading file");
844  break;
845  }
846 
847  // Update counters
848  left = (len >= (ssize_t)left) ? 0 : left - len;
849  p += len;
850  wanted = (left > kMAXBUF-1) ? kMAXBUF-1 : left;
851 
852  } while (len > 0 && left > 0);
853  // Close file
854  fclose(f);
855  } else {
856  // Add the message to the buffer
857  len = strlen(msg);
858  if (len > (ssize_t)space) {
859  Warning("SendMsgToUsers",
860  "requested to send %lld bytes: max size is %lld bytes: truncating",
861  (Long64_t)len, (Long64_t)space);
862  len = space;
863  }
864  memcpy(p, msg, len);
865  }
866 
867  // Null-terminate
868  buf[len + lusr] = 0;
869 
870  // Send the request
872 
873  return rc;
874 }
875 
876 ////////////////////////////////////////////////////////////////////////////////
877 /// Run 'grep' on the nodes
878 
879 void TXProofMgr::Grep(const char *what, const char *how, const char *where)
880 {
881  // Nothing to do if not in contact with proofserv
882  if (!IsValid()) {
883  Error("Grep","invalid TXProofMgr - do nothing");
884  return;
885  }
886  // Server may not support it
887  if (fSocket->GetXrdProofdVersion() < 1006) {
888  Error("Grep", "functionality not supported by server");
889  return;
890  }
891 
892  // Send the request
893  TObjString *os = Exec(kGrep, what, how, where);
894 
895  // Show the result, if any
896  if (os) Printf("%s", os->GetName());
897 
898  // Cleanup
899  SafeDelete(os);
900 }
901 
902 ////////////////////////////////////////////////////////////////////////////////
903 /// Run 'find' on the nodes
904 
905 void TXProofMgr::Find(const char *what, const char *how, const char *where)
906 {
907  // Nothing to do if not in contact with proofserv
908  if (!IsValid()) {
909  Error("Find","invalid TXProofMgr - do nothing");
910  return;
911  }
912  // Server may not support it
913  if (fSocket->GetXrdProofdVersion() < 1006) {
914  Error("Find", "functionality not supported by server (XrdProofd version: %d)",
916  return;
917  }
918 
919  // Send the request
920  TObjString *os = Exec(kFind, what, how, where);
921 
922  // Show the result, if any
923  if (os) Printf("%s", os->GetName());
924 
925  // Cleanup
926  SafeDelete(os);
927 }
928 
929 ////////////////////////////////////////////////////////////////////////////////
930 /// Run 'ls' on the nodes
931 
932 void TXProofMgr::Ls(const char *what, const char *how, const char *where)
933 {
934  // Nothing to do if not in contact with proofserv
935  if (!IsValid()) {
936  Error("Ls","invalid TXProofMgr - do nothing");
937  return;
938  }
939  // Server may not support it
940  if (fSocket->GetXrdProofdVersion() < 1006) {
941  Error("Ls", "functionality not supported by server");
942  return;
943  }
944 
945  // Send the request
946  TObjString *os = Exec(kLs, what, how, where);
947 
948  // Show the result, if any
949  if (os) Printf("%s", os->GetName());
950 
951  // Cleanup
952  SafeDelete(os);
953 }
954 
955 ////////////////////////////////////////////////////////////////////////////////
956 /// Run 'more' on the nodes
957 
958 void TXProofMgr::More(const char *what, const char *how, const char *where)
959 {
960  // Nothing to do if not in contact with proofserv
961  if (!IsValid()) {
962  Error("More","invalid TXProofMgr - do nothing");
963  return;
964  }
965  // Server may not support it
966  if (fSocket->GetXrdProofdVersion() < 1006) {
967  Error("More", "functionality not supported by server");
968  return;
969  }
970 
971  // Send the request
972  TObjString *os = Exec(kMore, what, how, where);
973 
974  // Show the result, if any
975  if (os) Printf("%s", os->GetName());
976 
977  // Cleanup
978  SafeDelete(os);
979 }
980 
981 ////////////////////////////////////////////////////////////////////////////////
982 /// Run 'rm' on the nodes. The user is prompted before removal, unless 'how'
983 /// contains "--force" or a combination of single letter options including 'f',
984 /// e.g. "-fv".
985 
986 Int_t TXProofMgr::Rm(const char *what, const char *how, const char *where)
987 {
988  // Nothing to do if not in contact with proofserv
989  if (!IsValid()) {
990  Error("Rm","invalid TXProofMgr - do nothing");
991  return -1;
992  }
993  // Server may not support it
994  if (fSocket->GetXrdProofdVersion() < 1006) {
995  Error("Rm", "functionality not supported by server");
996  return -1;
997  }
998 
999  TString prompt, ans("Y"), opt(how);
1000  Bool_t force = kFALSE;
1001  if (!opt.IsNull()) {
1002  TString t;
1003  Int_t from = 0;
1004  while (!force && opt.Tokenize(t, from, " ")) {
1005  if (t == "--force") {
1006  force = kTRUE;
1007  } else if (t.BeginsWith("-") && !t.BeginsWith("--") && t.Contains("f")) {
1008  force = kTRUE;
1009  }
1010  }
1011  }
1012 
1013  if (!force && isatty(0) != 0 && isatty(1) != 0) {
1014  // Really remove the file?
1015  prompt.Form("Do you really want to remove '%s'? [N/y]", what);
1016  ans = "";
1017  while (ans != "N" && ans != "Y") {
1018  ans = Getline(prompt.Data());
1019  ans.Remove(TString::kTrailing, '\n');
1020  if (ans == "") ans = "N";
1021  ans.ToUpper();
1022  if (ans != "N" && ans != "Y")
1023  Printf("Please answer y, Y, n or N");
1024  }
1025  }
1026 
1027  if (ans == "Y") {
1028  // Send the request
1029  TObjString *os = Exec(kRm, what, how, where);
1030  // Show the result, if any
1031  if (os) {
1032  if (gDebug > 1) Printf("%s", os->GetName());
1033  // Cleanup
1034  SafeDelete(os);
1035  // Success
1036  return 0;
1037  }
1038  // Failure
1039  return -1;
1040  }
1041  // Done
1042  return 0;
1043 }
1044 
1045 ////////////////////////////////////////////////////////////////////////////////
1046 /// Run 'tail' on the nodes
1047 
1048 void TXProofMgr::Tail(const char *what, const char *how, const char *where)
1049 {
1050  // Nothing to do if not in contact with proofserv
1051  if (!IsValid()) {
1052  Error("Tail","invalid TXProofMgr - do nothing");
1053  return;
1054  }
1055  // Server may not support it
1056  if (fSocket->GetXrdProofdVersion() < 1006) {
1057  Error("Tail", "functionality not supported by server");
1058  return;
1059  }
1060 
1061  // Send the request
1062  TObjString *os = Exec(kTail, what, how, where);
1063 
1064  // Show the result, if any
1065  if (os) Printf("%s", os->GetName());
1066 
1067  // Cleanup
1068  SafeDelete(os);
1069 }
1070 
1071 ////////////////////////////////////////////////////////////////////////////////
1072 /// Run 'md5sum' on one of the nodes
1073 
1074 Int_t TXProofMgr::Md5sum(const char *what, TString &sum, const char *where)
1075 {
1076  // Nothing to do if not in contact with proofserv
1077  if (!IsValid()) {
1078  Error("Md5sum","invalid TXProofMgr - do nothing");
1079  return -1;
1080  }
1081  // Server may not support it
1082  if (fSocket->GetXrdProofdVersion() < 1006) {
1083  Error("Md5sum", "functionality not supported by server");
1084  return -1;
1085  }
1086 
1087  if (where && !strcmp(where, "all")) {
1088  Error("Md5sum","cannot run on all nodes at once: please specify one");
1089  return -1;
1090  }
1091 
1092  // Send the request
1093  TObjString *os = Exec(kMd5sum, what, 0, where);
1094 
1095  // Show the result, if any
1096  if (os) {
1097  if (gDebug > 1) Printf("%s", os->GetName());
1098  sum = os->GetName();
1099  // Cleanup
1100  SafeDelete(os);
1101  // Success
1102  return 0;
1103  }
1104  // Failure
1105  return -1;
1106 }
1107 
1108 ////////////////////////////////////////////////////////////////////////////////
1109 /// Run 'stat' on one of the nodes
1110 
1111 Int_t TXProofMgr::Stat(const char *what, FileStat_t &st, const char *where)
1112 {
1113  // Nothing to do if not in contact with proofserv
1114  if (!IsValid()) {
1115  Error("Stat","invalid TXProofMgr - do nothing");
1116  return -1;
1117  }
1118  // Server may not support it
1119  if (fSocket->GetXrdProofdVersion() < 1006) {
1120  Error("Stat", "functionality not supported by server");
1121  return -1;
1122  }
1123 
1124  if (where && !strcmp(where, "all")) {
1125  Error("Stat","cannot run on all nodes at once: please specify one");
1126  return -1;
1127  }
1128 
1129  // Send the request
1130  TObjString *os = Exec(kStat, what, 0, where);
1131 
1132  // Show the result, if any
1133  if (os) {
1134  if (gDebug > 1) Printf("%s", os->GetName());
1135 #if 0
1136  Int_t mode, uid, gid, islink;
1137  Long_t dev, ino, mtime;
1138  Long64_t size;
1139 #ifdef R__WIN32
1140  sscanf(os->GetName(), "%ld %ld %d %d %d %I64d %ld %d", &dev, &ino, &mode,
1141  &uid, &gid, &size, &mtime, &islink);
1142 #else
1143  sscanf(os->GetName(), "%ld %ld %d %d %d %lld %ld %d", &dev, &ino, &mode,
1144  &uid, &gid, &size, &mtime, &islink);
1145 #endif
1146  if (dev == -1)
1147  return -1;
1148  st.fDev = dev;
1149  st.fIno = ino;
1150  st.fMode = mode;
1151  st.fUid = uid;
1152  st.fGid = gid;
1153  st.fSize = size;
1154  st.fMtime = mtime;
1155  st.fIsLink = (islink == 1);
1156 #else
1157  TString tkn;
1158  Ssiz_t from = 0;
1159  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1160  st.fDev = tkn.Atoi();
1161  if (st.fDev == -1) return -1;
1162  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1163  st.fIno = tkn.Atoi();
1164  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1165  st.fMode = tkn.Atoi();
1166  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1167  st.fUid = tkn.Atoi();
1168  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1169  st.fGid = tkn.Atoi();
1170  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1171  st.fSize = tkn.Atoll();
1172  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1173  st.fMtime = tkn.Atoi();
1174  if (!os->GetString().Tokenize(tkn, from, "[ ]+") || !tkn.IsDigit()) return -1;
1175  st.fIsLink = (tkn.Atoi() == 1) ? kTRUE : kFALSE;
1176 #endif
1177 
1178  // Cleanup
1179  SafeDelete(os);
1180  // Success
1181  return 0;
1182  }
1183  // Failure
1184  return -1;
1185 }
1186 
1187 ////////////////////////////////////////////////////////////////////////////////
1188 /// Execute 'action' (see EAdminExecType in 'XProofProtocol.h') at 'where'
1189 /// (default master), with options 'how', on 'what'. The option specified by
1190 /// 'how' are typically unix option for the relate commands. In addition to
1191 /// the unix authorizations, the limitations are:
1192 ///
1193 /// action = kRm limited to the sandbox (but basic dirs cannot be
1194 /// removed) and on files owned by the user in the
1195 /// allowed directories
1196 /// action = kTail option '-f' is not supported and will be ignored
1197 ///
1198 
1200  const char *what, const char *how, const char *where)
1201 {
1202  // Nothing to do if not in contact with proofserv
1203  if (!IsValid()) {
1204  Error("Exec","invalid TXProofMgr - do nothing");
1205  return (TObjString *)0;
1206  }
1207  // Server may not support it
1208  if (fSocket->GetXrdProofdVersion() < 1006) {
1209  Error("Exec", "functionality not supported by server");
1210  return (TObjString *)0;
1211  }
1212  // Check 'what'
1213  if (!what || strlen(what) <= 0) {
1214  Error("Exec","specifying a path is mandatory");
1215  return (TObjString *)0;
1216  }
1217  // Check the options
1218  TString opt(how);
1219  if (action == kTail && !opt.IsNull()) {
1220  // Keep only static options: -c, --bytes=N, -n , --lines=N, -N
1221  TString opts(how), o;
1222  Int_t from = 0;
1223  Bool_t isc = kFALSE, isn = kFALSE;
1224  while (opts.Tokenize(o, from, " ")) {
1225  // Skip values not starting with '-' is not argument to '-c' or '-n'
1226  if (!o.BeginsWith("-") && !isc && isn) continue;
1227  if (isc) {
1228  opt.Form("-c %s", o.Data());
1229  isc = kFALSE;
1230  }
1231  if (isn) {
1232  opt.Form("-n %s", o.Data());
1233  isn = kFALSE;
1234  }
1235  if (o == "-c") {
1236  isc = kTRUE;
1237  } else if (o == "-n") {
1238  isn = kTRUE;
1239  } else if (o == "--bytes=" || o == "--lines=") {
1240  opt = o;
1241  } else if (o.BeginsWith("-")) {
1242  o.Remove(TString::kLeading,'-');
1243  if (o.IsDigit()) opt.Form("-%s", o.Data());
1244  }
1245  }
1246  }
1247 
1248  // Build the command line
1249  TString cmd(where);
1250  if (cmd.IsNull()) cmd.Form("%s:%d", fUrl.GetHost(), fUrl.GetPort());
1251  cmd += "|";
1252  cmd += what;
1253  cmd += "|";
1254  cmd += opt;
1255 
1256  // On clients, handle Ctrl-C during collection
1257  if (fIntHandler) fIntHandler->Add();
1258 
1259  // Send the request
1261 
1262  // On clients, handle Ctrl-C during collection
1263  if (fIntHandler) fIntHandler->Remove();
1264 
1265  // Done
1266  return os;
1267 }
1268 
1269 ////////////////////////////////////////////////////////////////////////////////
1270 /// Get file 'remote' into 'local' from the master.
1271 /// If opt contains "force", the file, if it exists remotely, is copied in all cases,
1272 /// otherwise a check is done on the MD5sum.
1273 /// If opt contains "silent" standard notificatons are not printed (errors and
1274 /// warnings and prompts still are).
1275 /// Return 0 on success, -1 on error.
1276 
1277 Int_t TXProofMgr::GetFile(const char *remote, const char *local, const char *opt)
1278 {
1279  Int_t rc = -1;
1280  // Nothing to do if not in contact with proofserv
1281  if (!IsValid()) {
1282  Error("GetFile", "invalid TXProofMgr - do nothing");
1283  return rc;
1284  }
1285  // Server may not support it
1286  if (fSocket->GetXrdProofdVersion() < 1006) {
1287  Error("GetFile", "functionality not supported by server");
1288  return rc;
1289  }
1290 
1291  // Check remote path name
1292  TString filerem(remote);
1293  if (filerem.IsNull()) {
1294  Error("GetFile", "remote file path undefined");
1295  return rc;
1296  }
1297 
1298  // Parse option
1299  TString oo(opt);
1300  oo.ToUpper();
1301  Bool_t force = (oo.Contains("FORCE")) ? kTRUE : kFALSE;
1302  Bool_t silent = (oo.Contains("SILENT")) ? kTRUE : kFALSE;
1303 
1304  // Check local path name
1305  TString fileloc(local);
1306  if (fileloc.IsNull()) {
1307  // Set the same as the remote one, in the working dir
1308  fileloc = gSystem->BaseName(filerem);
1309  }
1310  gSystem->ExpandPathName(fileloc);
1311 
1312  // Default open and mode flags
1313 #ifdef WIN32
1314  UInt_t openflags = O_WRONLY | O_BINARY;
1315 #else
1316  UInt_t openflags = O_WRONLY;
1317 #endif
1318  UInt_t openmode = 0600;
1319 
1320  // Get information about the local file
1321  UserGroup_t *ugloc = 0;
1322  Int_t rcloc = 0;
1323  FileStat_t stloc;
1324  if ((rcloc = gSystem->GetPathInfo(fileloc, stloc)) == 0) {
1325  if (R_ISDIR(stloc.fMode)) {
1326  // Add the filename of the remote file and re-check
1327  if (!fileloc.EndsWith("/")) fileloc += "/";
1328  fileloc += gSystem->BaseName(filerem);
1329  // Get again the status of the path
1330  rcloc = gSystem->GetPathInfo(fileloc, stloc);
1331  }
1332  if (rcloc == 0) {
1333  // It exists already. If it is not a regular file we cannot continue
1334  if (!R_ISREG(stloc.fMode)) {
1335  if (!silent)
1336  Printf("[GetFile] local file '%s' exists and is not regular: cannot continue",
1337  fileloc.Data());
1338  return rc;
1339  }
1340  // Get our info
1341  if (!(ugloc = gSystem->GetUserInfo(gSystem->GetUid()))) {
1342  Error("GetFile", "cannot get user info for additional checks");
1343  return rc;
1344  }
1345  // Can we delete or overwrite it ?
1346  Bool_t owner = (ugloc->fUid == stloc.fUid && ugloc->fGid == stloc.fGid) ? kTRUE : kFALSE;
1347  Bool_t group = (!owner && ugloc->fGid == stloc.fGid) ? kTRUE : kFALSE;
1348  Bool_t other = (!owner && !group) ? kTRUE : kFALSE;
1349  delete ugloc;
1350  if ((owner && !(stloc.fMode & kS_IWUSR)) ||
1351  (group && !(stloc.fMode & kS_IWGRP)) || (other && !(stloc.fMode & kS_IWOTH))) {
1352  if (!silent) {
1353  Printf("[GetFile] file '%s' exists: no permission to delete or overwrite the file", fileloc.Data());
1354  Printf("[GetFile] ownership: owner: %d, group: %d, other: %d", owner, group, other);
1355  Printf("[GetFile] mode: %x", stloc.fMode);
1356  }
1357  return rc;
1358  }
1359  // In case we open the file, we need to truncate it
1360  openflags |= O_CREAT | O_TRUNC;
1361  } else {
1362  // In case we open the file, we need to create it
1363  openflags |= O_CREAT;
1364  }
1365  } else {
1366  // In case we open the file, we need to create it
1367  openflags |= O_CREAT;
1368  }
1369 
1370  // Check the remote file exists and get it check sum
1371  TString remsum;
1372  if (Md5sum(filerem, remsum) != 0) {
1373  if (!silent)
1374  Printf("[GetFile] remote file '%s' does not exists or cannot be read", filerem.Data());
1375  return rc;
1376  }
1377 
1378  // If the file exists already locally, check if it is different
1379  bool same = 0;
1380  if (rcloc == 0 && !force) {
1381  TMD5 *md5loc = TMD5::FileChecksum(fileloc);
1382  if (md5loc) {
1383  if (remsum == md5loc->AsString()) {
1384  if (!silent) {
1385  Printf("[GetFile] local file '%s' and remote file '%s' have the same MD5 check sum",
1386  fileloc.Data(), filerem.Data());
1387  Printf("[GetFile] use option 'force' to override");
1388  }
1389  same = 1;
1390  }
1391  delete md5loc;
1392  }
1393 
1394  // If a different file with the same name exists already, ask what to do
1395  if (!same) {
1396  const char *a = Getline("Local file exists already: would you like to overwrite it? [N/y]");
1397  if (a[0] == 'n' || a[0] == 'N' || a[0] == '\0') return 0;
1398  } else {
1399  return 0;
1400  }
1401  }
1402 
1403  // Open the local file for writing
1404  Int_t fdout = open(fileloc, openflags, openmode);
1405  if (fdout < 0) {
1406  Error("GetFile", "could not open local file '%s' for writing: errno: %d", local, errno);
1407  return rc;
1408  }
1409 
1410  // Build the command line
1411  TString cmd(filerem);
1412 
1413  // Disable TXSocket handling while receiving the file (CpProgress processes
1414  // pending events and this could screw-up synchronization in the TXSocket pipe)
1416 
1417  // Send the request
1418  TStopwatch watch;
1419  watch.Start();
1421 
1422  if (os) {
1423  // The message contains the size
1424  TString ssz(os->GetName());
1425  ssz.ReplaceAll(" ", "");
1426  if (!ssz.IsDigit()) {
1427  Error("GetFile", "received non-digit size string: '%s' ('%s')", os->GetName(), ssz.Data());
1428  close(fdout);
1429  return rc;
1430  }
1431  Long64_t size = ssz.Atoll();
1432  if (size <= 0) {
1433  Error("GetFile", "received null or negative size: %lld", size);
1434  close(fdout);
1435  return rc;
1436  }
1437 
1438  // Receive the file
1439  const Int_t kMAXBUF = 16384; //32768 //16384 //65536;
1440  char buf[kMAXBUF];
1441 
1442  rc = 0;
1443  Int_t rec, r;
1444  Long64_t filesize = 0, left = 0;
1445  while (rc == 0 && filesize < size) {
1446  left = size - filesize;
1447  if (left > kMAXBUF) left = kMAXBUF;
1448  rec = fSocket->RecvRaw(&buf, left);
1449  filesize = (rec > 0) ? (filesize + rec) : filesize;
1450  if (rec > 0) {
1451  char *p = buf;
1452  r = rec;
1453  while (r) {
1454  Int_t w = 0;
1455  while ((w = write(fdout, p, r)) < 0 && TSystem::GetErrno() == EINTR)
1457  if (w < 0) {
1458  SysError("GetFile", "error writing to unit: %d", fdout);
1459  rc = -1;
1460  break;
1461  }
1462  r -= w;
1463  p += w;
1464  }
1465  // Basic progress bar
1466  CpProgress("GetFile", filesize, size, &watch);
1467  } else if (rec < 0) {
1468  rc = -1;
1469  Error("GetFile", "error during receiving file");
1470  break;
1471  }
1472  }
1473  // Finalize the progress bar
1474  CpProgress("GetFile", filesize, size, &watch, kTRUE);
1475 
1476  } else {
1477  Error("GetFile", "size not received");
1478  rc = -1;
1479  }
1480 
1481  // Restore socket handling while receiving the file
1483 
1484  // Close local file
1485  close(fdout);
1486  watch.Stop();
1487  watch.Reset();
1488 
1489  if (rc == 0) {
1490  // Check if everything went fine
1491  std::auto_ptr<TMD5> md5loc(TMD5::FileChecksum(fileloc));
1492  if (!(md5loc.get())) {
1493  Error("GetFile", "cannot get MD5 checksum of the new local file '%s'", fileloc.Data());
1494  rc = -1;
1495  } else if (remsum != md5loc->AsString()) {
1496  Error("GetFile", "checksums for the local copy and the remote file differ: {rem:%s,loc:%s}",
1497  remsum.Data(), md5loc->AsString());
1498  rc = -1;
1499  }
1500  }
1501  // Done
1502  return rc;
1503 }
1504 
1505 ////////////////////////////////////////////////////////////////////////////////
1506 /// Put file 'local'to 'remote' to the master
1507 /// If opt is "force", the file, if it exists remotely, is copied in all cases,
1508 /// otherwise a check is done on the MD5sum.
1509 /// Return 0 on success, -1 on error
1510 
1511 Int_t TXProofMgr::PutFile(const char *local, const char *remote, const char *opt)
1512 {
1513  Int_t rc = -1;
1514  // Nothing to do if not in contact with proofserv
1515  if (!IsValid()) {
1516  Error("PutFile", "invalid TXProofMgr - do nothing");
1517  return rc;
1518  }
1519  // Server may not support it
1520  if (fSocket->GetXrdProofdVersion() < 1006) {
1521  Error("PutFile", "functionality not supported by server");
1522  return rc;
1523  }
1524 
1525  // Check local path name
1526  TString fileloc(local);
1527  if (fileloc.IsNull()) {
1528  Error("PutFile", "local file path undefined");
1529  return rc;
1530  }
1531  gSystem->ExpandPathName(fileloc);
1532 
1533  // Parse option
1534  TString oo(opt);
1535  oo.ToUpper();
1536  Bool_t force = (oo == "FORCE") ? kTRUE : kFALSE;
1537 
1538  // Check remote path name
1539  TString filerem(remote);
1540  if (filerem.IsNull()) {
1541  // Set the same as the local one, in the working dir
1542  filerem.Form("~/%s", gSystem->BaseName(fileloc));
1543  } else if (filerem.EndsWith("/")) {
1544  // Remote path is a directory: add the file name as in the local one
1545  filerem += gSystem->BaseName(fileloc);
1546  }
1547 
1548  // Default open flags
1549 #ifdef WIN32
1550  UInt_t openflags = O_RDONLY | O_BINARY;
1551 #else
1552  UInt_t openflags = O_RDONLY;
1553 #endif
1554 
1555  // Get information about the local file
1556  Int_t rcloc = 0;
1557  FileStat_t stloc;
1558  if ((rcloc = gSystem->GetPathInfo(fileloc, stloc)) != 0 || !R_ISREG(stloc.fMode)) {
1559  // It dies not exists or it is not a regular file: we cannot continue
1560  const char *why = (rcloc == 0) ? "is not regular" : "does not exists";
1561  Printf("[PutFile] local file '%s' %s: cannot continue", fileloc.Data(), why);
1562  return rc;
1563  }
1564  // Get our info
1565  UserGroup_t *ugloc = 0;
1566  if (!(ugloc = gSystem->GetUserInfo(gSystem->GetUid()))) {
1567  Error("PutFile", "cannot get user info for additional checks");
1568  return rc;
1569  }
1570  // Can we read it ?
1571  Bool_t owner = (ugloc->fUid == stloc.fUid && ugloc->fGid == stloc.fGid) ? kTRUE : kFALSE;
1572  Bool_t group = (!owner && ugloc->fGid == stloc.fGid) ? kTRUE : kFALSE;
1573  Bool_t other = (!owner && !group) ? kTRUE : kFALSE;
1574  delete ugloc;
1575  if ((owner && !(stloc.fMode & kS_IRUSR)) ||
1576  (group && !(stloc.fMode & kS_IRGRP)) || (other && !(stloc.fMode & kS_IROTH))) {
1577  Printf("[PutFile] file '%s': no permission to read the file", fileloc.Data());
1578  Printf("[PutFile] ownership: owner: %d, group: %d, other: %d", owner, group, other);
1579  Printf("[PutFile] mode: %x", stloc.fMode);
1580  return rc;
1581  }
1582 
1583  // Local MD5 sum
1584  TString locsum;
1585  TMD5 *md5loc = TMD5::FileChecksum(fileloc);
1586  if (!md5loc) {
1587  Error("PutFile", "cannot calculate the check sum for '%s'", fileloc.Data());
1588  return rc;
1589  } else {
1590  locsum = md5loc->AsString();
1591  delete md5loc;
1592  }
1593 
1594  // Check the remote file exists and get it check sum
1595  Bool_t same = kFALSE;
1596  FileStat_t strem;
1597  TString remsum;
1598  if (Stat(filerem, strem) == 0) {
1599  if (Md5sum(filerem, remsum) != 0) {
1600  Printf("[PutFile] remote file exists but the check sum calculation failed");
1601  return rc;
1602  }
1603  // Check sums
1604  if (remsum == locsum) {
1605  if (!force) {
1606  Printf("[PutFile] local file '%s' and remote file '%s' have the same MD5 check sum",
1607  fileloc.Data(), filerem.Data());
1608  Printf("[PutFile] use option 'force' to override");
1609  }
1610  same = kTRUE;
1611  }
1612  if (!force) {
1613  // If a different file with the same name exists already, ask what to do
1614  if (!same) {
1615  const char *a = Getline("Remote file exists already: would you like to overwrite it? [N/y]");
1616  if (a[0] == 'n' || a[0] == 'N' || a[0] == '\0') return 0;
1617  force = kTRUE;
1618  } else {
1619  return 0;
1620  }
1621  }
1622  }
1623 
1624  // Open the local file
1625  int fd = open(fileloc.Data(), openflags);
1626  if (fd < 0) {
1627  Error("PutFile", "cannot open file '%s': %d", fileloc.Data(), errno);
1628  return -1;
1629  }
1630 
1631  // Build the command line: 'path size [opt]'
1632  TString cmd;
1633  cmd.Form("%s %lld", filerem.Data(), stloc.fSize);
1634  if (force) cmd += " force";
1635 
1636  // Disable TXSocket handling while sending the file (CpProgress processes
1637  // pending events and this could screw-up synchronization in the TXSocket pipe)
1639 
1640  // Send the request
1641  TStopwatch watch;
1642  watch.Start();
1644 
1645  if (os) {
1646 
1647  // Send over the file
1648  const Int_t kMAXBUF = 16384; //32768 //16384 //65536;
1649  char buf[kMAXBUF];
1650 
1651  Long64_t pos = 0;
1652  lseek(fd, pos, SEEK_SET);
1653 
1654  rc = 0;
1655  while (rc == 0 && pos < stloc.fSize) {
1656  Long64_t left = stloc.fSize - pos;
1657  if (left > kMAXBUF) left = kMAXBUF;
1658  Int_t siz;
1659  while ((siz = read(fd, &buf[0], left)) < 0 && TSystem::GetErrno() == EINTR)
1661  if (siz < 0 || siz != left) {
1662  Error("PutFile", "error reading from file: errno: %d", errno);
1663  rc = -1;
1664  break;
1665  }
1666  Int_t src = 0;
1667  if ((src = fSocket->fConn->WriteRaw((void *)&buf[0], left)) != left) {
1668  Error("PutFile", "error sending over: errno: %d (rc: %d)", TSystem::GetErrno(), src);
1669  rc = -1;
1670  break;
1671  }
1672  // Basic progress bar
1673  CpProgress("PutFile", pos, stloc.fSize, &watch);
1674  // Re-position
1675  pos += left;
1676  }
1677  // Finalize the progress bar
1678  CpProgress("PutFile", pos, stloc.fSize, &watch, kTRUE);
1679 
1680  } else {
1681  Error("PutFile", "command could not be executed");
1682  rc = -1;
1683  }
1684 
1685  // Restore TXSocket handling
1687 
1688  // Close local file
1689  close(fd);
1690  watch.Stop();
1691  watch.Reset();
1692 
1693  if (rc == 0) {
1694  // Check if everything went fine
1695  if (Md5sum(filerem, remsum) != 0) {
1696  Printf("[PutFile] cannot get MD5 checksum of the new remote file '%s'", filerem.Data());
1697  rc = -1;
1698  } else if (remsum != locsum) {
1699  Printf("[PutFile] checksums for the local copy and the remote file differ: {rem:%s, loc:%s}",
1700  remsum.Data(), locsum.Data());
1701  rc = -1;
1702  }
1703  }
1704 
1705  // Done
1706  return rc;
1707 }
1708 
1709 ////////////////////////////////////////////////////////////////////////////////
1710 /// Print file copy progress.
1711 
1712 void TXProofMgr::CpProgress(const char *pfx, Long64_t bytes,
1713  Long64_t size, TStopwatch *watch, Bool_t cr)
1714 {
1715  // Protection
1716  if (!pfx || size == 0 || !watch) return;
1717 
1718  fprintf(stderr, "[%s] Total %.02f MB\t|", pfx, (Double_t)size/1048576);
1719 
1720  for (int l = 0; l < 20; l++) {
1721  if (size > 0) {
1722  if (l < 20*bytes/size)
1723  fprintf(stderr, "=");
1724  else if (l == 20*bytes/size)
1725  fprintf(stderr, ">");
1726  else if (l > 20*bytes/size)
1727  fprintf(stderr, ".");
1728  } else
1729  fprintf(stderr, "=");
1730  }
1731  // Allow to update the GUI while uploading files
1733  watch->Stop();
1734  Double_t copytime = watch->RealTime();
1735  fprintf(stderr, "| %.02f %% [%.01f MB/s]\r",
1736  100.0*(size?(bytes/size):1), bytes/copytime/1048576.);
1737  if (cr) fprintf(stderr, "\n");
1738  watch->Continue();
1739 }
1740 
1741 ////////////////////////////////////////////////////////////////////////////////
1742 /// Copy files in/out of the sandbox. Either 'src' or 'dst' must be in the
1743 /// sandbox.
1744 /// Return 0 on success, -1 on error
1745 
1746 Int_t TXProofMgr::Cp(const char *src, const char *dst, const char *fmt)
1747 {
1748  Int_t rc = -1;
1749  // Nothing to do if not in contact with proofserv
1750  if (!IsValid()) {
1751  Error("Cp", "invalid TXProofMgr - do nothing");
1752  return rc;
1753  }
1754  // Server may not support it
1755  if (fSocket->GetXrdProofdVersion() < 1006) {
1756  Error("Cp", "functionality not supported by server");
1757  return rc;
1758  }
1759 
1760  // Check source path name
1761  TString filesrc(src);
1762  if (filesrc.IsNull()) {
1763  Error("Cp", "source file path undefined");
1764  return rc;
1765  }
1766  // Check destination path name
1767  TString filedst(dst);
1768  if (filedst.IsNull()) {
1769  filedst = gSystem->BaseName(TUrl(filesrc.Data()).GetFile());
1770  } else if (filedst.EndsWith("/")) {
1771  // Remote path is a directory: add the file name as in the local one
1772  filedst += gSystem->BaseName(filesrc);
1773  }
1774 
1775  // Make sure that local files are in the format file://host/<file> otherwise
1776  // the URL class in the server will not parse them correctly
1777  TUrl usrc = TUrl(filesrc.Data(), kTRUE).GetUrl();
1778  filesrc = usrc.GetUrl();
1779  if (!strcmp(usrc.GetProtocol(), "file"))
1780  filesrc.Form("file://host/%s", usrc.GetFileAndOptions());
1781  TUrl udst = TUrl(filedst.Data(), kTRUE).GetUrl();
1782  filedst = udst.GetUrl();
1783  if (!strcmp(udst.GetProtocol(), "file"))
1784  filedst.Form("file://host/%s", udst.GetFileAndOptions());
1785 
1786  // Prepare the command
1787  TString cmd;
1788  cmd.Form("%s %s %s", filesrc.Data(), filedst.Data(), (fmt ? fmt : ""));
1789 
1790  // On clients, handle Ctrl-C during collection
1791  if (fIntHandler) fIntHandler->Add();
1792 
1793  // Send the request
1795 
1796  // On clients, handle Ctrl-C during collection
1797  if (fIntHandler) fIntHandler->Remove();
1798 
1799  // Show the result, if any
1800  if (os) {
1801  if (gDebug > 0) Printf("%s", os->GetName());
1802  rc = 0;
1803  }
1804 
1805  // Done
1806  return rc;
1807 }
Int_t fGid
Definition: TSystem.h:151
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:928
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition: TObject.cxx:932
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:1264
void ShowWorkers()
Show available workers.
Definition: TXProofMgr.cxx:339
Int_t GetOpenError() const
Getter for last error.
Definition: TXSocket.cxx:925
double read(const std::string &file_name)
reading
XYZVector ans(TestRotation const &t, XYZVector const &v_in)
TObjString * ReadBuffer(const char *file, Long64_t ofs, Int_t len)
Read, via the coordinator, &#39;len&#39; bytes from offset &#39;ofs&#39; of &#39;file&#39;.
Definition: TXProofMgr.cxx:676
An array of TObjects.
Definition: TObjArray.h:39
action
Definition: ROOT.py:93
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:420
TList * fSessions
Definition: TProofMgr.h:71
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
void SetPort(Int_t port)
Definition: TUrl.h:97
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
Definition: TStopwatch.cxx:108
void CpProgress(const char *pfx, Long64_t bytes, Long64_t size, TStopwatch *watch, Bool_t cr=kFALSE)
Print file copy progress.
long long Long64_t
Definition: RtypesCore.h:69
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:56
Int_t Stat(const char *what, FileStat_t &st, const char *where=0)
Run &#39;stat&#39; on one of the nodes.
Int_t Md5sum(const char *what, TString &sum, const char *where=0)
Run &#39;md5sum&#39; on one of the nodes.
Int_t GetPort() const
Definition: TSocket.h:145
void DetachSession(Int_t, Option_t *="")
Detach session with &#39;id&#39; from its proofserv.
Definition: TXProofMgr.cxx:232
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
Definition: TMD5.cxx:472
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition: TUrl.cxx:518
double write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
Bool_t HandleError(const void *in=0)
Handle error on the input socket.
Definition: TXProofMgr.cxx:509
Int_t Cp(const char *src, const char *dst=0, const char *opts=0)
Copy files in/out of the sandbox.
Collectable string class.
Definition: TObjString.h:32
virtual void Close(Option_t *opt="")
Close connection.
Definition: TXSocket.cxx:323
Int_t fRemoteProtocol
Definition: TProofMgr.h:69
const char Option_t
Definition: RtypesCore.h:62
void InterruptCurrentMonitor()
If in active in a monitor set ready state.
Definition: TProof.cxx:11902
This class represents a WWW compatible URL.
Definition: TUrl.h:41
XrdProofConn * fConn
Definition: TXSocket.h:98
Int_t fUid
Definition: TSystem.h:139
static TXSocketHandler * GetSocketHandler(TFileHandler *h=0, TSocket *s=0)
Get an instance of the input socket handler with &#39;h&#39; as handler, connected to socket &#39;s&#39;...
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1362
const char * GetProtocol() const
Definition: TUrl.h:73
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TH1 * h
Definition: legend2.C:5
TProof * GetProof() const
Definition: TProofMgr.h:174
virtual void Add()
Add signal handler to system signal handler list.
void SetInvalid()
Invalidate this manager by closing the connection.
Definition: TXProofMgr.cxx:163
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
void More(const char *what, const char *how=0, const char *where=0)
Run &#39;more&#39; on the nodes.
Definition: TXProofMgr.cxx:958
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition: TUrl.cxx:499
#define gROOT
Definition: TROOT.h:352
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
const char * AsString() const
Return message digest as string.
Definition: TMD5.cxx:218
#define O_BINARY
Definition: civetweb.c:273
Basic string class.
Definition: TString.h:137
void Grep(const char *what, const char *how=0, const char *where=0)
Run &#39;grep&#39; on the nodes.
Definition: TXProofMgr.cxx:879
Int_t GetFile(const char *remote, const char *local, const char *opt=0)
Get file &#39;remote&#39; into &#39;local&#39; from the master.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
Long_t fMtime
Definition: TSystem.h:142
const char * GetMssUrl(Bool_t=kFALSE)
Gets the URL to be prepended to paths when accessing the MSS associated with the connected cluster...
Definition: TXProofMgr.cxx:365
Long64_t fSize
Definition: TSystem.h:141
TList * QuerySessions(Option_t *opt="S")
Get list of sessions accessible to this manager.
Definition: TXProofMgr.cxx:399
static void retrieve(const gsl_integration_workspace *workspace, double *a, double *b, double *r, double *e)
Int_t fUid
Definition: TSystem.h:150
TXProofMgr(const char *url, Int_t loglevel=-1, const char *alias="")
Create a PROOF manager for the standard (old) environment.
Definition: TXProofMgr.cxx:97
void RemoteTouch()
Remote touch functionality: contact the server to proof our vitality.
Definition: TXSocket.cxx:1345
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
Definition: TSystem.cxx:568
void SetProof(TProof *p)
Definition: TProofMgr.h:189
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
Definition: TUrl.cxx:467
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:129
Int_t fOpt
Definition: TXSocket.h:71
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:385
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
static Int_t GetErrno()
Static function returning system error number.
Definition: TSystem.cxx:264
Int_t fMode
Definition: TSystem.h:138
Int_t SendMsgToUsers(const char *msg, const char *usr=0)
Send a message to connected users.
Definition: TXProofMgr.cxx:776
void SetRemoteId(Int_t id)
Definition: TProofMgr.h:190
TProofLog * GetSessionLogs(Int_t ridx=0, const char *stag=0, const char *pattern="-v \ SvcMsg\, Bool_t rescan=kFALSE)
Get logs or log tails from last session associated with this manager instance.
Definition: TXProofMgr.cxx:588
Bool_t MatchUrl(const char *url)
Checks if &#39;url&#39; refers to the same &#39;user:port&#39; entity as the URL in memory.
Definition: TXProofMgr.cxx:304
const char * GetHost() const
Definition: TUrl.h:76
static TXProofMgrInit gxproofmgr_init
Definition: TXProofMgr.cxx:92
#define SafeDelete(p)
Definition: RConfig.h:449
Int_t Reset(Bool_t hard=kFALSE, const char *usr=0)
Send a cleanup request for the sessions associated with the current user.
Definition: TXProofMgr.cxx:553
TProofMgr * GetTXProofMgr(const char *url, Int_t l, const char *al)
Definition: TXProofMgr.cxx:84
virtual int WriteRaw(const void *buf, int len, XrdClientPhyConnection *p=0)
Low level write call.
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:75
Int_t RecvRaw(void *buf, Int_t len, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition: TXSocket.cxx:1581
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
void Ls(const char *what="~/", const char *how=0, const char *where=0)
Run &#39;ls&#39; on the nodes.
Definition: TXProofMgr.cxx:932
virtual ~TXProofMgr()
Destructor: close the connection.
Definition: TXProofMgr.cxx:155
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2220
static const std::string pattern("pattern")
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition: TSystem.cxx:1562
virtual TProofDesc * GetProofDesc(Int_t id)
Get TProofDesc instance corresponding to &#39;id&#39;.
Definition: TProofMgr.cxx:325
void Continue()
Resume a stopped stopwatch.
Definition: TStopwatch.cxx:91
Bool_t IsServProofd()
Return kTRUE if the remote server is a &#39;proofd&#39;.
Definition: TXSocket.cxx:957
Long64_t Atoll() const
Return long long value of string.
Definition: TString.cxx:1990
Int_t GetRemoteProtocol() const
Definition: TSocket.h:156
Int_t fGid
Definition: TSystem.h:140
void SetManager(TProofMgr *mgr)
Set manager and schedule its destruction after this for clean operations.
Definition: TProof.cxx:1301
EServType fServType
Definition: TProofMgr.h:70
A doubly linked list.
Definition: TList.h:47
static const char * what
Definition: stlLoader.cc:6
const char * GetUser() const
Definition: TUrl.h:74
Bool_t IsValid() const
Definition: TXProofMgr.h:66
const char * GetName() const
Returns name of object.
Definition: TObjString.h:42
void ShowROOTVersions()
Display what ROOT versions are available on the cluster.
Definition: TXProofMgr.cxx:727
TSignalHandler * fIntHandler
Definition: TProofMgr.h:74
ROOT::R::TRInterface & r
Definition: Object.C:4
Bool_t fIsLink
Definition: TSystem.h:143
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
char * Form(const char *fmt,...)
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1069
TLine * l
Definition: textangle.C:4
Int_t PutFile(const char *local, const char *remote, const char *opt=0)
Put file &#39;local&#39;to &#39;remote&#39; to the master If opt is "force", the file, if it exists remotely...
virtual const char * GetUrl()
Definition: TProofMgr.h:104
const Int_t kPROOF_Protocol
Definition: TProof.h:143
TObjString * Exec(Int_t action, const char *what, const char *how, const char *where)
Execute &#39;action&#39; (see EAdminExecType in &#39;XProofProtocol.h&#39;) at &#39;where&#39; (default master), with options &#39;how&#39;, on &#39;what&#39;.
Int_t Rm(const char *what, const char *how=0, const char *where=0)
Run &#39;rm&#39; on the nodes.
Definition: TXProofMgr.cxx:986
Bool_t IsIdle() const
Definition: TProof.h:973
void Print(Option_t *opt="") const
Dump the content to the screen.
Definition: TProofMgr.cxx:1099
TString GetString() const
Definition: TObjString.h:50
#define Printf
Definition: TGeoToOCC.h:18
virtual Int_t Reconnect()
Try reconnection after failure.
Definition: TXSocket.cxx:2133
#define R__LOCKGUARD2(mutex)
void DisconnectSession(Int_t id, Option_t *opt="")
Disconnect a session.
Definition: TXSocket.cxx:280
UInt_t What() const
Definition: TMessage.h:80
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
int Ssiz_t
Definition: RtypesCore.h:63
TProof * AttachSession(Int_t id, Bool_t gui=kFALSE)
Dummy version provided for completeness.
Definition: TXProofMgr.h:69
TUrl fUrl
Definition: TProofMgr.h:72
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2240
void Close(Option_t *option="")
Close all open slave servers.
Definition: TProof.cxx:1792
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
const Int_t kXPROOF_Protocol
Definition: TXProofMgr.h:41
double Double_t
Definition: RtypesCore.h:55
virtual void Remove()
Remove signal handler from system signal handler list.
int type
Definition: TGX11.cxx:120
Definition: TProof.h:339
Bool_t HandleInput(const void *)
Handle asynchronous input on the socket.
Definition: TXProofMgr.cxx:481
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TXSocket.cxx:1774
virtual Int_t GetUid(const char *user=0)
Returns the user&#39;s id. If user = 0, returns current user&#39;s id.
Definition: TSystem.cxx:1523
static void SetTXProofMgrHook(TProofMgr_t pmh)
Set hook to TXProofMgr ctor.
Definition: TProofMgr.cxx:619
Int_t GetPort() const
Definition: TUrl.h:87
Bool_t IsNull() const
Definition: TString.h:387
Binding & operator=(OUT(*fun)(void))
void Find(const char *what="~/", const char *how="-type f", const char *where=0)
Run &#39;find&#39; on the nodes.
Definition: TXProofMgr.cxx:905
TString fMssUrl
Definition: TProofMgr.h:68
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:126
Int_t SetROOTVersion(const char *tag)
Set the default ROOT version to be used.
Definition: TXProofMgr.cxx:753
TProofLogElem * Add(const char *ord, const char *url)
Add new entry to the list of elements.
Definition: TProofLog.cxx:68
Bool_t IsValid() const
Getter for validity status.
Definition: TXSocket.cxx:949
virtual int GetServiceByName(const char *service)
Get port # of internet service.
Definition: TSystem.cxx:2259
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
Int_t Init(Int_t loglevel=-1)
Do real initialization: open the connection and set the relevant variables.
Definition: TXProofMgr.cxx:118
TXSocket * fSocket
Definition: TXProofMgr.h:50
TObjString * SendCoordinator(Int_t kind, const char *msg=0, Int_t int2=0, Long64_t l64=0, Int_t int3=0, const char *opt=0)
Send message to intermediate coordinator.
Definition: TXSocket.cxx:1825
Long_t fIno
Definition: TSystem.h:137
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1964
void Reset()
Definition: TStopwatch.h:54
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1806
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition: TSystem.cxx:558
static void ResetErrno()
Static function resetting system error number.
Definition: TSystem.cxx:280
Bool_t IsValid() const
Definition: TProof.h:970
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1242
void Tail(const char *what, const char *how=0, const char *where=0)
Run &#39;tail&#39; on the nodes.
Long_t fDev
Definition: TSystem.h:136
virtual Int_t GetSize() const
Definition: TCollection.h:95
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
Int_t GetRemoteId() const
Definition: TProofMgr.h:175
void SetStatus(Int_t st)
Definition: TProofMgr.h:187
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904
Int_t GetXrdProofdVersion() const
Definition: TXSocket.h:178
const char * Data() const
Definition: TString.h:349
Int_t Retrieve(const char *ord="*", TProofLog::ERetrieveOpt opt=TProofLog::kTrailing, const char *fname=0, const char *pattern=0)
Retrieve the content of the log file associated with worker &#39;ord&#39;.
Definition: TProofLog.cxx:88
Stopwatch class.
Definition: TStopwatch.h:30