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