]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/CDB/AliCDBGrid.h
Adding the possibility to specify SEs for mirroring when putting an object on AliEn
[u/mrichter/AliRoot.git] / STEER / CDB / AliCDBGrid.h
1 #ifndef ALICDBGRID_H
2 #define ALICDBGRID_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /////////////////////////////////////////////////////////////////////
8 //                                                                 //
9 //  class AliCDBGrid                                               //
10 //  access class to a DataBase in an AliEn storage                 //
11 //                                                                 //
12 /////////////////////////////////////////////////////////////////////
13
14 #include "AliCDBStorage.h"
15 #include "AliCDBManager.h"
16 #include "AliCDBMetaData.h"
17
18 class AliCDBGrid: public AliCDBStorage {
19         friend class AliCDBGridFactory;
20
21 public:
22                   
23         virtual Bool_t IsReadOnly() const {return kFALSE;}
24         virtual Bool_t HasSubVersion() const {return kFALSE;}
25         virtual Bool_t Contains(const char* path) const;
26         virtual Int_t  GetLatestVersion(const char* path, Int_t run);
27         virtual Int_t  GetLatestSubVersion(const char* path, Int_t run, Int_t version);
28         virtual Bool_t IdToFilename(const AliCDBId& id, TString& filename) const;
29         virtual void SetRetry(Int_t nretry, Int_t initsec);
30
31 protected:
32
33         virtual AliCDBEntry*    GetEntry(const AliCDBId& queryId);
34         virtual AliCDBId*       GetEntryId(const AliCDBId& queryId);
35         virtual TList*          GetEntries(const AliCDBId& queryId);
36         virtual Bool_t          PutEntry(AliCDBEntry* entry, const char* mirrors="");
37         virtual TList*          GetIdListFromFile(const char* fileName);
38
39 private:
40
41         AliCDBGrid(const char *gridUrl, const char *user, const char* dbFolder,
42                    const char *se, const char* cacheFolder, Bool_t operateDisconnected,
43                    Long64_t cacheSize, Long_t cleanupInterval);
44
45         virtual ~AliCDBGrid();
46
47         AliCDBGrid(const AliCDBGrid& db);
48         AliCDBGrid& operator = (const AliCDBGrid& db);
49
50         Bool_t FilenameToId(TString& filename, AliCDBId& id);
51
52         Bool_t PrepareId(AliCDBId& id);
53         AliCDBId* GetId(const TObjArray& validFileIds, const AliCDBId& query);
54         AliCDBEntry* GetEntryFromFile(TString& filename, AliCDBId* dataId);
55
56         // TODO  use AliEnTag classes!
57         Bool_t AddTag(TString& foldername, const char* tagname);
58         Bool_t TagFileId(TString& filename, const AliCDBId* id);
59         Bool_t TagFileMetaData(TString& filename, const AliCDBMetaData* md);
60         Bool_t TagShortLived(TString& filename, Bool_t value);
61
62         void MakeQueryFilter(Int_t firstRun, Int_t lastRun, const AliCDBMetaData* md, TString& result) const;
63
64         virtual void QueryValidFiles();
65
66         TString    fGridUrl;     // Grid Url ("alien://aliendb4.cern.ch:9000")
67         TString    fUser;        // User
68         TString    fDBFolder;    // path of the DB folder
69         TString    fSE;          // Storage Element
70         TString    fCacheFolder; // local cache folder
71         Bool_t     fOperateDisconnected; // Operate disconnected flag
72         Long64_t   fCacheSize;           // local cache size (in bytes)
73         Long_t     fCleanupInterval;     // local cache cleanup interval
74
75 ClassDef(AliCDBGrid, 0)      // access class to a DataBase in an AliEn storage
76 };
77
78 /////////////////////////////////////////////////////////////////////
79 //                                                                 //
80 //  class AliCDBGridFactory                                        //
81 //                                                                 //
82 /////////////////////////////////////////////////////////////////////
83
84 class AliCDBGridFactory: public AliCDBStorageFactory {
85
86 public:
87
88         virtual Bool_t Validate(const char* gridString);
89         virtual AliCDBParam* CreateParameter(const char* gridString);
90         virtual ~AliCDBGridFactory(){}
91
92 protected:
93         virtual AliCDBStorage* Create(const AliCDBParam* param);
94
95         ClassDef(AliCDBGridFactory, 0);
96 };
97
98 /////////////////////////////////////////////////////////////////////
99 //                                                                 //
100 //  class AliCDBGridParam                                          //
101 //                                                                 //
102 /////////////////////////////////////////////////////////////////////
103
104 class AliCDBGridParam: public AliCDBParam {
105         
106 public:
107         AliCDBGridParam();
108         AliCDBGridParam(const char* gridUrl, const char* user,
109                         const char* dbFolder, const char* se,
110                         const char* cacheFolder, Bool_t operateDisconnected,
111                         Long64_t cacheSize, Long_t cleanupInterval);
112         
113         virtual ~AliCDBGridParam();
114
115         const TString& GridUrl() const {return fGridUrl;}
116         const TString& GetUser() const {return fUser;}
117         const TString& GetDBFolder() const {return fDBFolder;}
118         const TString& GetSE()   const {return fSE;}
119         const TString& GetCacheFolder() const {return fCacheFolder;}
120         Bool_t  GetOperateDisconnected() const {return fOperateDisconnected;}
121         Long64_t  GetCacheSize() const {return fCacheSize;}
122         Long_t  GetCleanupInterval() const {return fCleanupInterval;}
123
124         virtual AliCDBParam* CloneParam() const;
125
126         virtual ULong_t Hash() const;
127         virtual Bool_t IsEqual(const TObject* obj) const;
128
129 private:
130         TString  fGridUrl;     // Grid url "Host:port"
131         TString  fUser;       // User
132         TString  fDBFolder;    // path of the DB folder
133         TString  fSE;         // Storage Element
134         TString  fCacheFolder; // Cache folder
135         Bool_t   fOperateDisconnected; // Operate disconnected flag
136         Long64_t fCacheSize;           // local cache size (in bytes)
137         Long_t   fCleanupInterval;     // local cache cleanup interval
138
139         ClassDef(AliCDBGridParam, 0);
140 };
141
142
143 #endif