Fixed bug in AliEveEventManager causing frequent crashes. Fixed bug in Storage Manage...
authorjniedzie <jeremi.niedziela@cern.ch>
Fri, 31 Oct 2014 09:27:15 +0000 (10:27 +0100)
committerjniedzie <jeremi.niedziela@cern.ch>
Fri, 31 Oct 2014 09:27:30 +0000 (10:27 +0100)
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManagerEditor.cxx
MONITOR/alistoragemanager/AliStorageAdministratorPanelListEvents.cxx
MONITOR/alistoragemanager/AliStorageDatabase.cxx
MONITOR/alistoragemanager/AliStorageEventManager.cxx
MONITOR/alistoragemanager/AliStorageServerThread.cxx
MONITOR/alistoragemanager/setupStorageDatabase.sh [changed mode: 0755->0644]

index 5ee9dab..8a109d4 100644 (file)
@@ -275,17 +275,17 @@ void AliEveEventManager::GetNextEvent()
             cout<<"taking event from storage manager"<<endl;
             if(iter<receivedList.size())
             {
+                cout<<"i:"<<iter<<endl;
                 struct eventStruct mark;
                 mark.runNumber = receivedList[iter].runNumber;
                 mark.eventNumber = receivedList[iter].eventNumber;
              
-                struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
                 requestMessage->messageType = REQUEST_GET_EVENT;
                 requestMessage->event = mark;
                 
                 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
                 tmpEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
-                delete requestMessage;
+
                 iter++;
                 sleep(1);
             }
@@ -311,10 +311,7 @@ void AliEveEventManager::GetNextEvent()
                 fMutex->UnLock();
             }
         }
-        else
-        {
-            cout<<"didn't receive new event"<<endl;
-        }
+        else{cout<<"didn't receive new event"<<endl;}
     }
     delete requestMessage;
     
index e4b84b2..0ed4555 100644 (file)
@@ -433,7 +433,7 @@ void AliEveEventManagerWindow::Update(int state)
     }
     fTrigSel->SetEnabled(!evNavOn);
 
-    fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
+//    fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
 
     Layout();
   }
index 58f756d..cba8e6d 100644 (file)
@@ -248,7 +248,7 @@ void AliStorageAdministratorPanelListEvents::onGetListButton()
        }
        if(fLeadLeadCheckButton->GetState()==1)
        {
-               strcpy(list.system[1],"Pb-Pb");
+               strcpy(list.system[1],"A-A");
        }
        else
        {
@@ -264,7 +264,7 @@ void AliStorageAdministratorPanelListEvents::onGetListButton()
        fEventsList->AddEntry(new TGString("Run   Event   System   Mult   Marked"),0);
        
        vector<serverListStruct> receivedList = fEventManager->GetServerListVector(fServerSocket);
-       
+    
        for(unsigned int i=0;i<receivedList.size();i++)
        {
                fEventsList->InsertEntry(Form("%d   %d   %s   %d   %d   ",
@@ -273,9 +273,6 @@ void AliStorageAdministratorPanelListEvents::onGetListButton()
                                              receivedList[i].system,
                                              receivedList[i].multiplicity,
                                              receivedList[i].marked),i+1,i);
-
-               cout<<receivedList[i].runNumber<<receivedList[i].eventNumber<<endl;
-       
        }
 
        fEventsListVector = receivedList;
index 606b92d..46015b8 100644 (file)
@@ -85,15 +85,21 @@ AliStorageDatabase::~AliStorageDatabase(){
 }
 
 void AliStorageDatabase::InsertEvent(int runNumber,
-                                    int eventNumber,
-                                    char *system,
-                                    int multiplicity,
-                                    char *filePath)
+                                     int eventNumber,
+                                     char *system,
+                                     int multiplicity,
+                                     char *filePath)
 {
-  TSQLResult* res;
-  res = fServer->Query(Form("replace into %s (run_number,event_number,system,multiplicity,permanent,file_path) values (%d,%d,'%s',%d,0,'%s');",fTable.c_str(),runNumber,eventNumber,system,multiplicity,filePath));
-  delete res;
+    TSQLResult *res = fServer->Query(Form("select * FROM %s WHERE run_number = %d AND event_number = %d AND permanent = 1;",fTable.c_str(),runNumber,eventNumber));
+    TSQLRow *row = res->Next();
+
+    if(!row)
+    {
+        res = fServer->Query(Form("REPLACE INTO %s (run_number,event_number,system,multiplicity,permanent,file_path) VALUES (%d,%d,'%s',%d,0,'%s');",fTable.c_str(),runNumber,eventNumber,system,multiplicity,filePath));
+    }
 
+    delete row;
+    delete res;
 }
 
 bool AliStorageDatabase::MarkEvent(struct eventStruct event)
