/*
$Log$
+Revision 1.8 2007/10/17 17:43:02 acolla
+nextMessage removed from client
+
Revision 1.7 2007/10/16 15:02:20 jgrosseo
fixed bug if zero values collected
#include <TMap.h>
#include <TObjString.h>
#include <TSystem.h>
+#include <TTimeStamp.h>
ClassImp(AliDCSClient)
const char* AliDCSClient::fgkBadMessageString = "BadMessage";
const char* AliDCSClient::fgkCommErrorString = "CommunicationError";
const char* AliDCSClient::fgkServerErrorString = "ServerError";
+const char* AliDCSClient::fgkUnknownDPString = "UnknownAlias/DP";
//______________________________________________________________________
AliDCSClient::AliDCSClient(const char* host, Int_t port, UInt_t timeout,
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(" *** Connection to AMANDA server failed Tried <%d> times ...", tries+1));
+ if(tries<fRetries-1) AliInfo(Form(" *** Waiting %d seconds before next retry.", sleeptime));
delete fSocket;
fSocket = NULL;
- gSystem->Sleep(fTimeout);
+ gSystem->Sleep(sleeptime);
tries ++;
}
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));
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;
if (fResultErrorCode < 0)
{
+ if (fResultErrorCode == fgkUnknownDP)
+ {
+ AliError(Form("%s",fServerError.Data()));
+ }
+
AliError("Can't get values");
delete resultSet;
return AliDCSClient::fgkServerError;
}
+
+ else if (message.GetType() == AliDCSMessage::kUnknownDP)
+ {
+ fServerError = message.GetErrorString();
+
+ return AliDCSClient::fgkUnknownDP;
+ }
+
AliError("Bad message type received!");
return AliDCSClient::fgkBadMessage;
//
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;
case AliDCSClient::fgkServerError:
return AliDCSClient::fgkServerErrorString;
+
+ case AliDCSClient::fgkUnknownDP:
+ return AliDCSClient::fgkUnknownDPString;
default:
AliErrorGeneral("AliDCSClient::GetErrorString",