]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTHOMERProxyHandler.cxx
adding unit test for AliHLTDataBuffer class
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERProxyHandler.cxx
index ba98e469e3157e313e3a27fd66fc5fde09148d2c..10f9a58eaf0e3d9bf0c7d41e8178567bd90ea8b7 100644 (file)
@@ -114,10 +114,12 @@ const Char_t *AliHLTHOMERProxyHandler::fgkHOMERProxyNode[] = {
   "alihlt-dcs0.cern.ch",
   "alihlt-vobox0.cern.ch",
   "alihlt-gw0.kip.uni-heidelberg.de",
+  "localhost",
   "portal-dcs1.internal", 
   "alihlt-dcs1.cern.ch",
   "alihlt-vobox1.cern.ch",
-  "alihlt-gw1.kip.uni-heidelberg.de"
+  "alihlt-gw1.kip.uni-heidelberg.de",
+  "localhost"
 };
 
 //##################################################################################
@@ -132,9 +134,15 @@ void AliHLTHOMERProxyHandler::IdentifyRealm() {
     fRealm = kACR;
   else if ( hostIP.Contains("129.206.") )
     fRealm = kKIP;
-  else 
+  else  if ( hostIP.Contains("137.138") 
+            || hostIP.Contains("128.141") 
+            || hostIP.Contains("127.0.") 
+            )
     fRealm = kGPN;
-  
+  else {
+    fRealm = kLoc;
+  }
+
   return;
 }
 
@@ -260,8 +268,8 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
   TDOMParser xmlParser;
   xmlParser.SetValidate(kFALSE);
 
-  HLTInfo(Form("XMLResponse: %s",fXmlRpcResponse.Data()));
-
+  HLTDebug(Form("XMLResponse: %s",fXmlRpcResponse.Data()));
+  
   iResult = xmlParser.ParseBuffer(fXmlRpcResponse.Data(), fXmlRpcResponse.Length());
   if ( iResult < 0 ) {
     HLTError(Form("Parsing buffer with error: %s", 
@@ -285,7 +293,7 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
   // -- Get Content
   TString xmlContent(node->GetText() );
 
-  HLTInfo(Form("XMLContent: %s",xmlContent.Data()));
+  HLTDebug(Form("XMLContent: %s",xmlContent.Data()));
 
   iResult = xmlParser.ParseBuffer(xmlContent.Data(), xmlContent.Length());
   if ( iResult < 0 ) {
@@ -295,7 +303,6 @@ Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
     return iResult;
   }
   
-
   if ( !xmlParser.GetXMLDocument()->GetRootNode()->HasChildren() ) {
     HLTWarning(Form("No Services active."));
     return 1;
@@ -335,6 +342,8 @@ Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
 
   HLTInfo(Form(">> New service"));    
 
+  TXMLNode* serviceNode = innerNode;
+
   // -- Loop over all service properties and 
   //    read them from the service tag
   // -----------------------------------------
@@ -347,18 +356,22 @@ Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
 
   TXMLNode* prevInnerNode = NULL;
 
+  // -- Retrieve hostname and port
+  // -------------------------------
+
   do {
     prevInnerNode = innerNode;
     
     if ( ! strcmp(innerNode->GetNodeName(), "text" ) )
       continue;
-    
-    HLTInfo(Form(" %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();
@@ -367,40 +380,104 @@ Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
        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 )
+  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() ) {
-    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 %s", 
-                 hostname.Data(), port, dataOrigin.Data(), dataType.Data(), dataSpecification.Data()));
 
-    return 1;
-  }
+  // -- 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;
 
-  // -- Create new source
-  // ----------------------
+    if ( ! blockNode ) {
+      HLTError(Form("No block present in the blocks tag"));
+      return 1;
+    }
+      
+    // -- blocks loop 
+    
+    do {
+      prevBlockNode = blockNode;
+      
+      if ( strcmp( blockNode->GetNodeName(), "block") )
+       continue;
 
-  AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc();
-  source->SetService( hostname, port, dataOrigin, dataType, dataSpecification );
+      TXMLNode *dataNode = blockNode->GetChildren();
+      TXMLNode *prevDataNode = NULL;
 
-  fSourceList->Add( source );
+      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
 
-  HLTInfo(Form( "New Source added : %s", source->GetSourceName().Data()));
+      // -- 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;
+      }
+
+      // -- 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 );
+
+
+    // -- blocks loop
+    
+  } while ( ( serviceNode = prevInnerNode->GetNextNode() ) && !iResult );
   
   return iResult;
 }