00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TDataSetManager
00013 #define ROOT_TDataSetManager
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TObject
00026 #include "TObject.h"
00027 #endif
00028 #ifndef ROOT_TString
00029 #include "TString.h"
00030 #endif
00031 #ifndef ROOT_TMap
00032 #include "TMap.h"
00033 #endif
00034 #ifndef ROOT_TUri
00035 #include "TUri.h"
00036 #endif
00037
00038
00039 class TFileCollection;
00040 class TFileInfo;
00041 class TMD5;
00042 class TUrl;
00043 class TVirtualMonitoringWriter;
00044
00045
00046 class TDataSetManager : public TObject {
00047
00048 private:
00049 TDataSetManager(const TDataSetManager&);
00050 TDataSetManager& operator=(const TDataSetManager&);
00051
00052 protected:
00053 TString fGroup;
00054 TString fUser;
00055 TString fCommonUser;
00056 TString fCommonGroup;
00057
00058 TUri fBase;
00059
00060 TMap fGroupQuota;
00061 TMap fGroupUsed;
00062 TMap fUserUsed;
00063
00064 Long64_t fAvgFileSize;
00065
00066 Int_t fNTouchedFiles;
00067 Int_t fNOpenedFiles;
00068 Int_t fNDisappearedFiles;
00069
00070 TString fGroupConfigFile;
00071 Long_t fMTimeGroupConfig;
00072
00073 static TString fgCommonDataSetTag;
00074
00075 static TList *fgDataSetSrvMaps;
00076
00077
00078 virtual TMap *GetGroupUsedMap() { return &fGroupUsed; }
00079 virtual TMap *GetUserUsedMap() { return &fUserUsed; }
00080 Int_t GetNTouchedFiles() const { return fNTouchedFiles; }
00081 Int_t GetNOpenedFiles() const { return fNOpenedFiles; }
00082 Int_t GetNDisapparedFiles() const { return fNDisappearedFiles; }
00083 void GetQuota(const char *group, const char *user, const char *dsName, TFileCollection *dataset);
00084 void PrintDataSet(TFileCollection *fc, Int_t popt = 0);
00085 void PrintUsedSpace();
00086 Bool_t ReadGroupConfig(const char *cf = 0);
00087 virtual void UpdateUsedSpace();
00088
00089 static Long64_t ToBytes(const char *size = 0);
00090
00091 public:
00092 enum EDataSetStatusBits {
00093 kCheckQuota = BIT(15),
00094 kAllowRegister = BIT(16),
00095 kAllowVerify = BIT(17),
00096 kTrustInfo = BIT(18),
00097 kIsSandbox = BIT(19),
00098 kUseCache = BIT(20),
00099 kDoNotUseCache = BIT(21)
00100 };
00101
00102 enum EDataSetWorkOpts {
00103 kDebug = 0x1, kShowDefault = 0x2, kPrint = 0x4, kExport = 0x8,
00104 kQuotaUpdate = 0x10, kSetDefaultTree = 0x20, kForceScan = 0x40,
00105 kNoHeaderPrint = 0x80,
00106
00107 kReopen = 0x100, kTouch = 0x200, kMaxFiles = 0x400, kReadShort = 0x800,
00108 kFileMustExist = 0x1000,
00109 kNoAction = 0x2000, kLocateOnly = 0x4000, kStageOnly = 0x8000,
00110
00111 kNoCacheUpdate = 0x10000, kRefreshLs = 0x20000, kList = 0x40000,
00112 kAllFiles = 0x80000, kStagedFiles = 0x100000, kNoStagedCheck = 0x200000
00113 };
00114
00115 TDataSetManager(const char *group = 0, const char *user = 0, const char *options = 0);
00116 virtual ~TDataSetManager();
00117
00118 virtual Int_t ClearCache(const char *uri);
00119 virtual Long64_t GetAvgFileSize() const { return fAvgFileSize; }
00120 virtual TFileCollection *GetDataSet(const char *uri, const char *server = 0);
00121 virtual TMap *GetDataSets(const char *uri, UInt_t = TDataSetManager::kExport);
00122 virtual TMap *GetSubDataSets(const char *uri, const char *excludeservers);
00123
00124 virtual Long64_t GetGroupQuota(const char *group);
00125 virtual TMap *GetGroupQuotaMap() { return &fGroupQuota; }
00126 virtual Long64_t GetGroupUsed(const char *group);
00127 virtual Bool_t ExistsDataSet(const char *uri);
00128 virtual void MonitorUsedSpace(TVirtualMonitoringWriter *monitoring);
00129 virtual Int_t NotifyUpdate(const char *group = 0, const char *user = 0,
00130 const char *dspath = 0, Long_t mtime = 0, const char *checksum = 0);
00131 Bool_t ParseUri(const char *uri, TString *dsGroup = 0, TString *dsUser = 0,
00132 TString *dsName = 0, TString *dsTree = 0,
00133 Bool_t onlyCurrent = kFALSE, Bool_t wildcards = kFALSE);
00134 virtual void ParseInitOpts(const char *opts);
00135 virtual Bool_t RemoveDataSet(const char *uri);
00136 virtual Int_t RegisterDataSet(const char *uri, TFileCollection *dataSet, const char *opt);
00137 Int_t ScanDataSet(const char *uri, const char *opt);
00138 virtual Int_t ScanDataSet(const char *uri, UInt_t option = kReopen | kDebug);
00139 void SetScanCounters(Int_t t = -1, Int_t o = -1, Int_t d = -1);
00140 virtual Int_t ShowCache(const char *uri);
00141 virtual void ShowQuota(const char *opt);
00142
00143 virtual void ShowDataSets(const char *uri = "*", const char *opt = "");
00144
00145 static TString CreateUri(const char *dsGroup = 0, const char *dsUser = 0,
00146 const char *dsName = 0, const char *dsTree = 0);
00147 static Bool_t CheckDataSetSrvMaps(TUrl *furl, TString &fn, TList *srvmaplist = 0);
00148 static TList *GetDataSetSrvMaps();
00149 static TList *ParseDataSetSrvMaps(const TString &srvmaps);
00150 static Int_t ScanDataSet(TFileCollection *dataset, Int_t fopt, Int_t sopt = 0, Int_t ropt = 0,
00151 Bool_t dbg = kFALSE,
00152 Int_t *touched = 0, Int_t *opened = 0, Int_t *disappeared = 0,
00153 TList *flist = 0, Long64_t avgsz = -1, const char *mss = 0,
00154 Int_t maxfiles = -1, const char *stageopts = 0);
00155 static Int_t ScanFile(TFileInfo *fileinfo, Bool_t notify);
00156 static Int_t FillMetaData(TFileInfo *fi, TDirectory *d, const char *rdir = "/");
00157
00158 ClassDef(TDataSetManager, 0)
00159 };
00160
00161 #endif