index 350de7b..a0a6da5 100644 (file)
@@ -63,22 +63,13 @@ AliStorageEventManager::AliStorageEventManager()
                 fXmlServerPort=atoi(line.substr(from,to-from).c_str());
             }
         }
-        if(configFile.eof())
-        {
-            configFile.clear();
-        }
+        if(configFile.eof()){configFile.clear();}
         configFile.close();
     }
-    else
-    {
-        cout<<"EVENT MANAGER -- Unable to open config file"<<endl;
-    }
+    else{cout<<"EVENT MANAGER -- Unable to open config file"<<endl;}
     TThread::UnLock();
     
-    for(int i=0;i<NUMBER_OF_SOCKETS;i++)
-    {
-        fContexts[i] = new context_t();
-    }
+    for(int i=0;i<NUMBER_OF_SOCKETS;i++){fContexts[i] = new context_t();}
 }
 AliStorageEventManager::~AliStorageEventManager()
 {
@@ -226,12 +217,23 @@ void AliStorageEventManager::Send(vector<serverListStruct> list,storageSockets s
     int numberOfRecords = list.size();
     message_t message(20);
     snprintf ((char *)message.data(), 20 ,"%d",numberOfRecords);
-    
-    fSockets[socket]->send(message);
-    if(numberOfRecords==0)return;
+    try{
+        fSockets[socket]->send(message);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send vector -- "<<e.what()<<endl;
+    }
+    //if(numberOfRecords==0)return;
     message_t *tmpMessage = new message_t();
-    fSockets[socket]->recv(tmpMessage);//empty message just to keep req-rep order
     
+    try{
+        fSockets[socket]->recv(tmpMessage);//empty message just to keep req-rep order
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send vector -- "<<e.what()<<endl;
+    }
     // //prepare message with event's list
     // char *buffer = reinterpret_cast<char*> (&list[0]);
     // message_t *reply = new message_t((void*)buffer,
@@ -242,7 +244,13 @@ void AliStorageEventManager::Send(vector<serverListStruct> list,storageSockets s
     message_t reply(sizeof(serverListStruct)*numberOfRecords);
     memcpy(reply.data(), reinterpret_cast<const char*> (&list[0]), sizeof(serverListStruct)*numberOfRecords);
     
-    fSockets[socket]->send(reply);
+    try{
+        fSockets[socket]->send(reply);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send vector -- "<<e.what()<<endl;
+    }
     if(tmpMessage){delete tmpMessage;}
 }
 
@@ -253,7 +261,13 @@ void AliStorageEventManager::Send(struct serverRequestStruct *request,storageSoc
                                               sizeof(struct serverRequestStruct)
                                               +sizeof(struct listRequestStruct)
                                               +sizeof(struct eventStruct),freeBuff);
-    fSockets[socket]->send(*requestMessage);
+    try{
+        fSockets[socket]->send(*requestMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send serverRequestStruct -- "<<e.what()<<endl;
+    }
 }
 
 bool AliStorageEventManager::Send(struct clientRequestStruct *request,storageSockets socket,int timeout)
@@ -265,8 +279,7 @@ bool AliStorageEventManager::Send(struct clientRequestStruct *request,storageSoc
     message_t *requestMessage = new message_t((void*)buffer,
                                               sizeof(struct clientRequestStruct),freeBuff);
     
-    try
-    {
+    try{
         fSockets[socket]->send(*requestMessage);
     }
     catch (const zmq::error_t& e)
@@ -300,7 +313,13 @@ void AliStorageEventManager::Send(long message,storageSockets socket)
     char *buffer = (char*)stringBuffer.c_str();
     message_t *replyMessage = new message_t((void*)buffer,sizeof(stringBuffer),freeBuff);
     
-    fSockets[socket]->send(*replyMessage);
+    try{
+        fSockets[socket]->send(*replyMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send long -- "<<e.what()<<endl;
+    }
     delete replyMessage;
     streamBuffer.str(string());
     streamBuffer.clear();
@@ -318,7 +337,13 @@ void AliStorageEventManager::Send(bool message,storageSockets socket)
         buffer = (char*)("false");
     }
     message_t *replyMessage = new message_t((void*)buffer,sizeof(buffer),freeBuff);
-    fSockets[socket]->send(*replyMessage);
+    try{
+        fSockets[socket]->send(*replyMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send bool -- "<<e.what()<<endl;
+    }
     delete replyMessage;
 }
 
@@ -334,7 +359,13 @@ void AliStorageEventManager::Send(AliESDEvent *event, storageSockets socket)
     memcpy(buf, tmess.Buffer(), bufsize);
     
     message_t message((void*)buf, bufsize, freeBuff);
-    fSockets[socket]->send(message);
+    try{
+        fSockets[socket]->send(message);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send AliESDEvent -- "<<e.what()<<endl;
+    }
 }
 
 void AliStorageEventManager::SendAsXml(AliESDEvent *event,storageSockets socket)
@@ -377,7 +408,13 @@ void AliStorageEventManager::SendAsXml(AliESDEvent *event,storageSockets socket)
     message_t message(bufferString.size());
     memcpy (message.data(), bufferString.data(), bufferString.size());
     
-    fSockets[socket]->send(message);
+    try{
+        fSockets[socket]->send(message);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- send send xml -- "<<e.what()<<endl;
+    }
     cout<<"xml sent"<<endl;
 }
 
@@ -385,18 +422,36 @@ vector<serverListStruct> AliStorageEventManager::GetServerListVector(storageSock
 {
     //get size of the incomming message
     message_t sizeMessage;
-    fSockets[socket]->recv(&sizeMessage);
+    
+    try{
+        fSockets[socket]->recv(&sizeMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get vector -- "<<e.what()<<endl;
+    }
     int numberOfRecords;
     istringstream iss(static_cast<char*>(sizeMessage.data()));
     iss >> numberOfRecords;
     
     if(numberOfRecords==0){cout<<"MANAGER -- list is empty"<<endl;}
     
-    fSockets[socket]->send(*(new message_t()));//receive empty message just to keep req-rep order
-    
+    try{
+        fSockets[socket]->send(*(new message_t()));//receive empty message just to keep req-rep order
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get vector -- "<<e.what()<<endl;
+    }
     //get list of events
     message_t *response = new message_t(sizeof(serverListStruct)*numberOfRecords);
-    fSockets[socket]->recv(response);
+    try{
+        fSockets[socket]->recv(response);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get vector -- "<<e.what()<<endl;
+    }
     
     vector<serverListStruct> receivedList(static_cast<serverListStruct*>(response->data()), static_cast<serverListStruct*>(response->data()) + numberOfRecords);
     
@@ -455,7 +510,13 @@ struct serverRequestStruct* AliStorageEventManager::GetServerStruct(storageSocke
 {
     struct serverRequestStruct *request = new struct serverRequestStruct;
     message_t *requestMessage = new message_t();
-    fSockets[socket]->recv(requestMessage);
+    try{
+        fSockets[socket]->recv(requestMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get serverRequestStruct -- "<<e.what()<<endl;
+    }
     request = static_cast<struct serverRequestStruct*>(requestMessage->data());
     return request;
 }
@@ -464,7 +525,13 @@ struct clientRequestStruct* AliStorageEventManager::GetClientStruct(storageSocke
 {
     struct clientRequestStruct *request = new struct clientRequestStruct;
     message_t *requestMessage = new message_t();
-    fSockets[socket]->recv(requestMessage);
+    try{
+        fSockets[socket]->recv(requestMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get clientRequestStruct -- "<<e.what()<<endl;
+    }
     request = static_cast<struct clientRequestStruct*>(requestMessage->data());
     return request;
 }
@@ -472,7 +539,13 @@ struct clientRequestStruct* AliStorageEventManager::GetClientStruct(storageSocke
 bool AliStorageEventManager::GetBool(storageSockets socket)
 {
     message_t *response = new message_t();
-    fSockets[socket]->recv(response);
+    try{
+        fSockets[socket]->recv(response);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get bool -- "<<e.what()<<endl;
+    }
     char *result = (char*)response->data();
     
     if(!strcmp("true",result)){return true;}
@@ -482,7 +555,13 @@ bool AliStorageEventManager::GetBool(storageSockets socket)
 long AliStorageEventManager::GetLong(storageSockets socket)
 {
     message_t *responseMessage = new message_t();
-    fSockets[socket]->recv(responseMessage);
+    try{
+        fSockets[socket]->recv(responseMessage);
+    }
+    catch(const zmq::error_t &e)
+    {
+        cout<<"MANAGER -- get long -- "<<e.what()<<endl;
+    }
     
     long result = 0;
     
index 73545a8..e64e2dc 100644 (file)
@@ -67,14 +67,18 @@ void AliStorageServerThread::StartCommunication()
        
        while(1)
        {
+        cout<<"Server waiting for requests"<<endl;
                request = eventManager->GetServerStruct(socket);
-               
+        cout<<"Server received request"<<endl;
                switch(request->messageType)
                  {
                  case REQUEST_LIST_EVENTS:
                    {
+                cout<<"SERVER -- received request for list of events"<<endl;
                      vector<serverListStruct> result = fDatabase->GetList(request->list);
+                cout<<"SERVER -- got list from database"<<endl;
                      eventManager->Send(result,socket);
+                cout<<"SERVER -- list was sent"<<endl;
                      break;
                    }
                  case REQUEST_GET_EVENT:
@@ -119,7 +123,9 @@ void AliStorageServerThread::StartCommunication()
                      eventManager->Send(MarkEvent(*markData),socket);
                      break;
                    }
-                 default:break;
+                 default:
+                  sleep(1);
+                  break;
                  }
 
        }
old mode 100755 (executable)
new mode 100644 (file)
index 2bf3a9b..29c4ffd
@@ -6,13 +6,13 @@ USER="storage"
 PASS="storage123"
 TABLE="events"
 STORAGE_PATH="/Users/Jerus/storedFiles"
-MAX_SIZE="30000000"
-MAX_OCCUPATION="80"
-REMOVE_PERCENT="60"
-EVENTS_IN_FILE="5"
+MAX_SIZE="300000000"
+MAX_OCCUPATION="100"
+REMOVE_PERCENT="50"
+EVENTS_IN_FILE="20"
 EVENT_SERVER="pcald39fix"   # IP of machine running alieventserver
 EVENT_SERVER_PORT="5024"
-STORAGE_SERVER="pcald39fix"      # IP of machine running alistorage
+STORAGE_SERVER="localhost"      # IP of machine running alistorage
 STORAGE_SERVER_PORT="5066"      # server thread communication port
 STORAGE_CLIENT_PORT="5088"      # client thread communication port
 XML_SERVER_PORT="5099"          # server of xml files
@@ -30,4 +30,4 @@ PRIMARY KEY(run_number,event_number));"
 
 echo "-----------------------------"
 echo "Databases successfuly created"
-echo "-----------------------------"
\ No newline at end of file
+echo "-----------------------------"