void ServiceController::requestComplete(Request *request) { m_mutex->acquire(); if (startreq == request) startreq = NULL; if (stopreq == request) stopreq = NULL; setState(getActualState()); m_mutex->release(); }
void ServiceController::restart() { m_mutex->acquire(); if (active && setState(getActualState()) && autorestart && startreq == NULL /*&& stopreq == NULL*/) { // restarts only if state has just changed from RUNNING/DEGRADED to NOT_EXISTING ACS_SHORT_LOG((LM_WARNING, "Restarting %s.", getServiceName().c_str())); stopreq = NULL; context->getRequestProcessor()->process(startreq = createControlledServiceRequest(START_SERVICE)); // enqueue service startup request } m_mutex->release(); }
void ServiceController::restart() { m_mutex->acquire(); if (active && setState(getActualState()) && autorestart && startreq == NULL /*&& stopreq == NULL*/) { // restarts only if state has just changed from RUNNING/DEGRADED to NOT_EXISTING ACS_SHORT_LOG((LM_WARNING, "Restarting %s.", getServiceName().c_str())); stopreq = NULL; context->getRequestProcessor()->process(startreq = createControlledServiceRequest(START_SERVICE)); // enqueue service startup request //restart loggingService, otherwise remote logger get stuck if (ACSServiceController * c = dynamic_cast<ACSServiceController*>(this)) { if (c->desc->getACSService() == NOTIFICATION_SERVICE && std::string(c->desc->getName()).compare("LoggingNotifyEventChannelFactory") == 0) { std::ostringstream addr_str; addr_str << "corbaloc::"; addr_str << c->desc->getHost() << ":" << acsServices[LOGGING_SERVICE].impport << "/"; addr_str << acsServices[LOGGING_SERVICE].imptype; ACS_SHORT_LOG((LM_INFO, "Getting reference of %s using address: %s", acsServices[LOGGING_SERVICE].imptype, addr_str.str().c_str())); int argc = 1; char *argv[] = {"some_daemon"}; CORBA::ORB_var orb = CORBA::ORB_init (argc,argv,"TAO"); CORBA::Object_var obj = orb->string_to_object(addr_str.str().c_str()); if (CORBA::is_nil(obj.in())){ ACS_SHORT_LOG( (LM_ERROR, "Failed to resolve reference '%s'.", addr_str.str().c_str())); return; } acsdaemon::LoggingServiceImp_var imp = acsdaemon::LoggingServiceImp::_narrow(obj.in()); if (CORBA::is_nil(imp.in())) { ACS_SHORT_LOG( (LM_ERROR, "Failed to narrow reference '%s'.", addr_str.str().c_str())); return; } ACS_SHORT_LOG((LM_INFO, "Calling stop_logging_service")); imp->stop_logging_service("Log", acsdaemon::DaemonCallback::_nil(), c->desc->getInstanceNumber()); ACS_SHORT_LOG((LM_INFO, "Calling stop_logging_service completed")); sleep(5); ACS_SHORT_LOG((LM_INFO, "Calling start_logging_service")); imp->start_logging_service("Log", acsdaemon::DaemonCallback::_nil(), c->desc->getInstanceNumber()); ACS_SHORT_LOG((LM_INFO, "Calling start_logging_service completed")); } } } m_mutex->release(); }
void ServiceController::stop(acsdaemon::DaemonCallback_ptr callback) throw(acsdaemonErrType::ServiceNotRunningEx) { m_mutex->acquire(); setState(getActualState()); active = false; if (startreq != NULL || stopreq == NULL && state != acsdaemon::NOT_EXISTING) { startreq = NULL; context->getRequestProcessor()->process(stopreq = createControlledServiceRequest(STOP_SERVICE, callback)); // enqueue service shutdown request } else if (callback != NULL) { // service is not running or already scheduled to stop! m_mutex->release(); throw acsdaemonErrType::ServiceNotRunningExImpl(__FILE__, __LINE__, "ServiceController::stop").getServiceNotRunningEx(); } m_mutex->release(); }
bool ServiceController::start(acsdaemon::DaemonCallback_ptr callback) throw(acsdaemonErrType::ServiceAlreadyRunningEx) { m_mutex->acquire(); setState(getActualState()); active = true; if (stopreq != NULL || startreq == NULL && state == acsdaemon::NOT_EXISTING) { stopreq = NULL; context->getRequestProcessor()->process(startreq = createControlledServiceRequest(START_SERVICE, callback)); // enqueue service startup request } else if (callback != NULL) { // service is already running or scheduled to start! m_mutex->release(); throw acsdaemonErrType::ServiceAlreadyRunningExImpl(__FILE__, __LINE__, "ServiceController::start").getServiceAlreadyRunningEx(); } bool willrun = startreq != NULL || stopreq == NULL && (state == acsdaemon::RUNNING || state == acsdaemon::DEGRADED); m_mutex->release(); // returns true if service is scheduled to start or already running return willrun; }
/* * For the actions in a parsing table. * if an action yyptblact[i] is positive, it's a shift/goto; * if it is negative, it's a reduce; * if it's zero, it's accept. */ void print_parsing_tbl() { int i, j, row, col; int col_size = ParsingTblCols; char action; int state_no; int * rowoffset = (int *) malloc(sizeof(int) * ParsingTblRows); int rowoffset_pt = 0; int count = 0; SymbolTblNode * n; fprintf(fp, "static YYCONST yytabelem yyptblact[] = {\n"); if (USE_REMOVE_UNIT_PRODUCTION) { i = 0; for (row = 0; row < ParsingTblRows; row ++) { if (isReachableState(row)) { #if USE_REM_FINAL_STATE if (final_state_list[row] < 0) { print_parsing_tbl_entry('s', final_state_list[row], &count); * (rowoffset + rowoffset_pt) = count; rowoffset_pt ++; continue; } #endif for (col = 0; col < ParsingTblCols; col ++) { n = ParsingTblColHdr[col]; if (isGoalSymbol(n) == FALSE && isParentSymbol(n) == FALSE) { getAction(n->type, col, row, & action, & state_no); if (action == 's' || action == 'g') state_no = getActualState(state_no); //printf("%c%d\t", action, state_no); print_parsing_tbl_entry(action, state_no, &count); } // end of if. } * (rowoffset + rowoffset_pt) = count; rowoffset_pt ++; //printf("\n"); } // end of if. } } else { for (i = 0; i < ParsingTblRows; i ++) { #if USE_REM_FINAL_STATE if (final_state_list[i] < 0) { print_parsing_tbl_entry('s', final_state_list[i], &count); * (rowoffset + rowoffset_pt) = count; rowoffset_pt ++; continue; } #endif for (j = 0; j < ParsingTblCols; j ++) { getAction(ParsingTblColHdr[j]->type, j, i, & action, & state_no); //printf("%c%d, ", action, state_no); print_parsing_tbl_entry(action, state_no, &count); } * (rowoffset + rowoffset_pt) = count; rowoffset_pt ++; //printf("\n"); } // end of for. } fprintf(fp, "-10000000};\n\n"); // -10000000 is space filler fprintf(fp, "static YYCONST yytabelem yyrowoffset[] = {\n0, "); for (i = 0; i < rowoffset_pt; i ++) { fprintf(fp, "%d", *(rowoffset + i)); if (i < rowoffset_pt - 1) fprintf(fp, ", "); if (i % 10 == 0 && i != 0) fprintf(fp, "\n"); } fprintf(fp, "};\n\n"); // NOTE: the last entry is (yyptbl.size - 1). }