ROOT  6.06/08
Reference Guide
TProofLite.cxx
Go to the documentation of this file.
1 // @(#)root/proof:$Id: 7735e42a1b96a9f40ae76bd884acac883a178dee $
2 // Author: G. Ganis March 2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 // TProofLite //
15 // //
16 // This class starts a PROOF session on the local machine: no daemons, //
17 // client and master merged, communications via UNIX-like sockets. //
18 // By default the number of workers started is NumberOfCores+1; a //
19 // different number can be forced on construction. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TProofLite.h"
24 
25 #ifdef WIN32
26 # include <io.h>
27 # include "snprintf.h"
28 #endif
29 #include "RConfigure.h"
30 #include "TDSet.h"
31 #include "TEnv.h"
32 #include "TError.h"
33 #include "TFile.h"
34 #include "TFileCollection.h"
35 #include "TFileInfo.h"
36 #include "THashList.h"
37 #include "TMessage.h"
38 #include "TMonitor.h"
39 #include "TObjString.h"
40 #include "TPluginManager.h"
41 #include "TDataSetManager.h"
42 #include "TDataSetManagerFile.h"
43 #include "TParameter.h"
44 #include "TPRegexp.h"
45 #include "TProofQueryResult.h"
46 #include "TProofServ.h"
47 #include "TQueryResultManager.h"
48 #include "TROOT.h"
49 #include "TServerSocket.h"
50 #include "TSlave.h"
51 #include "TSortedList.h"
52 #include "TTree.h"
53 #include "TVirtualProofPlayer.h"
54 #include "TSelector.h"
55 
57 
58 Int_t TProofLite::fgWrksMax = -2; // Unitialized max number of workers
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Create a PROOF environment. Starting PROOF involves either connecting
62 /// to a master server, which in turn will start a set of slave servers, or
63 /// directly starting as master server (if master = ""). Masterurl is of
64 /// the form: [proof[s]://]host[:port]. Conffile is the name of the config
65 /// file describing the remote PROOF cluster (this argument alows you to
66 /// describe different cluster configurations).
67 /// The default is proof.conf. Confdir is the directory where the config
68 /// file and other PROOF related files are (like motd and noproof files).
69 /// Loglevel is the log level (default = 1). User specified custom config
70 /// files will be first looked for in $HOME/.conffile.
71 
72 TProofLite::TProofLite(const char *url, const char *conffile, const char *confdir,
73  Int_t loglevel, const char *alias, TProofMgr *mgr)
74 {
75  fUrl.SetUrl(url);
76 
77  // Default initializations
78  fServSock = 0;
79  fCacheLock = 0;
80  fQueryLock = 0;
81  fQMgr = 0;
82  fDataSetManager = 0;
83  fDataSetStgRepo = 0;
84  fReInvalid = new TPMERegexp("[^A-Za-z0-9._-]");
85  InitMembers();
86 
87  // This may be needed during init
88  fManager = mgr;
89 
90  // Default server type
91  fServType = TProofMgr::kProofLite;
92 
93  // Default query mode
94  fQueryMode = kSync;
95 
96  // Client and master are merged
97  fMasterServ = kTRUE;
98  if (fManager) SetBit(TProof::kIsClient);
99  SetBit(TProof::kIsMaster);
100 
101  // Flag that we are a client
102  if (!gSystem->Getenv("ROOTPROOFCLIENT")) gSystem->Setenv("ROOTPROOFCLIENT","");
103 
104  // Protocol and Host
105  fUrl.SetProtocol("proof");
106  fUrl.SetHost("__lite__");
107  fUrl.SetPort(1093);
108 
109  // User
110  if (strlen(fUrl.GetUser()) <= 0) {
111  // Get user logon name
113  if (pw) {
114  fUrl.SetUser(pw->fUser);
115  delete pw;
116  }
117  }
118  fMaster = gSystem->HostName();
119 
120  // Analysise the conffile field
121  ParseConfigField(conffile);
122 
123  // Determine the number of workers giving priority to users request.
124  // Otherwise use the system information, if available, or just start
125  // the minimal number, i.e. 2 .
126  if ((fNWorkers = GetNumberOfWorkers(url)) > 0) {
127 
128  TString stup;
129  if (gProofServ) {
130  Int_t port = gEnv->GetValue("ProofServ.XpdPort", 1093);
131  stup.Form("%s @ %s:%d ", gProofServ->GetOrdinal(), gSystem->HostName(), port);
132  }
133  Printf(" +++ Starting PROOF-Lite %swith %d workers +++", stup.Data(), fNWorkers);
134  // Init the session now
135  Init(url, conffile, confdir, loglevel, alias);
136  }
137 
138  // For final cleanup
139  if (!gROOT->GetListOfProofs()->FindObject(this))
140  gROOT->GetListOfProofs()->Add(this);
141 
142  // Still needed by the packetizers: needs to be changed
143  gProof = this;
144 }
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// Start the PROOF environment. Starting PROOF involves either connecting
148 /// to a master server, which in turn will start a set of slave servers, or
149 /// directly starting as master server (if master = ""). For a description
150 /// of the arguments see the TProof ctor. Returns the number of started
151 /// master or slave servers, returns 0 in case of error, in which case
152 /// fValid remains false.
153 
154 Int_t TProofLite::Init(const char *, const char *conffile,
155  const char *confdir, Int_t loglevel, const char *)
156 {
158 
159  fValid = kFALSE;
160 
161  // Connected to terminal?
162  fTty = (isatty(0) == 0 || isatty(1) == 0) ? kFALSE : kTRUE;
163 
164  if (TestBit(TProof::kIsMaster)) {
165  // Fill default conf file and conf dir
166  if (!conffile || !conffile[0])
168  if (!confdir || !confdir[0])
170  } else {
171  fConfDir = confdir;
172  fConfFile = conffile;
173  }
174 
175  // The sandbox for this session
176  if (CreateSandbox() != 0) {
177  Error("Init", "could not create/assert sandbox for this session");
178  return 0;
179  }
180 
181  // UNIX path for communication with workers
182  TString sockpathdir = gEnv->GetValue("ProofLite.SockPathDir", gSystem->TempDirectory());
183  if (sockpathdir.IsNull()) sockpathdir = gSystem->TempDirectory();
184  if (sockpathdir(sockpathdir.Length()-1) == '/') sockpathdir.Remove(sockpathdir.Length()-1);
185  fSockPath.Form("%s/plite-%d", sockpathdir.Data(), gSystem->GetPid());
186  if (fSockPath.Length() > 104) {
187  // Sort of hardcoded limit length for Unix systems
188  Error("Init", "Unix socket path '%s' is too long (%d bytes):",
190  Error("Init", "use 'ProofLite.SockPathDir' to create it under a directory different"
191  " from '%s'", sockpathdir.Data());
192  return 0;
193  }
194 
195  fLogLevel = loglevel;
198  fImage = "<local>";
199  fIntHandler = 0;
200  fStatus = 0;
201  fRecvMessages = new TList;
203  fSlaveInfo = 0;
204  fChains = new TList;
205  fAvailablePackages = 0;
206  fEnabledPackages = 0;
208  fInputData = 0;
210 
213 
214  // Timeout for some collect actions
215  fCollectTimeout = gEnv->GetValue("Proof.CollectTimeout", -1);
216 
217  // Should the workers be started dynamically; default: no
219  fDynamicStartupStep = -1;
220  fDynamicStartupNMax = -1;
221  TString dynconf = gEnv->GetValue("Proof.SimulateDynamicStartup", "");
222  if (dynconf.Length() > 0) {
224  fLastPollWorkers_s = time(0);
225  // Extract parameters
226  Int_t from = 0;
227  TString p;
228  if (dynconf.Tokenize(p, from, ":"))
229  if (p.IsDigit()) fDynamicStartupStep = p.Atoi();
230  if (dynconf.Tokenize(p, from, ":"))
231  if (p.IsDigit()) fDynamicStartupNMax = p.Atoi();
232  }
233 
234 
235  fProgressDialog = 0;
237 
238  // Client logging of messages from the workers
239  fRedirLog = kFALSE;
240  if (TestBit(TProof::kIsClient)) {
241  fLogFileName = Form("%s/session-%s.log", fWorkDir.Data(), GetName());
242  if ((fLogFileW = fopen(fLogFileName.Data(), "w")) == 0)
243  Error("Init", "could not create temporary logfile %s", fLogFileName.Data());
244  if ((fLogFileR = fopen(fLogFileName.Data(), "r")) == 0)
245  Error("Init", "could not open logfile %s for reading", fLogFileName.Data());
246  }
248 
251  TString(fCacheDir).ReplaceAll("/","%").Data()));
252 
253  // Create 'queries' locker instance and lock it
256  TString(fQueryDir).ReplaceAll("/","%").Data()));
257  fQueryLock->Lock();
258  // Create the query manager
261 
262  // Apply quotas, if any
263  Int_t maxq = gEnv->GetValue("ProofLite.MaxQueriesSaved", 10);
264  if (fQMgr && fQMgr->ApplyMaxQueries(maxq) != 0)
265  Warning("Init", "problems applying fMaxQueries");
266 
267  if (InitDataSetManager() != 0)
268  Warning("Init", "problems initializing the dataset manager");
269 
270  // Status of cluster
271  fNotIdle = 0;
272 
273  // Query type
274  fSync = kTRUE;
275 
276  // List of queries
277  fQueries = 0;
278  fOtherQueries = 0;
279  fDrawQueries = 0;
280  fMaxDrawQueries = 1;
281  fSeqNum = 0;
282 
283  // Remote ID of the session
284  fSessionID = -1;
285 
286  // Part of active query
287  fWaitingSlaves = 0;
288 
289  // Make remote PROOF player
290  fPlayer = 0;
291  MakePlayer("lite");
292 
293  fFeedback = new TList;
294  fFeedback->SetOwner();
295  fFeedback->SetName("FeedbackList");
297 
298  // Sort workers by descending performance index
300  fActiveSlaves = new TList;
301  fInactiveSlaves = new TList;
302  fUniqueSlaves = new TList;
303  fAllUniqueSlaves = new TList;
304  fNonUniqueMasters = new TList;
305  fBadSlaves = new TList;
306  fAllMonitor = new TMonitor;
307  fActiveMonitor = new TMonitor;
308  fUniqueMonitor = new TMonitor;
310  fCurrentMonitor = 0;
311  fServSock = 0;
312 
315 
316  // Control how to start the workers; copy-on-write (fork) is *very*
317  // experimental and available on Unix only.
319  if (gEnv->GetValue("ProofLite.ForkStartup", 0) != 0) {
320 #ifndef WIN32
322 #else
323  Warning("Init", "fork-based workers startup is not available on Windows - ignoring");
324 #endif
325  }
326 
327  fPackageLock = 0;
329  fLoadedMacros = 0;
331  if (TestBit(TProof::kIsClient)) {
332 
333  // List of directories where to look for global packages
334  TString globpack = gEnv->GetValue("Proof.GlobalPackageDirs","");
335  if (globpack.Length() > 0) {
336  Int_t ng = 0;
337  Int_t from = 0;
338  TString ldir;
339  while (globpack.Tokenize(ldir, from, ":")) {
341  if (gSystem->AccessPathName(ldir, kReadPermission)) {
342  Warning("Init", "directory for global packages %s does not"
343  " exist or is not readable", ldir.Data());
344  } else {
345  // Add to the list, key will be "G<ng>", i.e. "G0", "G1", ...
346  TString key = Form("G%d", ng++);
347  if (!fGlobalPackageDirList) {
350  }
351  fGlobalPackageDirList->Add(new TNamed(key,ldir));
352  }
353  }
354  }
355 
356  TString lockpath(fPackageDir);
357  lockpath.ReplaceAll("/", "%");
359  fPackageLock = new TProofLockPath(lockpath.Data());
360 
362  fEnabledPackagesOnClient->SetOwner();
363  }
364 
365  // Start workers
366  if (SetupWorkers(0) != 0) {
367  Error("Init", "problems setting up workers");
368  return 0;
369  }
370 
371  // we are now properly initialized
372  fValid = kTRUE;
373 
374  // De-activate monitor (will be activated in Collect)
376 
377  // By default go into parallel mode
378  GoParallel(-1, kFALSE);
379 
380  // Send relevant initial state to slaves
382 
383  SetActive(kFALSE);
384 
385  if (IsValid()) {
386  // Activate input handler
388  // Set PROOF to running state
390  }
391  // We register the session as a socket so that cleanup is done properly
393  gROOT->GetListOfSockets()->Add(this);
394 
395  AskParallel();
396 
397  return fActiveSlaves->GetSize();
398 }
399 ////////////////////////////////////////////////////////////////////////////////
400 /// Destructor
401 
403 {
404  // Shutdown the workers
405  RemoveWorkers(0);
406 
407  if (!(fQMgr && fQMgr->Queries() && fQMgr->Queries()->GetSize())) {
408  // needed in case fQueryDir is on NFS ?!
409  gSystem->MakeDirectory(fQueryDir+"/.delete");
410  gSystem->Exec(Form("%s %s", kRM, fQueryDir.Data()));
411  }
412 
413  // Remove lock file
414  if (fQueryLock) {
416  fQueryLock->Unlock();
417  }
418 
422 
423  // Cleanup the socket
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Static method to determine the number of workers giving priority to users request.
430 /// Otherwise use the system information, if available, or just start
431 /// the minimal number, i.e. 2 .
432 
434 {
435  Bool_t notify = kFALSE;
436  if (fgWrksMax == -2) {
437  // Find the max number of workers, if any
438  TString sysname = "system.rootrc";
439  char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sysname);
440  TEnv sysenv(0);
441  sysenv.ReadFile(s, kEnvGlobal);
442  fgWrksMax = sysenv.GetValue("ProofLite.MaxWorkers", -1);
443  // Notify once the user if its will is changed
444  notify = kTRUE;
445  if (s) delete[] s;
446  }
447  if (fgWrksMax == 0) {
448  ::Error("TProofLite::GetNumberOfWorkers",
449  "PROOF-Lite disabled by the system administrator: sorry!");
450  return 0;
451  }
452 
453  TString nw;
454  Int_t nWorkers = -1;
455  Bool_t urlSetting = kFALSE;
456  if (url && strlen(url)) {
457  nw = url;
458  Int_t in = nw.Index("workers=");
459  if (in != kNPOS) {
460  nw.Remove(0, in + strlen("workers="));
461  while (!nw.IsDigit())
462  nw.Remove(nw.Length()-1);
463  if (!nw.IsNull()) {
464  if ((nWorkers = nw.Atoi()) <= 0) {
465  ::Warning("TProofLite::GetNumberOfWorkers",
466  "number of workers specified by 'workers='"
467  " is non-positive: using default");
468  } else {
469  urlSetting = kFALSE;
470  }
471  }
472  }
473  }
474  if (!urlSetting && fgProofEnvList) {
475  // Check PROOF_NWORKERS
476  TNamed *nm = (TNamed *) fgProofEnvList->FindObject("PROOF_NWORKERS");
477  if (nm) {
478  nw = nm->GetTitle();
479  if (nw.IsDigit()) {
480  if ((nWorkers = nw.Atoi()) == 0) {
481  ::Warning("TProofLite::GetNumberOfWorkers",
482  "number of workers specified by 'workers='"
483  " is non-positive: using default");
484  }
485  }
486  }
487  }
488  if (nWorkers <= 0) {
489  nWorkers = gEnv->GetValue("ProofLite.Workers", -1);
490  if (nWorkers <= 0) {
491  SysInfo_t si;
492  if (gSystem->GetSysInfo(&si) == 0 && si.fCpus > 2) {
493  nWorkers = si.fCpus;
494  } else {
495  // Two workers by default
496  nWorkers = 2;
497  }
498  if (notify) notify = kFALSE;
499  }
500  }
501  // Apply the max, if any
502  if (fgWrksMax > 0 && fgWrksMax < nWorkers) {
503  if (notify)
504  ::Warning("TProofLite::GetNumberOfWorkers", "number of PROOF-Lite workers limited by"
505  " the system administrator to %d", fgWrksMax);
506  nWorkers = fgWrksMax;
507  }
508 
509  // Done
510  return nWorkers;
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /// Start up PROOF workers.
515 
517 {
518  // Create server socket on the assigned UNIX sock path
519  if (!fServSock) {
520  if ((fServSock = new TServerSocket(fSockPath))) {
522  // Remove from the list so that cleanup can be done in the correct order
523  gROOT->GetListOfSockets()->Remove(fServSock);
524  }
525  }
526  if (!fServSock || !fServSock->IsValid()) {
527  Error("SetupWorkers",
528  "unable to create server socket for internal communications");
530  return -1;
531  }
532 
533  // Create a monitor and add the socket to it
534  TMonitor *mon = new TMonitor;
535  mon->Add(fServSock);
536 
537  TList started;
538  TSlave *wrk = 0;
539  Int_t nWrksDone = 0, nWrksTot = -1;
540  TString fullord;
541 
542  if (opt == 0) {
543  nWrksTot = fForkStartup ? 1 : fNWorkers;
544  // Now we create the worker applications which will call us back to finalize
545  // the setup
546  Int_t ord = 0;
547  for (; ord < nWrksTot; ord++) {
548 
549  // Ordinal for this worker server
550  const char *o = (gProofServ) ? gProofServ->GetOrdinal() : "0";
551  fullord.Form("%s.%d", o, ord);
552 
553  // Create environment files
554  SetProofServEnv(fullord);
555 
556  // Create worker server and add to the list
557  if ((wrk = CreateSlave("lite", fullord, 100, fImage, fWorkDir)))
558  started.Add(wrk);
559 
560  // Notify
561  NotifyStartUp("Opening connections to workers", ++nWrksDone, nWrksTot);
562 
563  } //end of worker loop
564  } else {
565  if (!fForkStartup) {
566  Warning("SetupWorkers", "standard startup: workers already started");
567  return -1;
568  }
569  nWrksTot = fNWorkers - 1;
570  // Now we create the worker applications which will call us back to finalize
571  // the setup
572  TString clones;
573  Int_t ord = 0;
574  for (; ord < nWrksTot; ord++) {
575 
576  // Ordinal for this worker server
577  const char *o = (gProofServ) ? gProofServ->GetOrdinal() : "0";
578  fullord.Form("%s.%d", o, ord + 1);
579  if (!clones.IsNull()) clones += " ";
580  clones += fullord;
581 
582  // Create worker server and add to the list
583  if ((wrk = CreateSlave("lite", fullord, -1, fImage, fWorkDir)))
584  started.Add(wrk);
585 
586  // Notify
587  NotifyStartUp("Opening connections to workers", ++nWrksDone, nWrksTot);
588 
589  } //end of worker loop
590 
591  // Send the request
593  m << clones;
594  Broadcast(m, kActive);
595  }
596 
597  // Wait for call backs
598  nWrksDone = 0;
599  nWrksTot = started.GetSize();
600  Int_t nSelects = 0;
601  Int_t to = gEnv->GetValue("ProofLite.StartupTimeOut", 5) * 1000;
602  while (started.GetSize() > 0 && nSelects < nWrksTot) {
603 
604  // Wait for activity on the socket for max 5 secs
605  TSocket *xs = mon->Select(to);
606 
607  // Count attempts and check
608  nSelects++;
609  if (xs == (TSocket *) -1) continue;
610 
611  // Get the connection
612  TSocket *s = fServSock->Accept();
613  if (s && s->IsValid()) {
614  // Receive ordinal
615  TMessage *msg = 0;
616  if (s->Recv(msg) < 0) {
617  Warning("SetupWorkers", "problems receiving message from accepted socket!");
618  } else {
619  if (msg) {
620  TString ord;
621  *msg >> ord;
622  // Find who is calling back
623  if ((wrk = (TSlave *) started.FindObject(ord))) {
624  // Remove it from the started list
625  started.Remove(wrk);
626 
627  // Assign tis socket the selected worker
628  wrk->SetSocket(s);
629  // Remove socket from global TROOT socket list. Only the TProof object,
630  // representing all worker sockets, will be added to this list. This will
631  // ensure the correct termination of all proof servers in case the
632  // root session terminates.
634  gROOT->GetListOfSockets()->Remove(s);
635  }
636  if (wrk->IsValid()) {
637  // Set the input handler
638  wrk->SetInputHandler(new TProofInputHandler(this, wrk->GetSocket()));
639  // Set fParallel to 1 for workers since they do not
640  // report their fParallel with a LOG_DONE message
641  wrk->fParallel = 1;
642  // Finalize setup of the server
643  wrk->SetupServ(TSlave::kSlave, 0);
644  }
645 
646  // Monitor good workers
647  fSlaves->Add(wrk);
648  if (wrk->IsValid()) {
649  if (opt == 1) fActiveSlaves->Add(wrk);
650  fAllMonitor->Add(wrk->GetSocket());
651  // Record also in the list for termination
652  if (startedWorkers) startedWorkers->Add(wrk);
653  // Notify startup operations
654  NotifyStartUp("Setting up worker servers", ++nWrksDone, nWrksTot);
655  } else {
656  // Flag as bad
657  fBadSlaves->Add(wrk);
658  }
659  }
660  } else {
661  Warning("SetupWorkers", "received empty message from accepted socket!");
662  }
663  }
664  }
665  }
666 
667  // Cleanup the monitor and the server socket
668  mon->DeActivateAll();
669  delete mon;
670 
671  // Create Progress dialog, if needed
672  if (!gROOT->IsBatch() && !fProgressDialog) {
673  if ((fProgressDialog =
674  gROOT->GetPluginManager()->FindHandler("TProofProgressDialog")))
675  if (fProgressDialog->LoadPlugin() == -1)
676  fProgressDialog = 0;
677  }
678 
679  if (opt == 1) {
680  // Collect replies
681  Collect(kActive);
682  // Update group view
683  SendGroupView();
684  // By default go into parallel mode
685  SetParallel(-1, 0);
686  }
687  // Done
688  return 0;
689 }
690 
691 ////////////////////////////////////////////////////////////////////////////////
692 /// Notify setting-up operation message
693 
694 void TProofLite::NotifyStartUp(const char *action, Int_t done, Int_t tot)
695 {
696  Int_t frac = (Int_t) (done*100.)/tot;
697  char msg[512] = {0};
698  if (frac >= 100) {
699  snprintf(msg, 512, "%s: OK (%d workers) \n",
700  action, tot);
701  } else {
702  snprintf(msg, 512, "%s: %d out of %d (%d %%)\r",
703  action, done, tot, frac);
704  }
705  fprintf(stderr,"%s", msg);
706 }
707 
708 ////////////////////////////////////////////////////////////////////////////////
709 /// Create environment files for worker 'ord'
710 
712 {
713  // Check input
714  if (!ord || strlen(ord) <= 0) {
715  Error("SetProofServEnv", "ordinal string undefined");
716  return -1;
717  }
718 
719  // ROOT env file
720  TString rcfile(Form("%s/worker-%s.rootrc", fWorkDir.Data(), ord));
721  FILE *frc = fopen(rcfile.Data(), "w");
722  if (!frc) {
723  Error("SetProofServEnv", "cannot open rc file %s", rcfile.Data());
724  return -1;
725  }
726 
727  // The session working dir depends on the role
728  fprintf(frc,"# The session working dir\n");
729  fprintf(frc,"ProofServ.SessionDir: %s/worker-%s\n", fWorkDir.Data(), ord);
730 
731  // The session unique tag
732  fprintf(frc,"# Session tag\n");
733  fprintf(frc,"ProofServ.SessionTag: %s\n", GetName());
734 
735  // Log / Debug level
736  fprintf(frc,"# Proof Log/Debug level\n");
737  fprintf(frc,"Proof.DebugLevel: %d\n", gDebug);
738 
739  // Ordinal number
740  fprintf(frc,"# Ordinal number\n");
741  fprintf(frc,"ProofServ.Ordinal: %s\n", ord);
742 
743  // ROOT Version tag
744  fprintf(frc,"# ROOT Version tag\n");
745  fprintf(frc,"ProofServ.RootVersionTag: %s\n", gROOT->GetVersion());
746 
747  // Work dir
748  TString sandbox = fSandbox;
749  if (GetSandbox(sandbox, kFALSE, "ProofServ.Sandbox") != 0)
750  Warning("SetProofServEnv", "problems getting sandbox string for worker");
751  fprintf(frc,"# Users sandbox\n");
752  fprintf(frc, "ProofServ.Sandbox: %s\n", sandbox.Data());
753 
754  // Cache dir
755  fprintf(frc,"# Users cache\n");
756  fprintf(frc, "ProofServ.CacheDir: %s\n", fCacheDir.Data());
757 
758  // Package dir
759  fprintf(frc,"# Users packages\n");
760  fprintf(frc, "ProofServ.PackageDir: %s\n", fPackageDir.Data());
761 
762  // Image
763  fprintf(frc,"# Server image\n");
764  fprintf(frc, "ProofServ.Image: %s\n", fImage.Data());
765 
766  // Set Open socket
767  fprintf(frc,"# Open socket\n");
768  fprintf(frc, "ProofServ.OpenSock: %s\n", fSockPath.Data());
769 
770  // Client Protocol
771  fprintf(frc,"# Client Protocol\n");
772  fprintf(frc, "ProofServ.ClientVersion: %d\n", kPROOF_Protocol);
773 
774  // ROOT env file created
775  fclose(frc);
776 
777  // System env file
778  TString envfile(Form("%s/worker-%s.env", fWorkDir.Data(), ord));
779  FILE *fenv = fopen(envfile.Data(), "w");
780  if (!fenv) {
781  Error("SetProofServEnv", "cannot open env file %s", envfile.Data());
782  return -1;
783  }
784  // ROOTSYS
785  fprintf(fenv, "export ROOTSYS=%s\n", TROOT::GetRootSys().Data());
786  // Conf dir
787  fprintf(fenv, "export ROOTCONFDIR=%s\n", TROOT::GetRootSys().Data());
788  // TMPDIR
789  fprintf(fenv, "export TMPDIR=%s\n", gSystem->TempDirectory());
790  // Log file in the log dir
791  TString logfile(Form("%s/worker-%s.log", fWorkDir.Data(), ord));
792  fprintf(fenv, "export ROOTPROOFLOGFILE=%s\n", logfile.Data());
793  // RC file
794  fprintf(fenv, "export ROOTRCFILE=%s\n", rcfile.Data());
795  // ROOT version tag (needed in building packages)
796  fprintf(fenv, "export ROOTVERSIONTAG=%s\n", gROOT->GetVersion());
797  // This flag can be used to identify the type of worker; for example, in BUILD.sh or SETUP.C ...
798  fprintf(fenv, "export ROOTPROOFLITE=%d\n", fNWorkers);
799  // Local files are on the local file system
800  fprintf(fenv, "export LOCALDATASERVER=\"file://\"\n");
801  // Set the user envs
802  if (fgProofEnvList) {
803  TString namelist;
804  TIter nxenv(fgProofEnvList);
805  TNamed *env = 0;
806  while ((env = (TNamed *)nxenv())) {
807  TString senv(env->GetTitle());
808  ResolveKeywords(senv, ord, logfile.Data());
809  fprintf(fenv, "export %s=%s\n", env->GetName(), senv.Data());
810  if (namelist.Length() > 0)
811  namelist += ',';
812  namelist += env->GetName();
813  }
814  fprintf(fenv, "export PROOF_ALLVARS=%s\n", namelist.Data());
815  }
816 
817  // System env file created
818  fclose(fenv);
819 
820  // Done
821  return 0;
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Resolve some keywords in 's'
826 /// <logfilewrk>, <user>, <rootsys>, <cpupin>
827 
828 void TProofLite::ResolveKeywords(TString &s, const char *ord,
829  const char *logfile)
830 {
831  if (!logfile) return;
832 
833  // Log file
834  if (s.Contains("<logfilewrk>") && logfile) {
835  TString lfr(logfile);
836  if (lfr.EndsWith(".log")) lfr.Remove(lfr.Last('.'));
837  s.ReplaceAll("<logfilewrk>", lfr.Data());
838  }
839 
840  // user
841  if (gSystem->Getenv("USER") && s.Contains("<user>")) {
842  s.ReplaceAll("<user>", gSystem->Getenv("USER"));
843  }
844 
845  // rootsys
846  if (gSystem->Getenv("ROOTSYS") && s.Contains("<rootsys>")) {
847  s.ReplaceAll("<rootsys>", gSystem->Getenv("ROOTSYS"));
848  }
849 
850  // cpupin: pin to this CPU num (from 0 to ncpus-1)
851  if (s.Contains("<cpupin>")) {
852  TString o = ord;
853  Int_t n = o.Index('.');
854  if (n != kNPOS) {
855 
856  o.Remove(0, n+1);
857  n = o.Atoi(); // n is ord
858 
859  TString cpuPinList;
860  {
861  const TList *envVars = GetEnvVars();
862  TNamed *var;
863  if (envVars) {
864  var = dynamic_cast<TNamed *>(envVars->FindObject("PROOF_SLAVE_CPUPIN_ORDER"));
865  if (var) cpuPinList = var->GetTitle();
866  }
867  }
868 
869  UInt_t nCpus = 1;
870  {
871  SysInfo_t si;
872  if (gSystem->GetSysInfo(&si) == 0 && (si.fCpus > 0))
873  nCpus = si.fCpus;
874  else nCpus = 1; // fallback
875  }
876 
877  if (cpuPinList.IsNull() || (cpuPinList == "*")) {
878  // Use processors in order
879  n = n % nCpus;
880  }
881  else {
882  // Use processors in user's order
883  // n is now the ordinal, converting to idx
884  n = n % (cpuPinList.CountChar('+')+1);
885  TString tok;
886  Ssiz_t from = 0;
887  for (Int_t i=0; cpuPinList.Tokenize(tok, from, "\\+"); i++) {
888  if (i == n) {
889  n = (tok.Atoi() % nCpus);
890  break;
891  }
892  }
893  }
894 
895  o.Form("%d", n);
896  }
897  else {
898  o = "0"; // should not happen
899  }
900  s.ReplaceAll("<cpupin>", o);
901  }
902 }
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Create the sandbox for this session
906 
908 {
909  // Make sure the sandbox area exist and is writable
910  if (GetSandbox(fSandbox, kTRUE, "ProofLite.Sandbox") != 0) return -1;
911 
912  // Package Dir
913  fPackageDir = gEnv->GetValue("Proof.PackageDir", "");
914  if (fPackageDir.IsNull())
916  if (AssertPath(fPackageDir, kTRUE) != 0) return -1;
917 
918  // Cache Dir
919  fCacheDir = gEnv->GetValue("Proof.CacheDir", "");
920  if (fCacheDir.IsNull())
922  if (AssertPath(fCacheDir, kTRUE) != 0) return -1;
923 
924  // Data Set Dir
925  fDataSetDir = gEnv->GetValue("Proof.DataSetDir", "");
926  if (fDataSetDir.IsNull())
928  if (AssertPath(fDataSetDir, kTRUE) != 0) return -1;
929 
930  // Session unique tag (name of this TProof instance)
931  TString stag;
932  stag.Form("%s-%d-%d", gSystem->HostName(), (int)time(0), gSystem->GetPid());
933  SetName(stag.Data());
934 
935  Int_t subpath = gEnv->GetValue("ProofLite.SubPath", 1);
936  // Subpath for this session in the fSandbox (<sandbox>/path-to-working-dir)
937  TString sessdir;
938  if (subpath != 0) {
939  sessdir = gSystem->WorkingDirectory();
940  sessdir.ReplaceAll(gSystem->HomeDirectory(),"");
941  sessdir.ReplaceAll("/","-");
942  sessdir.Replace(0,1,"/",1);
943  sessdir.Insert(0, fSandbox.Data());
944  } else {
945  // USe the sandbox
946  sessdir = fSandbox;
947  }
948 
949  // Session working and queries dir
950  fWorkDir.Form("%s/session-%s", sessdir.Data(), stag.Data());
951  if (AssertPath(fWorkDir, kTRUE) != 0) return -1;
952 
953  // Create symlink to the last session
954  TString lastsess;
955  lastsess.Form("%s/last-lite-session", sessdir.Data());
956  gSystem->Unlink(lastsess);
957  gSystem->Symlink(fWorkDir, lastsess);
958 
959  // Queries Dir: local to the working dir, unless required differently
960  fQueryDir = gEnv->GetValue("Proof.QueryDir", "");
961  if (fQueryDir.IsNull())
962  fQueryDir.Form("%s/%s", sessdir.Data(), kPROOF_QueryDir);
963  if (AssertPath(fQueryDir, kTRUE) != 0) return -1;
964 
965  // Cleanup old sessions dirs
966  CleanupSandbox();
967 
968  // Done
969  return 0;
970 }
971 
972 ////////////////////////////////////////////////////////////////////////////////
973 /// Print status of PROOF-Lite cluster.
974 
975 void TProofLite::Print(Option_t *option) const
976 {
977  TString ord;
978  if (gProofServ) ord.Form("%s ", gProofServ->GetOrdinal());
979  if (IsParallel())
980  Printf("*** PROOF-Lite cluster %s(parallel mode, %d workers):", ord.Data(), GetParallel());
981  else
982  Printf("*** PROOF-Lite cluster %s(sequential mode)", ord.Data());
983 
984  if (gProofServ) {
985  TString url(gSystem->HostName());
986  // Add port to URL, if defined
987  Int_t port = gEnv->GetValue("ProofServ.XpdPort", 1093);
988  if (port > -1) url.Form("%s:%d",gSystem->HostName(), port);
989  Printf("URL: %s", url.Data());
990  } else {
991  Printf("Host name: %s", gSystem->HostName());
992  }
993  Printf("User: %s", GetUser());
994  TString ver(gROOT->GetVersion());
995  ver += TString::Format("|%s", gROOT->GetGitCommit());
996  if (gSystem->Getenv("ROOTVERSIONTAG"))
997  ver += TString::Format("|%s", gSystem->Getenv("ROOTVERSIONTAG"));
998  Printf("ROOT version|rev|tag: %s", ver.Data());
999  Printf("Architecture-Compiler: %s-%s", gSystem->GetBuildArch(),
1001  Printf("Protocol version: %d", GetClientProtocol());
1002  Printf("Working directory: %s", gSystem->WorkingDirectory());
1003  Printf("Communication path: %s", fSockPath.Data());
1004  Printf("Log level: %d", GetLogLevel());
1005  Printf("Number of workers: %d", GetNumberOfSlaves());
1006  Printf("Number of active workers: %d", GetNumberOfActiveSlaves());
1007  Printf("Number of unique workers: %d", GetNumberOfUniqueSlaves());
1008  Printf("Number of inactive workers: %d", GetNumberOfInactiveSlaves());
1009  Printf("Number of bad workers: %d", GetNumberOfBadSlaves());
1010  Printf("Total MB's processed: %.2f", float(GetBytesRead())/(1024*1024));
1011  Printf("Total real time used (s): %.3f", GetRealTime());
1012  Printf("Total CPU time used (s): %.3f", GetCpuTime());
1013  if (TString(option).Contains("a", TString::kIgnoreCase) && GetNumberOfSlaves()) {
1014  Printf("List of workers:");
1015  TIter nextslave(fSlaves);
1016  while (TSlave* sl = dynamic_cast<TSlave*>(nextslave())) {
1017  if (sl->IsValid())
1018  sl->Print(option);
1019  }
1020  }
1021 }
1022 
1023 ////////////////////////////////////////////////////////////////////////////////
1024 /// Create a TProofQueryResult instance for this query.
1025 
1027  Long64_t fst, TDSet *dset,
1028  const char *selec)
1029 {
1030  // Increment sequential number
1031  Int_t seqnum = -1;
1032  if (fQMgr) {
1034  seqnum = fQMgr->SeqNum();
1035  }
1036 
1037  // Create the instance and add it to the list
1038  TProofQueryResult *pqr = new TProofQueryResult(seqnum, opt,
1039  fPlayer->GetInputList(), nent,
1040  fst, dset, selec,
1041  (dset ? dset->GetEntryList() : 0));
1042  // Title is the session identifier
1043  pqr->SetTitle(GetName());
1044 
1045  return pqr;
1046 }
1047 
1048 ////////////////////////////////////////////////////////////////////////////////
1049 /// Set query in running state.
1050 
1052 {
1053  // Record current position in the log file at start
1054  fflush(fLogFileW);
1055  Int_t startlog = lseek(fileno(fLogFileW), (off_t) 0, SEEK_END);
1056 
1057  // Add some header to logs
1058  Printf(" ");
1059  Info("SetQueryRunning", "starting query: %d", pq->GetSeqNum());
1060 
1061  // Build the list of loaded PAR packages
1062  TString parlist = "";
1064  TObjString *os= 0;
1065  while ((os = (TObjString *)nxp())) {
1066  if (parlist.Length() <= 0)
1067  parlist = os->GetName();
1068  else
1069  parlist += Form(";%s",os->GetName());
1070  }
1071 
1072  // Set in running state
1073  pq->SetRunning(startlog, parlist, GetParallel());
1074 
1075  // Bytes and CPU at start (we will calculate the differential at end)
1076  AskStatistics();
1078 }
1079 
1080 ////////////////////////////////////////////////////////////////////////////////
1081 /// Execute the specified drawing action on a data set (TDSet).
1082 /// Event- or Entry-lists should be set in the data set object using
1083 /// TDSet::SetEntryList.
1084 /// Returns -1 in case of error or number of selected events otherwise.
1085 
1086 Long64_t TProofLite::DrawSelect(TDSet *dset, const char *varexp,
1087  const char *selection, Option_t *option,
1088  Long64_t nentries, Long64_t first)
1089 {
1090  if (!IsValid()) return -1;
1091 
1092  // Make sure that asynchronous processing is not active
1093  if (!IsIdle()) {
1094  Info("DrawSelect","not idle, asynchronous Draw not supported");
1095  return -1;
1096  }
1097  TString opt(option);
1098  Int_t idx = opt.Index("ASYN", 0, TString::kIgnoreCase);
1099  if (idx != kNPOS)
1100  opt.Replace(idx,4,"");
1101 
1102  // Fill the internal variables
1103  fVarExp = varexp;
1104  fSelection = selection;
1105 
1106  return Process(dset, "draw:", opt, nentries, first);
1107 }
1108 
1109 ////////////////////////////////////////////////////////////////////////////////
1110 /// Process a data set (TDSet) using the specified selector (.C) file.
1111 /// Entry- or event-lists should be set in the data set object using
1112 /// TDSet::SetEntryList.
1113 /// The return value is -1 in case of error and TSelector::GetStatus() in
1114 /// in case of success.
1115 
1116 Long64_t TProofLite::Process(TDSet *dset, const char *selector, Option_t *option,
1117  Long64_t nentries, Long64_t first)
1118 {
1119  // For the time being cannot accept other queries if not idle, even if in async
1120  // mode; needs to set up an event handler to manage that
1121 
1122  TString opt(option), optfb, outfile;
1123  // Enable feedback, if required
1124  if (opt.Contains("fb=") || opt.Contains("feedback=")) SetFeedback(opt, optfb, 0);
1125  // Define output file, either from 'opt' or the default one
1126  if (HandleOutputOptions(opt, outfile, 0) != 0) return -1;
1127 
1128  // Resolve query mode
1129  fSync = (GetQueryMode(opt) == kSync);
1130  if (!fSync) {
1131  Info("Process","asynchronous mode not yet supported in PROOF-Lite");
1132  return -1;
1133  }
1134 
1135  if (!IsIdle()) {
1136  // Notify submission
1137  Info("Process", "not idle: cannot accept queries");
1138  return -1;
1139  }
1140 
1141  // Cleanup old temporary datasets
1142  if (IsIdle() && fRunningDSets && fRunningDSets->GetSize() > 0) {
1144  fRunningDSets->Delete();
1145  }
1146 
1147  if (!IsValid() || !fQMgr || !fPlayer) {
1148  Error("Process", "invalid sesion or query-result manager undefined!");
1149  return -1;
1150  }
1151 
1152  // Make sure that all enabled workers get some work, unless stated
1153  // differently
1154  if (!fPlayer->GetInputList()->FindObject("PROOF_MaxSlavesPerNode"))
1155  SetParameter("PROOF_MaxSlavesPerNode", (Long_t)0);
1156 
1157  Bool_t hasNoData = (!dset || (dset && dset->TestBit(TDSet::kEmpty))) ? kTRUE : kFALSE;
1158 
1159  // If just a name was given to identify the dataset, retrieve it from the
1160  // local files
1161  // Make sure the dataset contains the information needed
1162  TString emsg;
1163  if ((!hasNoData) && dset->GetListOfElements()->GetSize() == 0) {
1164  if (TProof::AssertDataSet(dset, fPlayer->GetInputList(), fDataSetManager, emsg) != 0) {
1165  Error("Process", "from AssertDataSet: %s", emsg.Data());
1166  return -1;
1167  }
1168  if (dset->GetListOfElements()->GetSize() == 0) {
1169  Error("Process", "no files to process!");
1170  return -1;
1171  }
1172  } else if (hasNoData) {
1173  // Check if we are required to process with TPacketizerFile a registered dataset
1174  TNamed *ftp = dynamic_cast<TNamed *>(fPlayer->GetInputList()->FindObject("PROOF_FilesToProcess"));
1175  if (ftp) {
1176  TString dsn(ftp->GetTitle());
1177  if (!dsn.Contains(":") || dsn.BeginsWith("dataset:")) {
1178  dsn.ReplaceAll("dataset:", "");
1179  // Make sure we have something in input and a dataset manager
1180  if (!fDataSetManager) {
1181  emsg.Form("dataset manager not initialized!");
1182  } else {
1183  TFileCollection *fc = 0;
1184  // Get the dataset
1185  if (!(fc = fDataSetManager->GetDataSet(dsn))) {
1186  emsg.Form("requested dataset '%s' does not exists", dsn.Data());
1187  } else {
1188  TMap *fcmap = TProofServ::GetDataSetNodeMap(fc, emsg);
1189  if (fcmap) {
1190  fPlayer->GetInputList()->Remove(ftp);
1191  delete ftp;
1192  fcmap->SetOwner(kTRUE);
1193  fcmap->SetName("PROOF_FilesToProcess");
1194  fPlayer->GetInputList()->Add(fcmap);
1195  }
1196  }
1197  }
1198  if (!emsg.IsNull()) {
1199  Error("HandleProcess", "%s", emsg.Data());
1200  return -1;
1201  }
1202  }
1203  }
1204  }
1205 
1206  TString selec(selector), varexp, selection, objname;
1207  // If a draw query, extract the relevant info
1208  if (selec.BeginsWith("draw:")) {
1209  varexp = fVarExp;
1210  selection = fSelection;
1211  // Decode now the expression
1212  if (fPlayer->GetDrawArgs(varexp, selection, opt, selec, objname) != 0) {
1213  Error("Process", "draw query: error parsing arguments '%s', '%s', '%s'",
1214  varexp.Data(), selection.Data(), opt.Data());
1215  return -1;
1216  }
1217  }
1218 
1219  // Create instance of query results (the data set is added after Process)
1220  TProofQueryResult *pq = MakeQueryResult(nentries, opt, first, 0, selec);
1221 
1222  // Check if queries must be saved into files
1223  // Automatic saving is controlled by ProofLite.AutoSaveQueries
1224  Bool_t savequeries =
1225  (!strcmp(gEnv->GetValue("ProofLite.AutoSaveQueries", "off"), "on")) ? kTRUE : kFALSE;
1226 
1227  // Keep queries in memory and how many (-1 = all, 0 = none, ...)
1228  Int_t memqueries = gEnv->GetValue("ProofLite.MaxQueriesMemory", 1);
1229 
1230  // If not a draw action add the query to the main list
1231  if (!(pq->IsDraw())) {
1232  if (fQMgr->Queries()) {
1233  if (memqueries != 0) fQMgr->Queries()->Add(pq);
1234  if (memqueries >= 0 && fQMgr->Queries()->GetSize() > memqueries) {
1235  // Remove oldest
1236  TObject *qfst = fQMgr->Queries()->First();
1237  fQMgr->Queries()->Remove(qfst);
1238  delete qfst;
1239  }
1240  }
1241  // Also save it to queries dir
1242  if (savequeries) fQMgr->SaveQuery(pq);
1243  }
1244 
1245  // Set the query number
1246  fSeqNum = pq->GetSeqNum();
1247 
1248  // Set in running state
1249  SetQueryRunning(pq);
1250 
1251  // Save to queries dir, if not standard draw
1252  if (!(pq->IsDraw())) {
1253  if (savequeries) fQMgr->SaveQuery(pq);
1254  } else {
1256  }
1257 
1258  // Start or reset the progress dialog
1259  if (!gROOT->IsBatch()) {
1260  Int_t dsz = (dset && dset->GetListOfElements()) ? dset->GetListOfElements()->GetSize() : -1;
1261  if (fProgressDialog &&
1263  if (!fProgressDialogStarted) {
1264  fProgressDialog->ExecPlugin(5, this, selec.Data(), dsz,
1265  first, nentries);
1267  } else {
1268  ResetProgressDialog(selec.Data(), dsz, first, nentries);
1269  }
1270  }
1272  }
1273 
1274  // Add query results to the player lists
1275  if (!(pq->IsDraw()))
1276  fPlayer->AddQueryResult(pq);
1277 
1278  // Set query currently processed
1279  fPlayer->SetCurrentQuery(pq);
1280 
1281  // Make sure the unique query tag is available as TNamed object in the
1282  // input list so that it can be used in TSelectors for monitoring
1283  TNamed *qtag = (TNamed *) fPlayer->GetInputList()->FindObject("PROOF_QueryTag");
1284  if (qtag) {
1285  qtag->SetTitle(Form("%s:%s",pq->GetTitle(),pq->GetName()));
1286  } else {
1287  TObject *o = fPlayer->GetInputList()->FindObject("PROOF_QueryTag");
1288  if (o) fPlayer->GetInputList()->Remove(o);
1289  fPlayer->AddInput(new TNamed("PROOF_QueryTag",
1290  Form("%s:%s",pq->GetTitle(),pq->GetName())));
1291  }
1292 
1293  // Set PROOF to running state
1295 
1296  // deactivate the default application interrupt handler
1297  // ctrl-c's will be forwarded to PROOF to stop the processing
1298  TSignalHandler *sh = 0;
1299  if (fSync) {
1300  if (gApplication)
1302  }
1303 
1304  // Make sure we get a fresh result
1305  fOutputList.Clear();
1306 
1307  // Start the additional workers now if using fork-based startup
1308  TList *startedWorkers = 0;
1309  if (fForkStartup) {
1310  startedWorkers = new TList;
1311  startedWorkers->SetOwner(kFALSE);
1312  SetupWorkers(1, startedWorkers);
1313  }
1314 
1315  // This is the end of preparation
1316  fQuerySTW.Reset();
1317 
1318  Long64_t rv = 0;
1319  if (!(pq->IsDraw())) {
1320  if (selector && strlen(selector)) {
1321  rv = fPlayer->Process(dset, selec, opt, nentries, first);
1322  } else {
1323  rv = fPlayer->Process(dset, fSelector, opt, nentries, first);
1324  }
1325  } else {
1326  rv = fPlayer->DrawSelect(dset, varexp, selection, opt, nentries, first);
1327  }
1328 
1329  // This is the end of merging
1330  fQuerySTW.Stop();
1331  Float_t rt = fQuerySTW.RealTime();
1332  // Update the query content
1333  TQueryResult *qr = GetQueryResult();
1334  if (qr) {
1335  qr->SetTermTime(rt);
1336  // Preparation time is always null in PROOF-Lite
1337  }
1338 
1339  // Disable feedback, if required
1340  if (!optfb.IsNull()) SetFeedback(opt, optfb, 1);
1341 
1342  if (fSync) {
1343 
1344  // Terminate additional workers if using fork-based startup
1345  if (fForkStartup && startedWorkers) {
1346  RemoveWorkers(startedWorkers);
1347  SafeDelete(startedWorkers);
1348  }
1349 
1350  // reactivate the default application interrupt handler
1351  if (sh)
1353 
1354  // Return number of events processed
1357  ? kTRUE : kFALSE;
1358  if (abort) fPlayer->StopProcess(kTRUE);
1359  Emit("StopProcess(Bool_t)", abort);
1360  }
1361 
1362  // In PROOFLite this has to be done once only in TProofLite::Process
1364  // If the last object, notify the GUI that the result arrived
1365  QueryResultReady(Form("%s:%s", pq->GetTitle(), pq->GetName()));
1366  // Processing is over
1367  UpdateDialog();
1368 
1369  // Save the data set into the TQueryResult (should be done after Process to avoid
1370  // improper deletion during collection)
1371  if (rv == 0 && dset && !dset->TestBit(TDSet::kEmpty) && pq->GetInputList()) {
1372  pq->GetInputList()->Add(dset);
1373  if (dset->GetEntryList())
1374  pq->GetInputList()->Add(dset->GetEntryList());
1375  }
1376 
1377  // Register any dataset produced during this processing, if required
1379  TNamed *psr = (TNamed *) fPlayer->GetOutputList()->FindObject("PROOFSERV_RegisterDataSet");
1380  if (psr) {
1381  TString err;
1383  fPlayer->GetOutputList(), fDataSetManager, err) != 0)
1384  Warning("ProcessNext", "problems registering produced datasets: %s", err.Data());
1385  fPlayer->GetOutputList()->Remove(psr);
1386  delete psr;
1387  }
1388  }
1389 
1390  // Complete filling of the TQueryResult instance
1391  AskStatistics();
1392  if (!(pq->IsDraw())) {
1393  if (fQMgr->FinalizeQuery(pq, this, fPlayer)) {
1394  if (savequeries) fQMgr->SaveQuery(pq, -1);
1395  }
1396  }
1397 
1398  // Remove aborted queries from the list
1401  if (fQMgr) fQMgr->RemoveQuery(pq);
1402  } else {
1403  // If the last object, notify the GUI that the result arrived
1404  QueryResultReady(Form("%s:%s", pq->GetTitle(), pq->GetName()));
1405  // Keep in memory only light info about a query
1406  if (!(pq->IsDraw()) && memqueries >= 0) {
1407  if (fQMgr && fQMgr->Queries()) {
1408  TQueryResult *pqr = pq->CloneInfo();
1409  if (pqr) fQMgr->Queries()->Add(pqr);
1410  // Remove from the fQueries list
1411  fQMgr->Queries()->Remove(pq);
1412  }
1413  }
1414  // To get the prompt back
1415  TString msg;
1416  msg.Form("Lite-0: all output objects have been merged ");
1417  fprintf(stderr, "%s\n", msg.Data());
1418  }
1419  // Save the performance info, if required
1420  if (!fPerfTree.IsNull()) {
1421  if (SavePerfTree() != 0) Error("Process", "saving performance info ...");
1422  // Must be re-enabled each time
1423  SetPerfTree(0);
1424  }
1425  }
1426  // Finalise output file settings (opt is ignored in here)
1427  if (HandleOutputOptions(opt, outfile, 1) != 0) return -1;
1428 
1429  // Retrieve status from the output list
1430  if (rv >= 0) {
1431  TParameter<Long64_t> *sst =
1432  (TParameter<Long64_t> *) fOutputList.FindObject("PROOF_SelectorStatus");
1433  if (sst) rv = sst->GetVal();
1434  }
1435 
1436 
1437  // Done
1438  return rv;
1439 }
1440 
1441 ////////////////////////////////////////////////////////////////////////////////
1442 /// Create in each worker sandbox symlinks to the files in the list
1443 /// Used to make the cache information available to workers.
1444 
1446 {
1447  Int_t rc = 0;
1448  if (files) {
1449  TList *wls = (wrks) ? wrks : fActiveSlaves;
1450  TIter nxf(files);
1451  TObjString *os = 0;
1452  while ((os = (TObjString *) nxf())) {
1453  // Expand target
1454  TString tgt(os->GetName());
1455  gSystem->ExpandPathName(tgt);
1456  // Loop over active workers
1457  TIter nxw(wls);
1458  TSlave *wrk = 0;
1459  while ((wrk = (TSlave *) nxw())) {
1460  // Link name
1461  TString lnk = Form("%s/%s", wrk->GetWorkDir(), gSystem->BaseName(os->GetName()));
1462  gSystem->Unlink(lnk);
1463  if (gSystem->Symlink(tgt, lnk) != 0) {
1464  rc++;
1465  Warning("CreateSymLinks", "problems creating sym link: %s", lnk.Data());
1466  } else {
1467  PDB(kGlobal,1)
1468  Info("CreateSymLinks", "created sym link: %s", lnk.Data());
1469  }
1470  }
1471  }
1472  } else {
1473  Warning("CreateSymLinks", "files list is undefined");
1474  }
1475  // Done
1476  return rc;
1477 }
1478 
1479 ////////////////////////////////////////////////////////////////////////////////
1480 /// Initialize the dataset manager from directives or from defaults
1481 /// Return 0 on success, -1 on failure
1482 
1484 {
1485  fDataSetManager = 0;
1486 
1487  // Default user and group
1488  TString user("???"), group("default");
1489  UserGroup_t *pw = gSystem->GetUserInfo();
1490  if (pw) {
1491  user = pw->fUser;
1492  delete pw;
1493  }
1494 
1495  // Dataset manager instance via plug-in
1496  TPluginHandler *h = 0;
1497  TString dsm = gEnv->GetValue("Proof.DataSetManager", "");
1498  if (!dsm.IsNull()) {
1499  // Get plugin manager to load the appropriate TDataSetManager
1500  if (gROOT->GetPluginManager()) {
1501  // Find the appropriate handler
1502  h = gROOT->GetPluginManager()->FindHandler("TDataSetManager", dsm);
1503  if (h && h->LoadPlugin() != -1) {
1504  // make instance of the dataset manager
1505  fDataSetManager =
1506  reinterpret_cast<TDataSetManager*>(h->ExecPlugin(3, group.Data(),
1507  user.Data(), dsm.Data()));
1508  }
1509  }
1510  }
1512  Warning("InitDataSetManager", "dataset manager plug-in initialization failed");
1514  }
1515 
1516  // If no valid dataset manager has been created we instantiate the default one
1517  if (!fDataSetManager) {
1518  TString opts("Av:");
1519  TString dsetdir = gEnv->GetValue("ProofServ.DataSetDir", "");
1520  if (dsetdir.IsNull()) {
1521  // Use the default in the sandbox
1522  dsetdir = fDataSetDir;
1523  opts += "Sb:";
1524  }
1525  // Find the appropriate handler
1526  if (!h) {
1527  h = gROOT->GetPluginManager()->FindHandler("TDataSetManager", "file");
1528  if (h && h->LoadPlugin() == -1) h = 0;
1529  }
1530  if (h) {
1531  // make instance of the dataset manager
1532  fDataSetManager = reinterpret_cast<TDataSetManager*>(h->ExecPlugin(3,
1533  group.Data(), user.Data(),
1534  Form("dir:%s opt:%s", dsetdir.Data(), opts.Data())));
1535  }
1537  Warning("InitDataSetManager", "default dataset manager plug-in initialization failed");
1539  }
1540  }
1541 
1542  if (gDebug > 0 && fDataSetManager) {
1543  Info("InitDataSetManager", "datasetmgr Cq: %d, Ar: %d, Av: %d, Ti: %d, Sb: %d",
1549  }
1550 
1551  // Dataset manager for staging requests
1552  TString dsReqCfg = gEnv->GetValue("Proof.DataSetStagingRequests", "");
1553  if (!dsReqCfg.IsNull()) {
1554  TPMERegexp reReqDir("(^| )(dir:)?([^ ]+)( |$)");
1555 
1556  if (reReqDir.Match(dsReqCfg) == 5) {
1557  TString dsDirFmt;
1558  dsDirFmt.Form("dir:%s perms:open", reReqDir[3].Data());
1559  fDataSetStgRepo = new TDataSetManagerFile("_stage_", "_stage_", dsDirFmt);
1561  Warning("InitDataSetManager", "failed init of dataset staging requests repository");
1563  }
1564  } else {
1565  Warning("InitDataSetManager", "specify, with [dir:]<path>, a valid path for staging requests");
1566  }
1567  } else if (gDebug > 0) {
1568  Warning("InitDataSetManager", "no repository for staging requests available");
1569  }
1570 
1571  // Done
1572  return (fDataSetManager ? 0 : -1);
1573 }
1574 
1575 ////////////////////////////////////////////////////////////////////////////////
1576 /// List contents of file cache. If all is true show all caches also on
1577 /// slaves. If everything is ok all caches are to be the same.
1578 
1580 {
1581  if (!IsValid()) return;
1582 
1583  Printf("*** Local file cache %s ***", fCacheDir.Data());
1584  gSystem->Exec(Form("%s %s", kLS, fCacheDir.Data()));
1585 }
1586 
1587 ////////////////////////////////////////////////////////////////////////////////
1588 /// Remove files from all file caches.
1589 
1590 void TProofLite::ClearCache(const char *file)
1591 {
1592  if (!IsValid()) return;
1593 
1594  fCacheLock->Lock();
1595  if (!file || strlen(file) <= 0) {
1596  gSystem->Exec(Form("%s %s/*", kRM, fCacheDir.Data()));
1597  } else {
1598  gSystem->Exec(Form("%s %s/%s", kRM, fCacheDir.Data(), file));
1599  }
1600  fCacheLock->Unlock();
1601 }
1602 
1603 ////////////////////////////////////////////////////////////////////////////////
1604 /// Copy the specified macro in the cache directory. The macro file is
1605 /// uploaded if new or updated. If existing, the corresponding header
1606 /// basename(macro).h or .hh, is also uploaded. For the other arguments
1607 /// see TProof::Load().
1608 /// Returns 0 in case of success and -1 in case of error.
1609 
1610 Int_t TProofLite::Load(const char *macro, Bool_t notOnClient, Bool_t uniqueOnly,
1611  TList *wrks)
1612 {
1613  if (!IsValid()) return -1;
1614 
1615  if (!macro || !macro[0]) {
1616  Error("Load", "need to specify a macro name");
1617  return -1;
1618  }
1619 
1620  TString macs(macro), mac;
1621  Int_t from = 0;
1622  while (macs.Tokenize(mac, from, ",")) {
1623  if (IsIdle()) {
1624  if (CopyMacroToCache(mac) < 0) return -1;
1625  } else {
1626  // The name
1627  TString macn = gSystem->BaseName(mac);
1628  macn.Remove(macn.Last('.'));
1629  // Relevant pointers
1630  TList cachedFiles;
1631  TString cacheDir = fCacheDir;
1632  gSystem->ExpandPathName(cacheDir);
1633  void * dirp = gSystem->OpenDirectory(cacheDir);
1634  if (dirp) {
1635  const char *e = 0;
1636  while ((e = gSystem->GetDirEntry(dirp))) {
1637  if (!strncmp(e, macn.Data(), macn.Length())) {
1638  TString fncache = Form("%s/%s", cacheDir.Data(), e);
1639  cachedFiles.Add(new TObjString(fncache.Data()));
1640  }
1641  }
1642  gSystem->FreeDirectory(dirp);
1643  }
1644  // Create the relevant symlinks
1645  CreateSymLinks(&cachedFiles, wrks);
1646  }
1647  }
1648 
1649  return TProof::Load(macro, notOnClient, uniqueOnly, wrks);
1650 }
1651 
1652 ////////////////////////////////////////////////////////////////////////////////
1653 /// Copy a macro, and its possible associated .h[h] file,
1654 /// to the cache directory, from where the workers can get the file.
1655 /// If headerRequired is 1, return -1 in case the header is not found.
1656 /// If headerRequired is 0, try to copy header too.
1657 /// If headerRequired is -1, don't look for header, only copy macro.
1658 /// If the selector pionter is not 0, consider the macro to be a selector
1659 /// and try to load the selector and set it to the pointer.
1660 /// The mask 'opt' is an or of ESendFileOpt:
1661 /// kCpBin (0x8) Retrieve from the cache the binaries associated
1662 /// with the file
1663 /// kCp (0x10) Retrieve the files from the cache
1664 /// Return -1 in case of error, 0 otherwise.
1665 
1666 Int_t TProofLite::CopyMacroToCache(const char *macro, Int_t headerRequired,
1667  TSelector **selector, Int_t opt, TList *wrks)
1668 {
1669  // Relevant pointers
1670  TString cacheDir = fCacheDir;
1671  gSystem->ExpandPathName(cacheDir);
1672  TProofLockPath *cacheLock = fCacheLock;
1673 
1674  // Split out the aclic mode, if any
1675  TString name = macro;
1676  TString acmode, args, io;
1677  name = gSystem->SplitAclicMode(name, acmode, args, io);
1678 
1679  PDB(kGlobal,1)
1680  Info("CopyMacroToCache", "enter: names: %s, %s", macro, name.Data());
1681 
1682  // Make sure that the file exists
1683  if (gSystem->AccessPathName(name, kReadPermission)) {
1684  Error("CopyMacroToCache", "file %s not found or not readable", name.Data());
1685  return -1;
1686  }
1687 
1688  // Update the macro path
1690  TString np(gSystem->DirName(name));
1691  if (!np.IsNull()) {
1692  np += ":";
1693  if (!mp.BeginsWith(np) && !mp.Contains(":"+np)) {
1694  Int_t ip = (mp.BeginsWith(".:")) ? 2 : 0;
1695  mp.Insert(ip, np);
1696  TROOT::SetMacroPath(mp);
1697  PDB(kGlobal,1)
1698  Info("CopyMacroToCache", "macro path set to '%s'", TROOT::GetMacroPath());
1699  }
1700  }
1701 
1702  // Check the header file
1703  Int_t dot = name.Last('.');
1704  const char *hext[] = { ".h", ".hh", "" };
1705  TString hname, checkedext;
1706  Int_t i = 0;
1707  while (strlen(hext[i]) > 0) {
1708  hname = name(0, dot);
1709  hname += hext[i];
1710  if (!gSystem->AccessPathName(hname, kReadPermission))
1711  break;
1712  if (!checkedext.IsNull()) checkedext += ",";
1713  checkedext += hext[i];
1714  hname = "";
1715  i++;
1716  }
1717  if (hname.IsNull() && headerRequired == 1) {
1718  Error("CopyMacroToCache", "header file for %s not found or not readable "
1719  "(checked extensions: %s)", name.Data(), checkedext.Data());
1720  return -1;
1721  }
1722  if (headerRequired < 0)
1723  hname = "";
1724 
1725  cacheLock->Lock();
1726 
1727  // Check these files with those in the cache (if any)
1728  Bool_t useCacheBinaries = kFALSE;
1729  TString cachedname = Form("%s/%s", cacheDir.Data(), gSystem->BaseName(name));
1730  TString cachedhname;
1731  if (!hname.IsNull())
1732  cachedhname = Form("%s/%s", cacheDir.Data(), gSystem->BaseName(hname));
1733  if (!gSystem->AccessPathName(cachedname, kReadPermission)) {
1734  TMD5 *md5 = TMD5::FileChecksum(name);
1735  TMD5 *md5cache = TMD5::FileChecksum(cachedname);
1736  if (md5 && md5cache && (*md5 == *md5cache))
1737  useCacheBinaries = kTRUE;
1738  if (!hname.IsNull()) {
1739  if (!gSystem->AccessPathName(cachedhname, kReadPermission)) {
1740  TMD5 *md5h = TMD5::FileChecksum(hname);
1741  TMD5 *md5hcache = TMD5::FileChecksum(cachedhname);
1742  if (md5h && md5hcache && (*md5h != *md5hcache))
1743  useCacheBinaries = kFALSE;
1744  SafeDelete(md5h);
1745  SafeDelete(md5hcache);
1746  }
1747  }
1748  SafeDelete(md5);
1749  SafeDelete(md5cache);
1750  }
1751 
1752  // Create version file name template
1753  TString vername(Form(".%s", name.Data()));
1754  dot = vername.Last('.');
1755  if (dot != kNPOS)
1756  vername.Remove(dot);
1757  vername += ".binversion";
1758  Bool_t savever = kFALSE;
1759 
1760  // Check binary version
1761  if (useCacheBinaries) {
1762  TString v, r;
1763  FILE *f = fopen(Form("%s/%s", cacheDir.Data(), vername.Data()), "r");
1764  if (f) {
1765  v.Gets(f);
1766  r.Gets(f);
1767  fclose(f);
1768  }
1769  if (!f || v != gROOT->GetVersion() || r != gROOT->GetGitCommit())
1770  useCacheBinaries = kFALSE;
1771  }
1772 
1773  // Create binary name template
1774  TString binname = gSystem->BaseName(name);
1775  dot = binname.Last('.');
1776  if (dot != kNPOS)
1777  binname.Replace(dot,1,"_");
1778  binname += ".";
1779 
1780  FileStat_t stlocal, stcache;
1781  void *dirp = 0;
1782  if (useCacheBinaries) {
1783  // Loop over binaries in the cache and copy them locally if newer then the local
1784  // versions or there is no local version
1785  dirp = gSystem->OpenDirectory(cacheDir);
1786  if (dirp) {
1787  const char *e = 0;
1788  while ((e = gSystem->GetDirEntry(dirp))) {
1789  if (!strncmp(e, binname.Data(), binname.Length())) {
1790  TString fncache = Form("%s/%s", cacheDir.Data(), e);
1791  Bool_t docp = kTRUE;
1792  if (!gSystem->GetPathInfo(fncache, stcache)) {
1793  Int_t rc = gSystem->GetPathInfo(e, stlocal);
1794  if (rc == 0 && (stlocal.fMtime >= stcache.fMtime))
1795  docp = kFALSE;
1796  // Copy the file, if needed
1797  if (docp) {
1798  gSystem->Exec(Form("%s %s", kRM, e));
1799  PDB(kGlobal,2)
1800  Info("CopyMacroToCache",
1801  "retrieving %s from cache", fncache.Data());
1802  gSystem->Exec(Form("%s %s %s", kCP, fncache.Data(), e));
1803  }
1804  }
1805  }
1806  }
1807  gSystem->FreeDirectory(dirp);
1808  }
1809  }
1810  cacheLock->Unlock();
1811 
1812  if (selector) {
1813  // Now init the selector in optimized way
1814  if (!(*selector = TSelector::GetSelector(macro))) {
1815  Error("CopyMacroToCache", "could not create a selector from %s", macro);
1816  return -1;
1817  }
1818  }
1819 
1820  cacheLock->Lock();
1821 
1822  TList *cachedFiles = new TList;
1823  // Save information in the cache now for later usage
1824  dirp = gSystem->OpenDirectory(".");
1825  if (dirp) {
1826  const char *e = 0;
1827  while ((e = gSystem->GetDirEntry(dirp))) {
1828  if (!strncmp(e, binname.Data(), binname.Length())) {
1829  Bool_t docp = kTRUE;
1830  if (!gSystem->GetPathInfo(e, stlocal)) {
1831  TString fncache = Form("%s/%s", cacheDir.Data(), e);
1832  Int_t rc = gSystem->GetPathInfo(fncache, stcache);
1833  if (rc == 0 && (stlocal.fMtime <= stcache.fMtime))
1834  docp = kFALSE;
1835  // Copy the file, if needed
1836  if (docp) {
1837  gSystem->Exec(Form("%s %s", kRM, fncache.Data()));
1838  PDB(kGlobal,2)
1839  Info("CopyMacroToCache","caching %s ...", e);
1840  gSystem->Exec(Form("%s %s %s", kCP, e, fncache.Data()));
1841  savever = kTRUE;
1842  }
1843  if (opt & kCpBin)
1844  cachedFiles->Add(new TObjString(fncache.Data()));
1845  }
1846  }
1847  }
1848  gSystem->FreeDirectory(dirp);
1849  }
1850 
1851  // Save binary version if requested
1852  if (savever) {
1853  FILE *f = fopen(Form("%s/%s", cacheDir.Data(), vername.Data()), "w");
1854  if (f) {
1855  fputs(gROOT->GetVersion(), f);
1856  fputs(Form("\n%s", gROOT->GetGitCommit()), f);
1857  fclose(f);
1858  }
1859  }
1860 
1861  // Save also the selector info, if needed
1862  if (!useCacheBinaries) {
1863  gSystem->Exec(Form("%s %s", kRM, cachedname.Data()));
1864  PDB(kGlobal,2)
1865  Info("CopyMacroToCache","caching %s ...", name.Data());
1866  gSystem->Exec(Form("%s %s %s", kCP, name.Data(), cachedname.Data()));
1867  if (!hname.IsNull()) {
1868  gSystem->Exec(Form("%s %s", kRM, cachedhname.Data()));
1869  PDB(kGlobal,2)
1870  Info("CopyMacroToCache","caching %s ...", hname.Data());
1871  gSystem->Exec(Form("%s %s %s", kCP, hname.Data(), cachedhname.Data()));
1872  }
1873  }
1874  if (opt & kCp) {
1875  cachedFiles->Add(new TObjString(cachedname.Data()));
1876  if (!hname.IsNull())
1877  cachedFiles->Add(new TObjString(cachedhname.Data()));
1878  }
1879 
1880  cacheLock->Unlock();
1881 
1882  // Create symlinks
1883  if (opt & (kCp | kCpBin))
1884  CreateSymLinks(cachedFiles, wrks);
1885 
1886  cachedFiles->SetOwner();
1887  delete cachedFiles;
1888 
1889  return 0;
1890 }
1891 
1892 ////////////////////////////////////////////////////////////////////////////////
1893 /// Remove old sessions dirs keep at most 'Proof.MaxOldSessions' (default 10)
1894 
1896 {
1897  Int_t maxold = gEnv->GetValue("Proof.MaxOldSessions", 1);
1898 
1899  if (maxold < 0) return 0;
1900 
1901  TSortedList *olddirs = new TSortedList(kFALSE);
1902 
1903  TString sandbox = gSystem->DirName(fWorkDir.Data());
1904 
1905  void *dirp = gSystem->OpenDirectory(sandbox);
1906  if (dirp) {
1907  const char *e = 0;
1908  while ((e = gSystem->GetDirEntry(dirp))) {
1909  if (!strncmp(e, "session-", 8) && !strstr(e, GetName())) {
1910  TString d(e);
1911  Int_t i = d.Last('-');
1912  if (i != kNPOS) d.Remove(i);
1913  i = d.Last('-');
1914  if (i != kNPOS) d.Remove(0,i+1);
1915  TString path = Form("%s/%s", sandbox.Data(), e);
1916  olddirs->Add(new TNamed(d, path));
1917  }
1918  }
1919  gSystem->FreeDirectory(dirp);
1920  }
1921 
1922  // Clean it up, if required
1923  Bool_t notify = kTRUE;
1924  while (olddirs->GetSize() > maxold) {
1925  if (notify && gDebug > 0)
1926  Printf("Cleaning sandbox at: %s", sandbox.Data());
1927  notify = kFALSE;
1928  TNamed *n = (TNamed *) olddirs->Last();
1929  if (n) {
1930  gSystem->Exec(Form("%s %s", kRM, n->GetTitle()));
1931  olddirs->Remove(n);
1932  delete n;
1933  }
1934  }
1935 
1936  // Cleanup
1937  olddirs->SetOwner();
1938  delete olddirs;
1939 
1940  // Done
1941  return 0;
1942 }
1943 
1944 ////////////////////////////////////////////////////////////////////////////////
1945 /// Get the list of queries.
1946 
1948 {
1949  Bool_t all = ((strchr(opt,'A') || strchr(opt,'a'))) ? kTRUE : kFALSE;
1950 
1951  TList *ql = new TList;
1952  Int_t ntot = 0, npre = 0, ndraw= 0;
1953  if (fQMgr) {
1954  if (all) {
1955  // Rescan
1956  TString qdir = fQueryDir;
1957  Int_t idx = qdir.Index("session-");
1958  if (idx != kNPOS)
1959  qdir.Remove(idx);
1960  fQMgr->ScanPreviousQueries(qdir);
1961  // Gather also information about previous queries, if any
1962  if (fQMgr->PreviousQueries()) {
1963  TIter nxq(fQMgr->PreviousQueries());
1964  TProofQueryResult *pqr = 0;
1965  while ((pqr = (TProofQueryResult *)nxq())) {
1966  ntot++;
1967  pqr->fSeqNum = ntot;
1968  ql->Add(pqr);
1969  }
1970  }
1971  }
1972 
1973  npre = ntot;
1974  if (fQMgr->Queries()) {
1975  // Add info about queries in this session
1976  TIter nxq(fQMgr->Queries());
1977  TProofQueryResult *pqr = 0;
1978  TQueryResult *pqm = 0;
1979  while ((pqr = (TProofQueryResult *)nxq())) {
1980  ntot++;
1981  if ((pqm = pqr->CloneInfo())) {
1982  pqm->fSeqNum = ntot;
1983  ql->Add(pqm);
1984  } else {
1985  Warning("GetListOfQueries", "unable to clone TProofQueryResult '%s:%s'",
1986  pqr->GetName(), pqr->GetTitle());
1987  }
1988  }
1989  }
1990  // Number of draw queries
1991  ndraw = fQMgr->DrawQueries();
1992  }
1993 
1994  fOtherQueries = npre;
1995  fDrawQueries = ndraw;
1996  if (fQueries) {
1997  fQueries->Delete();
1998  delete fQueries;
1999  fQueries = 0;
2000  }
2001  fQueries = ql;
2002 
2003  // This should have been filled by now
2004  return fQueries;
2005 }
2006 
2007 ////////////////////////////////////////////////////////////////////////////////
2008 /// Register the 'dataSet' on the cluster under the current
2009 /// user, group and the given 'dataSetName'.
2010 /// Fails if a dataset named 'dataSetName' already exists, unless 'optStr'
2011 /// contains 'O', in which case the old dataset is overwritten.
2012 /// If 'optStr' contains 'V' the dataset files are verified (default no
2013 /// verification).
2014 /// Returns kTRUE on success.
2015 
2017  TFileCollection *dataSet, const char* optStr)
2018 {
2019  if (!fDataSetManager) {
2020  Info("RegisterDataSet", "dataset manager not available");
2021  return kFALSE;
2022  }
2023 
2024  if (!uri || strlen(uri) <= 0) {
2025  Info("RegisterDataSet", "specifying a dataset name is mandatory");
2026  return kFALSE;
2027  }
2028 
2029  Bool_t parallelverify = kFALSE;
2030  TString sopt(optStr);
2031  if (sopt.Contains("V") && !sopt.Contains("S")) {
2032  // We do verification in parallel later on; just register for now
2033  parallelverify = kTRUE;
2034  sopt.ReplaceAll("V", "");
2035  }
2036  // This would screw up things remotely, make sure is not there
2037  sopt.ReplaceAll("S", "");
2038 
2039  Bool_t result = kTRUE;
2041  // Check the list
2042  if (!dataSet || dataSet->GetList()->GetSize() == 0) {
2043  Error("RegisterDataSet", "can not save an empty list.");
2044  result = kFALSE;
2045  }
2046  // Register the dataset (quota checks are done inside here)
2047  result = (fDataSetManager->RegisterDataSet(uri, dataSet, sopt) == 0)
2048  ? kTRUE : kFALSE;
2049  } else {
2050  Info("RegisterDataSet", "dataset registration not allowed");
2051  result = kFALSE;
2052  }
2053 
2054  if (!result)
2055  Error("RegisterDataSet", "dataset was not saved");
2056 
2057  // If old server or not verifying in parallel we are done
2058  if (!parallelverify) return result;
2059 
2060  // If we are here it means that we will verify in parallel
2061  sopt += "V";
2062  if (VerifyDataSet(uri, sopt) < 0){
2063  Error("RegisterDataSet", "problems verifying dataset '%s'", uri);
2064  return kFALSE;
2065  }
2066 
2067  // Done
2068  return kTRUE;
2069 }
2070 
2071 ////////////////////////////////////////////////////////////////////////////////
2072 /// Set/Change the name of the default tree. The tree name may contain
2073 /// subdir specification in the form "subdir/name".
2074 /// Returns 0 on success, -1 otherwise.
2075 
2076 Int_t TProofLite::SetDataSetTreeName(const char *dataset, const char *treename)
2077 {
2078  if (!fDataSetManager) {
2079  Info("ExistsDataSet", "dataset manager not available");
2080  return kFALSE;
2081  }
2082 
2083  if (!dataset || strlen(dataset) <= 0) {
2084  Info("SetDataSetTreeName", "specifying a dataset name is mandatory");
2085  return -1;
2086  }
2087 
2088  if (!treename || strlen(treename) <= 0) {
2089  Info("SetDataSetTreeName", "specifying a tree name is mandatory");
2090  return -1;
2091  }
2092 
2093  TUri uri(dataset);
2094  TString fragment(treename);
2095  if (!fragment.BeginsWith("/")) fragment.Insert(0, "/");
2096  uri.SetFragment(fragment);
2097 
2098  return fDataSetManager->ScanDataSet(uri.GetUri().Data(),
2100 }
2101 
2102 ////////////////////////////////////////////////////////////////////////////////
2103 /// Returns kTRUE if 'dataset' described by 'uri' exists, kFALSE otherwise
2104 
2106 {
2107  if (!fDataSetManager) {
2108  Info("ExistsDataSet", "dataset manager not available");
2109  return kFALSE;
2110  }
2111 
2112  if (!uri || strlen(uri) <= 0) {
2113  Error("ExistsDataSet", "dataset name missing");
2114  return kFALSE;
2115  }
2116 
2117  // Check if the dataset exists
2118  return fDataSetManager->ExistsDataSet(uri);
2119 }
2120 
2121 ////////////////////////////////////////////////////////////////////////////////
2122 /// lists all datasets that match given uri
2123 
2124 TMap *TProofLite::GetDataSets(const char *uri, const char *srvex)
2125 {
2126  if (!fDataSetManager) {
2127  Info("GetDataSets", "dataset manager not available");
2128  return (TMap *)0;
2129  }
2130 
2131  // Get the datasets and return the map
2132  if (srvex && strlen(srvex) > 0) {
2133  return fDataSetManager->GetSubDataSets(uri, srvex);
2134  } else {
2136  return fDataSetManager->GetDataSets(uri, opt);
2137  }
2138 }
2139 
2140 ////////////////////////////////////////////////////////////////////////////////
2141 /// Shows datasets in locations that match the uri
2142 /// By default shows the user's datasets and global ones
2143 
2144 void TProofLite::ShowDataSets(const char *uri, const char *opt)
2145 {
2146  if (!fDataSetManager) {
2147  Info("GetDataSet", "dataset manager not available");
2148  return;
2149  }
2150 
2151  fDataSetManager->ShowDataSets(uri, opt);
2152 }
2153 
2154 ////////////////////////////////////////////////////////////////////////////////
2155 /// Get a list of TFileInfo objects describing the files of the specified
2156 /// dataset.
2157 
2158 TFileCollection *TProofLite::GetDataSet(const char *uri, const char *)
2159 {
2160  if (!fDataSetManager) {
2161  Info("GetDataSet", "dataset manager not available");
2162  return (TFileCollection *)0;
2163  }
2164 
2165  if (!uri || strlen(uri) <= 0) {
2166  Info("GetDataSet", "specifying a dataset name is mandatory");
2167  return 0;
2168  }
2169 
2170  // Return the list
2171  return fDataSetManager->GetDataSet(uri);
2172 }
2173 
2174 ////////////////////////////////////////////////////////////////////////////////
2175 /// Remove the specified dataset from the PROOF cluster.
2176 /// Files are not deleted.
2177 
2178 Int_t TProofLite::RemoveDataSet(const char *uri, const char *)
2179 {
2180  if (!fDataSetManager) {
2181  Info("RemoveDataSet", "dataset manager not available");
2182  return -1;
2183  }
2184 
2186  if (!fDataSetManager->RemoveDataSet(uri)) {
2187  // Failure
2188  return -1;
2189  }
2190  } else {
2191  Info("RemoveDataSet", "dataset creation / removal not allowed");
2192  return -1;
2193  }
2194 
2195  // Done
2196  return 0;
2197 }
2198 
2199 ////////////////////////////////////////////////////////////////////////////////
2200 /// Allows users to request staging of a particular dataset. Requests are
2201 /// saved in a special dataset repository and must be honored by the endpoint.
2202 /// This is the special PROOF-Lite re-implementation of the TProof function
2203 /// and includes code originally implemented in TProofServ.
2204 
2206 {
2207  if (!dataset) {
2208  Error("RequestStagingDataSet", "invalid dataset specified");
2209  return kFALSE;
2210  }
2211 
2212  if (!fDataSetStgRepo) {
2213  Error("RequestStagingDataSet", "no dataset staging request repository available");
2214  return kFALSE;
2215  }
2216 
2217  TString dsUser, dsGroup, dsName, dsTree;
2218 
2219  // Transform input URI in a valid dataset name
2220  TString validUri = dataset;
2221  while (fReInvalid->Substitute(validUri, "_")) {}
2222 
2223  // Check if dataset exists beforehand: if it does, staging has already been requested
2224  if (fDataSetStgRepo->ExistsDataSet(validUri.Data())) {
2225  Warning("RequestStagingDataSet", "staging of %s already requested", dataset);
2226  return kFALSE;
2227  }
2228 
2229  // Try to get dataset from current manager
2231  if (!fc || (fc->GetNFiles() == 0)) {
2232  Error("RequestStagingDataSet", "empty dataset or no dataset returned");
2233  if (fc) delete fc;
2234  return kFALSE;
2235  }
2236 
2237  // Reset all staged bits and remove unnecessary URLs (all but last)
2238  TIter it(fc->GetList());
2239  TFileInfo *fi;
2240  while ((fi = dynamic_cast<TFileInfo *>(it.Next()))) {
2242  Int_t nToErase = fi->GetNUrls() - 1;
2243  for (Int_t i=0; i<nToErase; i++)
2244  fi->RemoveUrlAt(0);
2245  }
2246 
2247  fc->Update(); // absolutely necessary
2248 
2249  // Save request
2250  fDataSetStgRepo->ParseUri(validUri, &dsGroup, &dsUser, &dsName);
2251  if (fDataSetStgRepo->WriteDataSet(dsGroup, dsUser, dsName, fc) == 0) {
2252  // Error, can't save dataset
2253  Error("RequestStagingDataSet", "can't register staging request for %s", dataset);
2254  delete fc;
2255  return kFALSE;
2256  }
2257 
2258  Info("RequestStagingDataSet", "Staging request registered for %s", dataset);
2259  delete fc;
2260 
2261  return kTRUE;
2262 }
2263 
2264 ////////////////////////////////////////////////////////////////////////////////
2265 /// Cancels a dataset staging request. Returns kTRUE on success, kFALSE on
2266 /// failure. Dataset not found equals to a failure. PROOF-Lite
2267 /// re-implementation of the equivalent function in TProofServ.
2268 
2270 {
2271  if (!dataset) {
2272  Error("CancelStagingDataSet", "invalid dataset specified");
2273  return kFALSE;
2274  }
2275 
2276  if (!fDataSetStgRepo) {
2277  Error("CancelStagingDataSet", "no dataset staging request repository available");
2278  return kFALSE;
2279  }
2280 
2281  // Transform URI in a valid dataset name
2282  TString validUri = dataset;
2283  while (fReInvalid->Substitute(validUri, "_")) {}
2284 
2285  if (!fDataSetStgRepo->RemoveDataSet(validUri.Data()))
2286  return kFALSE;
2287 
2288  return kTRUE;
2289 }
2290 
2291 ////////////////////////////////////////////////////////////////////////////////
2292 /// Obtains a TFileCollection showing the staging status of the specified
2293 /// dataset. A valid dataset manager and dataset staging requests repository
2294 /// must be present on the endpoint. PROOF-Lite version of the equivalent
2295 /// function from TProofServ.
2296 
2298 {
2299  if (!dataset) {
2300  Error("GetStagingStatusDataSet", "invalid dataset specified");
2301  return 0;
2302  }
2303 
2304  if (!fDataSetStgRepo) {
2305  Error("GetStagingStatusDataSet", "no dataset staging request repository available");
2306  return 0;
2307  }
2308 
2309  // Transform URI in a valid dataset name
2310  TString validUri = dataset;
2311  while (fReInvalid->Substitute(validUri, "_")) {}
2312 
2313  // Get the list
2315  if (!fc) {
2316  // No such dataset (not an error)
2317  Info("GetStagingStatusDataSet", "no pending staging request for %s", dataset);
2318  return 0;
2319  }
2320 
2321  // Dataset found: return it (must be cleaned by caller)
2322  return fc;
2323 }
2324 
2325 ////////////////////////////////////////////////////////////////////////////////
2326 /// Verify if all files in the specified dataset are available.
2327 /// Print a list and return the number of missing files.
2328 
2329 Int_t TProofLite::VerifyDataSet(const char *uri, const char *optStr)
2330 {
2331  if (!fDataSetManager) {
2332  Info("VerifyDataSet", "dataset manager not available");
2333  return -1;
2334  }
2335 
2336  Int_t rc = -1;
2337  TString sopt(optStr);
2338  if (sopt.Contains("S")) {
2339 
2341  rc = fDataSetManager->ScanDataSet(uri);
2342  } else {
2343  Info("VerifyDataSet", "dataset verification not allowed");
2344  rc = -1;
2345  }
2346  return rc;
2347  }
2348 
2349  // Done
2350  return VerifyDataSetParallel(uri, optStr);
2351 }
2352 
2353 ////////////////////////////////////////////////////////////////////////////////
2354 /// Clear the content of the dataset cache, if any (matching 'dataset', if defined).
2355 
2356 void TProofLite::ClearDataSetCache(const char *dataset)
2357 {
2359  // Done
2360  return;
2361 }
2362 
2363 ////////////////////////////////////////////////////////////////////////////////
2364 /// Display the content of the dataset cache, if any (matching 'dataset', if defined).
2365 
2366 void TProofLite::ShowDataSetCache(const char *dataset)
2367 {
2368  // For PROOF-Lite act locally
2369  if (fDataSetManager) fDataSetManager->ShowCache(dataset);
2370  // Done
2371  return;
2372 }
2373 
2374 ////////////////////////////////////////////////////////////////////////////////
2375 /// Make sure that the input data objects are available to the workers in a
2376 /// dedicated file in the cache; the objects are taken from the dedicated list
2377 /// and / or the specified file.
2378 /// If the fInputData is empty the specified file is sent over.
2379 /// If there is no specified file, a file named "inputdata.root" is created locally
2380 /// with the content of fInputData and sent over to the master.
2381 /// If both fInputData and the specified file are not empty, a copy of the file
2382 /// is made locally and augmented with the content of fInputData.
2383 
2385 {
2386  // Prepare the file
2387  TString dataFile;
2388  PrepareInputDataFile(dataFile);
2389 
2390  // Make sure it is in the cache, if not empty
2391  if (dataFile.Length() > 0) {
2392 
2393  if (!dataFile.BeginsWith(fCacheDir)) {
2394  // Destination
2395  TString dst;
2396  dst.Form("%s/%s", fCacheDir.Data(), gSystem->BaseName(dataFile));
2397  // Remove it first if it exists
2398  if (!gSystem->AccessPathName(dst))
2399  gSystem->Unlink(dst);
2400  // Copy the file
2401  if (gSystem->CopyFile(dataFile, dst) != 0)
2402  Warning("SendInputDataFile", "problems copying '%s' to '%s'",
2403  dataFile.Data(), dst.Data());
2404  }
2405 
2406  // Set the name in the input list so that the workers can find it
2407  AddInput(new TNamed("PROOF_InputDataFile", Form("%s", gSystem->BaseName(dataFile))));
2408  }
2409 }
2410 
2411 ////////////////////////////////////////////////////////////////////////////////
2412 /// Handle remove request.
2413 
2414 Int_t TProofLite::Remove(const char *ref, Bool_t all)
2415 {
2416  PDB(kGlobal, 1)
2417  Info("Remove", "Enter: %s, %d", ref, all);
2418 
2419  if (all) {
2420  // Remove also local copies, if any
2421  if (fPlayer)
2422  fPlayer->RemoveQueryResult(ref);
2423  }
2424 
2425  TString queryref(ref);
2426 
2427  if (queryref == "cleanupdir") {
2428 
2429  // Cleanup previous sessions results
2430  Int_t nd = (fQMgr) ? fQMgr->CleanupQueriesDir() : -1;
2431 
2432  // Notify
2433  Info("Remove", "%d directories removed", nd);
2434  // We are done
2435  return 0;
2436  }
2437 
2438 
2439  if (fQMgr) {
2440  TProofLockPath *lck = 0;
2441  if (fQMgr->LockSession(queryref, &lck) == 0) {
2442 
2443  // Remove query
2444  fQMgr->RemoveQuery(queryref, 0);
2445 
2446  // Unlock and remove the lock file
2447  if (lck) {
2448  gSystem->Unlink(lck->GetName());
2449  SafeDelete(lck);
2450  }
2451 
2452  // We are done
2453  return 0;
2454  }
2455  } else {
2456  Warning("Remove", "query result manager undefined!");
2457  }
2458 
2459  // Notify failure
2460  Info("Remove",
2461  "query %s could not be removed (unable to lock session)", queryref.Data());
2462 
2463  // Done
2464  return -1;
2465 }
2466 
2467 ////////////////////////////////////////////////////////////////////////////////
2468 /// Creates a tree header (a tree with nonexisting files) object for
2469 /// the DataSet.
2470 
2472 {
2473  TTree *t = 0;
2474  if (!dset) {
2475  Error("GetTreeHeader", "undefined TDSet");
2476  return t;
2477  }
2478 
2479  dset->Reset();
2480  TDSetElement *e = dset->Next();
2481  Long64_t entries = 0;
2482  TFile *f = 0;
2483  if (!e) {
2484  PDB(kGlobal, 1) Info("GetTreeHeader", "empty TDSet");
2485  } else {
2486  f = TFile::Open(e->GetFileName());
2487  t = 0;
2488  if (f) {
2489  t = (TTree*) f->Get(e->GetObjName());
2490  if (t) {
2491  t->SetMaxVirtualSize(0);
2492  t->DropBaskets();
2493  entries = t->GetEntries();
2494 
2495  // compute #entries in all the files
2496  while ((e = dset->Next()) != 0) {
2497  TFile *f1 = TFile::Open(e->GetFileName());
2498  if (f1) {
2499  TTree *t1 = (TTree*) f1->Get(e->GetObjName());
2500  if (t1) {
2501  entries += t1->GetEntries();
2502  delete t1;
2503  }
2504  delete f1;
2505  }
2506  }
2507  t->SetMaxEntryLoop(entries); // this field will hold the total number of entries ;)
2508  }
2509  }
2510  }
2511  // Done
2512  return t;
2513 }
2514 
2515 ////////////////////////////////////////////////////////////////////////////////
2516 /// Add to the fUniqueSlave list the active slaves that have a unique
2517 /// (user) file system image. This information is used to transfer files
2518 /// only once to nodes that share a file system (an image). Submasters
2519 /// which are not in fUniqueSlaves are put in the fNonUniqueMasters
2520 /// list. That list is used to trigger the transferring of files to
2521 /// the submaster's unique slaves without the need to transfer the file
2522 /// to the submaster.
2523 
2525 {
2526  fUniqueSlaves->Clear();
2531 
2532  if (fActiveSlaves->GetSize() <= 0) return;
2533 
2534  TSlave *wrk = dynamic_cast<TSlave*>(fActiveSlaves->First());
2535  if (!wrk) {
2536  Error("FindUniqueSlaves", "first object in fActiveSlaves not a TSlave: embarrasing!");
2537  return;
2538  }
2539  fUniqueSlaves->Add(wrk);
2540  fAllUniqueSlaves->Add(wrk);
2541  fUniqueMonitor->Add(wrk->GetSocket());
2542  fAllUniqueMonitor->Add(wrk->GetSocket());
2543 
2544  // will be actiavted in Collect()
2547 }
2548 
2549 ////////////////////////////////////////////////////////////////////////////////
2550 /// List contents of the data directory in the sandbox.
2551 /// This is the place where files produced by the client queries are kept
2552 
2554 {
2555  if (!IsValid()) return;
2556 
2557  // Get worker infos
2558  TList *wrki = GetListOfSlaveInfos();
2559  TSlaveInfo *wi = 0;
2560  TIter nxwi(wrki);
2561  while ((wi = (TSlaveInfo *) nxwi())) {
2562  ShowDataDir(wi->GetDataDir());
2563  }
2564 }
2565 
2566 ////////////////////////////////////////////////////////////////////////////////
2567 /// List contents of the data directory 'dirname'
2568 
2569 void TProofLite::ShowDataDir(const char *dirname)
2570 {
2571  if (!dirname) return;
2572 
2573  FileStat_t dirst;
2574  if (gSystem->GetPathInfo(dirname, dirst) != 0) return;
2575  if (!R_ISDIR(dirst.fMode)) return;
2576 
2577  void *dirp = gSystem->OpenDirectory(dirname);
2578  TString fn;
2579  const char *ent = 0;
2580  while ((ent = gSystem->GetDirEntry(dirp))) {
2581  fn.Form("%s/%s", dirname, ent);
2582  FileStat_t st;
2583  if (gSystem->GetPathInfo(fn.Data(), st) == 0) {
2584  if (R_ISREG(st.fMode)) {
2585  Printf("lite:0| %s", fn.Data());
2586  } else if (R_ISREG(st.fMode)) {
2587  ShowDataDir(fn.Data());
2588  }
2589  }
2590  }
2591  // Done
2592  return;
2593 }
2594 
2595 ////////////////////////////////////////////////////////////////////////////////
2596 /// Simulate dynamic addition, for test purposes.
2597 /// Here we decide how many workers to add, we create them and set the
2598 /// environment.
2599 /// This call is called regularly by Collect if the opton is enabled.
2600 /// Returns the number of new workers added, or <0 on errors.
2601 
2603 {
2604  // Max workers
2605  if (fDynamicStartupNMax <= 0) {
2606  SysInfo_t si;
2607  if (gSystem->GetSysInfo(&si) == 0 && si.fCpus > 2) {
2609  } else {
2610  fDynamicStartupNMax = 2;
2611  }
2612  }
2613  if (fNWorkers >= fDynamicStartupNMax) {
2614  // Max reached: disable
2615  Info("PollForNewWorkers", "max reached: %d workers started", fNWorkers);
2617  return 0;
2618  }
2619 
2620  // Number of new workers
2621  Int_t nAdd = (fDynamicStartupStep > 0) ? fDynamicStartupStep : 1;
2622 
2623  // Create a monitor and add the socket to it
2624  TMonitor *mon = new TMonitor;
2625  mon->Add(fServSock);
2626 
2627  TList started;
2628  TSlave *wrk = 0;
2629  Int_t nWrksDone = 0, nWrksTot = -1;
2630  TString fullord;
2631 
2632  nWrksTot = fNWorkers + nAdd;
2633  // Now we create the worker applications which will call us back to finalize
2634  // the setup
2635  Int_t ord = fNWorkers;
2636  for (; ord < nWrksTot; ord++) {
2637 
2638  // Ordinal for this worker server
2639  fullord = Form("0.%d", ord);
2640 
2641  // Create environment files
2642  SetProofServEnv(fullord);
2643 
2644  // Create worker server and add to the list
2645  if ((wrk = CreateSlave("lite", fullord, 100, fImage, fWorkDir)))
2646  started.Add(wrk);
2647 
2648  PDB(kGlobal, 3)
2649  Info("PollForNewWorkers", "additional worker '%s' started", fullord.Data());
2650 
2651  // Notify
2652  NotifyStartUp("Opening connections to workers", ++nWrksDone, nWrksTot);
2653 
2654  } //end of worker loop
2655  fNWorkers = nWrksTot;
2656 
2657  // A list of TSlave objects for workers that are being added
2658  TList *addedWorkers = new TList();
2659  addedWorkers->SetOwner(kFALSE);
2660 
2661  // Wait for call backs
2662  nWrksDone = 0;
2663  nWrksTot = started.GetSize();
2664  Int_t nSelects = 0;
2665  Int_t to = gEnv->GetValue("ProofLite.StartupTimeOut", 5) * 1000;
2666  while (started.GetSize() > 0 && nSelects < nWrksTot) {
2667 
2668  // Wait for activity on the socket for max 5 secs
2669  TSocket *xs = mon->Select(to);
2670 
2671  // Count attempts and check
2672  nSelects++;
2673  if (xs == (TSocket *) -1) continue;
2674 
2675  // Get the connection
2676  TSocket *s = fServSock->Accept();
2677  if (s && s->IsValid()) {
2678  // Receive ordinal
2679  TMessage *msg = 0;
2680  if (s->Recv(msg) < 0) {
2681  Warning("PollForNewWorkers", "problems receiving message from accepted socket!");
2682  } else {
2683  if (msg) {
2684  *msg >> fullord;
2685  // Find who is calling back
2686  if ((wrk = (TSlave *) started.FindObject(fullord))) {
2687  // Remove it from the started list
2688  started.Remove(wrk);
2689 
2690  // Assign tis socket the selected worker
2691  wrk->SetSocket(s);
2692  // Remove socket from global TROOT socket list. Only the TProof object,
2693  // representing all worker sockets, will be added to this list. This will
2694  // ensure the correct termination of all proof servers in case the
2695  // root session terminates.
2697  gROOT->GetListOfSockets()->Remove(s);
2698  }
2699  if (wrk->IsValid()) {
2700  // Set the input handler
2701  wrk->SetInputHandler(new TProofInputHandler(this, wrk->GetSocket()));
2702  // Set fParallel to 1 for workers since they do not
2703  // report their fParallel with a LOG_DONE message
2704  wrk->fParallel = 1;
2705  // Finalize setup of the server
2706  wrk->SetupServ(TSlave::kSlave, 0);
2707  }
2708 
2709  // Monitor good workers
2710  fSlaves->Add(wrk);
2711  if (wrk->IsValid()) {
2712  fActiveSlaves->Add(wrk); // Is this required? Check!
2713  fAllMonitor->Add(wrk->GetSocket());
2714  // Record also in the list for termination
2715  if (addedWorkers) addedWorkers->Add(wrk);
2716  // Notify startup operations
2717  NotifyStartUp("Setting up added worker servers", ++nWrksDone, nWrksTot);
2718  } else {
2719  // Flag as bad
2720  fBadSlaves->Add(wrk);
2721  }
2722  }
2723  } else {
2724  Warning("PollForNewWorkers", "received empty message from accepted socket!");
2725  }
2726  }
2727  }
2728  }
2729 
2730  // Cleanup the monitor and the server socket
2731  mon->DeActivateAll();
2732  delete mon;
2733 
2734  Broadcast(kPROOF_GETSTATS, addedWorkers);
2735  Collect(addedWorkers, fCollectTimeout);
2736 
2737  // Update group view
2738  // SendGroupView();
2739 
2740  // By default go into parallel mode
2741  // SetParallel(-1, 0);
2742  SendCurrentState(addedWorkers);
2743 
2744  // Set worker processing environment
2745  SetupWorkersEnv(addedWorkers, kTRUE);
2746 
2747  // We are adding workers dynamically to an existing process, we
2748  // should invoke a special player's Process() to set only added workers
2749  // to the proper state
2750  if (fPlayer) {
2751  PDB(kGlobal, 3)
2752  Info("PollForNewWorkers", "Will send the PROCESS message to selected workers");
2753  fPlayer->JoinProcess(addedWorkers);
2754  }
2755 
2756  // Cleanup fwhat remained from startup
2757  Collect(addedWorkers);
2758 
2759  // Activate
2760  TIter naw(addedWorkers);
2761  while ((wrk = (TSlave *)naw())) {
2762  fActiveMonitor->Add(wrk->GetSocket());
2763  }
2764  // Cleanup
2765  delete addedWorkers;
2766 
2767  // Done
2768  return nWrksDone;
2769 }
Int_t SetProofServEnv(const char *ord)
Create environment files for worker &#39;ord&#39;.
Definition: TProofLite.cxx:711
void SetQueryRunning(TProofQueryResult *pq)
Set query in running state.
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 Int_t GetDrawArgs(const char *var, const char *sel, Option_t *opt, TString &selector, TString &objname)=0
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Long64_t GetEntries() const
Definition: TQueryResult.h:130
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
Int_t VerifyDataSet(const char *uri, const char *=0)
Verify if all files in the specified dataset are available.
Bool_t RequestStagingDataSet(const char *dataset)
Allows users to request staging of a particular dataset.
virtual TList * GetInputList() const =0
virtual Bool_t IsValid() const
Definition: TSocket.h:162
TQueryResultManager * fQMgr
Definition: TProofLite.h:64
virtual int GetPid()
Get process id.
Definition: TSystem.cxx:711
TString fPerfTree
Definition: TProof.h:588
action
Definition: ROOT.py:93
TString fPackageDir
Definition: TProof.h:560
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
void ActivateAsyncInput()
Activate the a-sync input handler.
Definition: TProof.cxx:4399
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
Int_t GetNumberOfActiveSlaves() const
Return number of active slaves, i.e.
Definition: TProof.cxx:1982
void AskParallel()
Ask the for the number of parallel slaves.
Definition: TProof.cxx:2072
TPMERegexp * fReInvalid
Definition: TProofLite.h:69
Long64_t GetBytesRead() const
Definition: TProof.h:962
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 ShowDataSetCache(const char *dataset=0)
Display the content of the dataset cache, if any (matching &#39;dataset&#39;, if defined).
virtual const char * GetBuildCompilerVersion() const
Return the build compiler version.
Definition: TSystem.cxx:3686
TMonitor * fAllUniqueMonitor
Definition: TProof.h:514
virtual Int_t ClearCache(const char *uri)
Clear cached information matching uri.
virtual void AddInput(TObject *inp)=0
long long Long64_t
Definition: RtypesCore.h:69
TFileCollection * GetDataSet(const char *uri, const char *=0)
Get a list of TFileInfo objects describing the files of the specified dataset.
virtual TDSetElement * Next(Long64_t totalEntries=-1)
Returns next TDSetElement.
Definition: TDSet.cxx:416
void PrepareInputDataFile(TString &dataFile)
Prepare the file with the input data objects to be sent the master; the objects are taken from the de...
Definition: TProof.cxx:10206
Int_t Load(const char *macro, Bool_t notOnClient=kFALSE, Bool_t uniqueOnly=kTRUE, TList *wrks=0)
Copy the specified macro in the cache directory.
void SetPerfTree(const char *pf="perftree.root", Bool_t withWrks=kFALSE)
Enable/Disable saving of the performance tree.
Definition: TProof.cxx:13192
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:865
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
Definition: TMD5.cxx:472
TString fConfDir
Definition: TProof.h:600
Bool_t ExistsDataSet(const char *uri)
Returns kTRUE if &#39;dataset&#39; described by &#39;uri&#39; exists, kFALSE otherwise.
const char *const kCP
Definition: TProof.h:164
const char *const kLS
Definition: TProof.h:166
Int_t fOtherQueries
Definition: TProof.h:551
Collectable string class.
Definition: TObjString.h:32
float Float_t
Definition: RtypesCore.h:53
virtual TVirtualProofPlayer * MakePlayer(const char *player=0, TSocket *s=0)
Construct a TProofPlayer object.
Definition: TProof.cxx:10778
const char Option_t
Definition: RtypesCore.h:62
virtual ~TProofLite()
Destructor.
Definition: TProofLite.cxx:402
Bool_t fSync
Definition: TProof.h:534
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
Definition: TSystem.cxx:4026
Bool_t RegisterDataSet(const char *dsName, TFileCollection *ds, const char *opt="")
Register the &#39;dataSet&#39; on the cluster under the current user, group and the given &#39;dataSetName&#39;...
TFileCollection * GetStagingStatusDataSet(const char *dataset)
Obtains a TFileCollection showing the staging status of the specified dataset.
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
void SetupWorkersEnv(TList *wrks, Bool_t increasingpool=kFALSE)
Set up packages, loaded macros, include and lib paths ...
Definition: TProof.cxx:1528
void SendInputDataFile()
Make sure that the input data objects are available to the workers in a dedicated file in the cache; ...
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
virtual Long64_t DrawSelect(TDSet *set, const char *varexp, const char *selection, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)=0
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TSocket.cxx:818
Definition: TDSet.h:153
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
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition: TProof.cxx:10389
virtual Bool_t RemoveDataSet(const char *uri)
Removes the indicated dataset.
static const TList * GetEnvVars()
Get environemnt variables.
Definition: TProof.cxx:12318
Int_t LockSession(const char *sessiontag, TProofLockPath **lck)
Try locking query area of session tagged sessiontag.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual EExitStatus GetExitStatus() const =0
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:580
TList * fAllUniqueSlaves
Definition: TProof.h:510
virtual int MakeDirectory(const char *name)
Make a directory.
Definition: TSystem.cxx:821
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
Definition: TSystem.cxx:536
virtual const char * HomeDirectory(const char *userName=0)
Return the user&#39;s home directory.
Definition: TSystem.cxx:881
TString fSelection
Definition: TProofLite.h:60
TString fImage
Definition: TProof.h:601
virtual TFileCollection * GetDataSet(const char *uri, const char *server=0)
Utility function used in various methods for user dataset upload.
Int_t PollForNewWorkers()
Simulate dynamic addition, for test purposes.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
void SetSocket(TSocket *s)
Definition: TSlave.h:116
#define R__ASSERT(e)
Definition: TError.h:98
#define gROOT
Definition: TROOT.h:352
TString fLogFileName
Definition: TProof.h:539
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
TProofLockPath * fCacheLock
Definition: TProofLite.h:62
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor&#39;s active list.
Definition: TMonitor.cxx:168
Int_t LoadPlugin()
Load the plugin library for this handler.
virtual void SetCurrentQuery(TQueryResult *q)=0
TList * Queries() const
TList * fQueries
Definition: TProof.h:550
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:128
Basic string class.
Definition: TString.h:137
void ClearDataSetCache(const char *dataset=0)
Clear the content of the dataset cache, if any (matching &#39;dataset&#39;, if defined).
Int_t GetNumberOfSlaves() const
Return number of slaves as described in the config file.
Definition: TProof.cxx:1973
Int_t GetClientProtocol() const
Definition: TProof.h:947
Int_t SetDataSetTreeName(const char *dataset, const char *treename)
Set/Change the name of the default tree.
int Int_t
Definition: RtypesCore.h:41
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:996
bool Bool_t
Definition: RtypesCore.h:59
void NotifyStartUp(const char *action, Int_t done, Int_t tot)
Notify setting-up operation message.
Definition: TProofLite.cxx:694
TQueryResult * CloneInfo()
Return an instance of TQueryResult containing only the local info fields, i.e.
TList * fUniqueSlaves
Definition: TProof.h:509
virtual Bool_t JoinProcess(TList *workers)=0
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition: TROOT.cxx:2517
TList * fWaitingSlaves
Definition: TProof.h:549
Int_t Broadcast(const TMessage &mess, TList *slaves)
Broadcast a message to all slaves in the specified list.
Definition: TProof.cxx:2470
const char *const kRM
Definition: TProof.h:165
virtual void RemoveAll()
Remove all sockets from the monitor.
Definition: TMonitor.cxx:241
virtual void ShowDataSets(const char *uri="*", const char *opt="")
Prints formatted information about the dataset &#39;uri&#39;.
const char *const kPROOF_PackageLockFile
Definition: TProof.h:155
This class represents a RFC 3986 compatible URI.
Definition: TUri.h:39
Long_t fMtime
Definition: TSystem.h:142
static Int_t fgWrksMax
Definition: TProofLite.h:71
Int_t GetSeqNum() const
Definition: TQueryResult.h:123
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
virtual void DeActivateAll()
De-activate all activated sockets.
Definition: TMonitor.cxx:302
void ShowData()
List contents of the data directory in the sandbox.
void ShowDataDir(const char *dirname)
List contents of the data directory &#39;dirname&#39;.
void ScanPreviousQueries(const char *dir)
Scan the queries directory for the results of previous queries.
TLatex * t1
Definition: textangle.C:20
static void ResolveKeywords(TString &fname, const char *path=0)
Replace <ord>, <user>, <u>, <group>, <stag>, <qnum>, <file>, <rver> and <build> placeholders in fname...
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:592
TList * fInputData
Definition: TProof.h:566
Int_t SendCurrentState(ESlaves list=kActive)
Transfer the current state of the master to the active slave servers.
Definition: TProof.cxx:6745
TList * GetListOfElements() const
Definition: TDSet.h:231
TVirtualProofPlayer * fPlayer
Definition: TProof.h:522
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:129
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
void ResolveKeywords(TString &s, const char *ord, const char *logfile)
Resolve some keywords in &#39;s&#39; <logfilewrk>, <user>, <rootsys>, <cpupin>
Definition: TProofLite.cxx:828
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:625
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2395
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3847
Int_t fMode
Definition: TSystem.h:138
Bool_t fForkStartup
Definition: TProofLite.h:54
virtual Long64_t Process(TDSet *set, const char *selector, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)=0
Int_t SavePerfTree(const char *pf=0, const char *qref=0)
Save performance information from TPerfStats to file &#39;pf&#39;.
Definition: TProof.cxx:13214
TDataSetManagerFile * fDataSetStgRepo
Definition: TProofLite.h:67
TSignalHandler * fIntHandler
Definition: TProof.h:519
Int_t fDrawQueries
Definition: TProof.h:552
TList * fChains
Definition: TProof.h:524
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:839
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition: TSystem.cxx:847
#define SafeDelete(p)
Definition: RConfig.h:449
TPluginHandler * fProgressDialog
Definition: TProof.h:520
TList * fBadSlaves
Definition: TProof.h:605
virtual TList * GetOutputList() const =0
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1345
TString fDataSetDir
Definition: TProofLite.h:51
Int_t CreateSymLinks(TList *files, TList *wrks=0)
Create in each worker sandbox symlinks to the files in the list Used to make the cache information av...
Double_t dot(const TVector2 &v1, const TVector2 &v2)
Definition: CsgOps.cxx:333
Bool_t fSendGroupView
list returned by kPROOF_GETSLAVEINFO
Definition: TProof.h:502
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:75
virtual Bool_t IsValid() const
Definition: TSlave.h:154
TObject * GetEntryList() const
Definition: TDSet.h:251
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2334
virtual int GetSysInfo(SysInfo_t *info) const
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
Definition: TSystem.cxx:2399
#define PDB(mask, level)
Definition: TProofDebug.h:58
void UpdateDialog()
Final update of the progress dialog.
Definition: TProof.cxx:4342
TList * fEnabledPackagesOnClient
Definition: TProof.h:563
THashList * fGlobalPackageDirList
Definition: TProof.h:561
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
TDataSetManager * fDataSetManager
Definition: TProofLite.h:66
TSlave * CreateSlave(const char *url, const char *ord, Int_t perf, const char *image, const char *workdir)
Create a new TSlave of type TSlave::kSlave.
Definition: TProof.cxx:1848
TSocket * GetSocket() const
Definition: TSlave.h:138
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
TString fCacheDir
Definition: TProofLite.h:49
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Long64_t Process(TDSet *dset, const char *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0)
Process a data set (TDSet) using the specified selector (.C) file.
TList * PreviousQueries() const
Int_t GetLogLevel() const
Definition: TProof.h:949
const char *const kPROOF_QueryDir
Definition: TProof.h:151
Int_t Init(const char *masterurl, const char *conffile, const char *confdir, Int_t loglevel, const char *alias=0)
Start the PROOF environment.
Definition: TProofLite.cxx:154
virtual Int_t RegisterDataSet(const char *uri, TFileCollection *dataSet, const char *opt)
Register a dataset, perfoming quota checkings, if needed.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
Int_t fParallel
Definition: TSlave.h:101
Bool_t CancelStagingDataSet(const char *dataset)
Cancels a dataset staging request.
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1626
TProofLockPath * fPackageLock
Definition: TProof.h:562
Int_t Collect(const TSlave *sl, Long_t timeout=-1, Int_t endtype=-1, Bool_t deactonfail=kFALSE)
Collect responses from slave sl.
Definition: TProof.cxx:2664
static Int_t RegisterDataSets(TList *in, TList *out, TDataSetManager *dsm, TString &e)
Register TFileCollections in &#39;out&#39; as datasets according to the rules in &#39;in&#39;.
Int_t ApplyMaxQueries(Int_t mxq)
Scan the queries directory and remove the oldest ones (and relative dirs, if empty) in such a way onl...
A sorted doubly linked list.
Definition: TSortedList.h:30
TString fConfFile
Definition: TProof.h:599
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2220
std::vector< std::vector< double > > Data
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition: TSystem.cxx:1562
TQueryResult * GetQueryResult(const char *ref=0)
Return pointer to the full TQueryResult instance owned by the player and referenced by &#39;ref&#39;...
Definition: TProof.cxx:2143
TList * fSlaves
Definition: TProof.h:603
Int_t fNotIdle
Definition: TProof.h:533
virtual void SetOutputList(TList *out, Bool_t adopt=kTRUE)
Set / change the output list.
virtual TSocket * Accept(UChar_t Opt=0)
Accept a connection on a server socket.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1446
const Bool_t kSortDescending
Definition: TList.h:41
friend class TProofInputHandler
Definition: TProof.h:347
const char * GetDataDir() const
Definition: TProof.h:252
TList * fInactiveSlaves
Definition: TProof.h:508
A container class for query results.
Definition: TQueryResult.h:44
Int_t fCollectTimeout
Definition: TProof.h:614
TList * GetListOfSlaveInfos()
Returns list of TSlaveInfo&#39;s. In case of error return 0.
Definition: TProof.cxx:2316
Int_t fDynamicStartupNMax
Definition: TProofLite.h:57
static TList * fgProofEnvList
Definition: TProof.h:576
Float_t GetRealTime() const
Definition: TProof.h:963
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition: TMonitor.cxx:322
virtual void SetProcessInfo(Long64_t ent, Float_t cpu=0., Long64_t siz=-1, Float_t inittime=0., Float_t proctime=0.)
Set processing info.
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
TString fQueryDir
Definition: TProofLite.h:50
void SetTermTime(Float_t termtime)
Definition: TQueryResult.h:108
TString fSandbox
Definition: TProofLite.h:48
Int_t GetNumberOfInactiveSlaves() const
Return number of inactive slaves, i.e.
Definition: TProof.cxx:1991
A doubly linked list.
Definition: TList.h:47
const char * GetObjName() const
Definition: TDSet.h:122
Bool_t fRedirLog
Definition: TProof.h:538
TMonitor * fUniqueMonitor
Definition: TProof.h:513
const char *const kPROOF_ConfFile
Definition: TProof.h:145
Bool_t RemoveDataSet(const char *group, const char *user, const char *dsName)
Removes the indicated dataset.
Int_t RemoveDataSet(const char *uri, const char *=0)
Remove the specified dataset from the PROOF cluster.
const char * GetName() const
Returns name of object.
Definition: TObjString.h:42
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
Definition: TEnv.cxx:581
const char *const kPROOF_QueryLockFile
Definition: TProof.h:156
TMonitor * fAllMonitor
Definition: TProof.h:606
virtual void AddQueryResult(TQueryResult *q)=0
void ShowDataSets(const char *uri="", const char *=0)
Shows datasets in locations that match the uri By default shows the user&#39;s datasets and global ones...
virtual TMap * GetSubDataSets(const char *uri, const char *excludeservers)
Partition dataset &#39;ds&#39; accordingly to the servers.
TString fUser
Definition: TSystem.h:152
virtual const char * GetBuildArch() const
Return the build architecture.
Definition: TSystem.cxx:3670
Int_t fLogLevel
Definition: TProof.h:497
TList * fActiveSlaves
Definition: TProof.h:505
Long64_t DrawSelect(TDSet *dset, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Execute the specified drawing action on a data set (TDSet).
void QueryResultReady(const char *ref)
Notify availability of a query result.
Definition: TProof.cxx:9936
const TString GetUri() const
Returns the whole URI - an implementation of chapter 5.3 component recomposition. ...
Definition: TUri.cxx:139
Int_t fNWorkers
Definition: TProofLite.h:47
Bool_t fValid
Definition: TProof.h:492
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition: TSystem.cxx:1610
Int_t fCpus
Definition: TSystem.h:165
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:556
ROOT::R::TRInterface & r
Definition: Object.C:4
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
TString fWorkDir
Definition: TProof.h:495
SVector< double, 2 > v
Definition: Dict.h:5
const char *const kPROOF_DataSetDir
Definition: TProof.h:152
TMonitor * fCurrentMonitor
Definition: TProof.h:515
THashList * GetList()
Long_t ExecPlugin(int nargs, const T &... params)
Int_t SetupWorkers(Int_t opt=0, TList *wrks=0)
Start up PROOF workers.
Definition: TProofLite.cxx:516
Long64_t GetNFiles() const
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:480
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
const char *const kPROOF_ConfDir
Definition: TProof.h:146
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
Definition: Stringio.cxx:198
virtual Bool_t ExistsDataSet(const char *uri)
Checks if the indicated dataset exits.
Bool_t IsDraw() const
Definition: TQueryResult.h:152
Bool_t ParseUri(const char *uri, TString *dsGroup=0, TString *dsUser=0, TString *dsName=0, TString *dsTree=0, Bool_t onlyCurrent=kFALSE, Bool_t wildcards=kFALSE)
Parses a (relative) URI that describes a DataSet on the cluster.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
Int_t fSeqNum
Definition: TProof.h:554
void ClearCache(const char *file=0)
Remove files from all file caches.
Int_t fDynamicStartupStep
Definition: TProofLite.h:56
virtual Int_t ShowCache(const char *uri)
Show cached information matching uri.
void SetActive(Bool_t=kTRUE)
Definition: TProof.h:1021
Int_t WriteDataSet(const char *group, const char *user, const char *dsName, TFileCollection *dataset, UInt_t option=0, TMD5 *checksum=0)
Writes indicated dataset.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
TList * fSlaveInfo
Definition: TProof.h:501
unsigned int UInt_t
Definition: RtypesCore.h:42
TList * GetInputList()
Definition: TQueryResult.h:128
TMarker * m
Definition: textangle.C:8
const char *const kPROOF_CacheLockFile
Definition: TProof.h:154
Int_t ScanDataSet(const char *uri, const char *opt)
Scans the dataset indicated by &#39;uri&#39; following the &#39;opts&#39; directives.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
char * Form(const char *fmt,...)
Ssiz_t Length() const
Definition: TString.h:390
void SetRunning(Int_t startlog, const char *par, Int_t nwrks)
Call when running starts.
TServerSocket * fServSock
Definition: TProofLite.h:53
Bool_t SetFragment(const TString &fragment)
Set fragment component of URI: fragment = *( pchar / "/" / "?" ).
Definition: TUri.cxx:497
TList * GetListOfQueries(Option_t *opt="")
Get the list of queries.
Bool_t fProgressDialogStarted
Definition: TProof.h:521
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:657
const Int_t kPROOF_Protocol
Definition: TProof.h:143
Int_t SendGroupView()
Send to all active slaves servers the current slave group size and their unique id.
Definition: TProof.cxx:6447
TStopwatch fQuerySTW
Definition: TProof.h:624
Bool_t FinalizeQuery(TProofQueryResult *pq, TProof *proof, TVirtualProofPlayer *player)
Final steps after Process() to complete the TQueryResult instance.
Int_t RemoveWorkers(TList *wrks)
Used for shuting down the workres after a query is finished.
Definition: TProof.cxx:1591
FILE * fLogFileR
Definition: TProof.h:541
void SetName(const char *name)
Definition: TCollection.h:116
Int_t fProtocol
Definition: TProof.h:602
static Int_t GetNumberOfWorkers(const char *url=0)
Static method to determine the number of workers giving priority to users request.
Definition: TProofLite.cxx:433
Bool_t fLogToWindowOnly
Definition: TProof.h:542
TList * fFeedback
Definition: TProof.h:523
Bool_t IsIdle() const
Definition: TProof.h:973
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition: TSystem.cxx:839
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition: TProof.cxx:10301
#define Printf
Definition: TGeoToOCC.h:18
TMap * GetDataSets(const char *uri="", const char *=0)
lists all datasets that match given uri
TList * fRunningDSets
Definition: TProof.h:612
#define R__LOCKGUARD2(mutex)
Int_t VerifyDataSetParallel(const char *uri, const char *optStr)
Internal function for parallel dataset verification used TProof::VerifyDataSet and TProofLite::Verify...
Definition: TProof.cxx:11748
Bool_t fDynamicStartup
Definition: TProof.h:620
virtual void RemoveQueryResult(const char *ref)=0
static TSelector * GetSelector(const char *filename)
The code in filename is loaded (interpreted or compiled, see below), filename must contain a valid cl...
Definition: TSelector.cxx:140
Int_t AssertPath(const char *path, Bool_t writable)
Make sure that &#39;path&#39; exists; if &#39;writable&#39; is kTRUE, make also sure that the path is writable...
Definition: TProof.cxx:1269
Int_t CreateSandbox()
Create the sandbox for this session.
Definition: TProofLite.cxx:907
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
int Ssiz_t
Definition: RtypesCore.h:63
TString fSockPath
Definition: TProofLite.h:52
Int_t HandleOutputOptions(TString &opt, TString &target, Int_t action)
Extract from opt information about output handling settings.
Definition: TProof.cxx:4927
R__EXTERN TProof * gProof
Definition: TProof.h:1110
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
Definition: TSystem.cxx:546
Bool_t fEndMaster
Definition: TProof.h:558
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2240
void SetFeedback(TString &opt, TString &optfb, Int_t action)
Extract from opt in optfb information about wanted feedback settings.
Definition: TProof.cxx:5222
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
Int_t GoParallel(Int_t nodes, Bool_t accept=kFALSE, Bool_t random=kFALSE)
Go in parallel mode with at most "nodes" slaves.
Definition: TProof.cxx:7260
TSignalHandler * GetSignalHandler() const
Definition: TApplication.h:112
virtual const char * HostName()
Return the system&#39;s host name.
Definition: TSystem.cxx:307
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Definition: TSystem.cxx:1336
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:864
Int_t Lock()
Locks the directory.
TList * fEnabledPackages
Definition: TProof.h:611
EQueryMode GetQueryMode(Option_t *mode=0) const
Find out the query mode based on the current setting and &#39;mode&#39;.
Definition: TProof.cxx:6106
Int_t GetParallel() const
Returns number of slaves active in parallel mode.
Definition: TProof.cxx:2299
TList * fNonUniqueMasters
Definition: TProof.h:511
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
Int_t CleanupSandbox()
Remove old sessions dirs keep at most &#39;Proof.MaxOldSessions&#39; (default 10)
TList * fRecvMessages
Definition: TProof.h:500
TNamed()
Definition: TNamed.h:40
Int_t GetNumberOfBadSlaves() const
Return number of bad slaves.
Definition: TProof.cxx:2009
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2601
TList * fEnabledPackagesOnCluster
Definition: TProof.h:564
int nentries
Definition: THbookFile.cxx:89
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual void Reset()
Reset or initialize access to the elements.
Definition: TDSet.cxx:1340
void SetRunStatus(ERunStatus rst)
Definition: TProof.h:707
const char * GetFileName() const
Definition: TDSet.h:113
const char * GetWorkDir() const
Definition: TSlave.h:131
void RemoveQuery(TQueryResult *qr, Bool_t soft=kFALSE)
Remove everything about query qr.
Int_t Unlock()
Unlock the directory.
virtual void StopProcess(Bool_t abort, Int_t timeout=-1)=0
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:348
Int_t GetSandbox(TString &sb, Bool_t assert=kFALSE, const char *rc=0)
Set the sandbox path from &#39; Proof.Sandbox&#39; or the alternative var &#39;rc&#39;.
Definition: TProof.cxx:1020
static TMap * GetDataSetNodeMap(TFileCollection *fc, TString &emsg)
Get a map {server-name, list-of-files} for collection &#39;fc&#39; to be used in TPacketizerFile.
virtual Long64_t GetEntries() const
Definition: TTree.h:382
Bool_t IsNull() const
Definition: TString.h:387
void SaveQuery(TProofQueryResult *qr, const char *fout=0)
Save current status of query &#39;qr&#39; to file name fout.
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex &#39;this&#39; was created with.
Definition: TPRegexp.cxx:704
#define name(a, b)
Definition: linkTestLib0.cpp:5
FILE * fLogFileW
Definition: TProof.h:540
Mother of all ROOT objects.
Definition: TObject.h:58
TSelector * fSelector
Definition: TProof.h:622
TString fVarExp
Definition: TProofLite.h:59
Bool_t ExistsDataSet(const char *group, const char *user, const char *dsName)
Checks if the indicated dataset exits.
Float_t GetCpuTime() const
Definition: TProof.h:964
Int_t InitDataSetManager()
Initialize the dataset manager from directives or from defaults Return 0 on success, -1 on failure.
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:126
static void SetMacroPath(const char *newpath)
Set or extend the macro search path.
Definition: TROOT.cxx:2421
R__EXTERN TProofServ * gProofServ
Definition: TProofServ.h:359
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition: TPRegexp.h:103
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
TProofOutputList fOutputList
Definition: TProof.h:569
TProofLockPath * fQueryLock
Definition: TProofLite.h:63
TFileCollection * GetDataSet(const char *uri, const char *srv=0)
Utility function used in various methods for user dataset upload.
Int_t CleanupQueriesDir()
Remove all queries results referring to previous sessions.
Int_t fSessionID
Definition: TProof.h:556
void AskStatistics()
Ask the for the statistics of the slaves.
Definition: TProof.cxx:2017
TF1 * f1
Definition: legend1.C:11
TTree * GetTreeHeader(TDSet *tdset)
Creates a tree header (a tree with nonexisting files) object for the DataSet.
Int_t fStatus
Definition: TProof.h:498
Int_t SetParallel(Int_t nodes=-1, Bool_t random=kFALSE)
Tell PROOF how many slaves to use in parallel.
Definition: TProof.cxx:7127
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
Definition: TSystem.cxx:1309
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:830
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition: TString.cxx:443
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 IsParallel() const
Definition: TProof.h:972
const char * GetUser() const
Definition: TProof.h:939
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1806
TList * fAvailablePackages
Definition: TProof.h:610
A TTree object has a header with a name and a title.
Definition: TTree.h:94
const AParamType & GetVal() const
Definition: TParameter.h:77
double result[121]
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
Int_t SendInitialState()
Transfer the initial (i.e.
Definition: TProof.cxx:6761
void ResetBit(UInt_t f)
Definition: TObject.h:172
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
TList * fTerminatedSlaveInfos
Definition: TProof.h:604
void Add(TObject *obj)
Add object in sorted list.
Definition: TSortedList.cxx:26
TProofQueryResult * MakeQueryResult(Long64_t nent, const char *opt, Long64_t fst, TDSet *dset, const char *selec)
Create a TProofQueryResult instance for this query.
TList * fLoadedMacros
Definition: TProof.h:575
Int_t Remove(const char *ref, Bool_t all)
Handle remove request.
virtual Int_t Load(const char *macro, Bool_t notOnClient=kFALSE, Bool_t uniqueOnly=kTRUE, TList *wrks=0)
Load the specified macro on master, workers and, if notOnClient is kFALSE, on the client...
Definition: TProof.cxx:9198
virtual Int_t GetSize() const
Definition: TCollection.h:95
Int_t Substitute(TString &s, const TString &r, Bool_t doDollarSubst=kTRUE)
Substitute matching part of s with r, dollar back-ref substitution is performed if doDollarSubst is t...
Definition: TPRegexp.cxx:870
Definition: TSlave.h:50
void FindUniqueSlaves()
Add to the fUniqueSlave list the active slaves that have a unique (user) file system image...
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
const Bool_t kTRUE
Definition: Rtypes.h:91
void ResetProgressDialog(const char *sel, Int_t sz, Long64_t fst, Long64_t ent)
Reset progress dialog.
Definition: TProof.cxx:9866
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
Bool_t fTty
Definition: TProof.h:493
virtual TMap * GetDataSets(const char *uri, UInt_t=TDataSetManager::kExport)
Returns all datasets for the <group> and <user> specified by <uri>.
void ShowCache(Bool_t all=kFALSE)
List contents of file cache.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1044
void Print(Option_t *option="") const
Print status of PROOF-Lite cluster.
Definition: TProofLite.cxx:975
const char * GetOrdinal() const
Definition: TProofServ.h:265
const Int_t n
Definition: legend1.C:16
virtual Int_t SetupServ(Int_t stype, const char *conffile)
Init a PROOF slave object.
Definition: TSlave.cxx:181
TMonitor * fActiveMonitor
Definition: TProof.h:512
virtual TList * GetListOfResults() const =0
Int_t GetNumberOfUniqueSlaves() const
Return number of unique slaves, i.e.
Definition: TProof.cxx:2000
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904
Long64_t fLastPollWorkers_s
Definition: TProof.h:504
Int_t fMaxDrawQueries
Definition: TProof.h:553
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
Int_t CopyMacroToCache(const char *macro, Int_t headerRequired=0, TSelector **selector=0, Int_t opt=0, TList *wrks=0)
Copy a macro, and its possible associated .h[h] file, to the cache directory, from where the workers ...
const char *const kPROOF_CacheDir
Definition: TProof.h:148
const char * Data() const
Definition: TString.h:349
const char *const kPROOF_PackDir
Definition: TProof.h:149
void SetInputHandler(TFileHandler *ih)
Adopt and register input handler for this slave.
Definition: TSlave.cxx:396
static Int_t AssertDataSet(TDSet *dset, TList *input, TDataSetManager *mgr, TString &emsg)
Make sure that dataset is in the form to be processed.
Definition: TProof.cxx:12582