repairing server's action after EOR signal
authorjniedzie <jeremi.niedziela@cern.ch>
Tue, 30 Sep 2014 05:57:42 +0000 (07:57 +0200)
committerjniedzie <jeremi.niedziela@cern.ch>
Mon, 13 Oct 2014 06:18:03 +0000 (08:18 +0200)
MONITOR/alieventserver/AliEventServer.cxx
MONITOR/alieventserver/AliEventServerReconstruction.cxx
MONITOR/alieventserver/AliEventServerReconstruction.h
MONITOR/alieventserver/AliEventServerWindow.cxx
MONITOR/alieventserver/alieventserver.rootrc

index 7c9261f..723079a 100644 (file)
@@ -81,8 +81,14 @@ void AliEventServer::StartOfRun(Int_t run)
 {
   cout<<"SOR signal received for run:"<<run<<endl;
   if(run<=0) return;
+  /*
+  while(!fRecoServer->StopReconstruction())
+    {
+      cout<<"Waiting for previous reco to be fully initialized"<<endl;
+      sleep(10);
+      }*/
   fRecoServer->StopReconstruction();
-       
+
   TEnv settings;
   settings.ReadFile(AliEventServerUtil::GetPathToServerConf(), kEnvUser);
     
index ed93a2e..5744b87 100644 (file)
@@ -45,7 +45,8 @@ AliEventServerReconstruction::AliEventServerReconstruction()
          fSettings(0),
          fHost(0),
          fRecoThread(0),
-         fRecoIsRunning(false)
+         fRecoIsRunning(false),
+         fRecoWasInitialized(false)
 {}
 
 AliEventServerReconstruction::~AliEventServerReconstruction()
@@ -67,6 +68,7 @@ void AliEventServerReconstruction::Close()
 
 Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char* input)
 {
+  cout<<"Start of run:"<<run<<endl;
        fCurrentRunId = run;
 
        // re-read settings
@@ -85,6 +87,7 @@ Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char*
        }
        gSystem->cd(recoBaseDir.Data());
 
+
        TString gdcs;
        if (RetrieveGRP(run,gdcs) <= 0 || gdcs.IsNull()){return kFALSE;}
          
@@ -92,32 +95,33 @@ Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char*
        gSystem->cd(Form("run%d", run));
 
        // Create Reco and Reco Thread
+       cout<<"Setup reco will be called"<<endl;
        SetupReco(input);
        
        fHost = (const char*)Form("%s:%d", fSettings->GetValue("server.host", DEFAULT_SERVER_HOST), fSettings->GetValue("server.port", DEFAULT_SERVER_PORT));
        
-       fRecoThread = new TThread("AliEventServerReconstruction",
-                              Dispatch,
-                              (void*)this);
+       cout<<"Creating new thread"<<endl;
+       fRecoThread = new TThread("AliEventServerReconstruction",Dispatch, (void*)this);
        fRecoThread->Run();
        fIsListenning = kTRUE;
        fRecoIsRunning=true;
-
+       cout<<"Reco started"<<endl;
        return true;
 }
 
-void AliEventServerReconstruction::StopReconstruction()
+bool AliEventServerReconstruction::StopReconstruction()
 {
   cout<<"Reco server -- StopPeconstruction() called"<<endl;
-  if(!fRecoIsRunning)
+  if(!fRecoIsRunning || !fRecoThread)
     {
-      cout<<"Reco is not running. Returning"<<endl;
-      return;
+      cout<<"Reco is not running. No need to stop it."<<endl;
+      return true;
     }
-  if(!fRecoThread) 
+  if(!fRecoWasInitialized)
     {
-      cout<<"Reco server -- no thread. Returning"<<endl;
-      return;
+      cout<<"Reco is under initialization. Wait until it's finished"<<endl;
+      
+      return false;
     }
   cout<<"killing thread"<<endl;
   fRecoThread->Kill();
@@ -129,15 +133,17 @@ void AliEventServerReconstruction::StopReconstruction()
 
   cout<<"Reco server -- terminating reconstruction"<<endl;     
   fAliReco->SlaveTerminate();
-  if (fAliReco->GetAbort() != TSelector::kContinue) return;
+  if (fAliReco->GetAbort() != TSelector::kContinue) return false;
   fAliReco->Terminate();
-  if (fAliReco->GetAbort() != TSelector::kContinue) return; 
+  if (fAliReco->GetAbort() != TSelector::kContinue) return false; 
        
   if(fAliReco){delete fAliReco;fAliReco=0;}
   cout<<"Reco server -- deleting CDBManager"<<endl;
-  if(fCDBmanager){delete fCDBmanager;fCDBmanager=0;}
+  if(fCDBmanager){fCDBmanager->Destroy();fCDBmanager=0;}
   cout<<"Reco server -- recontruction stopped"<<endl;
   fRecoIsRunning=false;
+  fRecoWasInitialized=false;
+  return true;
 }
 
 void AliEventServerReconstruction::ReconstructionHandle()
