ROOT  6.06/09
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  if (ndp > 0)
377  Printf("%s: WARNING: problems with %d dataset(s)", action, ndp);
378  else
379  Printf("%s: WARNING: some problems occured", action);
380  gSystem->Rename(flog.Data(), ferr.Data());
381  }
382  Printf("%s: %d dataset(s) registered", action, nd);
383 
384  // Done
385  return;
386 }
387 
388 ////////////////////////////////////////////////////////////////////////////////
389 /// Execute 'rm'
390 
391 void do_rm(const char *dsname)
392 {
393  const char *action = "pq2-ds";
394 
395  Int_t nd = 0;
396  Int_t printerr = 1;
397  TString ds(dsname);
398  if (!ds.Contains("*")) {
399  nd++;
400  // Remove the dataset
401  redirguard rog(flog.Data(), "a", gverbose);
402  if (RemoveDataSet(dsname) != 0) {
403  // Notify
404  gSystem->Rename(flog.Data(), ferr.Data());
405  Printf("%s: ERROR: problems removing dataset '%s'", action, dsname);
406  return;
407  }
408  printerr = 0;
409  } else {
410  // We need to scan all the datasets to find the matching ones ...
411  TMap *dss = 0;
412  { redirguard rog(flog.Data(), "a", gverbose);
413  dss = GetDataSets();
414  }
415  if (!dss) {
416  // Notify
417  gSystem->Rename(flog.Data(), ferr.Data());
418  Printf("%s: ERROR: problems retrieving info about datasets", action);
419  return;
420  }
421  printerr = 0;
422  // Iterate
423  TRegexp reg(dsname, kTRUE);
424  TIter nxd(dss);
425  TObjString *os = 0;
426  while ((os = dynamic_cast<TObjString*>(nxd()))) {
427  ds = os->GetName();
428  if (ds.Index(reg) != kNPOS) {
429  nd++;
430  // Remove the dataset
431  redirguard rog(flog.Data(), "a", gverbose);
432  if (RemoveDataSet(ds.Data()) != 0) {
433  printerr = 1;
434  // Notify
435  Printf("%s: ERROR: problems removing dataset '%s'", action, ds.Data());
436  continue;
437  }
438  }
439  }
440 
441  }
442 
443  // If no match, notify
444  if (nd == 0) {
445  Printf("%s: WARNING: no matching dataset found!", action);
446  } else {
447  Printf("%s: %d dataset(s) removed", action, nd);
448  }
449  if (printerr)
450  gSystem->Rename(flog.Data(), ferr.Data());
451 
452  // Done
453  return;
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Execute 'verify'
458 
459 int do_verify(const char *dsname, const char *opt, const char *redir)
460 {
461  const char *action = "pq2-verify";
462 
463  Int_t nd = 0, rc = -1;
464  Int_t printerr = 1;
465  TString ds(dsname);
466  if (!ds.Contains("*")) {
467  nd++;
468  // Verify the dataset
469  if ((rc = VerifyDataSet(dsname, opt, redir)) < 0) {
470  // Notify
471  Printf("%s: ERROR: problems verifing dataset '%s'", action, dsname);
472  return rc;
473  } else if (rc > 0) {
474  // Notify
475  Printf("%s: WARNING: %s: some files not yet online (staged)", action, dsname);
476  }
477  printerr = 0;
478  } else {
479  // We need to scan all the datasets to find the matching ones ...
480  TMap *dss = GetDataSets(dsname, "", "list");
481  if (!dss) {
482  // Notify
483  Printf("%s: ERROR: problems retrieving info about datasets", action);
484  return rc;
485  }
486  printerr = 0;
487  // Iterate
488  Int_t xrc = -1;
489  TIter nxd(dss);
490  TObjString *os = 0;
491  while ((os = dynamic_cast<TObjString*>(nxd()))) {
492  nd++;
493  // Verify the dataset
494  Printf("%s: start verification of dataset '%s' ...", action, os->GetName());
495  if ((xrc = VerifyDataSet(os->GetName(), opt, redir)) < 0) {
496  printerr = 1;
497  // Notify
498  Printf("%s: ERROR: problems verifying dataset '%s'", action, os->GetName());
499  continue;
500  } else if (xrc > 0) {
501  // At least one is not fully available
502  rc = 1;
503  // Notify
504  Printf("%s: WARNING: %s: some files not yet online (staged)", action, os->GetName());
505  } else if (rc < 0) {
506  // At least one is good
507  rc = 0;
508  }
509  }
510  }
511 
512  // If no match, notify
513  if (nd == 0) {
514  Printf("%s: WARNING: no matching dataset found!", action);
515  } else {
516  Printf("%s: %d dataset(s) verified", action, nd);
517  }
518  if (printerr)
519  gSystem->Rename(flog.Data(), ferr.Data());
520 
521  // Done
522  return rc;
523 }
524 
525 ////////////////////////////////////////////////////////////////////////////////
526 /// Execute 'analyze-distribution' for the dataset(s) described by 'ds'.
527 /// The result is output to the screan and the details about file movement to file
528 /// 'fnout', if defined.
529 
530 void do_anadist(const char *ds, const char *servers, const char *ignsrvs,
531  const char *excsrvs, const char *metrics, const char *fnout,
532  const char *plot, const char *outfile, const char *infile)
533 {
534  const char *action = "pq2-ana-dist";
535 
536  // Running mode
537  Bool_t plot_m = (plot && strlen(plot)) ? kTRUE : kFALSE;
538  Bool_t plotonly_m = (plot_m && infile && strlen(infile)) ? kTRUE : kFALSE;
539 
540  // We need to scan all the datasets to find the matching ones ...
541  TMap *fcmap = 0;
542  TObject *k = 0;
543  if (!plotonly_m) {
544  redirguard rog(flog.Data(), "a", gverbose);
545  TString dss(ds), d;
546  Int_t from = 0;
547  while (dss.Tokenize(d, from, ",")) {
548  TMap *xm = GetDataSets(d);
549  if (xm) {
550  if (!fcmap) {
551  fcmap = xm;
552  } else {
553  TIter nxds(xm);
554  while ((k = nxds())) {
555  fcmap->Add(k, xm->GetValue(k));
556  xm->Remove(k);
557  }
558  }
559  if (xm != fcmap) {
560  xm->SetOwner(kFALSE);
561  SafeDelete(xm);
562  }
563  }
564  }
565  if (!fcmap || fcmap->GetSize() <= 0) {
566  SafeDelete(fcmap);
567  // Notify
568  gSystem->Rename(flog.Data(), ferr.Data());
569  Printf("%s: ERROR: problems retrieving info about dataset '%s' (or empty dataset)", action, ds);
570  return;
571  }
572  if (gverbose > 0) fcmap->Print();
573  }
574 
575  // Which metrics
576  Int_t optMet = 0; // # of files
577  if (metrics && !strcmp(metrics, "S")) optMet = 1; // Size in bytes
578  if (gverbose > 0)
579  Printf("%s: using metrics: '%s'", action, glabMet[optMet]);
580 
581  TList distinfo;
582  if (plotonly_m) {
583  // Get the dist info
584  if (do_anadist_ds(0, 0, 0, 0, optMet, 0, &distinfo, 0, infile) != 0) {
585  Printf("%s: problems getting dist info from '%s'", action, infile);
586  }
587  } else {
588  // Name
589  TString cname(ds);
590  if (cname.BeginsWith("/")) cname.Remove(0,1);
591  Ssiz_t ilst = kNPOS;
592  if (cname.EndsWith("/") && (ilst = cname.Last('/')) != kNPOS) cname.Remove(ilst);
593  cname.ReplaceAll("/", "-");
594  cname.ReplaceAll("*", "-star-");
595  distinfo.SetName(cname);
596  TFileCollection *fc = 0;
597  TIter nxd(fcmap);
598  TFileCollection *fctot = 0;
599  while ((k = nxd()) && (fc = (TFileCollection *) fcmap->GetValue(k))) {
600  if (!fctot) {
601  // The first one
602  fctot = fc;
603  fcmap->Remove(k);
604  } else {
605  // Add
606  fctot->Add(fc);
607  }
608  }
609  // Analyse the global dataset
610  if (do_anadist_ds(fctot, servers, ignsrvs, excsrvs,
611  optMet, fnout, &distinfo, outfile, infile) != 0) {
612  Printf("%s: problems analysing dataset '%s'", action, fc ? fc->GetName() : "<undef>");
613  }
614  // Cleanup
615  SafeDelete(fcmap);
616  SafeDelete(fctot);
617  }
618 
619  // Save histo, if any
620  TString fileplot(plot), gext;
621  if (!(fileplot.IsNull())) {
622  if (fileplot.Contains(".")) {
623  gext = fileplot(fileplot.Last('.') + 1, fileplot.Length());
624  } else {
625  gext = "png";
626  }
627  const char *fmts[9] = {"png", "eps", "ps", "pdf", "svg", "gif", "xpm", "jpg", "tiff" };
628  Int_t iplot = 0;
629  while (iplot < 9 && gext != fmts[iplot]) { iplot++; }
630  if (iplot == 9) {
631  Printf("%s: graphics format '%s' not supported: switching to 'png'", action, gext.Data());
632  gext = "png";
633  }
634  if (!(fileplot.EndsWith(gext))) {
635  if (!(fileplot.EndsWith("."))) fileplot += ".";
636  fileplot += gext;
637  }
638  // Create the histogram
639  TH1D *h1d = 0;
640  if (distinfo.GetSize() > 0) {
641  h1d = new TH1D("DistInfoHist", distinfo.GetName(), distinfo.GetSize(), 0.5, distinfo.GetSize() + .5);
642  TIter nxs(&distinfo);
643  TParameter<Double_t> *ent = 0;
644  Double_t x = 0;
645  while ((ent = (TParameter<Double_t> *) nxs())) {
646  x += 1.;
647  h1d->Fill(x, ent->GetVal());
648  TString nn(TUrl(ent->GetName()).GetHost()), nnn(nn);
649  nnn.ReplaceAll(".", "");
650  if (!nnn.IsDigit() && nn.Contains(".")) nn.Remove(nn.First('.'));
651  Int_t i = h1d->FindBin(x);
652  h1d->GetXaxis()->SetBinLabel(i, nn.Data());
653  }
654  h1d->GetXaxis()->SetLabelSize(0.03);
655  } else {
656  Printf("%s: plot requested but no server found (info list is empty)!", action);
657  }
658  if (h1d) {
659  TString filehist(fileplot);
660  filehist.Remove(filehist.Last('.')+1);
661  filehist += "root";
662  TFile *f = TFile::Open(filehist, "RECREATE");
663  if (f) {
664  f->cd();
665  h1d->Write(0,TObject::kOverwrite);
666  SafeDelete(f);
667  // Write the instruction for the plotting macro
668  TString filetmp = TString::Format("%s/%s.tmp", gSystem->TempDirectory(), action);
669  FILE *ftmp = fopen(filetmp.Data(), "w");
670  if (ftmp) {
671  fprintf(ftmp, "%s %s %s", filehist.Data(), fileplot.Data(), glabMet[optMet]);
672  fclose(ftmp);
673  } else {
674  Printf("%s: problems opening temp file '%s' (errno: %d)", action, filetmp.Data(), errno);
675  Printf("%s: relevant info: %s %s %s (input to pq2PlotDist.C)",
676  action, filehist.Data(), fileplot.Data(), glabMet[optMet]);
677  }
678  } else {
679  Printf("%s: problems opening file '%s'", action, filehist.Data());
680  }
681  } else {
682  Printf("%s: histogram requested but not found", action);
683  }
684  }
685 
686  // Done
687  return;
688 }
689 
690 ////////////////////////////////////////////////////////////////////////////////
691 /// Do analysis of dataset 'fc'
692 
693 int do_anadist_ds(TFileCollection *fc, const char *servers, const char *ignsrvs,
694  const char *excsrvs, int met, const char *fnout,
695  TList *distinfo, const char *outfile, const char *infile)
696 {
697  const char *action = "pq2-ana-dist-ds";
698 
699  // Check the inputs
700  Bool_t distonly_m = (!fc && distinfo && infile && strlen(infile) > 0) ? kTRUE : kFALSE;
701  const char *dsname = 0;
702  if (!distonly_m) {
703  if (!fc) {
704  Printf("%s: dataset undefined!", action);
705  return -1;
706  }
707  dsname = fc->GetName();
708  if (fc->GetList()->GetSize() <= 0) {
709  Printf("%s: dataset '%s' is empty", action, dsname);
710  return -1;
711  }
712  } else {
713  dsname = distinfo->GetName();
714  }
715 
716  THashList *ignore = 0, *targets = 0, *exclude = 0;
717  Bool_t addmode = kFALSE;
718  if (!distonly_m) {
719  TString ss, k, key;
720  Int_t from = 0;
721  // List of servers to be ignored
722  if (ignsrvs && strlen(ignsrvs)) {
723  ss = ignsrvs;
724  from = 0;
725  while (ss.Tokenize(k, from, ",")) {
726  do_anadist_getkey(k.Data(), key);
727  if (!(key.IsNull())) {
728  if (!ignore) ignore = new THashList();
729  ignore->Add(new TObjString(key));
730  }
731  }
732  }
733  // List of servers to be excluded
734  if (excsrvs && strlen(excsrvs)) {
735  ss = excsrvs;
736  from = 0;
737  while (ss.Tokenize(k, from, ",")) {
738  do_anadist_getkey(k.Data(), key);
739  if (!(key.IsNull())) {
740  if (!exclude) exclude = new THashList();
741  exclude->Add(new TObjString(key));
742  }
743  }
744  }
745  // List of sub-TFileCollection for target servers: in add mode we complete it during
746  // the first scan
747  targets = new THashList();
748  if (servers && strlen(servers)) {
749  ss = servers;
750  if (ss.BeginsWith("+")) {
751  addmode = kTRUE;
752  ss.Remove(0,1);
753  }
754  from = 0;
755  while (ss.Tokenize(k, from, ",")) {
756  do_anadist_getkey(k.Data(), key);
757  if (!(key.IsNull())) targets->Add(new TFileCollection(key));
758  }
759  } else {
760  addmode = kTRUE;
761  }
762  }
763  // List of sub-TFileCollection for each server, so that we automatically count
764  // the sizes and totals
765  TNamed *fcsls_title = 0;
766  THashList *fcsls = 0;
767  Int_t targets_size = -1;
768  if (infile && strlen(infile)) {
769  TFile *flist = TFile::Open(infile);
770  if (flist) {
771  Printf("%s: reading info from file '%s' ", action, infile);
772  if (!(fcsls = (THashList *) flist->Get("FileDistList"))) {
773  Printf("%s: could not find starting file distribution 'FileDistList' in input file '%s' ",
774  action, infile);
775  flist->Close();
776  SafeDelete(flist);
777  SDELTRE(ignore, targets, exclude);
778  return -1;
779  }
780  // Get the title
781  fcsls_title = (TNamed *) flist->Get("FileDistList_Title");
782  // Get the targets size
783  TParameter<Int_t> *psz = (TParameter<Int_t> *) flist->Get("Targets_Size");
784  if (psz) targets_size = psz->GetVal();
785  // Close
786  flist->Close();
787  SafeDelete(flist);
788  // Add info about the current run in the title
789  if (distinfo && fcsls_title && strlen(fcsls_title->GetTitle()) > 0) {
790  TString runt(fcsls_title->GetTitle());
791  if (strcmp(distinfo->GetName(), "TList")) {
792  if (!(runt.IsNull())) runt += ",";
793  runt += distinfo->GetName();
794  fcsls_title->SetTitle(runt);
795  }
796  distinfo->SetName(fcsls_title->GetTitle());
797  }
798  } else {
799  Printf("%s: problems opening input file '%s' ", action, infile);
800  SDELTRE(ignore, targets, exclude);
801  return -1;
802  }
803  }
804  if (!fcsls) {
805  fcsls = new THashList();
806  fcsls->SetName("FileDistList");
807  fcsls_title = new TNamed("FileDistList_Title", distinfo ? distinfo->GetName() : "");
808  }
809 
810  // Set initial values for the counters, if needed
811  Long64_t totsz = 0, totfiles = 0;
812  TFileCollection *fcs = 0;
813  TIter nxfc(fcsls);
814  while ((fcs = (TFileCollection *) nxfc())) {
815  fcs->Update();
816  totfiles += fcs->GetNFiles();
817  totsz += fcs->GetTotalSize();
818  }
819 
820  // Analyze the file collection content now
821  TFileInfo *fi = 0;
822  if (fc) {
823  TIter nxfi(fc->GetList());
824  while ((fi = (TFileInfo *) nxfi())) {
825  // Get the key
826  TString key;
827  do_anadist_getkey(fi->GetCurrentUrl(), key);
828  // Ignore if requested
829  if (ignore && ignore->FindObject(key)) continue;
830  // Get the TFileCollection for this server
831  if (!(fcs = (TFileCollection *) fcsls->FindObject(key))) {
832  if (gverbose > 0)
833  Printf("%s:%s: found server '%s' ... ", action, dsname, key.Data());
834  fcs = new TFileCollection(key);
835  fcsls->Add(fcs);
836  }
837  fcs->Add(fi);
838  // In add mode, add as target, if needed
839  Bool_t excluded = (exclude && exclude->FindObject(key)) ? kTRUE : kFALSE;
840  if (!excluded) {
841  if (targets && !(fcs = (TFileCollection *) targets->FindObject(key))) {
842  if (addmode) {
843  if (gverbose > 0)
844  Printf("%s:%s: add new target server '%s' ...", action, dsname, key.Data());
845  fcs = new TFileCollection(key);
846  targets->Add(fcs);
847  }
848  }
849  if (fcs) fcs->Add(fi);
850  }
851  // Count
852  totsz += fi->GetSize();
853  totfiles++;
854  }
855 
856  // Nothing to do if no targets
857  if (targets->GetSize() <= 0) {
858  Printf("%s:%s: target servers list is empty!", action, dsname);
859  SDELETE(ignore, targets, exclude, fcsls, fcsls_title);
860  return -1;
861  } else {
862  Printf("%s:%s: %d target servers found", action, dsname, targets->GetSize());
863  if (gverbose > 0) targets->Print();
864  }
865  }
866  SDELTWO(ignore, exclude);
867 
868  // Separate into 'excess' and 'defect' lists
869  TList *excls = new TList;
870  TList *defls = new TList;
871  targets_size = (targets) ? targets->GetSize() : targets_size;
872  Double_t avgfiles = 0, avgsize = 0;
873  if (targets_size > 0) {
874  avgfiles = (Double_t)totfiles / targets_size;
875  avgsize = (Double_t)totsz / targets_size / 1024. / 1024. / 1024.;
876  Printf("%s:%s: %d servers found, %lld files; in average: %.3f files / %.3f GBs per server",
877  action, dsname, fcsls->GetSize(), totfiles, avgfiles, avgsize);
878  } else {
879  // Cannot continue;
880  Printf("%s:%s: target size is null or negative", action, dsname);
881  SDELETE(ignore, targets, exclude, fcsls, fcsls_title);
882  return -1;
883  }
884  // Before redistribution
885  if (gverbose > 0) Printf("\n%s:%s: Before redistribution:", action, dsname);
886  nxfc.Reset();
887  while ((fcs = (TFileCollection *) nxfc())) {
888  fcs->Update();
889  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
890  Double_t xdf = nfexcess / avgfiles;
891  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
892  Double_t szexcess = fcsz - avgsize;
893  Double_t xdsz = szexcess / avgsize;
894  // Fill the output histogram, if needed
895  if (distinfo) {
896  TParameter<Double_t> *ent = (TParameter<Double_t> *) distinfo->FindObject(fcs->GetName());
897  if (!ent) {
898  ent = new TParameter<Double_t>(fcs->GetName(), 0.);
899  distinfo->Add(ent);
900  }
901  if (met == 0) {
902  ent->SetVal(ent->GetVal() + (Double_t) fcs->GetNFiles());
903  } else if (met == 1) {
904  ent->SetVal(ent->GetVal() + fcsz);
905  }
906  }
907  if (gverbose > 0)
908  Printf("%s:%s: server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
909  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
910  if (fc) {
911  // Move to the appropriate list
912  Bool_t isExcess = kFALSE;
913  if (targets && targets->FindObject(fcs->GetName())) {
914  if (met == 0) {
915  if (nfexcess > 0.) isExcess = kTRUE;
916  } else if (met == 1) {
917  if (szexcess > 0.) isExcess = kTRUE;
918  }
919  } else {
920  // This server needs to be freed
921  isExcess = kTRUE;
922  }
923  if (isExcess) {
924  excls->Add(fcs);
925  } else {
926  defls->Add(fcs);
927  }
928  }
929  }
930  if (outfile && strlen(outfile)) {
931  TFile *flist = TFile::Open(outfile, "RECREATE");
932  if (flist) {
933  flist->cd();
934  Printf("%s: saving info to file '%s' ", action, outfile);
935  fcsls->Write("FileDistList", TObject::kOverwrite | TObject::kSingleKey);
936  if (fcsls_title) fcsls_title->Write("FileDistList_Title", TObject::kOverwrite);
937  if (targets) {
938  TParameter<Int_t> *psz = new TParameter<Int_t>("Targets_Size", targets->GetSize());
939  psz->Write("Targets_Size", TObject::kOverwrite);
940  }
941  flist->Close();
942  SafeDelete(flist);
943  } else {
944  Printf("%s: problems opening output file '%s' ", action, outfile);
945  return -1;
946  }
947  }
948  // Cleanup
949  fcsls->SetOwner(0);
950  SDELTWO(fcsls, fcsls_title);
951 
952  // If we just need the dist info we are done
953  if (!fc) {
954  SDELETE(targets, fcsls, fcsls_title, excls, defls);
955  return 0;
956  }
957 
958  // Notify
959  if (gverbose > 0) {
960  Printf("%s:%s: %d servers found in excess", action, dsname, excls->GetSize());
961  excls->Print();
962  Printf("%s:%s: %d servers found in defect", action, dsname, defls->GetSize());
963  defls->Print();
964  } else {
965  Printf("%s:%s: %d servers found in excess, %d in defect", action, dsname, excls->GetSize(), defls->GetSize());
966  }
967 
968  // Open output file, if requested
969  FILE *fout = 0;
970  if (fnout && strlen(fnout) > 0) {
971  if (!(fout = fopen(fnout, "a"))) {
972  Printf("%s: problems opening output file '%s' (errno: %d)", action, fnout, errno);
973  SDELETE(targets, fcsls, fcsls_title, excls, defls);
974  return -1;
975  }
976  }
977 
978  // Get the list of files to be moved
979  THashList szls;
980  TIter nxefc(excls);
981  TIter nxdfc(defls);
982  Int_t mvfiles = 0;
983  Bool_t printheader = kTRUE;
984  TFileCollection *fcd = (TFileCollection *) nxdfc();
985  while ((fcs = (TFileCollection *) nxefc())) {
986  Bool_t isTarget = (targets->FindObject(fcs->GetName())) ? kTRUE : kFALSE;
987  Long64_t fcfiles = 0;
988  Double_t fcsz = 0.;
989  TIter nxefi(fcs->GetList());
990  while ((fi = (TFileInfo *) nxefi())) {
991  if (!fcd) {
992  Printf("%s:%s: WARNING: processing list in excess '%s': no more lists in deficit!",
993  action, dsname, fcs->GetName());
994  break;
995  }
996  // Count
997  fcfiles++;
998  fcsz += (fi->GetSize() / 1024. / 1024. / 1024.) ;
999  if (!isTarget ||
1000  (((met == 0) && (fcfiles > avgfiles)) || ((met == 1) && (fcsz > avgsize)))) {
1001  // Write record in output file, if requested
1002  TUrl u(fi->GetCurrentUrl()->GetUrl());
1003  u.SetAnchor("");
1004  u.SetOptions("");
1005  TString php(u.GetUrl());
1006  php.Remove(php.Index(u.GetFile()));
1007  Ssiz_t ilst = kNPOS;
1008  if (php.EndsWith("/") && ((ilst = php.Last('/')) != kNPOS)) php.Remove(ilst);
1009  if (fout) {
1010  fprintf(fout,"%s %s %s\n", u.GetFile(), php.Data(), fcd->GetName());
1011  } else {
1012  if (printheader) Printf(" File Source_Server Destination_Server");
1013  Printf("%s %s %s", u.GetFile(), php.Data(), fcd->GetName());
1014  printheader = kFALSE;
1015  }
1016  fcs->GetList()->Remove(fi);
1017  fcd->Add(fi);
1018  Bool_t getnext = kFALSE;
1019  if (met == 0 && fcd->GetList()->GetSize() > avgfiles) getnext = kTRUE;
1020  if (met == 1) {
1021  Long64_t xfcsz = 0;
1023  if (!ptot) {
1024  fcd->Update();
1025  ptot = new TParameter<Long64_t>(fcd->GetName(), fcd->GetTotalSize());
1026  xfcsz = ptot->GetVal();
1027  szls.Add(ptot);
1028  } else {
1029  xfcsz = ptot->GetVal();
1030  xfcsz += fi->GetSize();
1031  }
1032  if ((xfcsz / 1024. / 1024. / 1024.) > avgsize) getnext = kTRUE;
1033  }
1034  if (getnext) fcd = (TFileCollection *) nxdfc();
1035  // Count files to be moved
1036  mvfiles++;
1037  }
1038  }
1039  }
1040  // Close the file
1041  if (fout) {
1042  if ((fclose(fout)) != 0)
1043  Printf("%s: problems closing output file '%s' (errno: %d)", action, fnout, errno);
1044  }
1045  Printf("%s:%s: %d files should be moved to make the distribution even (metrics: %s)",
1046  action, dsname, mvfiles, glabMet[met]);
1047 
1048  // After redistribution
1049  if (gverbose > 0) {
1050  Printf("\n%s:%s: After redistribution:", action, dsname);
1051  nxefc.Reset();
1052  while ((fcs = (TFileCollection *) nxefc())) {
1053  fcs->Update();
1054  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
1055  Double_t xdf = nfexcess / avgfiles;
1056  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
1057  Double_t szexcess = fcsz - avgsize;
1058  Double_t xdsz = szexcess / avgsize;
1059  Printf("%s:%s: Server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
1060  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
1061  }
1062  nxdfc.Reset();
1063  while ((fcs = (TFileCollection *) nxdfc())) {
1064  fcs->Update();
1065  Long64_t nfexcess = fcs->GetNFiles() - (Long64_t) avgfiles;
1066  Double_t xdf = nfexcess / avgfiles;
1067  Double_t fcsz = fcs->GetTotalSize() / 1024. / 1024. / 1024.;
1068  Double_t szexcess = fcsz - avgsize;
1069  Double_t xdsz = szexcess / avgsize;
1070  Printf("%s:%s: server %s: %lld files (diff: %lld, %.3f) - %.3f GBs (diff: %.3f, %.3f)",
1071  action, dsname, fcs->GetName(), fcs->GetNFiles(), nfexcess, xdf, fcsz, szexcess, xdsz);
1072  }
1073  }
1074  // Cleanup
1075  SDELETE(targets, fcsls, fcsls_title, excls, defls);
1076  // Done
1077  return 0;
1078 }
1079 
1080 ////////////////////////////////////////////////////////////////////////////////
1081 /// Get the key corresponding to path 'p'.
1082 
1083 void do_anadist_getkey(const char *p, TString &key)
1084 {
1085  TUrl u(p);
1086  if (strncmp(p, u.GetProtocol(), strlen(u.GetProtocol()))) {
1087  u.SetProtocol("root");
1088  TString sport = TString::Format(":%d", u.GetPort());
1089  if (!strstr(p, sport.Data())) u.SetPort(1094);
1090  }
1091  if (gverbose > 0) Printf("do_anadist_getkey: url: %s", u.GetUrl());
1092  return do_anadist_getkey(&u, key);
1093 }
1094 
1095 ////////////////////////////////////////////////////////////////////////////////
1096 /// Get the key corresponding to url 'u'.
1097 
1099 {
1100  key = "";
1101  if (u) {
1102  TParameter<Int_t> *php = (TParameter<Int_t> *)gProtoPortMap.FindObject(u->GetProtocol());
1103  if (!php) {
1104  TUrl xu(TString::Format("%s://host//file", u->GetProtocol()));
1105  php = new TParameter<Int_t>(u->GetProtocol(), xu.GetPort());
1106  gProtoPortMap.Add(php);
1107  }
1108  if (u->GetPort() != php->GetVal()) {
1109  key.Form("%s://%s:%d", u->GetProtocol(), u->GetHost(), u->GetPort());
1110  } else {
1111  key.Form("%s://%s", u->GetProtocol(), u->GetHost());
1112  }
1113  }
1114  // Done
1115  return;
1116 }
1117 ////////////////////////////////////////////////////////////////////////////////
1118 /// Create the plot for the histogram, and save to 'fnout'.
1119 /// Format determined by th extension of fnout.
1120 
1121 int do_anadist_plot(TH1D *h1d, const char */*fnout*/)
1122 {
1123  Printf("do_anadist_plot: will be doing a plot here ... ");
1124 
1125  if (h1d) {
1126  Printf("do_anadist_plot: we save the histo for now (to testhist.root)");
1127  TFile *f = TFile::Open("testhist.root", "RECREATE");
1128  if (f) {
1129  f->cd();
1130  h1d->Write(0,TObject::kOverwrite);
1131  SafeDelete(f);
1132  return 0;
1133  }
1134  }
1135  return -1;
1136 }
const char * GetHost() const
Definition: TUrl.h:76
const char * GetName() const
Returns name of object.
Definition: TObjString.h:42
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:928
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:823
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
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:3478
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:864
TMap * GetDataSets(const char *owner="", const char *server="", const char *opt=0)
GetDataSets wrapper.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3159
Long64_t GetNFiles() const
void SetPort(Int_t port)
Definition: TUrl.h:97
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 'analyze-distribution' for the dataset(s) described by 'ds'.
Definition: pq2actions.cxx:530
virtual const char * GetName() const
Return name of this collection.
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition: TUrl.cxx:518
Collectable string class.
Definition: TObjString.h:32
static const char * glabMet[]
Definition: pq2actions.cxx:43
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:212
This class represents a WWW compatible URL.
Definition: TUrl.h:41
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1363
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * GetProtocol() const
Definition: TUrl.h:73
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
Regular expression class.
Definition: TRegexp.h:35
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
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:52
TString ferr
Definition: pq2main.cxx:38
void SetVal(const AParamType &val)
Definition: TParameter.h:79
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1447
Basic string class.
Definition: TString.h:137
void do_rm(const char *dsname)
Execute 'rm'.
Definition: pq2actions.cxx:391
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
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
Int_t VerifyDataSet(const char *dsname, const char *opt=0, const char *redir=0)
VerifyDataSet wrapper.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:592
THist< 1, double > TH1D
Definition: THist.h:314
void Reset()
Definition: TCollection.h:161
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 'fc'.
Definition: pq2actions.cxx:693
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
#define SDELTRE(x, y, z)
Definition: pq2actions.cxx:54
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition: TSystem.cxx:1319
const char * Data() const
Definition: TString.h:349
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
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1346
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:2334
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:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void DataSetCache(bool clear, const char *ds)
ShowCache wrapper.
Definition: pq2wrappers.cxx:50
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:234
TString flog
Definition: pq2main.cxx:37
A doubly linked list.
Definition: TList.h:47
Int_t GetPort() const
Definition: TUrl.h:87
Named parameter, streamable and storable.
Definition: TParameter.h:49
Int_t RemoveDataSet(const char *dsname)
RemoveDataSet wrapper.
TFileCollection * GetDataSet(const char *ds, const char *server="")
GetDataSet wrapper.
Definition: pq2wrappers.cxx:87
TObjString * ExportInfo(const char *name=0, Int_t popt=0)
Export the relevant info as a string; use 'name' as collection name, if defined, else use GetName()...
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
return
Definition: TBase64.cxx:62
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
Definition: TMap.cxx:294
const char * GetName() const
Returns name of object.
Definition: TParameter.h:76
THashList * GetList()
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
TObject * Remove(TObject *obj)
Remove object from the list.
Definition: THashList.cxx:284
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
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 'info-server'.
Definition: pq2actions.cxx:204
#define SDELETE(x, y, z, w, t)
Definition: pq2actions.cxx:55
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
THashList gProtoPortMap
Definition: pq2actions.cxx:44
Bool_t IsNull() const
Definition: TString.h:387
void SetName(const char *name)
Definition: TCollection.h:116
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:613
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:186
int do_anadist_plot(TH1D *h1d, const char *)
Create the plot for the histogram, and save to 'fnout'.
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition: TSystem.cxx:839
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2240
void do_cache(bool clear, const char *ds)
Execute 'cache'.
Definition: pq2actions.cxx:60
#define Printf
Definition: TGeoToOCC.h:18
Int_t gverbose
Definition: pq2main.cxx:40
Long64_t GetTotalSize() const
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:385
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
int Ssiz_t
Definition: RtypesCore.h:63
int do_verify(const char *dsname, const char *opt, const char *redir)
Execute 'verify'.
Definition: pq2actions.cxx:459
void SetAnchor(const char *anchor)
Definition: TUrl.h:95
virtual Int_t GetSize() const
Definition: TCollection.h:95
void SetDefaultTreeName(const char *treeName)
double f(double x)
double Double_t
Definition: RtypesCore.h:55
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition: TAxis.cxx:793
void ShowDataSets(const char *ds, const char *opt="")
ShowDataSets wrapper.
Definition: pq2wrappers.cxx:70
#define name(a, b)
Definition: linkTestLib0.cpp:5
void do_put(const char *files, const char *opt)
Execute 'put'.
Definition: pq2actions.cxx:278
Mother of all ROOT objects.
Definition: TObject.h:58
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:246
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:126
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
void printDataSet(TFileCollection *fc, Int_t popt)
Formatted printout of the content of TFileCollection 'fc'.
Definition: pq2actions.cxx:172
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:830
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
const AParamType & GetVal() const
Definition: TParameter.h:77
void do_ls(const char *ds, const char *opt)
Execute 'ls'.
Definition: pq2actions.cxx:71
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
void do_anadist_getkey(const char *p, TString &key)
Get the key corresponding to path 'p'.
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
Int_t RegisterDataSet(const char *dsname, TFileCollection *fc, const char *opt="")
RegisterDataSet wrapper.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:379
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.
Long64_t GetSize() const
Definition: TFileInfo.h:91
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:466
Bool_t ExistsDataSet(const char *dsname)
ExistsDataSet wrapper.
TAxis * GetXaxis()
Definition: TH1.h:319
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1058
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
void do_ls_files_server(const char *ds, const char *server)
Execute 'ls-files'.
Definition: pq2actions.cxx:82