Logo ROOT   6.07/09
Reference Guide
TDataSetManager.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Jan Fiete Grosse-Oetringhaus, 08.08.07
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 #ifndef ROOT_TDataSetManager
13 #define ROOT_TDataSetManager
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TDataSetManager //
18 // //
19 // This class contains functions to handle datasets in PROOF //
20 // It is the layer between TProofServ and the file system that stores //
21 // the datasets. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 #ifndef ROOT_TString
29 #include "TString.h"
30 #endif
31 #ifndef ROOT_TMap
32 #include "TMap.h"
33 #endif
34 #ifndef ROOT_TUri
35 #include "TUri.h"
36 #endif
37 
38 
39 class TFileCollection;
40 class TFileInfo;
41 class TMD5;
42 class TUrl;
44 class TFileStager;
45 
46 class TDataSetManager : public TObject {
47 
48 private:
49  TDataSetManager(const TDataSetManager&); // not implemented
50  TDataSetManager& operator=(const TDataSetManager&); // not implemented
51 
52 protected:
53  TString fGroup; // Group to which the owner of this session belongs
54  TString fUser; // Owner of the session
55  TString fCommonUser; // User that stores the COMMON datasets
56  TString fCommonGroup; // Group that stores the COMMON datasets
57 
58  TUri fBase; // Base URI used to parse dataset names
59 
60  TMap fGroupQuota; // Group quotas (read from config file)
61  TMap fGroupUsed; // <group> --> <used bytes> (TParameter)
62  TMap fUserUsed; // <group> --> <map of users> --> <value>
63 
64  Long64_t fAvgFileSize; // Average file size to be used to estimate the dataset size (in MB)
65 
66  Int_t fNTouchedFiles; // Number of files touched in the last ScanDataSet operation
67  Int_t fNOpenedFiles; // Number of files opened in the last ScanDataSet operation
68  Int_t fNDisappearedFiles; // Number of files disappared in the last ScanDataSet operation
69 
70  TString fGroupConfigFile; // Path to the group config file
71  Long_t fMTimeGroupConfig; // Last modification of the group config file
72 
73  static TString fgCommonDataSetTag; // Name for common datasets, default: COMMON
74 
75  static TList *fgDataSetSrvMaps; // List of TPair(TRegexp, TObjString) for mapping server coordinates
76  // for dataset files (init from DataSet.SrvMap)
77 
78  virtual TMap *GetGroupUsedMap() { return &fGroupUsed; }
79  virtual TMap *GetUserUsedMap() { return &fUserUsed; }
81  Int_t GetNOpenedFiles() const { return fNOpenedFiles; }
83  void GetQuota(const char *group, const char *user, const char *dsName, TFileCollection *dataset);
84  void PrintDataSet(TFileCollection *fc, Int_t popt = 0);
85  void PrintUsedSpace();
86  Bool_t ReadGroupConfig(const char *cf = 0);
87  virtual void UpdateUsedSpace();
88 
89  static Long64_t ToBytes(const char *size = 0);
90 
91 public:
93  kCheckQuota = BIT(15), // quota checking enabled
94  kAllowRegister = BIT(16), // allow registration of a new dataset
95  kAllowVerify = BIT(17), // allow verification of a dataset (requires registration permit)
96  kTrustInfo = BIT(18), // during registration, trust the available information provided by the user
97  kIsSandbox = BIT(19), // dataset dir is in the user sandbox (simplified naming)
98  kUseCache = BIT(20), // force the usage of cache
99  kDoNotUseCache = BIT(21) // disable the cache
100  };
101 
102  enum EDataSetWorkOpts { // General (bits 1-8)
103  kDebug = 0x1, kShowDefault = 0x2, kPrint = 0x4, kExport = 0x8,
104  kQuotaUpdate = 0x10, kSetDefaultTree = 0x20, kForceScan = 0x40,
106  // File-based specific (bits 9-16)
107  kReopen = 0x100, kTouch = 0x200, kMaxFiles = 0x400, kReadShort = 0x800,
108  kFileMustExist = 0x1000,
109  kNoAction = 0x2000, kLocateOnly = 0x4000, kStageOnly = 0x8000,
110  // Auxilliary bits (bits 17-)
111  kNoCacheUpdate = 0x10000, kRefreshLs = 0x20000, kList = 0x40000,
112  kAllFiles = 0x80000, kStagedFiles = 0x100000, kNoStagedCheck = 0x200000
113  };
114 
115  TDataSetManager(const char *group = 0, const char *user = 0, const char *options = 0);
116  virtual ~TDataSetManager();
117 
118  virtual Int_t ClearCache(const char *uri);
119  virtual Long64_t GetAvgFileSize() const { return fAvgFileSize; }
120  virtual TFileCollection *GetDataSet(const char *uri, const char *server = 0);
121  virtual TMap *GetDataSets(const char *uri, UInt_t /*option*/ = TDataSetManager::kExport);
122  virtual TMap *GetSubDataSets(const char *uri, const char *excludeservers);
123 
124  virtual Long64_t GetGroupQuota(const char *group);
125  virtual TMap *GetGroupQuotaMap() { return &fGroupQuota; }
126  virtual Long64_t GetGroupUsed(const char *group);
127  virtual Bool_t ExistsDataSet(const char *uri);
128  virtual void MonitorUsedSpace(TVirtualMonitoringWriter *monitoring);
129  virtual Int_t NotifyUpdate(const char *group = 0, const char *user = 0,
130  const char *dspath = 0, Long_t mtime = 0, const char *checksum = 0);
131  Bool_t ParseUri(const char *uri, TString *dsGroup = 0, TString *dsUser = 0,
132  TString *dsName = 0, TString *dsTree = 0,
133  Bool_t onlyCurrent = kFALSE, Bool_t wildcards = kFALSE);
134  virtual void ParseInitOpts(const char *opts);
135  virtual Bool_t RemoveDataSet(const char *uri);
136  virtual Int_t RegisterDataSet(const char *uri, TFileCollection *dataSet, const char *opt);
137  Int_t ScanDataSet(const char *uri, const char *opt);
138  virtual Int_t ScanDataSet(const char *uri, UInt_t option = kReopen | kDebug);
139  void SetScanCounters(Int_t t = -1, Int_t o = -1, Int_t d = -1);
140  virtual Int_t ShowCache(const char *uri);
141  virtual void ShowQuota(const char *opt);
142 
143  virtual void ShowDataSets(const char *uri = "*", const char *opt = "");
144 
145  static TString CreateUri(const char *dsGroup = 0, const char *dsUser = 0,
146  const char *dsName = 0, const char *dsTree = 0);
147  static Bool_t CheckDataSetSrvMaps(TUrl *furl, TString &fn, TList *srvmaplist = 0);
148  static TList *GetDataSetSrvMaps();
149  static TList *ParseDataSetSrvMaps(const TString &srvmaps);
150  static Int_t ScanDataSet(TFileCollection *dataset, Int_t fopt, Int_t sopt = 0, Int_t ropt = 0,
151  Bool_t dbg = kFALSE,
152  Int_t *touched = 0, Int_t *opened = 0, Int_t *disappeared = 0,
153  TList *flist = 0, Long64_t avgsz = -1, const char *mss = 0,
154  Int_t maxfiles = -1, const char *stageopts = 0);
155  static Bool_t CheckStagedStatus(TFileInfo *fileInfo, Int_t fopt, Int_t maxfiles,
156  Int_t newstagedfiles, TFileStager* stager, Bool_t createStager,
157  Bool_t dbg, Bool_t &changed, Bool_t& touched,
158  Bool_t& disappeared);
159  static void ProcessFile(TFileInfo *fileInfo, Int_t sopt, Bool_t checkstg, Bool_t doall,
160  TFileStager* stager, Bool_t createStager, const char* stageopts,
161  Bool_t dbg, Bool_t &changed, Bool_t& opened);
162 
163  static Int_t ScanFile(TFileInfo *fileinfo, Bool_t notify);
164  static Int_t FillMetaData(TFileInfo *fi, TDirectory *d, const char *rdir = "/");
165 
166  ClassDef(TDataSetManager, 0) // Abstract data set manager class
167 };
168 
169 #endif
static Bool_t CheckDataSetSrvMaps(TUrl *furl, TString &fn, TList *srvmaplist=0)
Check if the dataset server mappings apply to the url defined by &#39;furl&#39;.
Int_t GetNDisapparedFiles() const
virtual Int_t ClearCache(const char *uri)
Clear cached information matching uri.
long long Long64_t
Definition: RtypesCore.h:69
static TList * fgDataSetSrvMaps
virtual void ParseInitOpts(const char *opts)
Parse the opts string and set the init bits accordingly Available options: Cq: set kCheckQuota Ar: se...
TString fGroupConfigFile
TDataSetManager & operator=(const TDataSetManager &)
This class represents a WWW compatible URL.
Definition: TUrl.h:41
virtual Bool_t RemoveDataSet(const char *uri)
Removes the indicated dataset.
virtual TFileCollection * GetDataSet(const char *uri, const char *server=0)
Utility function used in various methods for user dataset upload.
void SetScanCounters(Int_t t=-1, Int_t o=-1, Int_t d=-1)
Update scan counters.
virtual ~TDataSetManager()
Destructor.
Basic string class.
Definition: TString.h:137
static Long64_t ToBytes(const char *size=0)
Static utility function to gt the number of bytes from a string representation in the form "<digit><s...
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void ShowDataSets(const char *uri="*", const char *opt="")
Prints formatted information about the dataset &#39;uri&#39;.
This class represents a RFC 3986 compatible URI.
Definition: TUri.h:39
static TString CreateUri(const char *dsGroup=0, const char *dsUser=0, const char *dsName=0, const char *dsTree=0)
Creates URI for the dataset manger in the form &#39;[[/dsGroup/]dsUser/]dsName[#dsObjPath]&#39;, The optional dsObjPath can be in the form [subdir/]objname]&#39;.
virtual TMap * GetGroupQuotaMap()
static void ProcessFile(TFileInfo *fileInfo, Int_t sopt, Bool_t checkstg, Bool_t doall, TFileStager *stager, Bool_t createStager, const char *stageopts, Bool_t dbg, Bool_t &changed, Bool_t &opened)
Locate, stage, or fully validate file "fileInfo".
virtual void MonitorUsedSpace(TVirtualMonitoringWriter *monitoring)
Log info to the monitoring server.
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:1956
TDataSetManager(const TDataSetManager &)
#define ClassDef(name, id)
Definition: Rtypes.h:254
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
virtual void ShowQuota(const char *opt)
Display quota information.
virtual Int_t RegisterDataSet(const char *uri, TFileCollection *dataSet, const char *opt)
Register a dataset, perfoming quota checkings, if needed.
Long_t fMTimeGroupConfig
virtual Long64_t GetGroupQuota(const char *group)
returns the quota a group is allowed to have
static TList * GetDataSetSrvMaps()
Static getter for server mapping list.
virtual TMap * GetGroupUsedMap()
Int_t GetNTouchedFiles() const
static Bool_t CheckStagedStatus(TFileInfo *fileInfo, Int_t fopt, Int_t maxfiles, Int_t newstagedfiles, TFileStager *stager, Bool_t createStager, Bool_t dbg, Bool_t &changed, Bool_t &touched, Bool_t &disappeared)
Check stage status of the file described by "fileInfo".
virtual Long64_t GetAvgFileSize() const
A doubly linked list.
Definition: TList.h:47
Int_t GetNOpenedFiles() const
void PrintUsedSpace()
Prints the quota.
virtual void UpdateUsedSpace()
updates the used space maps
virtual TMap * GetSubDataSets(const char *uri, const char *excludeservers)
Partition dataset &#39;ds&#39; accordingly to the servers.
static Int_t FillMetaData(TFileInfo *fi, TDirectory *d, const char *rdir="/")
Navigate the directory &#39;d&#39; (and its subdirectories) looking for TTree objects.
Bool_t ReadGroupConfig(const char *cf=0)
Read group config file &#39;cf&#39;.
virtual TMap * GetUserUsedMap()
virtual Bool_t ExistsDataSet(const char *uri)
Checks if the indicated dataset exits.
Bool_t ParseUri(const char *uri, TString *dsGroup=0, TString *dsUser=0, TString *dsName=0, TString *dsTree=0, Bool_t onlyCurrent=kFALSE, Bool_t wildcards=kFALSE)
Parses a (relative) URI that describes a DataSet on the cluster.
virtual Int_t ShowCache(const char *uri)
Show cached information matching uri.
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t ScanDataSet(const char *uri, const char *opt)
Scans the dataset indicated by &#39;uri&#39; following the &#39;opts&#39; directives.
Long64_t fAvgFileSize
static Int_t ScanFile(TFileInfo *fileinfo, Bool_t notify)
Open the file described by &#39;fileinfo&#39; to extract the relevant meta-information.
void GetQuota(const char *group, const char *user, const char *dsName, TFileCollection *dataset)
Gets quota information from this dataset.
long Long_t
Definition: RtypesCore.h:50
static TString fgCommonDataSetTag
Describe directory structure in memory.
Definition: TDirectory.h:44
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
virtual Int_t NotifyUpdate(const char *group=0, const char *user=0, const char *dspath=0, Long_t mtime=0, const char *checksum=0)
Save into the <datasetdir>/dataset.list file the name of the last updated or created or modified data...
#define BIT(n)
Definition: Rtypes.h:120
Mother of all ROOT objects.
Definition: TObject.h:44
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
void PrintDataSet(TFileCollection *fc, Int_t popt=0)
Formatted printout of the content of TFileCollection &#39;fc&#39;.
static TList * ParseDataSetSrvMaps(const TString &srvmaps)
Create a server mapping list from the content of &#39;srvmaps&#39; Return the list (owned by the caller) or 0...
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
virtual Long64_t GetGroupUsed(const char *group)
Returns the used space of that group.
virtual TMap * GetDataSets(const char *uri, UInt_t=TDataSetManager::kExport)
Returns all datasets for the <group> and <user> specified by <uri>.