]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTHOMERProxyHandler.cxx
Cluster indices are published via AliKalmanTrack::GetClusterIndex()
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERProxyHandler.cxx
index 7ff8b98fd6b7ef91cd81c02dc5234f2cf42f34d6..c0ff11e438e1df3e22a1ab11eaf17a6f7a76d0cc 100644 (file)
@@ -37,6 +37,7 @@
 #include "TSystem.h"
 // -- -- -- -- -- -- -- 
 #include "AliHLTHOMERProxyHandler.h"
+// -- -- -- -- -- -- -- 
 
 ClassImp(AliHLTHOMERProxyHandler)
 
@@ -94,8 +95,9 @@ Int_t AliHLTHOMERProxyHandler::FillSourceList(TList *srcList) {
   if (!iResult)
     iResult = ProcessXmlRpcResponse();
 
-  if (iResult)
-    HLTError("Filling SourceList failed.");
+  if (iResult < 0) {
+    HLTError(Form("Filling SourceList failed."));
+  }
 
   return iResult;
 }
@@ -155,14 +157,15 @@ Int_t AliHLTHOMERProxyHandler::RequestXmlRpcResponse() {
 
   TSocket *socket = new TSocket(fgkHOMERProxyNode[fRealm], proxyPort);
   if ( ! socket->IsValid() ) {
-    HLTWarning("Failed to create socket to %s:%d,",fgkHOMERProxyNode[fRealm], proxyPort);
-    HLTWarning("trying %s:%d now.", fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort);
+    HLTWarning(Form("Failed to create socket to %s:%d,",fgkHOMERProxyNode[fRealm], proxyPort));
+    HLTWarning(Form("trying %s:%d now.", fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort));
 
     socket = new TSocket(fgkHOMERProxyNode[fRealm+kHOMERRealmsMax], proxyPort);
     if ( ! socket->IsValid() ) {
-      HLTError("Failed to create socket to %s:%d and %s:%d.",
-              fgkHOMERProxyNode[fRealm], proxyPort,
-              fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort);
+      HLTError(Form("Failed to create socket to %s:%d and %s:%d.",
+                   fgkHOMERProxyNode[fRealm], proxyPort,
+                   fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort));
+
       fRealm = -1;
       return -1;
     }
@@ -184,7 +187,7 @@ Content-Length: 68\r\n\
   iResult = socket->SendRaw( reqMsg, strlen(reqMsg) );
   if ( iResult < 1 || 
        iResult !=  static_cast<Int_t>(strlen(reqMsg))) {
-    HLTError("Error sending! -- send length %d  -- msg length %d.", iResult, strlen(reqMsg) );
+    HLTError(Form("Error sending! -- send length %d  -- msg length %d.", iResult, static_cast<Int_t>(strlen(reqMsg)) ));
     socket->Close();
     return iResult;
   }
@@ -209,7 +212,7 @@ Content-Length: 68\r\n\
 
       iResult = socket->RecvRaw(&buffer[bufferLength], 1);
       if ( iResult < 0) {
-       HLTError("Error reading form socket.");
+       HLTError(Form("Error reading form socket."));
        socket->Close();
        return iResult;
       }
@@ -257,12 +260,14 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
   TDOMParser xmlParser;
   xmlParser.SetValidate(kFALSE);
 
-  HLTDebug("XMLResponse:\n %s",fXmlRpcResponse.Data());
-
+  HLTDebug(Form("XMLResponse: %s",fXmlRpcResponse.Data()));
+  
   iResult = xmlParser.ParseBuffer(fXmlRpcResponse.Data(), fXmlRpcResponse.Length());
   if ( iResult < 0 ) {
-    HLTError("Parsing buffer with error: %s", 
-            xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) );
+    HLTError(Form("Parsing buffer with error: %s", 
+                 xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) ));
+    
+
     return iResult;
   }
 
