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