11 fManager(onlineReconstructionManager),
12 fCommunicationThread(0)
37 storageSockets socket = CLIENT_COMMUNICATION_REP;
40 struct clientRequestStruct *request;
41 struct clientRequestStruct *response =
new struct clientRequestStruct;
43 cout<<
"COMMUNICATION -- Communication stated"<<endl;
46 bool receiveStatus =
false;
47 bool sendStatus =
false;
51 cout<<
"COMMUNICATION -- waiting for requests"<<endl;
54 receiveStatus = eventManager->
Get(request,socket);
56 }
while (receiveStatus ==
false);
58 cout<<
"COMMUNICATION -- received request"<<endl;
59 switch(request->messageType)
61 case REQUEST_CONNECTION:
64 case REQUEST_RECEIVING:
70 case REQUEST_CURRENT_SIZE:
73 case REQUEST_GET_PARAMS:
79 sendStatus = eventManager->
Send(response,socket);
81 case REQUEST_SET_PARAMS:
83 request->maxOccupation,
84 request->removeEvents,
85 request->eventsInChunk);
92 sendStatus = eventManager->
Send(
true,socket);
95 cout<<
"COMMUNICATION -- unknown request"<<endl;
99 if(sendStatus ==
false)
111 cout<<maxStorageSize<<endl<<maxOccupation<<endl<<removeEvents<<endl<<eventsInChunk<<endl;
114 ifstream configFile (GetConfigFilePath());
115 ofstream tmpFile(
"tmpFile.bla");
117 if (configFile.is_open())
122 while(configFile.good())
124 getline(configFile,line);
125 from = line.find(
"\"")+1;
126 to = line.find_last_of(
"\"");
128 if(line.find(
"MAX_SIZE=")==0){
129 tmpLine = Form(
"MAX_SIZE=\"%d\"",maxStorageSize);
131 else if(line.find(
"MAX_OCCUPATION=")==0){
132 tmpLine = Form(
"MAX_OCCUPATION=\"%d\"",maxOccupation);
134 else if(line.find(
"REMOVE_PERCENT=")==0){
135 tmpLine = Form(
"REMOVE_PERCENT=\"%d\"",removeEvents);
137 else if(line.find(
"EVENTS_IN_FILE=")==0){
138 tmpLine = Form(
"EVENTS_IN_FILE=\"%d\"",eventsInChunk);
143 if(configFile.eof()){configFile.clear();}
146 rename(
"tmpFile.bla",GetConfigFilePath());
148 else{cout<<
"CLIENT -- Unable to open config file"<<endl;}
void CommunicationHandle()
~AliCommunicationThread()
static AliZMQManager * GetInstance()
int fRemoveEventsPercentage
int fNumberOfEventsInFile
ZMQ communication manager.
AliCommunicationThread(AliStorageClientThread *onlineReconstructionManager)
void CreateSocket(storageSockets socket)
bool Send(std::vector< serverListStruct > list, storageSockets socket)
AliStorageClientThread * fManager
void SetStorageParams(int maxStorageSize, int maxOccupation, int removeEvents, int eventsInChunk)
static void * Dispatch(void *arg)
TThread * fCommunicationThread
int fStorageOccupationLevel
void RecreateSocket(storageSockets socket)
bool Get(std::vector< serverListStruct > *&result, storageSockets socket)