/*
$Log$
+Revision 1.2 2006/03/07 07:52:34 hristov
+New version (B.Yordanov)
+
Revision 1.3 2005/11/17 17:47:34 byordano
TList changed to TObjArray
//
#include "AliDCSClient.h"
-
#include "AliDCSValue.h"
#include "AliLog.h"
+#include <TSocket.h>
#include <TObjArray.h>
#include <TMap.h>
#include <TObjString.h>
ClassImp(AliDCSClient)
const Int_t AliDCSClient::fgkBadState;
-
const Int_t AliDCSClient::fgkInvalidParameter;
-
const Int_t AliDCSClient::fgkTimeout;
-
const Int_t AliDCSClient::fgkBadMessage;
-
const Int_t AliDCSClient::fgkCommError;
-
const Int_t AliDCSClient::fgkServerError;
const char* AliDCSClient::fgkBadStateString = "BadState";
-
const char* AliDCSClient::fgkInvalidParameterString = "InvalidParameter";
-
const char* AliDCSClient::fgkTimeoutString = "Timeout";
-
const char* AliDCSClient::fgkBadMessageString = "BadMessage";
-
const char* AliDCSClient::fgkCommErrorString = "CommunicationError";
-
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),
}
}
-AliDCSClient::~AliDCSClient() {
+//______________________________________________________________________
+AliDCSClient::AliDCSClient(const AliDCSClient& /*other*/):
+TObject()
+{
+// copy constructor (not implemented)
+
+}
+
+//______________________________________________________________________
+AliDCSClient &AliDCSClient::operator=(const AliDCSClient& /*other*/)
+{
+// assignment operator (not implemented)
+
+return *this;
+}
+
+//______________________________________________________________________
+AliDCSClient::~AliDCSClient()
+{
+// destructor
+
if (fSocket) {
Close();
delete fSocket;
}
}
-Int_t AliDCSClient::SendBuffer(const char* buffer, Int_t size) {
+//______________________________________________________________________
+Int_t AliDCSClient::SendBuffer(const char* buffer, Int_t size)
+{
+// send buffer containing the message to the DCS server
Int_t sentSize = 0;
Int_t tries = 0;
return sentSize;
}
-Int_t AliDCSClient::ReceiveBuffer(char* buffer, Int_t size) {
+//______________________________________________________________________
+Int_t AliDCSClient::ReceiveBuffer(char* buffer, Int_t size)
+{
+// Receive message from the DCS server and fill buffer
Int_t receivedSize = 0;
Int_t tries = 0;
return receivedSize;
}
-Int_t AliDCSClient::SendMessage(AliDCSMessage& message) {
+//______________________________________________________________________
+Int_t AliDCSClient::SendMessage(AliDCSMessage& message)
+{
+// send message to the DCS server
message.StoreToBuffer();
return SendBuffer(message.GetMessage(), message.GetMessageSize());
}
-Int_t AliDCSClient::ReceiveMessage(AliDCSMessage& message) {
+//______________________________________________________________________
+Int_t AliDCSClient::ReceiveMessage(AliDCSMessage& message)
+{
+// receive message from the DCS server
char header[HEADER_SIZE];
return HEADER_SIZE + sResult;
}
+//______________________________________________________________________
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
+
if (!IsConnected()) {
AliError("Not connected!");
return AliDCSClient::fgkBadState;
return sResult;
}
+//______________________________________________________________________
Int_t AliDCSClient::GetValues(AliDCSMessage::RequestType reqType,
UInt_t startTime, UInt_t endTime, TMap& result)
{
+// get array of DCS values from the DCS server
+// startTime, endTime: start time and end time of the query
+// result: map containing the array of alias names. It will be filled with
+// the values retrieved for each alias
+
if (!IsConnected()) {
AliError("Not connected!");
return AliDCSClient::fgkBadState;
return sResult;
}
-Int_t AliDCSClient::ReceiveValueSet(TObjArray& result) {
+//______________________________________________________________________
+Int_t AliDCSClient::ReceiveValueSet(TObjArray& result)
+{
+// receive set of values
Int_t sResult;
return receivedValues;
}
+//______________________________________________________________________
Int_t AliDCSClient::GetDPValues(const char* dpName, UInt_t startTime,
UInt_t endTime, TObjArray& result)
{
dpName, startTime, endTime, result);
}
+//______________________________________________________________________
Int_t AliDCSClient::GetAliasValues(const char* alias, UInt_t startTime,
UInt_t endTime, TObjArray& result)
{
alias, startTime, endTime, result);
}
+//______________________________________________________________________
Int_t AliDCSClient::GetDPValues(UInt_t startTime, UInt_t endTime,
TMap& result)
{
return GetValues(AliDCSMessage::kDPName, startTime, endTime, result);
}
+//______________________________________________________________________
Int_t AliDCSClient::GetAliasValues(UInt_t startTime, UInt_t endTime,
TMap& result)
{
return GetValues(AliDCSMessage::kAlias, startTime, endTime, result);
}
-Bool_t AliDCSClient::IsConnected() {
+//______________________________________________________________________
+Bool_t AliDCSClient::IsConnected()
+{
//
// Returns kTRUE if there is a valid connection to the server.
//
return kFALSE;
}
-void AliDCSClient::Close() {
+//______________________________________________________________________
+void AliDCSClient::Close()
+{
//
// Close the connection.
//
}
}
-const char* AliDCSClient::GetErrorString(Int_t code) {
+//______________________________________________________________________
+const char* AliDCSClient::GetErrorString(Int_t code)
+{
//
// Returns a short string describing the error code.
// code: the error code.
//
// This class represents the AliDCSClient.
// The client used for data retrieval from DCS server.
+// For more info see AliDCSClient.cxx
//
#include "AliDCSMessage.h"
-#include <TSocket.h>
-
-
class TObjArray;
+class TSocket;
class TMap;
class AliDCSClient: public TObject {
public:
- static const Int_t fgkBadState = -1;
-
- static const Int_t fgkInvalidParameter = -2;
-
- static const Int_t fgkTimeout = -3;
-
- static const Int_t fgkBadMessage = -4;
-
- static const Int_t fgkCommError = -5;
-
- static const Int_t fgkServerError = -6;
-
- static const char* fgkBadStateString;
-
- static const char* fgkInvalidParameterString;
-
- static const char* fgkTimeoutString;
-
- static const char* fgkBadMessageString;
-
- static const char* fgkCommErrorString;
-
- static const char* fgkServerErrorString;
-
-
+ friend class AliShuttle;
+
AliDCSClient(const char* host, Int_t port, UInt_t timeout = 5000,
Int_t retries = 5);
virtual ~AliDCSClient();
Int_t GetAliasValues(UInt_t startTime, UInt_t endTime, TMap& result);
- AliDCSMessage::ErrorCode GetServerErrorCode()
+ AliDCSMessage::ErrorCode GetServerErrorCode() const
{ return fServerErrorCode;};
- const TString& GetServerError() {return fServerError;};
+ const TString& GetServerError() const {return fServerError;};
Bool_t IsConnected();
private:
- TSocket* fSocket;
+ static const Int_t fgkBadState = -1; // Bad state
+ static const Int_t fgkInvalidParameter = -2; // Invalid parameter
+ static const Int_t fgkTimeout = -3; // Timeout
+ static const Int_t fgkBadMessage = -4; // Bad message
+ static const Int_t fgkCommError = -5; // Communication error
+ static const Int_t fgkServerError = -6; // Server error
+
+ static const char* fgkBadStateString; // Bad state string
+ static const char* fgkInvalidParameterString; // Invalid parameter string
+ static const char* fgkTimeoutString; // Timeout string
+ static const char* fgkBadMessageString; // Bad message string
+ 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
- UInt_t fTimeout;
+ UInt_t fTimeout; // timeout parameter
- Int_t fRetries;
+ Int_t fRetries; // number of retries
- AliDCSMessage::ErrorCode fServerErrorCode;
+ AliDCSMessage::ErrorCode fServerErrorCode; // error code
- TString fServerError;
+ TString fServerError; // server error string
Int_t SendBuffer(const char* buffer, Int_t size);
/*
$Log$
+Revision 1.2 2006/03/07 07:52:34 hristov
+New version (B.Yordanov)
+
Revision 1.3 2005/11/17 17:47:34 byordano
TList changed to TObjArray
ClassImp(AliDCSMessage)
+//______________________________________________________________________
AliDCSMessage::AliDCSMessage():
fMessage(NULL), fMessageSize(0), fType(kInvalid)
{
+// default constructor
}
+//______________________________________________________________________
AliDCSMessage::AliDCSMessage(const char* message, UInt_t size):
fMessageSize(size), fType(kInvalid)
{
+// default constructor
+
fMessage = new char[size];
memcpy(fMessage, message, size);
}
-AliDCSMessage::~AliDCSMessage() {
+//______________________________________________________________________
+AliDCSMessage::AliDCSMessage(const AliDCSMessage& /*other*/):
+TObject()
+{
+// copy constructor (not implemented)
+
+}
+
+//______________________________________________________________________
+AliDCSMessage &AliDCSMessage::operator=(const AliDCSMessage& /*other*/)
+{
+// assignment operator (not implemented)
+
+return *this;
+}
+
+//______________________________________________________________________
+AliDCSMessage::~AliDCSMessage()
+{
+// destructor
+
DestroyMessage();
DestroyBuffer();
}
+//______________________________________________________________________
void AliDCSMessage::CreateRequestMessage(RequestType type,
UInt_t startTime, UInt_t endTime, const char* request)
{
+// Create request message
+
DestroyMessage();
fType = AliDCSMessage::kRequest;
fRequestString = request;
}
+//______________________________________________________________________
void AliDCSMessage::CreateMultiRequestMessage(RequestType type,
UInt_t startTime, UInt_t endTime)
{
+// Create multi request message
+
DestroyMessage();
fType = AliDCSMessage::kMultiRequest;
fEndTime = endTime;
}
-void AliDCSMessage::CreateCountMessage(UInt_t count) {
+//______________________________________________________________________
+void AliDCSMessage::CreateCountMessage(UInt_t count)
+{
+// Create count request message
+
DestroyMessage();
fType = AliDCSMessage::kCount;
fCount = count;
}
-void AliDCSMessage::CreateResultSetMessage(AliSimpleValue::Type type) {
+//______________________________________________________________________
+void AliDCSMessage::CreateResultSetMessage(AliSimpleValue::Type type)
+{
+// Create result set message
+
DestroyMessage();
fType = AliDCSMessage::kResultSet;
fSimpleValueType = type;
}
+//______________________________________________________________________
void AliDCSMessage::CreateErrorMessage(ErrorCode errorCode,
const char* errorString)
{
+// Create error message
+
DestroyMessage();
fType = AliDCSMessage::kError;
fType = AliDCSMessage::kNext;
} */
-void AliDCSMessage::DestroyMessage() {
+//______________________________________________________________________
+void AliDCSMessage::DestroyMessage()
+{
+// Destroy message
+
fType = kInvalid;
ClearValues();
ClearRequestStrings();
}
-void AliDCSMessage::SetBool(char* buf, Bool_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetBool(char* buf, Bool_t val)
+{
+// Set bool value to buf
+
tobuf(buf, val);
}
-void AliDCSMessage::SetByte(char* buf, Char_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetByte(char* buf, Char_t val)
+{
+// Set byte value to buf
+
tobuf(buf, val);
}
-void AliDCSMessage::SetUByte(char* buf, UChar_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetUByte(char* buf, UChar_t val)
+{
+// Set ubyte value to buf
+
tobuf(buf, val);
}
-void AliDCSMessage::SetInt(char* buf, Int_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetInt(char* buf, Int_t val)
+{
+// Set int value to buf
+
tobuf(buf, val);
}
-void AliDCSMessage::SetUInt(char* buf, UInt_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetUInt(char* buf, UInt_t val)
+{
+// Set uint value to buf
+
tobuf(buf, val);
}
-void AliDCSMessage::SetFloat(char* buf, Float_t val) {
+//______________________________________________________________________
+void AliDCSMessage::SetFloat(char* buf, Float_t val)
+{
+// Set float value to buf
+
tobuf(buf, val);
}
-Bool_t AliDCSMessage::GetBool(const char* buf) {
+//______________________________________________________________________
+Bool_t AliDCSMessage::GetBool(const char* buf)
+{
+// get bool value from buf
+
Bool_t val;
char* aBuffer = (char*) buf;
return val;
}
-Char_t AliDCSMessage::GetByte(const char* buf) {
+//______________________________________________________________________
+Char_t AliDCSMessage::GetByte(const char* buf)
+{
+// get byte value from buf
+
Char_t val;
char* aBuffer = (char*) buf;
return val;
}
-UChar_t AliDCSMessage::GetUByte(const char* buf) {
+//______________________________________________________________________
+UChar_t AliDCSMessage::GetUByte(const char* buf)
+{
+// get ubyte value from buf
+
UChar_t val;
char* aBuffer = (char*) buf;
return val;
}
-Int_t AliDCSMessage::GetInt(const char* buf) {
+//______________________________________________________________________
+Int_t AliDCSMessage::GetInt(const char* buf)
+{
+// get int value from buf
+
Int_t val;
char* aBuffer = (char*) buf;
return val;
}
-UInt_t AliDCSMessage::GetUInt(const char* buf) {
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetUInt(const char* buf)
+{
+// get uint value from buf
+
UInt_t val;
char* aBuffer = (char*) buf;
return val;
}
-Float_t AliDCSMessage::GetFloat(const char* buf) {
+//______________________________________________________________________
+Float_t AliDCSMessage::GetFloat(const char* buf)
+{
+// get float value from buf
+
Float_t val;
char* aBuffer = (char*) buf;
return val;
}
-TString AliDCSMessage::GetString(const char* buf, Int_t maxLen) {
+//______________________________________________________________________
+TString AliDCSMessage::GetString(const char* buf, Int_t maxLen)
+{
+// get string from buf
for (Int_t k = 0; k < maxLen; k ++) {
if (buf[k] == 0) {
return TString(buf, maxLen);
}
-void AliDCSMessage::StoreHeader() {
+//______________________________________________________________________
+void AliDCSMessage::StoreHeader()
+{
+// store header message
SetUByte(fMessage + ID_OFFSET, 'A');
SetUByte(fMessage + ID_OFFSET + 1, 'D');
SetUInt(fMessage + BODY_SIZE_OFFSET, fMessageSize - HEADER_SIZE);
}
-void AliDCSMessage::StoreRequestMessage() {
+//______________________________________________________________________
+void AliDCSMessage::StoreRequestMessage()
+{
+// store request message
fMessageSize = REQUEST_STRING_OFFSET +
fRequestString.Length() + 1;
strcpy(fMessage + REQUEST_STRING_OFFSET, fRequestString.Data());
}
-void AliDCSMessage::StoreCountMessage() {
+//______________________________________________________________________
+void AliDCSMessage::StoreCountMessage()
+{
+// store count message
fMessageSize = COUNT_OFFSET + sizeof(UInt_t);
SetUInt(fMessage + COUNT_OFFSET, fCount);
}
-void AliDCSMessage::StoreResultSetMessage() {
+//______________________________________________________________________
+void AliDCSMessage::StoreResultSetMessage()
+{
+// store result set message
TIter iter(&fValues);
AliDCSValue* aValue;
}
-void AliDCSMessage::StoreErrorMessage() {
+//______________________________________________________________________
+void AliDCSMessage::StoreErrorMessage()
+{
+// store error message
fMessageSize = ERROR_STRING_OFFSET + fErrorString.Length() + 1;
strcpy(fMessage + ERROR_STRING_OFFSET, fErrorString.Data());
}
-void AliDCSMessage::StoreMultiRequestMessage() {
+//______________________________________________________________________
+void AliDCSMessage::StoreMultiRequestMessage()
+{
+// store multi request message
UInt_t requestDataSize = 0;
}
}
+//______________________________________________________________________
/*
void AliDCSMessage::StoreNextMessage() {
StoreHeader();
} */
-Bool_t AliDCSMessage::ValidateHeader(const char* buf) {
+//______________________________________________________________________
+Bool_t AliDCSMessage::ValidateHeader(const char* buf)
+{
+// validate message header
if (!(buf[ID_OFFSET] == 'A' && buf[ID_OFFSET + 1] == 'D')) {
AliError("Bad message ID!");
return kTRUE;
}
-void AliDCSMessage::LoadRequestMessage() {
+//______________________________________________________________________
+void AliDCSMessage::LoadRequestMessage()
+{
+// load request message
if (fMessageSize < REQUEST_STRING_OFFSET) {
AliError("Body size is too small for request message!");
}
}
-void AliDCSMessage::LoadCountMessage() {
+//______________________________________________________________________
+void AliDCSMessage::LoadCountMessage()
+{
+// load count message
if (fMessageSize < HEADER_SIZE + sizeof(UInt_t)) {
AliError("Body size is too small for count message!");
fType = kCount;
}
-void AliDCSMessage::LoadResultSetMessage() {
+//______________________________________________________________________
+void AliDCSMessage::LoadResultSetMessage()
+{
+// load result message
if (fMessageSize < VALUES_OFFSET) {
AliError("Body size is too small for result set message!");
fType = kResultSet;
}
-void AliDCSMessage::LoadErrorMessage() {
+//______________________________________________________________________
+void AliDCSMessage::LoadErrorMessage()
+{
+// load error message
if (fMessageSize < ERROR_STRING_OFFSET) {
AliError("Body size is too small for error message!");
}
}
-void AliDCSMessage::LoadMultiRequestMessage() {
+//______________________________________________________________________
+void AliDCSMessage::LoadMultiRequestMessage()
+{
+// load multi request message
if (fMessageSize - HEADER_SIZE < REQUEST_STRINGS_OFFSET) {
AliError("Body size is too small for multi request message!");
fType = kMultiRequest;
}
+//______________________________________________________________________
/*
void AliDCSMessage::LoadNextMessage() {
fType = kNext;
} */
-void AliDCSMessage::StoreToBuffer() {
- //
- // Creates an underlying message buffer which can be sent to the
- // socket.
- //
+//______________________________________________________________________
+void AliDCSMessage::StoreToBuffer()
+{
+ // Creates an underlying message buffer which can be sent to the socket.
DestroyBuffer();
}
}
-void AliDCSMessage::LoadFromBuffer() {
- //
+//______________________________________________________________________
+void AliDCSMessage::LoadFromBuffer()
+{
// Reads the underlying message buffer and if it's valid message
// creates the corresponding message.
// If not set the message type kInvalid.
// This buffer is read from the socket.
- //
DestroyMessage();
}
}
-AliDCSMessage::RequestType AliDCSMessage::GetRequestType() const {
- //
+//______________________________________________________________________
+AliDCSMessage::RequestType AliDCSMessage::GetRequestType() const
+{
// Request and MultiRequest.
// Returns the request type: alias or dp (Data Point)
- //
if (!(fType == kRequest || fType == kMultiRequest)) {
AliError("Invalid AliDCSMessage type!");
return fRequestType;
}
-UInt_t AliDCSMessage::GetStartTime() const {
- //
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetStartTime() const
+{
// Request and MultiRequest.
// Returns the request start time. (begining of the time interval).
- //
if (!(fType == kRequest || fType == kMultiRequest)) {
AliError("Invalid AliDCSMessage type!");
return fStartTime;
}
-UInt_t AliDCSMessage::GetEndTime() const {
- //
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetEndTime() const
+{
// Request and MultiRequest.
// Returns the request start time. (end of the time interval).
- //
if (!(fType == kRequest || fType == kMultiRequest)) {
return fEndTime;
}
-TString AliDCSMessage::GetRequestString() const {
- //
+//______________________________________________________________________
+TString AliDCSMessage::GetRequestString() const
+{
// Request.
// Returns the request string. (alias or dp)
- //
if (fType != kRequest) {
AliError("Invalid AliDCSMessage type!");
return fRequestString;
}
-Bool_t AliDCSMessage::AddRequestString(const char* request) {
- //
+//______________________________________________________________________
+Bool_t AliDCSMessage::AddRequestString(const char* request)
+{
// MultRequest.
// Add a request to the request set.
// Returns kFALSE in case of invalid request (too long request string).
// Otherwise returns kTRUE.
- //
-
+
if (fType != kMultiRequest) {
AliError("Invalid AliDCSMessage type!");
return kTRUE;
}
-void AliDCSMessage::ClearRequestStrings() {
- //
+//______________________________________________________________________
+void AliDCSMessage::ClearRequestStrings()
+{
// MultRequest.
// Clears the request set.
- //
-
+
fRequestStrings.Delete();
}
-void AliDCSMessage::GetRequestStrings(TObjArray& result) const {
- //
+//______________________________________________________________________
+void AliDCSMessage::GetRequestStrings(TObjArray& result) const
+{
// MultRequest.
// Returns all request strings in this message.
// result: container where the requests are returned. Collection of
// TObjString.
- //
if (fType != kMultiRequest) {
}
}
-UInt_t AliDCSMessage::GetCount() const {
- //
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetCount() const
+{
// Count.
// Returns the total number of values.
- //
if (fType != kCount) {
return fCount;
}
-AliSimpleValue::Type AliDCSMessage::GetSimpleValueType() const {
- //
+//______________________________________________________________________
+AliSimpleValue::Type AliDCSMessage::GetSimpleValueType() const
+{
// ResultSet.
// Returns simple value type (see AliSimpleValue) for the values
// in this ResultSet.
- //
-
+
if (fType != kResultSet) {
AliError("Invalid AliDCSMessage type!");
return fSimpleValueType;
}
-UInt_t AliDCSMessage::GetValueCount() const {
- //
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetValueCount() const
+{
// ResultSet.
// Returns the count of values in this ResultSet.
- //
if (fType != kResultSet) {
return fValues.GetEntriesFast();
}
-UInt_t AliDCSMessage::GetValues(TObjArray& result) const {
- //
+//______________________________________________________________________
+UInt_t AliDCSMessage::GetValues(TObjArray& result) const
+{
// ResultSet.
// Returns the number of values got from the message.
// result: used to return the values. Collection of AliDCSValue.
- //
if (fType != kResultSet) {
return fValues.GetEntriesFast();
}
-Bool_t AliDCSMessage::AddValue(const AliDCSValue& value) {
- //
+//______________________________________________________________________
+Bool_t AliDCSMessage::AddValue(const AliDCSValue& value)
+{
// ResultSet.
// Adds value to the ResultSet value list.
// Returns kFALSE in case of error.
// Otherwise returns kTRUE;
- //
if (fType != kResultSet) {
AliError("Invalid AliDCSMessage type!");
return kTRUE;
}
-void AliDCSMessage::ClearValues() {
+//______________________________________________________________________
+void AliDCSMessage::ClearValues()
+{
+// clear values array
+
fValues.Delete();
}
-AliDCSMessage::ErrorCode AliDCSMessage::GetErrorCode() const {
+//______________________________________________________________________
+AliDCSMessage::ErrorCode AliDCSMessage::GetErrorCode() const
+{
//
// Error.
// Returns the error code which has this error message.
return fErrorCode;
}
-TString AliDCSMessage::GetErrorString() const {
+//______________________________________________________________________
+TString AliDCSMessage::GetErrorString() const
+{
//
// Error.
// Returns the error string (error description) which has this
}
-void AliDCSMessage::Print(Option_t* /*option*/) const {
+//______________________________________________________________________
+void AliDCSMessage::Print(Option_t* /*option*/) const
+{
+// print message
if (AliLog::GetGlobalDebugLevel() < 2) {
return;
AliDebug(2, printString);
}
-Bool_t AliDCSMessage::SetRawHeader(const char* header) {
+//______________________________________________________________________
+Bool_t AliDCSMessage::SetRawHeader(const char* header)
+{
//
// Checks if the header buffer represents a valid header message.
// If so it creates a message buffer with the appropriate body size
}
-void AliDCSMessage::DestroyBuffer() {
+//______________________________________________________________________
+void AliDCSMessage::DestroyBuffer()
+{
//
// Destroy the underlying message buffer.
//
fMessageSize = 0;
}
+//______________________________________________________________________
void AliDCSMessage::PrintBuffer(const char* buffer, UInt_t size,
TString& output)
{
+// print buffer
UInt_t index = 0;
//
// This class is a wrapper of AliDCSMessage.
// These are the messages which form AliDCSProtocol.
+// Used by AliDCSClient to communicate with the DCS Amanda server
//
-
-#include "AliDCSValue.h"
-
#include <TString.h>
#include <TObjArray.h>
+#include "AliDCSValue.h"
+#include "AliSimpleValue.h"
#define HEADER_SIZE 8
#define ID_OFFSET 0
#define ERROR_CODE_OFFSET HEADER_SIZE
#define ERROR_STRING_OFFSET (HEADER_SIZE + 1)
-
-
class AliDCSMessage: public TObject {
public:
enum Type {
AliDCSMessage(const char* buffer, UInt_t size);
- ~AliDCSMessage();
+ virtual ~AliDCSMessage();
void CreateRequestMessage(RequestType type,
private:
- char* fMessage;
+ AliDCSMessage(const AliDCSMessage& other);
+ AliDCSMessage& operator= (const AliDCSMessage& other);
+
+
+ char* fMessage; // Array of bytes building the message
- UInt_t fMessageSize;
+ UInt_t fMessageSize; // Size of the message array
- Type fType;
+ Type fType; // Message type (request, count...)
//Request message fields
- RequestType fRequestType;
+ RequestType fRequestType; // Type of request message
- UInt_t fStartTime;
+ UInt_t fStartTime; // Start time of query
- UInt_t fEndTime;
+ UInt_t fEndTime; // End time of query
- TString fRequestString;
+ TString fRequestString; // Request string
//Count message fields
- UInt_t fCount;
+ UInt_t fCount; // count counter
//ResultSet message fields
- AliSimpleValue::Type fSimpleValueType;
+ AliSimpleValue::Type fSimpleValueType; // Simple value type
- TObjArray fValues;
+ TObjArray fValues; // array of received values
//Error message fields
- ErrorCode fErrorCode;
+ ErrorCode fErrorCode; // error code
- TString fErrorString;
+ TString fErrorString; // error string
//MultiRequest message fields
- TObjArray fRequestStrings;
+ TObjArray fRequestStrings; // multi request string array
// Message setter helpers
/*
$Log$
+Revision 1.3 2006/06/06 14:26:40 jgrosseo
+o) removed files that were moved to STEER
+o) shuttle updated to follow the new interface (Alberto)
+
Revision 1.2 2006/03/07 07:52:34 hristov
New version (B.Yordanov)
#include "AliPreprocessor.h"
#include "AliDefaultPreprocessor.h"
+#include <TObject.h>
#include <TString.h>
#include <TObjString.h>
}
+//______________________________________________________________________
+AliShuttle::AliShuttle(const AliShuttle& /*other*/):
+AliShuttleInterface()
+{
+// copy constructor (not implemented)
+
+}
+
+//______________________________________________________________________
+AliShuttle &AliShuttle::operator=(const AliShuttle& /*other*/)
+{
+// assignment operator (not implemented)
+
+return *this;
+}
+
//______________________________________________________________________________________________
-AliShuttle::~AliShuttle() {
+AliShuttle::~AliShuttle()
+{
+// destructor
+
fPreprocessorMap.DeleteAll();
}
//______________________________________________________________________________________________
-void AliShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor) {
+void AliShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
+{
//
// Registers new AliPreprocessor.
// It uses GetName() for indentificator of the pre processor.
}
//______________________________________________________________________________________________
-Bool_t AliShuttle::Process(Int_t run, UInt_t startTime, UInt_t endTime) {
+Bool_t AliShuttle::Process(Int_t run, UInt_t startTime, UInt_t endTime)
+{
//
// Makes data retrieval for all detectors in the configuration.
// run: is the run number used
Bool_t AliShuttle::GetValueSet(const char* host, Int_t port, const char* alias,
TObjArray& valueSet)
{
+// Retrieve all "alias" data points from the DCS server
+// host, port: TSocket connection parameters
+// alias: name of the alias
+// valueSet: array of retrieved AliDCSValue's
+
AliDCSClient client(host, port, fTimeout, fRetries);
if (!client.IsConnected()) {
return kFALSE;
const char* AliShuttle::GetFile(Int_t /*system*/, const char* /*detector*/,
const char* /*id*/, const char* /*source*/)
{
+// Get calibration file from DAQ transient file system
AliInfo("You are in AliShuttle::GetFile!");
return 0;
//______________________________________________________________________________________________
TList* AliShuttle::GetFileSources(Int_t /*system*/, const char* /*detector*/, const char* /*id*/)
{
+// Get list of sources that provided the files to be retrieved from DAQ
AliInfo("You are in AliShuttle::GetFileSources!");
return 0;
//______________________________________________________________________________________________
void AliShuttle::Log(const char* detector, const char* message)
{
+// Fill log string with a message
TString toLog = Form("%s - %s", detector, message);
AliError(toLog.Data());
}
//______________________________________________________________________________________________
-void AliShuttle::StoreLog(Int_t run){
+void AliShuttle::StoreLog(Int_t run)
+{
+// store error log string to SHUTTLE/SYSTEM/ERROR (on local storage)
AliInfo("Printing fLog...");
AliInfo(fLog.Data());
// AliCDBPreProcessor.
//
-#include <TObject.h>
#include <TMap.h>
#include <TString.h>
#include "AliShuttleInterface.h"
+class TObject;
class AliShuttleConfig;
class AliPreprocessor;
class AliCDBMetaData;
private:
- static TString fgkLocalUri;
+ AliShuttle(const AliShuttle& other);
+ AliShuttle& operator= (const AliShuttle& other);
+
+ static TString fgkLocalUri; // URI of the local backup storage location
void ClearLog() {fLog = "";}
void StoreLog(Int_t run);
// AliCDBStorage* fLocalStorage;
- UInt_t fTimeout;
- Int_t fRetries;
+ UInt_t fTimeout; // DCS server connection timeout parameter
+ Int_t fRetries; // Number of DCS server connection retries
- TMap fPreprocessorMap;
+ TMap fPreprocessorMap; // list of detector Preprocessors ("DET", "Preprocessor")
- Int_t fCurrentRun;
- UInt_t fCurrentStartTime;
- UInt_t fCurrentEndTime;
+ Int_t fCurrentRun; // run currenty processed
+ UInt_t fCurrentStartTime; // Run Start time
+ UInt_t fCurrentEndTime; // Run end time
- TString fLog;
+ TString fLog; // log message
Bool_t GetValueSet(const char* host, Int_t port, const char* alias,
TObjArray& result);
/*
$Log$
+Revision 1.3 2006/06/06 14:26:40 jgrosseo
+o) removed files that were moved to STEER
+o) shuttle updated to follow the new interface (Alberto)
+
Revision 1.7 2006/05/12 09:07:16 colla
12/05/06
New configuration complete
#include <TLDAPEntry.h>
#include <TLDAPAttribute.h>
-AliShuttleConfig::ConfigHolder::ConfigHolder(const TLDAPEntry* entry):
+AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry):
fIsValid(kFALSE)
{
+// constructor of the shuttle configuration holder
+
TLDAPAttribute* anAttribute;
anAttribute = entry->GetAttribute("det");
fIsValid = kTRUE;
}
-AliShuttleConfig::ConfigHolder::~ConfigHolder() {
+AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
+{
+// destructor of the shuttle configuration holder
+
fDCSAliases.Delete();
}
}
while ((anEntry = aResult->GetNext())) {
- ConfigHolder* aHolder = new ConfigHolder(anEntry);
+ AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry);
delete anEntry;
if (!aHolder->IsValid()) {
fIsValid = kTRUE;
}
-AliShuttleConfig::~AliShuttleConfig() {
+AliShuttleConfig::~AliShuttleConfig()
+{
+// destructor
+
fDetectorMap.DeleteAll();
}
-const TObjArray* AliShuttleConfig::GetDetectors() const {
+const TObjArray* AliShuttleConfig::GetDetectors() const
+{
//
// returns collection of TObjString which contains the name
// of every detector which is in the configuration.
return &fDetectorList;
}
-Bool_t AliShuttleConfig::HasDetector(const char* detector) const {
+Bool_t AliShuttleConfig::HasDetector(const char* detector) const
+{
//
// checks for paricular detector in the configuration.
//
return fDetectorMap.GetValue(detector) != NULL;
}
-const char* AliShuttleConfig::GetDCSHost(const char* detector) const {
+const char* AliShuttleConfig::GetDCSHost(const char* detector) const
+{
//
// returns DCS server host used by particular detector
//
- ConfigHolder* aHolder = (ConfigHolder*) fDetectorMap.GetValue(detector);
+ AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
if (!aHolder) {
AliError(Form("There isn't configuration for detector: %s",
detector));
return aHolder->GetDCSHost();
}
-Int_t AliShuttleConfig::GetDCSPort(const char* detector) const {
+Int_t AliShuttleConfig::GetDCSPort(const char* detector) const
+{
//
// returns DCS server port used by particular detector
//
- ConfigHolder* aHolder = (ConfigHolder*) fDetectorMap.GetValue(detector);
+ AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
if (!aHolder) {
AliError(Form("There isn't configuration for detector: %s",
detector));
return aHolder->GetDCSPort();
}
-const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const {
+const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const
+{
//
// returns collection of TObjString which represents the set of aliases
// which used for data retrieval for particular detector
//
- ConfigHolder* aHolder = (ConfigHolder*) fDetectorMap.GetValue(detector);
+ AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
if (!aHolder) {
AliError(Form("There isn't configuration for detector: %s",
detector));
return aHolder->GetDCSAliases();
}
-const TObjArray* AliShuttleConfig::GetDAQFileIDs(const char* detector) const {
+const TObjArray* AliShuttleConfig::GetDAQFileIDs(const char* detector) const
+{
//
// returns collection of TObjString which represents the set of DAQ file IDs
// which used for data retrieval for particular detector
//
- ConfigHolder* aHolder = (ConfigHolder*) fDetectorMap.GetValue(detector);
+ AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
if (!aHolder) {
AliError(Form("There isn't configuration for detector: %s",
detector));
return aHolder->GetDAQFileIDs();
}
-Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const {
+Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
+{
// return TRUE if detector is handled by host or if fProcessAll is TRUE
if(fProcessAll) return kTRUE;
return kFALSE;
}
-void AliShuttleConfig::Print(Option_t* /*option*/) const {
+void AliShuttleConfig::Print(Option_t* /*option*/) const
+{
+// print configuration
TString result;
result += '\n';
TIter iter(fDetectorMap.GetTable());
TPair* aPair;
while ((aPair = (TPair*) iter.Next())) {
- ConfigHolder* aHolder = (ConfigHolder*) aPair->Value();
+ AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
result += '\n';
result += " Detector: ";
result += aHolder->GetDetector();
//
// This class keeps the AliShuttle configuration.
// It reads the configuration for LDAP server.
+// For more info see AliShuttleConfig.cxx
//
#include <TObject.h>
const TObjArray* GetDAQFileIDs(const char* detector) const;
void SetProcessAll(Bool_t flag=kTRUE) {fProcessAll=flag;}
- Bool_t ProcessAll() {return fProcessAll;}
+ Bool_t ProcessAll() const {return fProcessAll;}
Bool_t HostProcessDetector(const char* detector) const;
private:
- class ConfigHolder: public TObject {
- TString fDetector;
- TString fDCSHost;
- Int_t fDCSPort;
- TObjArray fDCSAliases;
- TObjArray fDAQFileIDs;
- Bool_t fIsValid;
-
+ class AliShuttleConfigHolder: public TObject {
public:
- ConfigHolder(const TLDAPEntry* entry);
- ~ConfigHolder();
+ AliShuttleConfigHolder(const TLDAPEntry* entry);
+ ~AliShuttleConfigHolder();
const char* GetDetector() const {return fDetector.Data();};
const char* GetDCSHost() const {return fDCSHost.Data();};
Bool_t IsValid() const {return fIsValid;};
- ClassDef(ConfigHolder, 0);
+ private:
+ TString fDetector; // Detector name
+ TString fDCSHost; // Host name of the DCS server
+ Int_t fDCSPort; // port of the DCS server
+ TObjArray fDCSAliases; // List of DCS aliases to be retrieved
+ TObjArray fDAQFileIDs; // list of IDs of the files to be retrived from DAQ
+ Bool_t fIsValid; // flag for the validity of the configuration
+
+
+ ClassDef(AliShuttleConfigHolder, 0);
};
- Bool_t fIsValid;
+ Bool_t fIsValid; // flag for the validity of the configuration
- TString fDAQLogBookHost;
- TString fDAQLogBookUser;
- TString fDAQLogBookPassword;
+ TString fDAQLogBookHost; // Host of the DAQ logbook MySQL Server
+ TString fDAQLogBookUser; // username of the DAQ logbook MySQL Server
+ TString fDAQLogBookPassword; // password of the DAQ logbook MySQL Server
- TString fDAQFSHost;
+ TString fDAQFSHost; // Host of the DAQ file system
- TMap fDetectorMap;
- TObjArray fDetectorList;
+ TMap fDetectorMap; // Map of the detector-by-detector configuration
+ TObjArray fDetectorList; // List of detectors with valid configuration
- TString fShuttleInstanceHost;
- TObjArray fProcessedDetectors;
- Bool_t fProcessAll;
+ TString fShuttleInstanceHost; // Instance of the SHUTTLE
+ TObjArray fProcessedDetectors; // list of the detector to be processed by this machine
+ Bool_t fProcessAll; // flag indicating that all detectors will be processed
ClassDef(AliShuttleConfig, 0);
};
/*
$Log$
+ Revision 1.2 2006/06/06 14:26:40 jgrosseo
+ o) removed files that were moved to STEER
+ o) shuttle updated to follow the new interface (Alberto)
+
Revision 1.1 2006/03/07 07:52:34 hristov
New version (B.Yordanov)
ClassImp(TerminateSignalHandler)
+//______________________________________________________________________
+TerminateSignalHandler::TerminateSignalHandler(const TerminateSignalHandler& /*other*/):
+TSignalHandler()
+{
+// copy constructor (not implemented)
+
+}
+
+//______________________________________________________________________
+TerminateSignalHandler &TerminateSignalHandler::operator=(const TerminateSignalHandler& /*other*/)
+{
+// assignment operator (not implemented)
+
+return *this;
+}
+
//______________________________________________________________________________________________
-Bool_t TerminateSignalHandler::Notify() {
+Bool_t TerminateSignalHandler::Notify()
+{
+// Sentd terminate command to the Shuttle trigger
AliInfo("Terminate signal received ...");
fTrigger->Terminate();
return kTRUE;
}
+//______________________________________________________________________________________________
+//______________________________________________________________________________________________
+
ClassImp(AliShuttleTrigger)
//______________________________________________________________________________________________
gSystem->AddSignalHandler(&fInterruptSignalHandler);
}
+
+
+//______________________________________________________________________
+AliShuttleTrigger::AliShuttleTrigger(const AliShuttleTrigger& /*other*/):
+TObject()
+{
+// copy constructor (not implemented)
+
+}
+
+//______________________________________________________________________
+AliShuttleTrigger &AliShuttleTrigger::operator=(const AliShuttleTrigger& /*other*/)
+{
+// assignment operator (not implemented)
+
+return *this;
+}
+
+
+
+
+
//______________________________________________________________________________________________
-AliShuttleTrigger::~AliShuttleTrigger() {
+AliShuttleTrigger::~AliShuttleTrigger()
+{
+// destructor
gSystem->RemoveSignalHandler(&fQuitSignalHandler);
gSystem->RemoveSignalHandler(&fInterruptSignalHandler);
//______________________________________________________________________________________________
Bool_t AliShuttleTrigger::RetrieveDATEEntries(const char* whereClause,
- TObjArray& entries, Int_t& lastRun) {
+ TObjArray& entries, Int_t& lastRun)
+{
+// Retrieve start time and end time for all runs in the DAQ logbook
+// that aren't processed yet
TString sqlQuery;
sqlQuery += "select run, time_start, time_end from logbook ";
continue;
}
- entries.AddLast(new DATEEntry(run, startTime, endTime));
+ entries.AddLast(new AliShuttleTriggerDATEEntry(run, startTime, endTime));
if (lastRun < run) {
lastRun = run;
}
}
//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::RetrieveConditionsData(const TObjArray& dateEntries) {
+Bool_t AliShuttleTrigger::RetrieveConditionsData(const TObjArray& dateEntries)
+{
+// Retrieve conditions data for all runs that aren't processed yet
Bool_t hasError = kFALSE;
TIter iter(&dateEntries);
- DATEEntry* anEntry;
- while ((anEntry = (DATEEntry*) iter.Next())) {
+ AliShuttleTriggerDATEEntry* anEntry;
+ while ((anEntry = (AliShuttleTriggerDATEEntry*) iter.Next())) {
if(!fShuttle->Process(anEntry->GetRun(),
anEntry->GetStartTime(),
anEntry->GetEndTime())) {
}
//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::Collect(Int_t run) {
+Bool_t AliShuttleTrigger::Collect(Int_t run)
+{
//
// Collects conditions date for the given run.
//
}
//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::CollectNew() {
+Bool_t AliShuttleTrigger::CollectNew()
+{
//
// Collects conditions data for all new run written to DAQ LogBook.
//
}
//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::CollectAll() {
+Bool_t AliShuttleTrigger::CollectAll()
+{
//
// Collects conditions data for all run written in DAQ LogBook.
//
//
// This class is to deal with DAQ LogBook and DAQ end run notification.
// It executes AliShuttle for retrieval of conditions data.
+// For more info see AliShuttleTrigger.cxx
//
#include <TObject.h>
class TerminateSignalHandler: public TSignalHandler {
- AliShuttleTrigger* fTrigger;
public:
+ TerminateSignalHandler(): TSignalHandler((ESignals) 0,0), fTrigger(0) { }
TerminateSignalHandler(AliShuttleTrigger* trigger, ESignals signal):
TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
+ virtual ~TerminateSignalHandler() { }
virtual Bool_t Notify();
+private:
+
+ TerminateSignalHandler(const TerminateSignalHandler& other);
+ TerminateSignalHandler& operator= (const TerminateSignalHandler& other);
+
+ AliShuttleTrigger* fTrigger; // pointer to the current AliShuttleTrigger
+
ClassDef(TerminateSignalHandler, 0)
};
private:
- class DATEEntry: public TObject {
- Int_t fRun;
- UInt_t fStartTime;
- UInt_t fEndTime;
+ AliShuttleTrigger(const AliShuttleTrigger& other);
+ AliShuttleTrigger& operator= (const AliShuttleTrigger& other);
+
+ class AliShuttleTriggerDATEEntry: public TObject {
public:
- DATEEntry(Int_t run, UInt_t startTime, UInt_t endTime):
+ AliShuttleTriggerDATEEntry(Int_t run, UInt_t startTime, UInt_t endTime):
fRun(run), fStartTime(startTime), fEndTime(endTime) {}
- Int_t GetRun() {return fRun;}
- UInt_t GetStartTime() {return fStartTime;}
- UInt_t GetEndTime() {return fEndTime;}
+ Int_t GetRun() const {return fRun;}
+ UInt_t GetStartTime() const {return fStartTime;}
+ UInt_t GetEndTime() const {return fEndTime;}
- ClassDef(DATEEntry, 0)
+ private:
+ Int_t fRun; // Run number
+ UInt_t fStartTime; // Run start time
+ UInt_t fEndTime; // Run end time
+ ClassDef(AliShuttleTriggerDATEEntry, 0)
};
Bool_t RetrieveDATEEntries(const char* whereClause, TObjArray& entries,
const AliShuttleConfig* fConfig;
//AliCDBStorage* fLocalStorage;
- AliShuttle* fShuttle;
+ AliShuttle* fShuttle; // Pointer to the actual Shuttle instance
- Bool_t fNotified;
- Bool_t fTerminate;
+ Bool_t fNotified; // Notified flag
+ Bool_t fTerminate; // Terminate flag
- TMutex fMutex;
- TCondition fCondition;
+ TMutex fMutex; // Mutex
+ TCondition fCondition; // Condition
- TerminateSignalHandler fQuitSignalHandler;
- TerminateSignalHandler fInterruptSignalHandler;
+ TerminateSignalHandler fQuitSignalHandler; // Quit signal
+ TerminateSignalHandler fInterruptSignalHandler; // Interrupt signal
ClassDef(AliShuttleTrigger, 0)
// Shuttle classes ...
#pragma link C++ class AliShuttleConfig;
-#pragma link C++ class AliShuttleConfig::ConfigHolder;
+#pragma link C++ class AliShuttleConfig::AliShuttleConfigHolder;
#pragma link C++ class AliShuttle;
#pragma link C++ class AliShuttleTrigger;
#pragma link C++ class TerminateSignalHandler;
-#pragma link C++ class AliShuttleTrigger::DATEEntry;
+#pragma link C++ class AliShuttleTrigger::AliShuttleTriggerDATEEntry;
#endif