1) Connect and Close are called before and after each query, so one can
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Sep 2007 16:46:14 +0000 (16:46 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Sep 2007 16:46:14 +0000 (16:46 +0000)
keep the same AliDCSClient object.
2) The splitting of a query is moved to GetDPValues/GetAliasValues.
3) Splitting interval can be specified in constructor

SHUTTLE/AliShuttle.cxx
SHUTTLE/DCSClient/AliDCSClient.cxx
SHUTTLE/DCSClient/AliDCSClient.h

index 1618cad..e252310 100644 (file)
 
 /*
 $Log$
+Revision 1.55  2007/08/06 12:26:40  acolla
+Function Bool_t GetHLTStatus added to preprocessor. It returns the status of HLT
+read from the run logbook.
+
 Revision 1.54  2007/07/12 09:51:25  jgrosseo
 removed duplicated log message in GetFile
 
@@ -1812,67 +1816,31 @@ TMap* AliShuttle::GetValueSet(const char* host, Int_t port, const TSeqCollection
        // type: kAlias or kDP
        // returns TMap of values, 0 when failure
 
-       const Int_t kSplit = 100; // maximum number of DPs at a time
-       
-       Int_t totalEntries = entries->GetEntries();
-       
+       AliDCSClient client(host, port, fTimeout, fRetries);
+
        TMap* result = 0;
-       
-       for (Int_t index=0; index < totalEntries; index += kSplit)
+       if (type == kAlias)
        {
-               Int_t endIndex = index + kSplit;
-       
-               AliDCSClient client(host, port, fTimeout, fRetries);
-               if (!client.IsConnected())
-                       return 0;
-
-               TMap* partialResult = 0;
+               result = client.GetAliasValues(entries, GetCurrentStartTime(), 
+                       GetCurrentEndTime());
+       } 
+       else if (type == kDP)
+       {
+               result = client.GetDPValues(entries, GetCurrentStartTime(), 
+                       GetCurrentEndTime());
+       }
 
-               if (type == kAlias)
-               {
-                       partialResult = client.GetAliasValues(entries, GetCurrentStartTime(), 
-                               GetCurrentEndTime(), index, endIndex);
-               } 
-               else if (type == kDP)
-               {
-                       partialResult = client.GetDPValues(entries, GetCurrentStartTime(), 
-                               GetCurrentEndTime(), index, endIndex);
-               }
+       if (result == 0)
+       {
+               Log(fCurrentDetector.Data(), Form("GetValueSet - Can't get entries! Reason: %s",
+                       client.GetServerError().Data()));
 
-               if (partialResult == 0)
-               {
-                       Log(fCurrentDetector.Data(), Form("GetValueSet - Can't get entries (%d...%d)! Reason: %s",
-                               index, endIndex, client.GetServerError().Data()));
-       
-                       if (result)
-                               delete result;
-                               
-                       return 0;
-               }
-               
-               AliInfo(Form("Retrieved entries %d..%d (total %d); E.g. %s has %d values collected",
-                                       index, endIndex, totalEntries, entries->At(index)->GetName(), ((TObjArray*)
-                                       partialResult->GetValue(entries->At(index)->GetName()))->GetEntriesFast()));
-               
-               if (!result)
-               {
-                       result = partialResult;
-               }
-               else
-               {               
-                       TIter iter(partialResult);
-                       TObjString* key = 0;
-                       while ((key = (TObjString*) iter.Next()))
-                               result->Add(key, partialResult->GetValue(key->String()));
-                               
-                       partialResult->SetOwner(kFALSE);
-                       delete partialResult;
-               }
-       
+               return 0;
        }
-
+               
        return result;
 }
+
 //______________________________________________________________________________________________
 const char* AliShuttle::GetFile(Int_t system, const char* detector,
                const char* id, const char* source)
index c4b1b86..80ea035 100644 (file)
 
 /*
 $Log$
+Revision 1.3  2007/09/11 16:42:02  jgrosseo
+starting modifying AliDCSClient to transparently switch between single and multi query
+first step: same alidcsclient can be used for several queries
+
 Revision 1.2  2007/06/09 13:01:09  jgrosseo
 Switching to retrieval of several DCS DPs at a time (multiDPrequest)
 
@@ -96,8 +100,8 @@ const char* AliDCSClient::fgkServerErrorString = "ServerError";
 
 //______________________________________________________________________
 AliDCSClient::AliDCSClient(const char* host, Int_t port, UInt_t timeout,
-       Int_t retries):
-       fSocket(NULL), fHost(host), fPort(port), fTimeout(timeout), fRetries(retries),
+       Int_t retries, Int_t multiSplit):
+       fSocket(NULL), fHost(host), fPort(port), fTimeout(timeout), fRetries(retries), fMultiSplit(multiSplit),
        fServerErrorCode(AliDCSMessage::kNoneError), fServerError("")
 {
        // 
@@ -326,60 +330,88 @@ TMap* AliDCSClient::GetValues(AliDCSMessage::RequestType reqType,
        // Result: map containing the array of alias names. It will be filled with
        // the values retrieved for each alias
 
-       Connect();
-       
-       if (!IsConnected()) {
-               AliError("Not connected!");
-               return 0;
-       }
-
-       AliDCSMessage multiRequestMessage;
-       multiRequestMessage.CreateMultiRequestMessage(reqType,
-                       startTime, endTime);
+       TMap* result = new TMap;
+       result->SetOwner(1);
 
        if (endIndex < 0 || endIndex > list->GetEntries())
                endIndex = list->GetEntries();
-                       
-       for (Int_t i=startIndex; i<endIndex; i++)
-       {
-               TObjString* aRequest = (TObjString*) list->At(i);
-               if (!multiRequestMessage.AddRequestString(aRequest->String()))
-                       return 0;
-       }
-       
-       Int_t sResult = 0;
-       if ((sResult = SendMessage(multiRequestMessage)) < 0)
-       {
-                AliError(Form("Can't send request message! Reason: %s",
-                        GetErrorString(sResult)));
-                Close();
-                return 0;
-        }
 
-       TMap* result = new TMap;
-       result->SetOwner(1);
-
-       for (Int_t i=startIndex; i<endIndex; i++)
+       for (Int_t subsetBegin = startIndex; subsetBegin < endIndex; subsetBegin += fMultiSplit)
        {
-               TObjString* aRequest = (TObjString*) list->At(i);
+               Connect();
+       
+               if (!IsConnected()) 
+               {
+                       AliError("Not connected!");
+                       delete result;
+                       return 0;
+               }
+
+               Int_t subsetEnd = subsetBegin + fMultiSplit;
+               if (subsetEnd > endIndex)
+                   subsetEnd = endIndex;
+       
+               AliDCSMessage requestMessage;
+               if (fMultiSplit == 1)
+               {
+                   // single dp request
+            
+                       TObjString* aRequest = (TObjString*) list->At(subsetBegin);
+                       requestMessage.CreateRequestMessage(reqType, startTime, endTime, aRequest->String());
+               }
+               else
+               {
+                   // multi dp request
+            
+                   requestMessage.CreateMultiRequestMessage(reqType,
+                               startTime, endTime);
+
+                       for (Int_t i=subsetBegin; i<subsetEnd; i++)
+                       {
+                               TObjString* aRequest = (TObjString*) list->At(i);
+                               if (!requestMessage.AddRequestString(aRequest->String()))
+                                       return 0;
+                       }
+               }
+       
+               Int_t sResult = 0;
+               if ((sResult = SendMessage(requestMessage)) < 0)
+               {
+                    AliError(Form("Can't send request message! Reason: %s",
+                            GetErrorString(sResult)));
+                    Close();
+                    delete result;
+                    return 0;
+               }
+    
+               for (Int_t i=subsetBegin; i<subsetEnd; i++)
+               {
+                       TObjString* aRequest = (TObjString*) list->At(i);
+               
+                       TObjArray* resultSet = new TObjArray();
+                       resultSet->SetOwner(1);
+    
+                       if ((sResult = ReceiveValueSet(resultSet)) < 0) 
+                       {
+                               AliError(Form("Can't get values for %s!" ,
+                               aRequest->String().Data()));
+    
+                               delete resultSet;
+                               result->DeleteValues();
+                               delete result;
+                               return 0;
+                       }
+
+                       result->Add(aRequest, resultSet);
+                  }
+
+              Close();
+
+                  AliInfo(Form("Retrieved entries %d..%d (total %d..%d); E.g. %s has %d values collected",
+                                       subsetBegin, subsetEnd, startIndex, endIndex, list->At(subsetBegin)->GetName(), ((TObjArray*)
+                                       result->GetValue(list->At(subsetBegin)->GetName()))->GetEntriesFast()));
                
-               TObjArray* resultSet = new TObjArray();
-               resultSet->SetOwner(1);
-
-               if ((sResult = ReceiveValueSet(resultSet)) < 0) {
-                       AliError(Form("Can't get values for %s!" ,
-                               aRequest->String().Data()));
-
-                       delete resultSet;
-                       result->DeleteValues();
-                       delete result;
-                       return 0;
-               }
-
-               result->Add(aRequest, resultSet);
-       }
-
-       Close();
+           }
 
        return result;
 }
index 3991452..91f0117 100644 (file)
@@ -31,10 +31,10 @@ public:
                fgkServerError = -6          // Server error
        };
        
-       friend class AliShuttle;
+////   friend class AliShuttle;
 
        AliDCSClient(const char* host, Int_t port, UInt_t timeout = 5000,
-                        Int_t retries = 5);
+                        Int_t retries = 5, Int_t multiSplit = 100);
         virtual ~AliDCSClient();
 
 
@@ -74,6 +74,7 @@ private:
        Int_t   fPort;          // server port
        UInt_t fTimeout;        // timeout parameter
        Int_t fRetries;         // number of retries
+       Int_t   fMultiSplit; // number of datapoints that are queried at a time in a multi dp request, if set to 1 forces single requests 
        AliDCSMessage::ErrorCode fServerErrorCode;      // error code
        TString fServerError;   // server error string