Added new message type "Unknown alias/DP" (type n. 7)
authoracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Nov 2007 16:25:37 +0000 (16:25 +0000)
committeracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Nov 2007 16:25:37 +0000 (16:25 +0000)
Updated server error code schema

Started implementing keepAlive message handling

SHUTTLE/DCSClient/AliDCSClient.cxx
SHUTTLE/DCSClient/AliDCSClient.h
SHUTTLE/DCSClient/AliDCSMessage.cxx
SHUTTLE/DCSClient/AliDCSMessage.h

index 82b33dd..3c4752b 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $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
 
@@ -113,6 +116,7 @@ const char* AliDCSClient::fgkTimeoutString = "Timeout";
 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,
@@ -423,6 +427,11 @@ TMap* AliDCSClient::GetValues(AliDCSMessage::RequestType reqType,
 
                        if (fResultErrorCode < 0)
                        {
+                               if (fResultErrorCode == fgkUnknownDP)
+                               {
+                                       AliError(Form("%s",fServerError.Data()));
+                               }
+                               
                                AliError("Can't get values");
 
                                delete resultSet;
@@ -509,6 +518,14 @@ Int_t AliDCSClient::ReceiveValueSet(TObjArray* result, Int_t& ownerIndex)
 
                return AliDCSClient::fgkServerError;
        }
+       
+       else if (message.GetType() == AliDCSMessage::kUnknownDP)
+       {
+               fServerError = message.GetErrorString();
+
+               return AliDCSClient::fgkUnknownDP;
+       }
+       
 
        AliError("Bad message type received!");
        return AliDCSClient::fgkBadMessage;
@@ -643,6 +660,9 @@ const char* AliDCSClient::GetErrorString(Int_t code)
 
                case AliDCSClient::fgkServerError:
                        return AliDCSClient::fgkServerErrorString;
+               
+               case AliDCSClient::fgkUnknownDP:
+                       return AliDCSClient::fgkUnknownDPString;
 
                default:
                        AliErrorGeneral("AliDCSClient::GetErrorString",
index df1bb6b..b05d47e 100644 (file)
@@ -28,7 +28,8 @@ public:
                fgkTimeout = -3,             // Timeout
                fgkBadMessage = -4,          // Bad message
                fgkCommError = -5,           // Communication error
-               fgkServerError = -6          // Server error
+               fgkServerError = -6,         // Server error
+               fgkUnknownDP = -7            // unknown alias/DP error
        };
        
 ////   friend class AliShuttle;
@@ -68,6 +69,7 @@ private:
        static const char* fgkBadMessageString;         // Bad message string
        static const char* fgkCommErrorString;          // Communication error string
        static const char* fgkServerErrorString;        // Server error string
+       static const char* fgkUnknownDPString;          // Unknown alias/DP string
 
        TSocket* fSocket;       // Pointer to the TCP socket client
        TString fHost;          // server host
index b73ca52..79b000b 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.2  2007/10/16 14:37:17  jgrosseo
+changing to AMANDA protocol version 2
+
 Revision 1.1  2006/11/06 14:22:47  jgrosseo
 major update (Alberto)
 o) reading of run parameters from the logbook
@@ -232,6 +235,7 @@ void AliDCSMessage::CreateErrorMessage(ErrorCode errorCode,
 }
 
 
+//______________________________________________________________________
 void AliDCSMessage::CreateNextMessage() {
        DestroyMessage();
 
@@ -581,6 +585,8 @@ Bool_t AliDCSMessage::ValidateHeader(const char* buf)
                return kFALSE;
        }
 
+       
+       
        Type type = (Type) GetUByte(buf + TYPE_OFFSET); 
        switch (type) {
                case kRequest:
@@ -588,6 +594,8 @@ Bool_t AliDCSMessage::ValidateHeader(const char* buf)
                case kResultSet:
                case kError:
                case kMultiRequest:
+               case kUnknownDP:
+               case kHeartBeat:
                        break;
                default:
                        AliError("Unknown message type!");
@@ -760,17 +768,34 @@ void AliDCSMessage::LoadErrorMessage()
                fMessageSize - ERROR_STRING_OFFSET);
 
        switch (fErrorCode) {
-               case kUnknownAliasDPName:
-                case kInvalidTimeRange:
-                case kInvalidBufferSize:
-                case kInvalidRequest:
-                case kUnsupportedType:
-                case kUnknownError:
+               case kConnectionFailed:
+               case kUnexpectedPacketFormat:
+               case kDataRetrievingFailed:
+               case kUnsupportedProtocolVersion:
+               case kUnknownError:
                        fType = kError;
                        break;
                default:
                        AliError("Invalid error code!");
        }
+       
+}
+
+//______________________________________________________________________
+void AliDCSMessage::LoadUnknownDPMessage()
+{
+// load unknown message
+       
+       if (fMessageSize < ERROR_STRING_OFFSET) {
+               AliError("Body size is too small for error message!");
+               return;
+       }
+       
+       fType = kUnknownDP;
+       
+       fErrorString = GetString(fMessage + UNKNOWN_DP_OFFSET,
+               fMessageSize - UNKNOWN_DP_OFFSET);
+
 }
 
 //______________________________________________________________________
@@ -828,6 +853,14 @@ void AliDCSMessage::LoadNextMessage()
 }
 
 //______________________________________________________________________