@@ -146,20 +152,22 @@ void AliEventServerReconstruction::ReconstructionHandle()
        TThread::SetCancelOn();
        
        if(!fAliReco) return;
-       
-       AliESDEvent* event;
-       
+
        AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
        eventManager->CreateSocket(EVENTS_SERVER_PUB);
        eventManager->CreateSocket(XML_PUB);
-
+       cout<<"Sockets created"<<endl;
        fAliReco->Begin(NULL);
+       cout<<"Reco began"<<endl;
        if (fAliReco->GetAbort() != TSelector::kContinue) return;
        fAliReco->SlaveBegin(NULL);
+       cout<<"Slave began"<<endl;
        if (fAliReco->GetAbort() != TSelector::kContinue) return;
 
+       fRecoWasInitialized=true;
        //******* The loop over events
        Int_t iEvent = 0;
+       AliESDEvent* event;
        while (fAliReco->HasNextEventAfter(iEvent))
        {
                // check if process has enough resources 
@@ -180,12 +188,7 @@ void AliEventServerReconstruction::ReconstructionHandle()
                fAliReco->CleanProcessedEvent();
                iEvent++;
        }
-       fAliReco->SlaveTerminate();
-       if (fAliReco->GetAbort() != TSelector::kContinue) return;
-       fAliReco->Terminate();
-       if (fAliReco->GetAbort() != TSelector::kContinue) return;
        StopReconstruction();
-       fRecoIsRunning=false;
 }
 
 Int_t AliEventServerReconstruction::RetrieveGRP(UInt_t run, TString &gdc)
index 1c78aa1..e8bc44f 100644 (file)
@@ -26,7 +26,7 @@ public:
        virtual ~AliEventServerReconstruction();
 
        Bool_t StartReconstruction(Int_t run, const char* input="mem://@*:");
-       void  StopReconstruction();  
+       bool  StopReconstruction();  
        
        // Closes the server. The server will no longer listen/serve
        void Close();
@@ -49,6 +49,8 @@ private:
        TString fHost;
        TThread *fRecoThread;
        bool fRecoIsRunning;
+       bool fRecoWasInitialized;
+       const char *fInput;
 
        AliEventServerReconstruction(const AliEventServerReconstruction&);
        AliEventServerReconstruction& operator=(const AliEventServerReconstruction&);
index f2938a6..764069d 100644 (file)
@@ -275,7 +275,6 @@ void AliEventServerWindow::StartOfRun(Int_t run)
 
        // Slot called from DIM handler on start of run.
        AliInfo(Form("called for Run %d ", run));
-
        fRunList->AddEntrySort(TString::Format("%d", run), run);
        fRunList->Layout();
        gClient->NeedRedraw(fRunList);
index 753e5f7..84057b1 100644 (file)
@@ -15,7 +15,7 @@ reco.runPlaneEff:                        1
 reco.writeESDfriend:                     0
 reco.writeAlignment:                     1
 reco.cleanESD:                           0
-reco.detectors:                          ALL  -PHOS -EMCAL
+reco.detectors:                          ALL  -PHOS -EMCAL -HLT
 logbook.host:                            localhost
 logbook.port:                            3306
 logbook.db:                              logbook