43 const
char *textfile,
Int_t nfiles,
Int_t firstfile)
44 :
TNamed(name, title), fList(0), fMetaDataList(0), fDefaultTree(),
45 fTotalSize(0), fNFiles(0), fNStagedFiles(0), fNCorruptFiles(0)
50 fMetaDataList =
new TList;
53 AddFromFile(textfile, nfiles, firstfile);
76 Warning(
"Add",
"file: '%s' already in the list - ignoring",
121 Int_t ff = (!all && (firstfile < 1)) ? 1 : firstfile;
123 while (f.good() && (all || nf < nfiles)) {
129 if (all || nn >= ff) {
140 Error(
"AddFromFile",
"unable to open file %s (%s)", textfile, fn.
Data());
160 Error(
"Add",
"input dir undefined");
183 Error(
"Add",
"directory %s cannot be opened",
241 Info(
"RemoveDuplicates",
"%d duplicates found and removed", nr);
258 while ((fileInfo = dynamic_cast<TFileInfo*>(iter.
Next()))) {
260 subset->
Add(fileInfo);
284 Error(
"Add",
"attempt to add object of class: %s to a %s",
331 while ((fileInfo = dynamic_cast<TFileInfo*> (iter.
Next()))) {
350 while ((obj = metaDataIter.Next())) {
400 TPMERegexp re(
"(^|;| )filter:([SsCc]+)( |;|$)", 4);
401 if (re.
Match(option) == 4) {
407 Printf(
"TFileCollection %s - %s contains: %lld files with a size of"
408 " %lld bytes, %.1f %% staged - default tree name: '%s'",
413 Printf(
"The files contain the following trees:");
417 while ((metaData = dynamic_cast<TFileInfoMeta*>(metaDataIter.
Next()))) {
426 Printf(
"The collection contains the following files:");
439 bS = bs = bC = bc =
kFALSE;
447 if (!bc && !bC) bc = bC =
kTRUE;
448 if (!bs && !bS) bs = bS =
kTRUE;
455 Printf(
"\033[1m #. SC | Entries | Size | URL\033[m");
460 while ((info = dynamic_cast<TFileInfo *>(it.
Next()))) {
469 if ( ((s && bS) || (!s && bs)) && ((c && bC) || (!c && bc)) ) {
481 const char *curUrlStr = curUrl ? curUrl->
GetUrl() :
"n.a.";
482 Printf(
"\033[1m%4u.\033[m %c%c | %-7s | %6.1lf %s | %s",
484 (s ?
'S' :
's'), (c ?
'C' :
'c'),
485 ((entries > 0) ?
Form(
"% 7d", entries) :
"n.a."),
486 sz, um.
Data(), curUrlStr);
490 while ((url = info->
NextUrl())) {
501 Printf(
">> There are \033[1m%u\033[m file(s) in dataset: "
502 "\033[1m%u (%5.1f%%)\033[m matched your criteria (%s)",
503 countAll, countMatch,
507 Printf(
">> Total size : \033[1m%.1f %s\033[m", sz, um.
Data());
509 Printf(
">> Corrupted (C) : \033[1m%5.1f %%\033[m",
514 Printf(
">> No files in dataset");
518 Printf(
">> Default tree : \033[1m%s\033[m",
519 (treeName ? treeName :
"(no default tree)"));
529 static const char *ums[] = {
"byt",
"KiB",
"MiB",
"GiB",
"TiB" };
530 Int_t maxDiv =
sizeof(ums)/
sizeof(
const char *);
534 while ((b >= 1024.) && (nDiv+1 < maxDiv)) {
553 while ((fileInfo = dynamic_cast<TFileInfo*>(iter.
Next()))) {
556 while ((url = fileInfo->
NextUrl()))
572 while ((fileInfo = dynamic_cast<TFileInfo*>(iter.
Next())))
586 while ((fileInfo = dynamic_cast<TFileInfo*>(iter.
Next())))
602 while ((metaData = dynamic_cast<TFileInfoMeta*>(metaDataIter.
Next()))) {
617 if (!tree || !*tree) {
664 while ((fileInfo = dynamic_cast<TFileInfo*>(iter.
Next())))
712 treeInfo +=
TString::Format(
", %3.1f %% of total", frac->GetEntries() / 10.);
728 if (popt == 0) treeInfo.
Resize(25);
731 const char *unit[4] = {
"kB",
"MB",
"GB",
"TB"};
735 while (xsz > 1024 && k < 3) {
748 outs =
new TObjString(
Form(
"%s %lld files, %lld %s, staged %d %%, tree: %s", dsname.
Data(),
769 if (!server || strlen(server) <= 0) {
770 Info(
"GetFilesOnServer",
"server undefined - do nothing");
776 Info(
"GetFilesOnServer",
"the list is empty - do nothing");
782 TString srv, scheme(
"root"), port;
787 Info(
"GetFilesOnServer",
"searching for files on server: '%s' (input: '%s')",
798 fc->SetTitle(title.
Data());
825 Info(
"GetFilesOnServer",
"adding: %s", xu->
GetUrl());
831 if (fc->GetList()->GetSize() <= 0) {
834 Info(
"GetFilesOnServer",
"dataset '%s' has no files on server: '%s' (searched for: '%s')",
864 Info(
"GetFilesPerServer",
"the list is empty - do nothing");
870 if (exclude && strlen(exclude) > 0) {
874 TString srvs(exclude), s, srv, scheme, port;
876 while (srvs.Tokenize(s, from,
",")) {
903 while ((xurl = (curronly) ? curl : fi->
NextUrl())) {
910 }
else if (excl && xurl->
GetPort() > 0) {
936 Info(
"GetFilesPerServer",
"found server: '%s' (fc: %p)", key.
Data(),
fc);
975 if (excl)
delete excl;
const char * GetDefaultTreeName() const
Returns the tree set with SetDefaultTreeName if set Returns the name of the first tree in the meta da...
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual Int_t GetEntries() const
virtual const char * GetTitle() const
Returns title of object.
Long64_t GetNFiles() const
ClassImp(TFileCollection) TFileCollection
TFileCollection constructor.
TFileCollection * GetFilesOnServer(const char *server)
Return the subset of files served by 'server'.
void SetAnchor(const char *anchor)
Calls TUrl::SetAnchor() for all URLs contained in all TFileInfos.
const TString GetScheme() const
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Collectable string class.
TObject * FindObject(const char *name) const
Find object using its name.
This class represents a WWW compatible URL.
TString & ReplaceAll(const TString &s1, const TString &s2)
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.
virtual void SetName(const char *name)
Change (i.e.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * GetProtocol() const
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Regular expression class.
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
This class represents a RFC 3986 compatible URI.
Long64_t GetTotalEntries(const char *tree) const
Returns the number of entries for the specified tree (retrieved from meta data).
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Insert(Ssiz_t pos, const char *s)
Bool_t R_ISREG(Int_t mode)
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
TFileInfoMeta * GetMetaData(const char *meta=0) const
Returns the meta data object with the specified meta name.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
const char * Data() const
static struct mg_connection * fc(struct mg_context *ctx)
Float_t GetStagedPercentage() const
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
Bool_t SetUri(const TString &uri)
Parse URI and set the member variables accordingly, returns kTRUE if URI validates, and kFALSE otherwise: URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
void FormatSize(Long64_t bytes, TString &um, Double_t &size) const
Format size.
const TString GetPort() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
const char * AsString() const
Return message digest as string.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
The TNamed class is the base class for all named ROOT classes.
TFileCollection * GetStagedSubset()
Creates a subset of the files that have the kStaged & !kCorrupted bit set.
virtual Bool_t IsEmpty() const
std::map< std::string, std::string >::const_iterator iter
Bool_t SetCurrentUrl(const char *url)
Set 'url' as current URL, if in the list Return kFALSE if not in the list.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
void RemoveMetaData(const char *meta=0)
Removes the indicated meta data object in all TFileInfos and this object If no name is given all meta...
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
Long64_t Merge(TCollection *list)
Merge all TFileCollection objects in li into this TFileCollection object.
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
TList * GetMetaDataList() const
void Sort(Bool_t useindex=kFALSE)
Sort the collection.
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file collection object.
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()...
TFileInfoMeta * GetMetaData(const char *meta=0) const
Get meta data object with specified name.
R__EXTERN TSystem * gSystem
Int_t RemoveDuplicates()
Remove duplicates based on the UUID, typically after a verification.
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
TObject * Remove(TObject *obj)
Remove object from the list.
Collection abstract base class.
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t TestBit(UInt_t f) const
char * Form(const char *fmt,...)
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Bool_t IsWhitespace() const
virtual const char * GetName() const
Returns name of object.
virtual void FreeDirectory(void *dirp)
Free a directory.
std::istream & ReadToDelim(std::istream &str, char delim= '\n')
Read up to an EOF, or a delimiting character, whichever comes first.
Long64_t GetTotalSize() const
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
TFileCollection(const TFileCollection &)
Class used by TMap to store (key,value) pairs.
void SetAnchor(const char *anchor)
virtual Int_t GetSize() const
void SetDefaultTreeName(const char *treeName)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
Mother of all ROOT objects.
void Print(Option_t *option="") const
Prints the contents of the TFileCollection.
Int_t AddFromFile(const char *file, Int_t nfiles=-1, Int_t firstfile=1)
Add file names contained in the specified text file.
void SetDefaultMetaData(const char *meta)
Moves the indicated meta data in the first position, so that it becomes effectively the default...
TUrl * GetCurrentUrl() const
Return the current url.
Bool_t RemoveMetaData(const char *meta=0)
Remove the metadata object.
virtual void Add(TObject *obj)
virtual ~TFileCollection()
Cleanup.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
Float_t GetCorruptedPercentage() const
void ResetBitAll(UInt_t f)
Reset the bit for all TFileInfos.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Class describing a generic file including meta information.
void PrintDetailed(TString &showOnly) const
Print detailed.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
TMap * GetFilesPerServer(const char *exclude=0, Bool_t curronly=kFALSE)
Return a map of TFileCollections with the files on each data server, excluding servers in the comma-s...
void SetBitAll(UInt_t f)
Set the bit for all TFileInfos.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.