]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCDBGrid.cxx
online hot channels introduced
[u/mrichter/AliRoot.git] / STEER / AliCDBGrid.cxx
index ce7c7ef750ab6b13a7307c3dc0c5fee09d64b9ea..300265bafe2af889dfe16ae2f9a49bcba61145f6 100644 (file)
@@ -20,7 +20,7 @@
 //                                                                                             //
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
-
+#include <cstdlib>
 #include <TGrid.h>
 #include <TGridResult.h>
 #include <TFile.h>
@@ -64,6 +64,9 @@ fCleanupInterval(cleanupInterval)
                        AliInfo(Form("gGrid = %x; fGridUrl = %s; gGrid->GridUrl() = %s",gGrid,fGridUrl.Data(), gGrid->GridUrl()));
                        AliInfo(Form("fUser = %s; gGrid->GetUser() = %s",fUser.Data(), gGrid->GetUser()));
                }
+               AliDebug(2,Form("1. Grid Url = %s",fGridUrl.Data()));
+               if (fGridUrl == "raw://") fGridUrl = "alien://";
+               AliDebug(2,Form("2. Grid Url = %s (should be different from previous in cas eof raw)", fGridUrl.Data()));
                TGrid::Connect(fGridUrl.Data(),fUser.Data());
        }
 
@@ -80,8 +83,11 @@ fCleanupInterval(cleanupInterval)
        // check DBFolder: trying to cd to DBFolder; if it does not exist, create it
        if(!gGrid->Cd(fDBFolder.Data(),0)){
                AliDebug(2,Form("Creating new folder <%s> ...",fDBFolder.Data()));
-               if(!gGrid->Mkdir(fDBFolder.Data(),"",0)){
-                       AliError(Form("Cannot create folder <%s> !",fDBFolder.Data()));
+               TGridResult* res = gGrid->Command(Form("mkdir -p %s",fDBFolder.Data()));
+               TString result = res->GetKey(0,"__result__");
+               if(result == "0"){
+                       AliFatal(Form("Cannot create folder <%s> !",fDBFolder.Data()));
+                       return;
                }
        } else {
                AliDebug(2,Form("Folder <%s> found",fDBFolder.Data()));
@@ -316,6 +322,13 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
        }
        delete res;
 
+       // GRP entries with explicitly set version escape default incremental versioning
+       if(id.GetPath().Contains("GRP") && id.HasVersion() && lastVersion!=0)
+       {
+               AliDebug(5,Form("Entry %s won't be put in the destination OCDB", id.ToString().Data()));
+               return kFALSE;
+       }
+
        id.SetVersion(lastVersion + 1);
        id.SetSubVersion(0);
 
@@ -417,14 +430,16 @@ AliCDBId* AliCDBGrid::GetEntryId(const AliCDBId& queryId) {
                AliDebug(2,Form("pattern: %s", pattern.Data()));
 
                TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
-               AliCDBId validFileId;
-               for(int i=0; i<res->GetEntries(); i++){
-                       TString filename = res->GetKey(i, "lfn");
-                       if(filename == "") continue;
-                       if(FilenameToId(filename, validFileId))
-                                       validFileIds.AddLast(validFileId.Clone());
-               }
-               delete res;
+               if (res) {
+                       AliCDBId validFileId;
+                       for(int i=0; i<res->GetEntries(); i++){
+                               TString filename = res->GetKey(i, "lfn");
+                               if(filename == "") continue;
+                               if(FilenameToId(filename, validFileId))
+                                               validFileIds.AddLast(validFileId.Clone());
+                       }
+                       delete res;
+               }       
                dataId = GetId(validFileIds, selectedId);
        }
 
@@ -856,6 +871,11 @@ void AliCDBGrid::QueryValidFiles()
 
        TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
 
+       if (!res) {
+               AliError("Grid query failed");
+               return;
+       }
+
        AliCDBId validFileId;
        for(int i=0; i<res->GetEntries(); i++){
                TString filename = res->GetKey(i, "lfn");
@@ -989,8 +1009,9 @@ Bool_t AliCDBGridFactory::Validate(const char* gridString) {
 // check if the string is valid Grid URI
 
         TRegexp gridPattern("^alien://.+$");
+        TRegexp gridRawPattern("^raw://.+$");
 
-        return TString(gridString).Contains(gridPattern);
+        return (TString(gridString).Contains(gridPattern)||TString(gridString).Contains(gridRawPattern));
 }
 
 //_____________________________________________________________________________
@@ -1002,6 +1023,7 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
        }
 
        TString buffer(gridString);
+       Bool_t rawFlag = kFALSE; // flag to say whether we are in the "raw://" case
 
        TString gridUrl         = "alien://";
        TString user            = "";
@@ -1023,6 +1045,10 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
                        if(entry.BeginsWith("alien://")) { // maybe it's a gridUrl!
                                gridUrl = entry;
                                continue;
+                       } else if(entry.BeginsWith("raw://")) { // maybe it's a gridRawUrl!
+                               gridUrl = entry;
+                               rawFlag = kTRUE;
+                               continue;
                        } else {
                                AliError(Form("Invalid entry! %s",entry.Data()));
                                continue;
@@ -1038,17 +1064,17 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
                else if (key.Contains("user",TString::kIgnoreCase)){
                        user = value;
                }
-               else if (key.Contains("folder",TString::kIgnoreCase)){
-                       dbFolder = value;
-               }
                else if (key.Contains("se",TString::kIgnoreCase)){
                        se = value;
                }
-               else if (key.Contains("cacheFold",TString::kIgnoreCase)){
+               else if (key.Contains("cacheF",TString::kIgnoreCase)){
                        cacheFolder = value;
                        if (!cacheFolder.EndsWith("/"))
                                cacheFolder += "/";
                }
+               else if (key.Contains("folder",TString::kIgnoreCase)){
+                       dbFolder = value;
+               }
                else if (key.Contains("operateDisc",TString::kIgnoreCase)){
                        if(value == "kTRUE") {
                                operateDisconnected = kTRUE;
@@ -1061,7 +1087,7 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
                                return NULL;
                        }
                }
-               else if (key.Contains("cacheSiz",TString::kIgnoreCase)){
+               else if (key.Contains("cacheS",TString::kIgnoreCase)){
                        if(value.IsDigit()) {
                                cacheSize = value.Atoi();
                        } else {
@@ -1093,7 +1119,7 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
        AliDebug(2, Form("local cache size: %d", cacheSize));
        AliDebug(2, Form("local cache cleanup interval: %d", cleanupInterval));
 
-       if(dbFolder == ""){
+       if(dbFolder == "" && !rawFlag){
                AliError("Base folder must be specified!");
                return NULL;
        }
@@ -1178,6 +1204,7 @@ AliCDBGridParam::AliCDBGridParam(const char* gridUrl, const char* user, const ch
                        fDBFolder.Data(), fSE.Data(), fCacheFolder.Data(),
                        fOperateDisconnected, fCacheSize, fCleanupInterval);
 
+       AliDebug(2,Form("uri = %s", uri.Data()));
        SetURI(uri.Data());
 }