+void AliDCSMessage::LoadHeartBeatMessage()
+{
+       //
+
+       fType = kHeartBeat;
+}
+
+//______________________________________________________________________
 void AliDCSMessage::StoreToBuffer() 
 {
        // Creates an underlying message buffer which can be sent to the socket.
@@ -906,11 +939,16 @@ void AliDCSMessage::LoadFromBuffer()
                case kError:
                        LoadErrorMessage();
                        break;
+               case kUnknownDP:
+                       LoadUnknownDPMessage();
+                       break;
                case kMultiRequest:
                        LoadMultiRequestMessage();
                        break;
                case kNext:
                        LoadNextMessage();
+               case kHeartBeat:
+                       LoadHeartBeatMessage();
                        break;
                default:
                        AliError("Invalid message type!");
@@ -1156,12 +1194,12 @@ TString AliDCSMessage::GetErrorString() const
        // error message.
        //
 
-        if (GetType() != kError) {
-                AliError("Invalid AliDCSMessage type!");
-                return TString("");
+        if (GetType() == kError || GetType() == kUnknownDP) {
+               return fErrorString;
         }
 
-       return fErrorString;
+        AliError("Invalid AliDCSMessage type!");
+        return TString("");
 }
 
 
@@ -1175,13 +1213,12 @@ void AliDCSMessage::Print(Option_t* /*option*/) const
        }
 
        TString printString;
-       printString += "\n <<AliDCSMessage>>\n";
+       printString += "\n <<AliDCSMessage>> - ";
 
        printString += " Size: ";
        printString += fMessageSize;
-       printString += '\n';
-
-       printString += " Type: ";
+       
+       printString += "  - Type: ";
        switch (GetType()) {
                case kRequest: {
                        printString += "Request\n";
@@ -1235,20 +1272,17 @@ void AliDCSMessage::Print(Option_t* /*option*/) const
                                case AliDCSMessage::kNoneError:
                                        printString += "NoneError";
                                        break;
-                               case AliDCSMessage::kUnknownAliasDPName:
-                                       printString += "UnknownAliasDPName";
+                               case AliDCSMessage::kConnectionFailed:
+                                       printString += "ConnectionFailed";
                                        break;
-                               case AliDCSMessage::kInvalidTimeRange:
-                                       printString += "InvalidTimeRange";
+                               case AliDCSMessage::kUnexpectedPacketFormat:
+                                       printString += "UnexpectedPacketFormat";
                                        break;
-                               case AliDCSMessage::kInvalidBufferSize:
-                                       printString += "InvalidBufferSize";
+                               case AliDCSMessage::kDataRetrievingFailed:
+                                       printString += "DataRetrievingFailed";
                                        break;
-                               case AliDCSMessage::kInvalidRequest:
-                                       printString += "InvalidRequest";
-                                       break;
-                               case AliDCSMessage::kUnsupportedType:
-                                       printString += "UnsupportedType";
+                               case AliDCSMessage::kUnsupportedProtocolVersion:
+                                       printString += "UnsupportedProtocolVersion";
                                        break;
                                case AliDCSMessage::kUnknownError:
                                        printString += "UnknownError";
@@ -1264,6 +1298,15 @@ void AliDCSMessage::Print(Option_t* /*option*/) const
                        break;
                }
 
+               case kUnknownDP: {
+                       printString += "UnknownAlias/DP\n";
+                       printString += '\n';
+                       printString += " Message: ";
+                       printString += GetErrorString();
+                       printString += '\n';
+                       break;
+               }
+               
                case kMultiRequest: {
                        printString += "MultiRequest\n";
 
@@ -1297,6 +1340,11 @@ void AliDCSMessage::Print(Option_t* /*option*/) const
                        printString += "Next\n";
                        break;
                }
+               
+               case kHeartBeat: {
+                       printString += "HeartBeat\n";
+                       break;
+               }
 
                default:
                        printString += "Invalid\n";
index ab53904..c5305fe 100644 (file)
@@ -39,6 +39,7 @@
 #define VALUES_OFFSET (VALUE_COUNT_OFFSET + 4)
 
 #define ERROR_CODE_OFFSET HEADER_SIZE
+#define UNKNOWN_DP_OFFSET HEADER_SIZE
 #define ERROR_STRING_OFFSET (HEADER_SIZE + 1)
 
 class AliDCSMessage: public TObject {
@@ -46,11 +47,13 @@ public:
        enum Type {
                kInvalid = 0,
                kRequest = 1,
-               kCount = 2,
+               kCount = 2,     // obsolete in protocol 2
                kResultSet = 3,
                kError = 4,
                kMultiRequest = 5,
-               kNext = 6
+               kNext = 6,
+               kUnknownDP = 7,
+               kHeartBeat = 8
        };
 
        enum RequestType {
@@ -58,14 +61,13 @@ public:
                kAlias = 1,
                kDPName = 2     
        };
-
+       
        enum ErrorCode {
                kNoneError = 0,
-               kUnknownAliasDPName = 1,
-               kInvalidTimeRange = 2,
-               kInvalidBufferSize = 3,
-               kInvalidRequest = 4,
-               kUnsupportedType = 5,
+               kConnectionFailed = 1,
+               kUnexpectedPacketFormat = 2,
+               kDataRetrievingFailed = 3,
+               kUnsupportedProtocolVersion = 4,
                kUnknownError = 255
        };
 
@@ -179,7 +181,7 @@ private:
        UInt_t fCount;                  // count counter
 
        //ResultSet message fields
-  Int_t fOwnerIndex;  // owner index of this result
+       Int_t fOwnerIndex;  // owner index of this result
        AliDCSValue::Type fValueType; // Simple value type
 
        TObjArray* fValues;             // array of received values
@@ -219,9 +221,13 @@ private:
 
        void LoadErrorMessage();
 
+       void LoadUnknownDPMessage();
+
        void LoadMultiRequestMessage();
 
        void LoadNextMessage();
+       
+       void LoadHeartBeatMessage();
 
        // Buffer helpers
        static void SetBool(char* buf, Bool_t val);