@@ -270,7 +275,7 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
     GetChildren()->GetChildren()->GetChildren()->GetChildren();
   
   if ( strcmp( node->GetNodeName(), "string" ) ) {
-    HLTError("No node 'string' in XmlRpcResponse.");
+    HLTError(Form("No node 'string' in XmlRpcResponse."));
     return -1;
   }
 
@@ -280,19 +285,19 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
   // -- Get Content
   TString xmlContent(node->GetText() );
 
-  HLTDebug("XMLContent:\n %s",xmlContent.Data());
+  HLTDebug(Form("XMLContent: %s",xmlContent.Data()));
 
   iResult = xmlParser.ParseBuffer(xmlContent.Data(), xmlContent.Length());
   if ( iResult < 0 ) {
-    HLTError("Parsing buffer with error: %s", 
-            xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) );
+    HLTError(Form("Parsing buffer with error: %s", 
+                 xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) ));
+
     return iResult;
   }
   
-
   if ( !xmlParser.GetXMLDocument()->GetRootNode()->HasChildren() ) {
-    HLTInfo("No Services active.");
-    return 0;
+    HLTWarning(Form("No Services active."));
+    return 1;
   }
 
   // -- Loop over all service nodes
@@ -304,9 +309,14 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
 
     // -- Add service to list
     iResult = AddService( serviceNode->GetChildren() );
-       
+    if ( iResult > 0 ) {
+      HLTWarning(Form("Incomplete Service not added."));
+      iResult = 0;
+    }
   } while ( ( serviceNode = prevServiceNode->GetNextNode() ) && !iResult );
 
+
+
   return iResult;
 }
 
@@ -322,7 +332,9 @@ Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
 
   Int_t iResult = 0;
 
-  HLTInfo(">> New service");    
+  HLTInfo(Form(">> New service"));    
+
+  TXMLNode* serviceNode = innerNode;
 
   // -- Loop over all service properties and 
   //    read them from the service tag
@@ -336,59 +348,128 @@ Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
 
   TXMLNode* prevInnerNode = NULL;
 
+  // -- Retrieve hostname and port
+  // -------------------------------
+
   do {
     prevInnerNode = innerNode;
     
     if ( ! strcmp(innerNode->GetNodeName(), "text" ) )
       continue;
-    
-    HLTInfo(" %s ++ %s", innerNode->GetNodeName(), innerNode->GetText() );
-    
+        
     // -- hostname
-    if ( ! strcmp( innerNode->GetNodeName(), "address") )
+    if ( ! strcmp( innerNode->GetNodeName(), "address") ) {
+      HLTInfo(Form("  > %s ++ %s", innerNode->GetNodeName(), innerNode->GetText() ));
       hostname = innerNode->GetText();
+    }
     else if ( ! strcmp( innerNode->GetNodeName(), "port") ) {
+      HLTInfo(Form("  > %s ++ %s", innerNode->GetNodeName(), innerNode->GetText() ));
       TString portS(innerNode->GetText());
       if ( portS.IsDigit() )
        port = portS.Atoi();
       else {
-       HLTError("Port %s is not a digit.", portS.Data());
+       HLTError(Form("Port %s is not a digit.", portS.Data()));
        iResult = -1;
       }
     }
-    else if ( ! strcmp( innerNode->GetNodeName(), "dataorigin") )
-      dataOrigin = innerNode->GetText();
-    else if ( ! strcmp( innerNode->GetNodeName(), "datatype") )
-      dataType = innerNode->GetText();
-    else if ( ! strcmp( innerNode->GetNodeName(), "dataspecification") )
-      dataSpecification = innerNode->GetText();    
-  
   } while ( ( innerNode = prevInnerNode->GetNextNode() ) && !iResult );
 
-  // -- Check the service properties
-  // ---------------------------------
 
   // -- Change hostame from service with proxy, if outside HLT
   if ( fRealm != kHLT || fRealm != kHLT+kHOMERRealmsMax )
     hostname = fgkHOMERProxyNode[fRealm];
 
