Modifications for correct use of timeout and slightly improved error/debug output...
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Mar 2008 13:34:49 +0000 (13:34 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Mar 2008 13:34:49 +0000 (13:34 +0000)
SHUTTLE/AliShuttle.cxx
SHUTTLE/DCSClient/AliDCSClient.cxx

index ba681ca..94fa409 100644 (file)
@@ -1575,7 +1575,7 @@ Bool_t AliShuttle::ProcessCurrentDetector()
                                        
                                        if (!SendMailToDCS())
                                                Log("SHUTTLE", Form("ProcessCurrentDetector - "
-                                                       "Could not send mail to DCS experts!"));
+                                                                   "Could not send mail to DCS experts!"));
 
                                        delete dcsMap;
                                        return kFALSE;
@@ -1597,7 +1597,7 @@ Bool_t AliShuttle::ProcessCurrentDetector()
                                        
                                        if (!SendMailToDCS())
                                                Log("SHUTTLE", Form("ProcessCurrentDetector - "
-                                                       "Could not send mail to DCS experts!"));
+                                                                   "Could not send mail to DCS experts!"));
                                        
                                        if (aliasMap) delete aliasMap;
                                        delete dcsMap;
@@ -2102,11 +2102,10 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
                 if (fileSize.Length()>0)
                 {
                         // compare filesize of local file with the one stored in the FXS DB
-                       TString command=("stat --format=%s");
-                       Int_t sizeComp = gSystem->Exec(Form("%s %s |grep %s 2>&1 > /dev/null",
-                                               command.Data(), localFileName.Data(),fileSize.Data()));
+                       Long_t id,size,flags,mtime;
+                       Int_t sizeComp = gSystem->GetPathInfo(localFileName.Data(),&id,&size,&flags,&mtime);
 
-                       if ( sizeComp != 0)
+                       if ( sizeComp != 0 || size != fileSize.Atoi())
                        {
                                Log(detector, Form("GetFileName - size of file %s does not match with local copy!",
                                                        filePath.Data()));
@@ -2122,6 +2121,7 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
                if (fileChecksum.Length()>0)
                {
                        // compare md5sum of local file with the one stored in the FXS DB
+                       if(fileChecksum.Contains(' ')) fileChecksum.Resize(fileChecksum.First(' '));
                        Int_t md5Comp = gSystem->Exec(Form("md5sum %s |grep %s 2>&1 > /dev/null",
                                                localFileName.Data(), fileChecksum.Data()));
 
index 3c4752b..a1456b0 100644 (file)
@@ -107,6 +107,7 @@ some more descriptions added
 #include <TMap.h>
 #include <TObjString.h>
 #include <TSystem.h>
+#include <TTimeStamp.h>
 
 ClassImp(AliDCSClient)
 
@@ -149,23 +150,27 @@ Bool_t AliDCSClient::Connect()
        
        Close();
        
-       Int_t tries = 0;        
+       Int_t tries = 0;
+       Int_t sleeptime=300;
+       
        while (tries < fRetries) 
        {
                fSocket = new TSocket(fHost, fPort);
-               if (fSocket->IsValid()) 
+                       
+               if (fSocket && fSocket->IsValid()) 
                {
-                       AliDebug(1, Form("Connected to %s:%d", fHost.Data(), fPort));
+                       AliDebug(1, Form("%s  *** Connected to %s:%d", TTimeStamp(time(0)).AsString("s"), fHost.Data(), fPort));
                        fSocket->SetOption(kNoBlock, 1);
                        return kTRUE;
                }
 
-               AliDebug(1, Form("Connection timeout! tries <%d> ...", tries));
+               AliError(Form("%d *** Connection to AMANDA server failed! Tried <%d> times ...", tries+1));
+               if(tries<fRetries-1) AliInfo(Form("%d *** Waiting %d seconds before next retry.", sleeptime));
 
                delete fSocket;
                fSocket = NULL;
 
-               gSystem->Sleep(fTimeout);
+               gSystem->Sleep(sleeptime);
                tries ++;
        }
        
@@ -182,7 +187,7 @@ Int_t AliDCSClient::SendBuffer(const char* buffer, Int_t size)
 
         while (sentSize < size && tries < fRetries) {
 
-                Int_t sResult = fSocket->Select(TSocket::kWrite, fTimeout);
+                Int_t sResult = fSocket->Select(TSocket::kWrite, fTimeout*1000); //timeout for TSocket::Select is in msec
 
                 if (sResult == 0) {
                        AliDebug(1, Form("Timeout! tries <%d> ...", tries));
@@ -224,9 +229,10 @@ Int_t AliDCSClient::ReceiveBuffer(char* buffer, Int_t size)
 
         while (receivedSize < size && tries < fRetries) {
 
-                Int_t sResult = fSocket->Select(TSocket::kRead, fTimeout);
+                Int_t sResult = fSocket->Select(TSocket::kRead, fTimeout*1000); //timeout for TSocket::Select is in msec
 
                 if (sResult == 0) {
+                       AliDebug(1, Form("Time when timing out: %s   Timeout value: %d seconds",TTimeStamp(time(0)).AsString("s"),fTimeout));
                         AliDebug(1, Form("Timeout! tries <%d> ...", tries));
                         tries ++;
                         continue;
@@ -627,6 +633,7 @@ void AliDCSClient::Close()
        //
 
        if (fSocket) {
+               AliDebug(1, Form("%s  *** Closing connection to %s:%d", TTimeStamp(time(0)).AsString("s"), fHost.Data(), fPort));
                fSocket->Close();
                delete fSocket;
                fSocket = 0;