Logo ROOT   6.12/07
Reference Guide
pq2actions.cxx
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: G. Ganis, Mar 2010
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 // * p q 2 a c t i o n s * //
15 // * * //
16 // * This file implements the action functions used in PQ2 * //
17 // * * //
18 // ************************************************************************* //
19 
20 #include <errno.h>
21 
22 #include "pq2actions.h"
23 #include "pq2wrappers.h"
24 #include "redirguard.h"
25 
26 #include "TFile.h"
27 #include "TFileCollection.h"
28 #include "TFileInfo.h"
29 #include "THashList.h"
30 #include "TH1D.h"
31 #include "TParameter.h"
32 #include "TRegexp.h"
33 #include "TString.h"
34 #include "TSystem.h"
35 
36 // Global variables defined by other PQ2 components
37 extern TString flog;
38 extern TString ferr;
39 extern TString fres;
40 extern Int_t gverbose;
41 
42 // Local globals
43 static const char *glabMet[] = { "#files", "size" };
45 // Local functions
46 int do_anadist_ds(TFileCollection *fc, const char *newsrvs = 0, const char *ignsrvs = 0,
47  const char *excsrvs = 0, int met = 0, const char *fnout = 0,
48  TList *distinfo = 0, const char *outfile = 0, const char *infile = 0);
49 void do_anadist_getkey(const char *p, TString &key);
50 void do_anadist_getkey(TUrl *u, TString &key);
51 
52 // Usefule macros
53 #define SDELTWO(x,y) { SafeDelete(x); SafeDelete(y); }
54 #define SDELTRE(x,y,z) { SafeDelete(x); SafeDelete(y); SafeDelete(z); }
55 #define SDELETE(x,y,z,w,t) { SafeDelete(x); SafeDelete(y); SafeDelete(z); SafeDelete(w); SafeDelete(t); }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Execute 'cache'
59 
60 void do_cache(bool clear, const char *ds)
61 {
62  // Show / Clear the cache
63  DataSetCache(clear, ds);
64  // Remove the error file
65  gSystem->Unlink(ferr.Data());
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Execute 'ls'
70 
71 void do_ls(const char *ds, const char *opt)
72 {
73  // List the data sets
74  ShowDataSets(ds, opt);
75  // Remove the error file
76  gSystem->Unlink(ferr.Data());
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Execute 'ls-files'
81 
82 void do_ls_files_server(const char *ds, const char *server)
83 {
84  const char *action = (server && strlen(server) > 0) ? "pq2-ls-files-server" : "pq2-ls-files";
85 
86  // We need to scan all the datasets to find the matching ones ...
87  TFileCollection *fc = 0;
88  { redirguard rog(flog.Data(), "a", gverbose);
89  if (server && strlen(server) > 0) {
90  fc = GetDataSet(ds, server);
91  } else {
92  fc = GetDataSet(ds);
93  }
94  }
95  if (!fc) {
96  // Notify
97  gSystem->Rename(flog.Data(), ferr.Data());
98  Printf("%s: ERROR: problems retrieving info about dataset '%s'", action, ds);
99  return;
100  }
101 
102  // Overall info
103  if (server && strlen(server) > 0) {
104  Printf("%s: dataset '%s' has %d files on server: %s",
105  action, ds, fc->GetList()->GetSize(), server);
106  } else {
107  Printf("%s: dataset '%s' has %d files", action, ds, fc->GetList()->GetSize());
108  }
109 
110  // Header
111  TString num(" # ");
112  TString nam("File"); nam.Resize(80);
113  TString siz(" Size");
114  TString met("#Objs Obj|Type|Entries, ...");
115  TString header;
116  header.Form("%s%s%s %s", num.Data(), nam.Data(), siz.Data(), met.Data());
117 
118  // Iterate
119  const char *unit[4] = {"kB", "MB", "GB", "TB"};
120  TString uu, meta, name;
121  TIter nxf(fc->GetList());
122  TFileInfo *fi = 0;
123  Int_t nf = 0;
124  while ((fi = (TFileInfo *) nxf())) {
125  nf++;
126  if (nf == 1)
127  Printf("%s:%s", action, header.Data());
128  // URL
129  uu = fi->GetCurrentUrl()->GetUrl();
130  if (uu.Length() < 80) uu.Resize(80);
131  // Size renormalize to kB, MB or GB
132  Int_t k = 0;
133  Long64_t refsz = 1024;
134  Long64_t xsz = (Long64_t) (fi->GetSize() / refsz);
135  while (xsz > 1024 && k < 3) {
136  k++;
137  refsz *= 1024;
138  xsz = (Long64_t) (fi->GetSize() / refsz);
139  }
140  // Meta info
141  meta = "";
142  if (fi->GetMetaDataList()) {
143  meta.Form(" %d ", fi->GetMetaDataList()->GetSize());
144  Bool_t firstObj = kTRUE;
145  TIter nxm(fi->GetMetaDataList());
146  TFileInfoMeta *fim = 0;
147  while ((fim = (TFileInfoMeta *) nxm())) {
148  if (!firstObj) meta += ",";
149  name = fim->GetObject();
150  if (strcmp(fim->GetDirectory(),"/")) name = fim->GetName();
151  meta += Form("%s|%s|%lld", name.Data(), fim->GetClass(), fim->GetEntries());
152  firstObj = kFALSE;
153  }
154  }
155  // Printout
156  if (xsz > 0) {
157  Printf("%s: %5d %s %8lld %s %s", action, nf, uu.Data(), xsz, unit[k], meta.Data());
158  } else {
159  Printf("%s: %5d %s N/A N/A", action, nf, uu.Data());
160  }
161  }
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// Formatted printout of the content of TFileCollection 'fc'.
166 /// Options in the form
167 /// popt = u * 10 + f
168 /// f 0 => header only, 1 => header + files
169 /// when printing files
170 /// u 0 => print file name only, 1 => print full URL
171 
173 {
174  if (!fc) return;
175 
176  Int_t f = popt%10;
177  Int_t u = popt - 10 * f;
178 
179  Printf("+++");
180  if (fc->GetTitle() && (strlen(fc->GetTitle()) > 0)) {
181  Printf("+++ Dumping: %s: ", fc->GetTitle());
182  } else {
183  Printf("+++ Dumping: %s: ", fc->GetName());
184  }
185  Printf("%s", fc->ExportInfo("+++ Summary:", 1)->GetName());
186  if (f == 1) {
187  Printf("+++ Files:");
188  Int_t nf = 0;
189  TIter nxfi(fc->GetList());
190  TFileInfo *fi = 0;
191  while ((fi = (TFileInfo *)nxfi())) {
192  if (u == 1)
193  Printf("+++ %5d. %s", ++nf, fi->GetCurrentUrl()->GetUrl());
194  else
195  Printf("+++ %5d. %s", ++nf, fi->GetCurrentUrl()->GetFile());
196  }
197  }
198  Printf("+++");
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 /// Execute 'info-server'
203 
204 void do_info_server(const char *server)
205 {
206  const char *action = "pq2-info-server";
207 
208  // We need to scan all the datasets to find the matching ones ...
209  TMap *dsmap = 0;
210  { redirguard rog(flog.Data(), "a", gverbose);
211  dsmap = GetDataSets("/*/*", server);
212  }
213  if (!dsmap) {
214  // Notify
215  gSystem->Rename(flog.Data(), ferr.Data());
216  Printf("%s: ERROR: problems retrieving info about datasets for server '%s'", action, server);
217  return;
218  }
219 
220  redirguard rog(fres.Data(), "w", gverbose);
221  Int_t popt = 0;
222  TIter nxk(dsmap);
223  TObject *k = 0;
224  TFileCollection *fc = 0;
225  while ((k = nxk()) && (fc = (TFileCollection *) dsmap->GetValue(k))) {
226  printDataSet(fc, popt);
227  }
228  delete dsmap;
229 
230  // Done
231  return;
232 }
233 
234 ////////////////////////////////////////////////////////////////////////////////
235 
236 Int_t pq2register(const char *dsname, const char *files, const char *opt) {
237  // If the dataset exists already do not continue
238  TString oo(opt);
239  oo.ToUpper();
240  redirguard rog(flog.Data(), "a", gverbose);
241  if (ExistsDataSet(dsname) &&
242  !oo.Contains("O") && !oo.Contains("U")) {
243  return 2;
244  }
245  // Create the file collection
246  TFileCollection *fc = new TFileCollection("dum", "dum", files);
247 
248  // The option may contain the default tree name and/or the staged status
249  Int_t itb = kNPOS, ite = kNPOS;
250  TString o(opt), deftree;
251  if ((itb = o.Index("tree:")) != kNPOS) {
252  deftree = o(itb + 5, o.Length());
253  if ((ite = deftree.Index('|')) != kNPOS) deftree.Remove(ite);
254  o.ReplaceAll(TString::Format("tree:%s|", deftree.Data()), "");
255  if (!deftree.BeginsWith("/")) deftree.Insert(0, "/");
256  if (!deftree.IsNull()) fc->SetDefaultTreeName(deftree);
257  }
258  if (o.Contains("staged|")) {
260  o.ReplaceAll("staged|", "");
261  }
262  // Update the collection
263  fc->Update();
264 
265  // Register the file collection
266  Int_t rc =0;
267  if (RegisterDataSet(dsname, fc, o) == 0) rc = 1;
268  // Cleanup
269  delete fc;
270 
271  // Done
272  return rc;
273 }
274 
275 ////////////////////////////////////////////////////////////////////////////////
276 /// Execute 'put'
277 
278 void do_put(const char *files, const char *opt)
279 {
280  const char *action = "pq2-put";
281 
282  // Check the file path makes sense
283  if (!files || strlen(files) <= 0) {
284  // Notify
285  gSystem->Rename(flog.Data(), ferr.Data());
286  Printf("%s: ERROR: path files not defined!", action);
287  return ;
288  }
289 
290  // Find out if it is a single file or a directory or contains a wildcard
291  Bool_t isDir = kFALSE;
292  Bool_t isWild = kFALSE;
293  TString dir, base;
294  FileStat_t st;
295  if (gSystem->GetPathInfo(files, st) != 0) {
296  // Path does not exists: check the basename for wild cards; in such a case
297  // we have to do a selective search in the directory
298  base = gSystem->BaseName(files);
299  if (base.Contains("*")) {
300  isWild = kTRUE;
301  base.ReplaceAll("*", ".*");
302  isDir = kTRUE;
303  dir = gSystem->DirName(files);
304  }
305 
306  } else {
307  // Path exists: is it a dir or a file ?
308  if (R_ISDIR(st.fMode)) {
309  isDir = kTRUE;
310  dir = files;
311  }
312  }
313 
314  Int_t ndp = 0, nd = 0;
315  Int_t printerr = 1;
316  Int_t rc = 0;
317  // If simple file ...
318  if (!isDir) {
319  nd++;
320  // ... just register and exit
321  TString dsname = gSystem->BaseName(files);
322  if ((rc = pq2register(dsname.Data(), files, opt)) != 0) {
323  // Notify
324  gSystem->Rename(flog.Data(), ferr.Data());
325  if (rc == 2) {
326  Printf("%s: WARNING: dataset '%s' already exists - ignoring request", action, dsname.Data());
327  Printf("%s: (use '-o O' to overwrite, '-o U' to update)", action);
328  } else {
329  Printf("%s: ERROR: problems registering '%s' from '%s'", action, dsname.Data(), files);
330  }
331  return;
332  }
333  printerr = 0;
334  } else {
335  // ... else, scan the directory
336  void *dirp = gSystem->OpenDirectory(dir.Data());
337  if (!dirp) {
338  // Notify
339  gSystem->Rename(flog.Data(), ferr.Data());
340  Printf("%s: ERROR: could not open directory '%s'", action, dir.Data());
341  return;
342  }
343  printerr = 0;
344  // Loop over the entries
345  TString file;
346  TRegexp reg(base);
347  const char *ent = 0;
348  while ((ent = gSystem->GetDirEntry(dirp))) {
349  // Skip default entries
350  if (!strcmp(ent, ".") || !strcmp(ent, "..")) continue;
351  if (isWild) {
352  file = ent;
353  if (file.Index(reg) == kNPOS) continue;
354  }
355  nd++;
356  file.Form("%s/%s", dir.Data(), ent);
357  if ((rc = pq2register(ent, file.Data(), opt)) != 0) {
358  nd--;
359  ndp++;
360  printerr = 1;
361  // Notify
362  if (rc == 1) {
363  Printf("%s: ERROR: problems registering '%s' from '%s'", action, ent, file.Data());
364  } else {
365  Printf("%s: WARNING: dataset '%s' already exists - ignoring request", action, ent);
366  Printf("%s: (use '-o O' to overwrite, '-o U' to update)", action);
367  }
368  continue;
369  }
370  }
371  gSystem->FreeDirectory(dirp);
372  }
373 
374  // If no match, notify
375  if (printerr == 1) {
376  Printf("%s: WARNING: problems with %d dataset(s)", action, ndp);
377  gSystem->Rename(flog.Data(), ferr.Data());
378  }
379  Printf("%s: %d dataset(s) registered", action, nd);
380 
381  // Done
382  return;
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Execute 'rm'
387 
388 void do_rm(const char *dsname)
389 {
390  const char *action = "pq2-ds";
391 
392  Int_t nd = 0;
393  Int_t printerr = 1;
394  TString ds(dsname);
395  if (!ds.Contains("*")) {
396  nd++;
397  // Remove the dataset
398  redirguard rog(flog.Data(), "a", gverbose);
399  if (RemoveDataSet(dsname) != 0) {
400  // Notify
401  gSystem->Rename(flog.Data(), ferr.Data());
402  Printf("%s: ERROR: problems removing dataset '%s'", action, dsname);
403  return;
404  }
405  printerr = 0;
406  } else {
407  // We need to scan all the datasets to find the matching ones ...
408  TMap *dss = 0;
409  { redirguard rog(flog.Data(), "a", gverbose);
410  dss = GetDataSets();
411  }
412  if (!dss) {
413  // Notify
414  gSystem->Rename(flog.Data(), ferr.Data());
415  Printf("%s: ERROR: problems retrieving info about datasets", action);
416  return;
417  }
418  printerr = 0;
419  // Iterate
420  TRegexp reg(dsname, kTRUE);
421  TIter nxd(dss);
422  TObjString *os = 0;
423  while ((os = dynamic_cast<TObjString*>(nxd()))) {
424  ds = os->GetName();
425  if (ds.Index(reg) != kNPOS) {
426  nd++;
427  // Remove the dataset
428  redirguard rog(flog.Data(), "a", gverbose);
429  if (RemoveDataSet(ds.Data()) != 0) {
430  printerr = 1;
431  // Notify
432  Printf("%s: ERROR: problems removing dataset '%s'", action, ds.Data());
433  continue;
434  }
435  }
436  }
437 
438  }
439 
440  // If no match, notify
441  if (nd == 0) {
442  Printf("%s: WARNING: no matching dataset found!", action);
443  } else {
444  Printf("%s: %d dataset(s) removed", action, nd);
445  }
446  if (printerr)
447  gSystem->Rename(flog.Data(), ferr.Data());
448 
449  // Done
450  return;
451 }
452 
453 ////////////////////////////////////////////////////////////////////////////////
454 /// Execute 'verify'
455 
456 int do_verify(const char *dsname, const char *opt, const char *redir)
457 {
458  const char *action = "pq2-verify";
459 
460  Int_t nd = 0, rc = -1;
461  Int_t printerr = 1;
462  TString ds(dsname);
463  if (!ds.Contains("*")) {
464  nd++;
465  // Verify the dataset
466  if ((rc = VerifyDataSet(dsname, opt, redir)) < 0) {
467  // Notify
468  Printf("%s: ERROR: problems verifing dataset '%s'", action, dsname);
469  return rc;
470  } else if (rc > 0) {
471  // Notify
472  Printf("%s: WARNING: %s: some files not yet online (staged)", action, dsname);
473  }
474  printerr = 0;
475  } else {
476  // We need to scan all the datasets to find the matching ones ...
477  TMap *dss = GetDataSets(dsname, "", "list");
478  if (!dss) {
479  // Notify
480  Printf("%s: ERROR: problems retrieving info about datasets", action);
481  return rc;
482  }
483  printerr = 0;
484  // Iterate
485  Int_t xrc = -1;
486  TIter nxd(dss);
487  TObjString *os = 0;
488  while ((os = dynamic_cast<TObjString*>(nxd()))) {
489  nd++;
490  // Verify the dataset
491  Printf("%s: start verification of dataset '%s' ...", action, os->GetName());
492  if ((xrc = VerifyDataSet(os->GetName(), opt, redir)) < 0) {
493  printerr = 1;
494  // Notify
495  Printf("%s: ERROR: problems verifying dataset '%s'", action, os->GetName());
496  continue;
497  } else if (xrc > 0) {
498  // At least one is not fully available
499  rc = 1;
500  // Notify
501  Printf("%s: WARNING: %s: some files not yet online (staged)", action, os->GetName());
502  } else if (rc < 0) {
503  // At least one is good
504  rc = 0;
505  }
506  }
507  }
508 
509  // If no match, notify
510  if (nd == 0) {
511  Printf("%s: WARNING: no matching dataset found!", action);
512  } else {
513  Printf("%s: %d dataset(s) verified", action, nd);
514  }
515  if (printerr)
516  gSystem->Rename(flog.Data(), ferr.Data());
517 
518  // Done
519  return rc;
520 }
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// Execute 'analyze-distribution' for the dataset(s) described by 'ds'.
524 /// The result is output to the screan and the details about file movement to file
525 /// 'fnout', if defined.
526 
527 void do_anadist(const char *ds, const char *servers, const char *ignsrvs,
528  const char *excsrvs, const char *metrics, const char *fnout,
529  const char *plot, const char *outfile, const char *infile)
530 {
531  const char *action = "pq2-ana-dist";
532 
533  // Running mode
534  Bool_t plot_m = (plot && strlen(plot)) ? kTRUE : kFALSE;
535  Bool_t plotonly_m = (plot_m && infile && strlen(infile)) ? kTRUE : kFALSE;
536 
537  // We need to scan all the datasets to find the matching ones ...
538  TMap *fcmap = 0;
539  TObject *k = 0;
540  if (!plotonly_m) {
541  redirguard rog(flog.Data(), "a", gverbose);
542  TString dss(ds), d;
543  Int_t from = 0;
544  while (dss.Tokenize(d, from, ",")) {
545  TMap *xm = GetDataSets(d);
546  if (xm) {
547  if (!fcmap) {
548  fcmap = xm;
549  } else {
550  TIter nxds(xm);
551  while ((k = nxds())) {
552  fcmap->Add(k, xm->GetValue(k));
553  xm->Remove(k);
554  }
555  }
556  if (xm != fcmap) {
557  xm->SetOwner(kFALSE);
558  SafeDelete(xm);
559  }
560  }
561  }
562  if (!fcmap || fcmap->GetSize() <= 0) {
563  SafeDelete(fcmap);
564  // Notify
565  gSystem->Rename(flog.Data(), ferr.Data());
566  Printf("%s: ERROR: problems retrieving info about dataset '%s' (or empty dataset)", action, ds);
567  return;
568  }
569  if (gverbose > 0) fcmap->Print();
570  }
571 
572  // Which metrics
573  Int_t optMet = 0; // # of files
574  if (metrics && !strcmp(metrics, "S")) optMet = 1; // Size in bytes
575  if (gverbose > 0)
576  Printf("%s: using metrics: '%s'", action, glabMet[optMet]);
577 
578  TList distinfo;
579  if (plotonly_m) {
580  // Get the dist info
581  if (do_anadist_ds(0, 0, 0, 0, optMet, 0, &distinfo, 0, infile) != 0) {
582  Printf("%s: problems getting dist info from '%s'", action, infile);
583  }
584  } else {
585  // Name
586  TString cname(ds);
587  if (cname.BeginsWith("/")) cname.Remove(0,1);
588  Ssiz_t ilst = kNPOS;
589  if (cname.EndsWith("/") && (ilst = cname.Last('/')) != kNPOS) cname.Remove(ilst);
590  cname.ReplaceAll("/", "-");
591  cname.ReplaceAll("*", "-star-");
592  distinfo.SetName(cname);
593  TFileCollection *fc = 0;
594  TIter nxd(fcmap);
595  TFileCollection *fctot = 0;
596  while ((k = nxd()) && (fc = (TFileCollection *) fcmap->GetValue(k))) {
597  if (!fctot) {
598  // The first one
599  fctot = fc;
600  fcmap->Remove(k);
601  } else {
602  // Add
603  fctot->Add(fc);
604  }
605  }
606  // Analyse the global dataset
607  if (do_anadist_ds(fctot, servers, ignsrvs, excsrvs,
608  optMet, fnout, &distinfo, outfile, infile) != 0) {
609  Printf("%s: problems analysing dataset '%s'", action, fc ? fc->GetName() : "<undef>");
610  }
611  // Cleanup
612  SafeDelete(fcmap);
613  SafeDelete(fctot);
614  }
615 
616  // Save histo, if any
617  TString fileplot(plot), gext;
618  if (!(fileplot.IsNull())) {
619  if (fileplot.Contains(".")) {
620  gext = fileplot(fileplot.Last('.') + 1, fileplot.Length());
621  } else {
622  gext = "png";
623  }
624  const char *fmts[9] = {"png", "eps", "ps", "pdf", "svg", "gif", "xpm", "jpg", "tiff" };
625  Int_t iplot = 0;
626  while (iplot < 9 && gext != fmts[iplot]) { iplot++; }
627  if (iplot == 9) {
628  Printf("%s: graphics format '%s' not supported: switching to 'png'", action, gext.Data());
629  gext = "png";
630  }
631  if (!(fileplot.EndsWith(gext))) {
632  if (!(fileplot.EndsWith("."))) fileplot += ".";
633  fileplot += gext;
634  }
635  // Create the histogram
636  TH1D *h1d = 0;
637  if (distinfo.GetSize() > 0) {
638  h1d = new TH1D("DistInfoHist", distinfo.GetName(), distinfo.GetSize(), 0.5, distinfo.GetSize() + .5);
639  TIter nxs(&distinfo);
640  TParameter<Double_t> *ent = 0;
641  Double_t x = 0;
642  while ((ent = (TParameter<Double_t> *) nxs())) {
643  x += 1.;
644  h1d->Fill(x, ent->GetVal());
645  TString nn(TUrl(ent->GetName()).GetHost()), nnn(nn);
646  nnn.ReplaceAll(".", "");
647  if (!nnn.IsDigit() && nn.Contains(".")) nn.Remove(nn.First('.'));
648  Int_t i = h1d->FindBin(x);
649  h1d->GetXaxis()->SetBinLabel(i, nn.Data());
650  }
651  h1d->GetXaxis()->SetLabelSize(0.03);
652  } else {
653  Printf("%s: plot requested but no server found (info list is empty)!", action);
654  }
655  if (h1d) {
656  TString filehist(fileplot);
657  filehist.Remove(filehist.Last('.')+1);
658  filehist += "root";
659  TFile *f = TFile::Open(filehist, "RECREATE");
660  if (f) {
661  f->cd();
662  h1d->Write(0,TObject::kOverwrite);
663  SafeDelete(f);
664  // Write the instruction for the plotting macro
665  TString filetmp = TString::Format("%s/%s.tmp", gSystem->TempDirectory(), action);
666  FILE *ftmp = fopen(filetmp.Data(), "w");
667  if (ftmp) {
668  fprintf(ftmp, "%s %s %s", filehist.Data(), fileplot.Data(), glabMet[optMet]);
669  fclose(ftmp);
670  } else {
671  Printf("%s: problems opening temp file '%s' (errno: %d)", action, filetmp.Data(), errno);
672  Printf("%s: relevant info: %s %s %s (input to pq2PlotDist.C)",
673  action, filehist.Data(), fileplot.Data(), glabMet[optMet]);
674  }
675  } else {
676  Printf("%s: problems opening file '%s'", action, filehist.Data());
677  }
678  } else {
679  Printf("%s: histogram requested but not found", action);
680  }
681  }
682 
683  // Done
684  return;
685 }
686 
687 ////////////////////////////////////////////////////////////////////////////////
688 /// Do analysis of dataset 'fc'
689 
690 int do_anadist_ds(TFileCollection *fc, const char *servers, const char *ignsrvs,
691  const char *excsrvs, int met, const char *fnout,
692  TList *distinfo, const char *outfile, const char *infile)
693 {
694  const char *action = "pq2-ana-dist-ds";
695 
696  // Check the inputs
697  Bool_t distonly_m = (!fc && distinfo && infile && strlen(infile) > 0) ? kTRUE : kFALSE;
698  const char *dsname = 0;
699  if (!distonly_m) {
700  if (!fc) {
701  Printf("%s: dataset undefined!", action);
702  return -1;
703  }
704  dsname = fc->GetName();
705  if (fc->GetList()->GetSize() <= 0) {
706  Printf("%s: dataset '%s' is empty", action, dsname);
707  return -1;
708  }
709  } else {
710  dsname = distinfo->GetName();
711  }
712 
713  THashList *ignore = 0, *targets = 0, *exclude = 0;
714  Bool_t addmode = kFALSE;
715  if (!distonly_m) {
716  TString ss, k, key;
717  Int_t from = 0;
718  // List of servers to be ignored
719  if (ignsrvs && strlen(ignsrvs)) {
720  ss = ignsrvs;
721  from = 0;
722  while (ss.Tokenize(k, from, ",")) {
723  do_anadist_getkey(k.Data(), key);
724  if (!(key.IsNull())) {
725  if (!ignore) ignore = new THashList();
726  ignore->Add(new TObjString(key));
727  }
728  }
729  }
730  // List of servers to be excluded
731  if (excsrvs && strlen(excsrvs)) {
732  ss = excsrvs;
733  from = 0;
734  while (ss.Tokenize(k, from, ",")) {
735  do_anadist_getkey(k.Data(), key);
736  if (!(key.IsNull())) {
737  if (!exclude) exclude = new THashList();
738  exclude->Add(new TObjString(key));
739  }
740  }
741  }
742  // List of sub-TFileCollection for target servers: in add mode we complete it during
743  // the first scan
744  targets = new THashList();
745  if (servers && strlen(servers)) {
746  ss = servers;
747  if (ss.BeginsWith("+")) {
748  addmode = kTRUE;
749  ss.Remove(0,1);
750  }
751  from = 0;
752  while (ss.Tokenize(k, from, ",")) {
753  do_anadist_getkey(k.Data(), key);
754  if (!(key.IsNull())) targets->Add(new TFileCollection(key));
755  }
756  } else {
757  addmode = kTRUE;
758  }
759  }
760  // List of sub-TFileCollection for each server, so that we automatically count
761  // the sizes and totals
762  TNamed *fcsls_title = 0;
763  THashList *fcsls = 0;
764  Int_t targets_size = -1;
765  if (infile && strlen(infile)) {
766  TFile *flist = TFile::Open(infile);
767  if (flist) {
768  Printf("%s: reading info from file '%s' ", action, infile);
769  if (!(fcsls = (THashList *) flist->Get("FileDistList"))) {
770  Printf("%s: could not find starting file distribution 'FileDistList' in input file '%s' ",
771  action, infile);
772  flist->Close();
773  SafeDelete(flist);
774  SDELTRE(ignore, targets, exclude);
775  return -1;
776  }
777  // Get the title
778  fcsls_title = (TNamed *) flist->Get("FileDistList_Title");
779  // Get the targets size
780  TParameter<Int_t> *psz = (TParameter<Int_t> *) flist->Get("Targets_Size");
781  if (psz) targets_size = psz->GetVal();
782  // Close
783  flist->Close();
784  SafeDelete(flist);
785  // Add info about the current run in the title
786  if (distinfo && fcsls_title && strlen(fcsls_title->GetTitle()) > 0) {
787  TString runt(fcsls_title->GetTitle());
788  if (strcmp(distinfo->GetName(), "TList")) {
789  if (!(runt.IsNull())) runt += ",";
790  runt += distinfo->GetName();
791  fcsls_title->SetTitle(runt);
792  }
793  distinfo->SetName(fcsls_title->GetTitle());
794  }
795  } else {
796  Printf("%s: problems opening input file '%s' ", action, infile);
797  SDELTRE(ignore, targets, exclude);
798  return -1;
799  }
800  }
801  if (!fcsls) {
802  fcsls = new THashList();
803  fcsls->SetName("FileDistList");
804  fcsls_title = new TNamed("FileDistList_Title", distinfo ? distinfo->GetName() : "");
805  }
806 
807  // Set initial values for the counters, if needed
808  Long64_t totsz = 0, totfiles = 0;
809  TFileCollection *fcs = 0;
810  TIter nxfc(fcsls);
811  while ((fcs = (TFileCollection *) nxfc())) {
812  fcs->Update();
813  totfiles += fcs->GetNFiles();
814  totsz += fcs->GetTotalSize();
815  }
816 
817  // Analyze the file collection content now
818  TFileInfo *fi = 0;
819  if (fc) {
820  TIter nxfi(fc->GetList());
821  while ((fi = (TFileInfo *) nxfi())) {
822  // Get the key
823  TString key;
824  do_anadist_getkey(fi->GetCurrentUrl(), key);
825  // Ignore if requested
826  if (ignore && ignore->FindObject(key)) continue;
827  // Get the TFileCollection for this server
828  if (!(fcs = (TFileCollection *) fcsls->FindObject(key))) {
829  if (gverbose > 0)
830  Printf("%s:%s: found server '%s' ... ", action, dsname, key.Data());
831  fcs = new TFileCollection(key);
832  fcsls->Add(fcs);
833  }
834  fcs->Add(fi);
835  // In add mode, add as target, if needed
836  Bool_t excluded = (exclude && exclude->FindObject(key)) ? kTRUE : kFALSE;
837  if (!excluded) {
838  if (targets && !(fcs = (TFileCollection *) targets->FindObject(key))) {
839  if (addmode) {
840  if (gverbose > 0)
841  Printf("%s:%s: add new target server '%s' ...", action, dsname, key.Data());
842  fcs = new TFileCollection(key);
843  targets->Add(fcs);
844  }
845  }
846  if (fcs) fcs->Add(fi);
847  }
848  // Count
849  totsz += fi->GetSize();
850  totfiles++;
851  }
852 
853  // Nothing to do if no targets
854  if (targets->GetSize() <= 0) {
855  Printf("%s:%s: target servers list is empty!", action, dsname);
856  SDELETE(ignore, targets, exclude, fcsls, fcsls_title);
857  return -1;
858  } else {
859  Printf("%s:%s: %d target servers found", action, dsname, targets->GetSize());
860  if (gverbose > 0) targets->Print();
861  }
862  }
863  SDELTWO(ignore, exclude);
864 
865  // Separate into 'excess' and 'defect' lists
866  TList *excls = new TList;
867  TList *defls = new TList;
868  targets_size = (targets) ? targets->GetSize() : targets_size;
869  Double_t avgfiles = 0, avgsize = 0;
870  if (targets_size > 0) {
871  avgfiles = (Double_t)totfiles / targets_size;
872  avgsize = (Double_t)totsz / targets_size / 1024. / 1024. / 1024.;
873  Printf("%s:%s: %d servers found, %lld files; in average: %.3f files / %.3f GBs per server",
874  action, dsname, fcsls->GetSize(), totfiles, avgfiles, avgsize);
875  } else {
876  // Cannot continue;
877  Printf("%s:%s: target size is null or negative", action, dsname);
878  SDELETE(ignore, targets, exclude, fcsls, fcsls_title);
879  return -1;
880  }
881  // Before redistribution
882  if (gverbose > 0) Printf("\n%s:%s: Before redistribution:", action, dsname);
883  nxfc.Reset();
884  while ((fcs = (TFileCollection *) nxfc())) {
885  fcs->Update();
886  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
887  Double_t xdf = nfexcess / avgfiles;
888  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
889  Double_t szexcess = fcsz - avgsize;
890  Double_t xdsz = szexcess / avgsize;
891  // Fill the output histogram, if needed
892  if (distinfo) {
893  TParameter<Double_t> *ent = (TParameter<Double_t> *) distinfo->FindObject(fcs->GetName());
894  if (!ent) {
895  ent = new TParameter<Double_t>(fcs->GetName(), 0.);
896  distinfo->Add(ent);
897  }
898  if (met == 0) {
899  ent->SetVal(ent->GetVal() + (Double_t) fcs->GetNFiles());
900  } else if (met == 1) {
901  ent->SetVal(ent->GetVal() + fcsz);
902  }
903  }
904  if (gverbose > 0)
905  Printf("%s:%s: server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
906  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
907  if (fc) {
908  // Move to the appropriate list
909  Bool_t isExcess = kFALSE;
910  if (targets && targets->FindObject(fcs->GetName())) {
911  if (met == 0) {
912  if (nfexcess > 0.) isExcess = kTRUE;
913  } else if (met == 1) {
914  if (szexcess > 0.) isExcess = kTRUE;
915  }
916  } else {
917  // This server needs to be freed
918  isExcess = kTRUE;
919  }
920  if (isExcess) {
921  excls->Add(fcs);
922  } else {
923  defls->Add(fcs);
924  }
925  }
926  }
927  if (outfile && strlen(outfile)) {
928  TFile *flist = TFile::Open(outfile, "RECREATE");
929  if (flist) {
930  flist->cd();
931  Printf("%s: saving info to file '%s' ", action, outfile);
932  fcsls->Write("FileDistList", TObject::kOverwrite | TObject::kSingleKey);
933  if (fcsls_title) fcsls_title->Write("FileDistList_Title", TObject::kOverwrite);
934  if (targets) {
935  TParameter<Int_t> *psz = new TParameter<Int_t>("Targets_Size", targets->GetSize());
936  psz->Write("Targets_Size", TObject::kOverwrite);
937  }
938  flist->Close();
939  SafeDelete(flist);
940  } else {
941  Printf("%s: problems opening output file '%s' ", action, outfile);
942  return -1;
943  }
944  }
945  // Cleanup
946  fcsls->SetOwner(0);
947  SDELTWO(fcsls, fcsls_title);
948 
949  // If we just need the dist info we are done
950  if (!fc) {
951  SDELETE(targets, fcsls, fcsls_title, excls, defls);
952  return 0;
953  }
954 
955  // Notify
956  if (gverbose > 0) {
957  Printf("%s:%s: %d servers found in excess", action, dsname, excls->GetSize());
958  excls->Print();
959  Printf("%s:%s: %d servers found in defect", action, dsname, defls->GetSize());
960  defls->Print();
961  } else {
962  Printf("%s:%s: %d servers found in excess, %d in defect", action, dsname, excls->GetSize(), defls->GetSize());
963  }
964 
965  // Open output file, if requested
966  FILE *fout = 0;
967  if (fnout && strlen(fnout) > 0) {
968  if (!(fout = fopen(fnout, "a"))) {
969  Printf("%s: problems opening output file '%s' (errno: %d)", action, fnout, errno);
970  SDELETE(targets, fcsls, fcsls_title, excls, defls);
971  return -1;
972  }
973  }
974 
975  // Get the list of files to be moved
976  THashList szls;
977  TIter nxefc(excls);
978  TIter nxdfc(defls);
979  Int_t mvfiles = 0;
980  Bool_t printheader = kTRUE;
981  TFileCollection *fcd = (TFileCollection *) nxdfc();
982  while ((fcs = (TFileCollection *) nxefc())) {
983  Bool_t isTarget = (targets->FindObject(fcs->GetName())) ? kTRUE : kFALSE;
984  Long64_t fcfiles = 0;
985  Double_t fcsz = 0.;
986  TIter nxefi(fcs->GetList());
987  while ((fi = (TFileInfo *) nxefi())) {
988  if (!fcd) {
989  Printf("%s:%s: WARNING: processing list in excess '%s': no more lists in deficit!",
990  action, dsname, fcs->GetName());
991  break;
992  }
993  // Count
994  fcfiles++;
995  fcsz += (fi->GetSize() / 1024. / 1024. / 1024.) ;
996  if (!isTarget ||
997  (((met == 0) && (fcfiles > avgfiles)) || ((met == 1) && (fcsz > avgsize)))) {
998  // Write record in output file, if requested
999  TUrl u(fi->GetCurrentUrl()->GetUrl());
1000  u.SetAnchor("");
1001  u.SetOptions("");
1002  TString php(u.GetUrl());
1003  php.Remove(php.Index(u.GetFile()));
1004  Ssiz_t ilst = kNPOS;
1005  if (php.EndsWith("/") && ((ilst = php.Last('/')) != kNPOS)) php.Remove(ilst);
1006  if (fout) {
1007  fprintf(fout,"%s %s %s\n", u.GetFile(), php.Data(), fcd->GetName());
1008  } else {
1009  if (printheader) Printf(" File Source_Server Destination_Server");
1010  Printf("%s %s %s", u.GetFile(), php.Data(), fcd->GetName());
1011  printheader = kFALSE;
1012  }
1013  fcs->GetList()->Remove(fi);
1014  fcd->Add(fi);
1015  Bool_t getnext = kFALSE;
1016  if (met == 0 && fcd->GetList()->GetSize() > avgfiles) getnext = kTRUE;
1017  if (met == 1) {
1018  Long64_t xfcsz = 0;
1020  if (!ptot) {
1021  fcd->Update();
1022  ptot = new TParameter<Long64_t>(fcd->GetName(), fcd->GetTotalSize());
1023  xfcsz = ptot->GetVal();
1024  szls.Add(ptot);
1025  } else {
1026  xfcsz = ptot->GetVal();
1027  xfcsz += fi->GetSize();
1028  }
1029  if ((xfcsz / 1024. / 1024. / 1024.) > avgsize) getnext = kTRUE;
1030  }
1031  if (getnext) fcd = (TFileCollection *) nxdfc();
1032  // Count files to be moved
1033  mvfiles++;
1034  }
1035  }
1036  }
1037  // Close the file
1038  if (fout) {
1039  if ((fclose(fout)) != 0)
1040  Printf("%s: problems closing output file '%s' (errno: %d)", action, fnout, errno);
1041  }
1042  Printf("%s:%s: %d files should be moved to make the distribution even (metrics: %s)",
1043  action, dsname, mvfiles, glabMet[met]);
1044 
1045  // After redistribution
1046  if (gverbose > 0) {
1047  Printf("\n%s:%s: After redistribution:", action, dsname);
1048  nxefc.Reset();
1049  while ((fcs = (TFileCollection *) nxefc())) {
1050  fcs->Update();
1051  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
1052  Double_t xdf = nfexcess / avgfiles;
1053  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
1054  Double_t szexcess = fcsz - avgsize;
1055  Double_t xdsz = szexcess / avgsize;
1056  Printf("%s:%s: Server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
1057  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
1058  }
1059  nxdfc.Reset();
1060  while ((fcs = (TFileCollection *) nxdfc())) {
1061  fcs->Update();
1062  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
1063  Double_t xdf = nfexcess / avgfiles;
1064  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
1065  Double_t szexcess = fcsz - avgsize;
1066  Double_t xdsz = szexcess / avgsize;
1067  Printf("%s:%s: server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
1068  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
1069  }
1070  }
1071  // Cleanup
1072  SDELETE(targets, fcsls, fcsls_title, excls, defls);
1073  // Done
1074  return 0;
1075 }
1076 
1077 ////////////////////////////////////////////////////////////////////////////////
1078 /// Get the key corresponding to path 'p'.
1079 
1080 void do_anadist_getkey(const char *p, TString &key)
1081 {
1082  TUrl u(p);
1083  if (strncmp(p, u.GetProtocol(), strlen(u.GetProtocol()))) {
1084  u.SetProtocol("root");
1085  TString sport = TString::Format(":%d", u.GetPort());
1086  if (!strstr(p, sport.Data())) u.SetPort(1094);
1087  }
1088  if (gverbose > 0) Printf("do_anadist_getkey: url: %s", u.GetUrl());
1089  return do_anadist_getkey(&u, key);
1090 }
1091 
1092 ////////////////////////////////////////////////////////////////////////////////
1093 /// Get the key corresponding to url 'u'.
1094 
1096 {
1097  key = "";
1098  if (u) {
1099  TParameter<Int_t> *php = (TParameter<Int_t> *)gProtoPortMap.FindObject(u->GetProtocol());
1100  if (!php) {
1101  TUrl xu(TString::Format("%s://host//file", u->GetProtocol()));
1102  php = new TParameter<Int_t>(u->GetProtocol(), xu.GetPort());
1103  gProtoPortMap.Add(php);
1104  }
1105  if (u->GetPort() != php->GetVal()) {
1106  key.Form("%s://%s:%d", u->GetProtocol(), u->GetHost(), u->GetPort());
1107  } else {
1108  key.Form("%s://%s", u->GetProtocol(), u->GetHost());
1109  }
1110  }
1111  // Done
1112  return;
1113 }
1114 ////////////////////////////////////////////////////////////////////////////////
1115 /// Create the plot for the histogram, and save to 'fnout'.
1116 /// Format determined by th extension of fnout.
1117 
1118 int do_anadist_plot(TH1D *h1d, const char * /*fnout*/)
1119 {
1120  Printf("do_anadist_plot: will be doing a plot here ... ");
1121 
1122  if (h1d) {
1123  Printf("do_anadist_plot: we save the histo for now (to testhist.root)");
1124  TFile *f = TFile::Open("testhist.root", "RECREATE");
1125  if (f) {
1126  f->cd();
1127  h1d->Write(0,TObject::kOverwrite);
1128  SafeDelete(f);
1129  return 0;
1130  }
1131  }
1132  return -1;
1133 }
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:932
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:785
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
Definition: TH1.cxx:3565
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3244
Int_t RemoveDataSet(const char *dsname)
RemoveDataSet wrapper.
void SetPort(Int_t port)
Definition: TUrl.h:91
long long Long64_t
Definition: RtypesCore.h:69
void do_anadist(const char *ds, const char *servers, const char *ignsrvs, const char *excsrvs, const char *metrics, const char *fnout, const char *plot, const char *outfile, const char *infile)
Execute &#39;analyze-distribution&#39; for the dataset(s) described by &#39;ds&#39;.
Definition: pq2actions.cxx:527
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition: TUrl.cxx:520
Collectable string class.
Definition: TObjString.h:28
static const char * glabMet[]
Definition: pq2actions.cxx:43
Long64_t GetTotalSize() const
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
This class represents a WWW compatible URL.
Definition: TUrl.h:35
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:638
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:1374
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:248
const char * GetProtocol() const
Definition: TUrl.h:67
TFileCollection * GetDataSet(const char *ds, const char *server)
GetDataSet wrapper.
Definition: pq2wrappers.cxx:87
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1112
Regular expression class.
Definition: TRegexp.h:31
const char * GetName() const
Returns name of object.
Definition: TParameter.h:68
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
overwrite existing object with same name
Definition: TObject.h:88
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
TString ferr
Definition: pq2main.cxx:38
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
void SetVal(const AParamType &val)
Definition: TParameter.h:71
Basic string class.
Definition: TString.h:125
void do_rm(const char *dsname)
Execute &#39;rm&#39;.
Definition: pq2actions.cxx:388
int Int_t
Definition: RtypesCore.h:41
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:1004
bool Bool_t
Definition: RtypesCore.h:59
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
Int_t RegisterDataSet(const char *dsname, TFileCollection *fc, const char *opt)
RegisterDataSet wrapper.
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:595
void Reset()
Definition: TCollection.h:250
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
int do_anadist_ds(TFileCollection *fc, const char *newsrvs=0, const char *ignsrvs=0, const char *excsrvs=0, int met=0, const char *fnout=0, TList *distinfo=0, const char *outfile=0, const char *infile=0)
Do analysis of dataset &#39;fc&#39;.
Definition: pq2actions.cxx:690
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:3950
Int_t fMode
Definition: TSystem.h:128
#define SDELTRE(x, y, z)
Definition: pq2actions.cxx:54
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition: TSystem.cxx:1330
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:1956
const char * GetHost() const
Definition: TUrl.h:70
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:851
#define SafeDelete(p)
Definition: RConfig.h:509
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1357
Double_t x[n]
Definition: legend1.C:17
#define SDELTWO(x, y)
Definition: pq2actions.cxx:53
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:2365
TString fres
Definition: pq2main.cxx:39
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2231
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:477
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1458
TString flog
Definition: pq2main.cxx:37
A doubly linked list.
Definition: TList.h:44
const char * GetName() const
Returns name of object.
Definition: TObjString.h:39
Named parameter, streamable and storable.
Definition: TParameter.h:37
TObjString * ExportInfo(const char *name=0, Int_t popt=0)
Export the relevant info as a string; use &#39;name&#39; as collection name, if defined, else use GetName()...
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:321
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
write collection with single key
Definition: TObject.h:87
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
Definition: TMap.cxx:295
THashList * GetList()
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
Long64_t GetNFiles() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:561
TObject * Remove(TObject *obj)
Remove object from the list.
Definition: THashList.cxx:378
Bool_t ExistsDataSet(const char *dsname)
ExistsDataSet wrapper.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2343
Int_t pq2register(const char *dsname, const char *files, const char *opt)
Definition: pq2actions.cxx:236
char * Form(const char *fmt,...)
void do_info_server(const char *server)
Execute &#39;info-server&#39;.
Definition: pq2actions.cxx:204
#define SDELETE(x, y, z, w, t)
Definition: pq2actions.cxx:55
THashList gProtoPortMap
Definition: pq2actions.cxx:44
void SetName(const char *name)
Definition: TCollection.h:202
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:610
TMap * GetDataSets(const char *owner, const char *server, const char *opt)
GetDataSets wrapper.
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:204
int do_anadist_plot(TH1D *h1d, const char *)
Create the plot for the histogram, and save to &#39;fnout&#39;.
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition: TSystem.cxx:843
void do_cache(bool clear, const char *ds)
Execute &#39;cache&#39;.
Definition: pq2actions.cxx:60
#define Printf
Definition: TGeoToOCC.h:18
Int_t gverbose
Definition: pq2main.cxx:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
TString & Remove(Ssiz_t pos)
Definition: TString.h:619
int Ssiz_t
Definition: RtypesCore.h:63
int do_verify(const char *dsname, const char *opt, const char *redir)
Execute &#39;verify&#39;.
Definition: pq2actions.cxx:456
void SetAnchor(const char *anchor)
Definition: TUrl.h:89
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2251
void SetDefaultTreeName(const char *treeName)
double Double_t
Definition: RtypesCore.h:55
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:875
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:570
Int_t VerifyDataSet(const char *dsname, const char *opt, const char *redir)
VerifyDataSet wrapper.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition: TAxis.cxx:809
void DataSetCache(bool clear, const char *ds)
ShowCache wrapper.
Definition: pq2wrappers.cxx:50
Int_t GetPort() const
Definition: TUrl.h:81
Bool_t IsNull() const
Definition: TString.h:383
void do_put(const char *files, const char *opt)
Execute &#39;put&#39;.
Definition: pq2actions.cxx:278
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:116
virtual void Add(TObject *obj)
Definition: TList.h:87
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
Definition: file.py:1
void printDataSet(TFileCollection *fc, Int_t popt)
Formatted printout of the content of TFileCollection &#39;fc&#39;.
Definition: pq2actions.cxx:172
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
Definition: THist.hxx:284
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:834
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
void ShowDataSets(const char *ds, const char *opt)
ShowDataSets wrapper.
Definition: pq2wrappers.cxx:70
const AParamType & GetVal() const
Definition: TParameter.h:69
Class describing a generic file including meta information.
Definition: TFileInfo.h:38
void do_ls(const char *ds, const char *opt)
Execute &#39;ls&#39;.
Definition: pq2actions.cxx:71
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
void do_anadist_getkey(const char *p, TString &key)
Get the key corresponding to path &#39;p&#39;.
virtual Int_t GetSize() const
Definition: TCollection.h:180
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
const Bool_t kTRUE
Definition: RtypesCore.h:87
Long64_t GetSize() const
Definition: TFileInfo.h:79
void SetBitAll(UInt_t f)
Set the bit for all TFileInfos.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write all objects in this collection.
char name[80]
Definition: TGX11.cxx:109
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:315
virtual const char * GetName() const
Return name of this collection.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1069
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:916
void do_ls_files_server(const char *ds, const char *server)
Execute &#39;ls-files&#39;.
Definition: pq2actions.cxx:82
const char * Data() const
Definition: TString.h:345