-  // -- Check for completeness of the source properties
-  if ( hostname.IsNull() || !port || dataOrigin.IsNull() ||
-       dataType.IsNull() /*|| dataSpecification.IsNull()*/ ) {
-    HLTError("Service provides not all values:\n\thostname\t\t %s\n\tport\t\t\t %d\n\tdataorigin\t\t %s\n\tdatatype\t\t %s\n\tdataspecification\t %s", hostname.Data(),
-            port, dataOrigin.Data(), dataType.Data(), dataSpecification.Data());
-    return -2;
-  }
 
-  // -- Create new source
-  // ----------------------
+  // -- Get Data Specifications from blocks
+  // ----------------------------------------
+
+  do {
+    prevInnerNode = serviceNode;
+
+    if ( strcmp( serviceNode->GetNodeName(), "blocks") )
+      continue;
+    TXMLNode* blocks = serviceNode->GetChildren();
+
+    if ( ! blocks ) {
+      HLTError(Form("No blocks present"));
+      return 1;
+    }
+      
+    TXMLNode* blockNode = blocks->GetNextNode();
+    TXMLNode* prevBlockNode = NULL;
+
+    if ( ! blockNode ) {
+      HLTError(Form("No block present in the blocks tag"));
+      return 1;
+    }
+      
+    // -- blocks loop 
+    
+    do {
+      prevBlockNode = blockNode;
+      
+      if ( strcmp( blockNode->GetNodeName(), "block") )
+       continue;
+
+      TXMLNode *dataNode = blockNode->GetChildren();
+      TXMLNode *prevDataNode = NULL;
+
+      if ( ! dataNode ) {
+       HLTError(Form("No data specification tags present in block tag."));
+       return 1;
+      }
+      // -- data spec loop
+      
+      do {
+       prevDataNode = dataNode;
+
+       if ( ! strcmp(dataNode->GetNodeName(), "text" ) )
+         continue;
+
+       HLTInfo(Form(" %s ++ %s", dataNode->GetNodeName(), dataNode->GetText() ));      
+
+       if ( ! strcmp( dataNode->GetNodeName(), "dataorigin") ) {
+         dataOrigin = dataNode->GetText();
+       }
+       else if ( ! strcmp( dataNode->GetNodeName(), "datatype") ) {
+         dataType = dataNode->GetText();
+       }
+       else if ( ! strcmp( dataNode->GetNodeName(), "dataspecification") ) {
+         dataSpecification = dataNode->GetText();    
+       }
+      } while ( ( dataNode = prevDataNode->GetNextNode() ) && !iResult );
+      
+      // -- data spec loop
 
-  AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc();
-  source->SetService( hostname, port, dataOrigin, dataType, dataSpecification );
+      // -- Check the service properties
+      // ---------------------------------
+      
+      // -- Check for completeness of the source properties
+      if ( hostname.IsNull() || !port || dataOrigin.IsNull() ||
+          dataType.IsNull() || dataSpecification.IsNull() ) {
+       HLTWarning(Form("Service provides not all values:\n\thostname\t\t %s\n\tport\t\t\t %d\n\tdataorigin\t\t %s\n\tdatatype\t\t %s\n\tdataspecification\t 0x%08X", 
+                       hostname.Data(), port, dataOrigin.Data(), dataType.Data(), dataSpecification.Atoi()));
+       
+       return 1;
+      }
 
-  fSourceList->Add( source );
+      // -- Create new source
+      // ----------------------
+      
+      AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc();
+      source->SetService( hostname, port, dataOrigin, dataType, dataSpecification );
+      
+      fSourceList->Add( source );
+      
+      HLTInfo(Form( "New Source added : %s", source->GetSourceName().Data()));
+
+    } while ( ( blockNode = prevBlockNode->GetNextNode() ) && !iResult );
 
-  HLTInfo( "New Source added : %s", source->GetSourceName().Data());
+
+    // -- blocks loop
+    
+  } while ( ( serviceNode = prevInnerNode->GetNextNode() ) && !iResult );
   
   return iResult;
 }