]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
starting modifying AliDCSClient to transparently switch between single and multi...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Sep 2007 16:42:02 +0000 (16:42 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Sep 2007 16:42:02 +0000 (16:42 +0000)
first step: same alidcsclient can be used for several queries

SHUTTLE/DCSClient/AliDCSClient.cxx
SHUTTLE/DCSClient/AliDCSClient.h
SHUTTLE/DCSClient/macros/TestClientAlias.C

index 04c73f79476457af45cc9d3428b2389fd61fbc82..c4b1b86c24053ac5a99c2914e606901c69cda96b 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.2  2007/06/09 13:01:09  jgrosseo
+Switching to retrieval of several DCS DPs at a time (multiDPrequest)
+
 Revision 1.1  2006/11/06 14:22:47  jgrosseo
 major update (Alberto)
 o) reading of run parameters from the logbook
@@ -94,7 +97,7 @@ const char* AliDCSClient::fgkServerErrorString = "ServerError";
 //______________________________________________________________________
 AliDCSClient::AliDCSClient(const char* host, Int_t port, UInt_t timeout,
        Int_t retries):
-       fSocket(NULL), fTimeout(timeout), fRetries(retries),
+       fSocket(NULL), fHost(host), fPort(port), fTimeout(timeout), fRetries(retries),
        fServerErrorCode(AliDCSMessage::kNoneError), fServerError("")
 {
        // 
@@ -105,54 +108,44 @@ AliDCSClient::AliDCSClient(const char* host, Int_t port, UInt_t timeout,
        // retries: the number of retries after which the connection is 
        //              is considered as invalid and error is returned.
        //
-
-       Int_t tries = 0;        
-       
-       while (tries < fRetries) {
-               fSocket = new TSocket(host, port);
-               if (fSocket->IsValid()) {
-                       AliDebug(1, Form("Connected to %s:%d", host, port));
-                       fSocket->SetOption(kNoBlock, 1);
-                       break;
-               }
-
-               AliDebug(1, Form("Connection timeout! tries <%d> ...", tries));
-
-               delete fSocket;
-               fSocket = NULL;
-
-               gSystem->Sleep(fTimeout);
-               tries ++;
-       }
 }
 
 //______________________________________________________________________
-AliDCSClient::AliDCSClient(const AliDCSClient& /*other*/):
-       TObject(), fSocket(NULL), fTimeout(0), fRetries(0),
-       fServerErrorCode(AliDCSMessage::kNoneError), fServerError("")
-
+AliDCSClient::~AliDCSClient() 
 {
-// copy constructor (not implemented)
+       // destructor
 
+       Close();
 }
 
 //______________________________________________________________________
-AliDCSClient &AliDCSClient::operator=(const AliDCSClient& /*other*/)
+Bool_t AliDCSClient::Connect()
 {
-// assignment operator (not implemented)
-
-return *this;
-}
+       //  connects to the AMANDA server
+       
+       Close();
+       
+       Int_t tries = 0;        
+       while (tries < fRetries) 
+       {
+               fSocket = new TSocket(fHost, fPort);
+               if (fSocket->IsValid()) 
+               {
+                       AliDebug(1, Form("Connected to %s:%d", fHost.Data(), fPort));
+                       fSocket->SetOption(kNoBlock, 1);
+                       return kTRUE;
+               }
 
-//______________________________________________________________________
-AliDCSClient::~AliDCSClient() 
-{
-// destructor
+               AliDebug(1, Form("Connection timeout! tries <%d> ...", tries));
 
-       if (fSocket) {
-               Close();
                delete fSocket;
+               fSocket = NULL;
+
+               gSystem->Sleep(fTimeout);
+               tries ++;
        }
+       
+       return kFALSE;
 }
 
 //______________________________________________________________________
@@ -291,17 +284,19 @@ Int_t AliDCSClient::ReceiveMessage(AliDCSMessage& message)
 Int_t AliDCSClient::GetValues(AliDCSMessage::RequestType reqType,
        const char* reqString, UInt_t startTime, UInt_t endTime, TObjArray* result)
 {
-// get array of DCS values from the DCS server
-// reqString: alias name
-// startTime, endTime: start time and end time of the query
-// result: contains the array of retrieved AliDCSValue's
+       // get array of DCS values from the DCS server
+       // reqString: alias name
+       // startTime, endTime: start time and end time of the query
+       // result: contains the array of retrieved AliDCSValue's
 
+       Connect();
+       
        if (!IsConnected()) {
                AliError("Not connected!");
                return AliDCSClient::fgkBadState;
        }
 
-       Int_t sResult;
+       Int_t sResult = -1;
        AliDCSMessage requestMessage;
        requestMessage.CreateRequestMessage(reqType, startTime, endTime,
                        reqString);
@@ -331,6 +326,8 @@ 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;
@@ -561,6 +558,8 @@ void AliDCSClient::Close()
 
        if (fSocket) {
                fSocket->Close();
+               delete fSocket;
+               fSocket = 0;
        }
 }
 
index c2dabdb8075f2879c3fed644fbe152d4ee1038f8..399145263dace435cc8d326999c737fdc70e3370 100644 (file)
@@ -49,9 +49,9 @@ public:
         TMap* GetAliasValues(const TSeqCollection* aliasList, UInt_t startTime, UInt_t endTime, Int_t startIndex = 0, Int_t endIndex = -1);
 
         AliDCSMessage::ErrorCode GetServerErrorCode() const
-                { return fServerErrorCode;};
+                { return fServerErrorCode;}
 
-        const TString& GetServerError() const {return fServerError;};
+        const TString& GetServerError() const {return fServerError;}
 
 
         Bool_t IsConnected();
@@ -69,19 +69,15 @@ private:
        static const char* fgkCommErrorString;          // Communication error string
        static const char* fgkServerErrorString;        // Server error string
 
-       AliDCSClient(const AliDCSClient& other);
-       AliDCSClient& operator= (const AliDCSClient& other);
-
        TSocket* fSocket;       // Pointer to the TCP socket client
-
+       TString fHost;          // server host
+       Int_t   fPort;          // server port
        UInt_t fTimeout;        // timeout parameter
-
        Int_t fRetries;         // number of retries
-
        AliDCSMessage::ErrorCode fServerErrorCode;      // error code
-
        TString fServerError;   // server error string
 
+       Bool_t Connect();
 
        Int_t SendBuffer(const char* buffer, Int_t size);
 
@@ -101,6 +97,8 @@ private:
 
        Int_t ReceiveValueSet(TObjArray* result);
 
+       AliDCSClient(const AliDCSClient& other);                // not implemented
+       AliDCSClient& operator= (const AliDCSClient& other);    // not implemented
 
        ClassDef(AliDCSClient, 0);
 };
index 38a706951852021b83b47d2ace6ae25c1d2c9990..9211b5849a0643c4f42ab3e689286f980a7a5436 100644 (file)
@@ -1,8 +1,7 @@
 void GetValues(const char* host, Int_t port, const char* request,
-       Long_t startTime, Long_t endTime) 
+       UInt_t startTime, UInt_t endTime) 
 {
-
-       AliDCSClient client(host, port, 1000, 5);
+       AliDCSClient client(host, port, 1000, 20);
 
        Int_t result;
 
@@ -18,8 +17,7 @@ void GetValues(const char* host, Int_t port, const char* request,
        TStopwatch sw;
        sw.Start();
 
-       if (requests->GetEntries() > 1) {
-
+       if (requests->GetEntries() > 0) {
                TIter iter(requests);
                TObjString* aString;
                TObjArray* valueSet;
@@ -28,19 +26,10 @@ void GetValues(const char* host, Int_t port, const char* request,
                        valueSet = new TObjArray();
                        valueSet->SetOwner(1);
 
-                       result = client.GetDPValues(aString->GetName(), startTime,
+                       result = client.GetAliasValues(aString->GetName(), startTime,
                                endTime, valueSet);
                        values.Add(aString->Clone(), valueSet);
                }
-
-       } else {
-               TObjArray* valueSet = new TObjArray();
-               valueSet->SetOwner(1);
-
-               values.Add(new TObjString(request), valueSet);
-
-               result = client.GetAliasValues(request, startTime,
-                               endTime, valueSet);
        }
 
        if (result < 0) {