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