]>
Commit | Line | Data |
---|---|---|
7e0cf530 | 1 | // Author: Mihai Niculescu 2013 |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-2013, ALICE Experiment at CERN, all rights reserved. * | |
5 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
6 | * full copyright notice. * | |
7 | **************************************************************************/ | |
8 | ||
bd2715e3 | 9 | #include <RVersion.h> |
7e0cf530 | 10 | #include <stdlib.h> |
11 | ||
7e0cf530 | 12 | #include <TCondition.h> |
13 | #include <TBufferFile.h> | |
14 | #include <TMessage.h> | |
15 | #include <TObjArray.h> | |
16 | #include <TStreamerInfo.h> | |
17 | #include <TThread.h> | |
18 | ||
7e0cf530 | 19 | #include <AliESDEvent.h> |
20 | #include <AliESDfriend.h> | |
21 | #include <AliRawReader.h> | |
22 | #include <AliRunLoader.h> | |
23 | #include <AliReconstruction.h> | |
24 | ||
db352b46 | 25 | #include <AliNetMessage.h> |
26 | #include <AliSocket.h> | |
27 | ||
28 | #include <zmq.hpp> | |
29 | ||
7e0cf530 | 30 | #include "AliRecoServerThread.h" |
31 | ||
db352b46 | 32 | ClassImp(AliRecoServerThread) |
7e0cf530 | 33 | AliRecoServerThread::AliRecoServerThread(zmq::context_t *context, AliReconstruction* reco) |
f05dd9ed | 34 | : AliThreadedSocket(context, AliThreadedSocket::kWRITE), |
7e0cf530 | 35 | fReco(0), |
7e0cf530 | 36 | fCond(0) |
37 | { | |
7e0cf530 | 38 | fReco = reco; |
39 | } | |
40 | ||
41 | AliRecoServerThread::~AliRecoServerThread() | |
42 | { | |
5eb34a26 | 43 | Wait(); |
7e0cf530 | 44 | Stop(); |
45 | } | |
46 | ||
db352b46 | 47 | Bool_t AliRecoServerThread::Start(const char* endpoint) |
7e0cf530 | 48 | { |
db352b46 | 49 | fHost = endpoint; |
7e0cf530 | 50 | |
db352b46 | 51 | return AliThreadedSocket::Start(); |
7e0cf530 | 52 | } |
53 | ||
f05dd9ed | 54 | void AliRecoServerThread::RunThrdWrite() |
7e0cf530 | 55 | { |
56 | TThread::SetCancelAsynchronous(); | |
57 | TThread::SetCancelOn(); | |
58 | ||
db352b46 | 59 | // generate a publish socket |
f05dd9ed | 60 | AliSocket publisher(fContext, ZMQ_PUB); |
61 | publisher.Bind(fHost); | |
7e0cf530 | 62 | |
f05dd9ed | 63 | if(fReco==0) return; |
7e0cf530 | 64 | |
65 | AliESDEvent* event; | |
66 | ||
f05dd9ed | 67 | fReco->Begin(NULL); |
68 | if (fReco->GetAbort() != TSelector::kContinue) return; | |
7e0cf530 | 69 | |
f05dd9ed | 70 | fReco->SlaveBegin(NULL); |
71 | if (fReco->GetAbort() != TSelector::kContinue) return; | |
7e0cf530 | 72 | |
73 | //******* The loop over events | |
74 | Int_t iEvent = 0; | |
f05dd9ed | 75 | while ( fReco->HasNextEventAfter(iEvent) ) { |
7e0cf530 | 76 | // check if process has enough resources |
f05dd9ed | 77 | if (!fReco->HasEnoughResources(iEvent)) break; |
78 | Bool_t status = fReco->ProcessEvent(iEvent); | |
7e0cf530 | 79 | |
80 | if (status) | |
81 | { | |
f05dd9ed | 82 | event = fReco->GetESDEvent(); |
db352b46 | 83 | |
84 | AliNetMessage tmess(kMESS_OBJECT); | |
85 | tmess.Reset(); | |
86 | tmess.WriteObject(event); | |
87 | ||
88 | publisher.Send(tmess); | |
7e0cf530 | 89 | |
90 | sleep(1); | |
91 | } | |
92 | else { | |
f05dd9ed | 93 | fReco->Abort("ProcessEvent",TSelector::kAbortFile); |
7e0cf530 | 94 | } |
95 | ||
f05dd9ed | 96 | fReco->CleanProcessedEvent(); |
5eb34a26 | 97 | /* |
f05dd9ed | 98 | if(fCond->TimedWaitRelative(500)==0){ |
7e0cf530 | 99 | break; |
5eb34a26 | 100 | } */ |
7e0cf530 | 101 | iEvent++; |
102 | } | |
f05dd9ed | 103 | fReco->SlaveTerminate(); |
104 | if (fReco->GetAbort() != TSelector::kContinue) return; | |
105 | fReco->Terminate(); | |
106 | if (fReco->GetAbort() != TSelector::kContinue) return; | |
7e0cf530 | 107 | |
108 | } |