void MonitorCallback() { while (true) { if( ! Nova::ConnectToNovad() ) { LOG(ERROR, "CLI Unable to connect to Novad right now. Trying again in 3 seconds...",""); sleep(3); continue; } CallbackChange cb; CallbackHandler callbackHandler; Suspect s; do { cb = callbackHandler.ProcessCallbackMessage(); switch( cb.m_type ) { case CALLBACK_NEW_SUSPECT: cout << "Got new suspect: " << cb.m_suspect->GetIdString() << + " with classification of " << cb.m_suspect->GetClassification() << endl; // We get a suspect pointer and are responsible for deleting it delete cb.m_suspect; break; case CALLBACK_ERROR: cout << "WARNING: Recieved a callback error message!" << endl; break; case CALLBACK_ALL_SUSPECTS_CLEARED: cout << "Got notice that all suspects were cleared" << endl; break; case CALLBACK_SUSPECT_CLEARED: s.SetIdentifier(cb.m_suspectIP); cout << "Got a notice that suspect was cleared: " + s.GetIdString() << endl; break; case CALLBACK_HUNG_UP: cout << "Got CALLBACK_HUNG_UP" << endl; break; default: cout << "WARNING: Got a callback message we don't know what to do with. Type " << cb.m_type << endl; break; } } while(cb.m_type != CALLBACK_HUNG_UP); cout << "Novad hung up, closing callback processing and trying again in 3 seconds" << endl; sleep(3); } }
void NovaNode::NovaCallbackHandling(eio_req*) { using namespace Nova; CallbackChange cb; LOG(DEBUG, "Initializing Novad callback processing",""); CallbackHandler callbackHandler; m_callbackRunning = true; do { Suspect *s; cb = callbackHandler.ProcessCallbackMessage(); switch( cb.m_type ) { case CALLBACK_NEW_SUSPECT: HandleNewSuspect(cb.m_suspect); break; case CALLBACK_ERROR: HandleCallbackError(); break; case CALLBACK_ALL_SUSPECTS_CLEARED: HandleAllSuspectsCleared(); break; case CALLBACK_SUSPECT_CLEARED: s = new Suspect(); s->SetIdentifier(cb.m_suspectIP); LOG(DEBUG, "Got a clear callback request for a suspect on interface " + cb.m_suspectIP.m_interface, ""); HandleSuspectCleared(s); break; default: break; } } while(cb.m_type != CALLBACK_HUNG_UP); LOG(DEBUG, "Novad hung up, closing callback processing",""); m_callbackRunning = false; }
void NovaNode::NovaCallbackHandling(eio_req*) { LOG(DEBUG, "Initializing Novad callback processing",""); while(true) { Nova::Message *message = DequeueUIMessage(); //If this is a callback for a specific operation if(message->m_contents.has_m_messageid()) { eio_nop(EIO_PRI_DEFAULT, NovaNode::HandleMessageWithIDOnV8Thread, message); continue; } switch(message->m_contents.m_type()) { case UPDATE_SUSPECT: { if(!message->m_suspects.empty()) { HandleNewSuspect(message->m_suspects[0]); } break; } case REQUEST_ALL_SUSPECTS_REPLY: { for(uint i = 0; i < message->m_suspects.size(); i++) { HandleNewSuspect(message->m_suspects[i]); } break; } case REQUEST_SUSPECT_REPLY: { break; } case UPDATE_ALL_SUSPECTS_CLEARED: { HandleAllSuspectsCleared(); break; } case UPDATE_SUSPECT_CLEARED: { Suspect *suspect = new Suspect(); suspect->SetIdentifier(message->m_contents.m_suspectid()); LOG(DEBUG, "Got a clear suspect response for a suspect on interface " + message->m_contents.m_suspectid().m_ifname(), ""); HandleSuspectCleared(suspect); break; } case REQUEST_PONG: { break; } case CONNECTION_SHUTDOWN: { break; } default: { HandleCallbackError(); break; } } delete message; } }