Skip to content
Snippets Groups Projects
Commit ec79c696 authored by blaakmeer's avatar blaakmeer
Browse files

BugID: 802

Implemented shutdown procedure
parent 975677af
No related branches found
No related tags found
No related merge requests found
...@@ -377,9 +377,9 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface& ...@@ -377,9 +377,9 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface&
case CONTROL_RELEASE: { case CONTROL_RELEASE: {
CONTROLReleaseEvent msg(event); CONTROLReleaseEvent msg(event);
LOG_DEBUG_STR("Received RELEASED(" << msg.cntlrName << ")"); LOG_DEBUG_STR("Received RELEASE(" << msg.cntlrName << ")");
setState(CTState::RELEASE); setState(CTState::RELEASE);
doRelease(event); doRelease();
setState(CTState::RELEASED); setState(CTState::RELEASED);
CONTROLReleasedEvent answer; CONTROLReleasedEvent answer;
answer.cntlrName = msg.cntlrName; answer.cntlrName = msg.cntlrName;
...@@ -396,6 +396,33 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface& ...@@ -396,6 +396,33 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface&
return (status); return (status);
} }
//
// finished_state(event, port)
//
// Finishing state.
//
GCFEvent::TResult OnlineControl::finished_state(GCFEvent& event, GCFPortInterface& port)
{
LOG_DEBUG_STR ("active:" << evtstr(event) << "@" << port.getName());
GCFEvent::TResult status = GCFEvent::HANDLED;
switch (event.signal) {
case F_ENTRY: {
GCFTask::stop();
break;
}
default:
LOG_DEBUG("active_state, default");
status = GCFEvent::NOT_HANDLED;
break;
}
return (status);
}
// //
// doPrepare(cntlrName) // doPrepare(cntlrName)
...@@ -519,27 +546,44 @@ uint16_t OnlineControl::doPrepare(const string& cntlrName) ...@@ -519,27 +546,44 @@ uint16_t OnlineControl::doPrepare(const string& cntlrName)
} }
// //
// doRelease(event) // doRelease()
// //
void OnlineControl::doRelease(GCFEvent& /*event*/) void OnlineControl::doRelease(void)
{ {
string hostName, remoteFile, resultFile; try
hostName = itsCepAppParams.getString("AC.hostname"); {
resultFile = formatString("ACC-%s_result.param", getName().c_str()); string hostName, remoteFile, resultFile;
remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile; hostName = itsCepAppParams.getString("AC.hostname");
APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile); resultFile = formatString("ACC-%s_result.param", getName().c_str());
itsResultParams.adoptFile(resultFile); remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile;
// itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality())); APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile);
if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str()))) itsResultParams.adoptFile(resultFile);
// itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality()));
if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str())))
{
itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), "");
}
itsResultParams.writeFile(formatString("%s_result.param", getName().c_str()));
}
catch(...)
{ {
itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), "");
} }
itsResultParams.writeFile(formatString("%s_result.param", getName().c_str()));
itsCepApplication.quit(0); itsCepApplication.quit(0);
} }
//
// finishController
//
void OnlineControl::finishController(uint16_t result)
{
setState(CTState::RELEASE);
doRelease();
setState(CTState::RELEASED);
LOG_DEBUG ("Going to finished state");
TRAN(OnlineControl::finished_state); // go to next state.
}
//
// _connectedHandler(port) // _connectedHandler(port)
// //
void OnlineControl::_connectedHandler(GCFPortInterface& /*port*/) void OnlineControl::_connectedHandler(GCFPortInterface& /*port*/)
...@@ -567,8 +611,7 @@ void OnlineControl::appBooted(uint16 result) ...@@ -567,8 +611,7 @@ void OnlineControl::appBooted(uint16 result)
else if (result == 0) // Error else if (result == 0) // Error
{ {
LOG_ERROR("Error in ACC. Stops CEP application and releases Online Control."); LOG_ERROR("Error in ACC. Stops CEP application and releases Online Control.");
itsCepApplication.quit(0); finishController(CT_RESULT_UNSPECIFIED);
// _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY);
} }
} }
...@@ -584,8 +627,7 @@ void OnlineControl::appDefined(uint16 result) ...@@ -584,8 +627,7 @@ void OnlineControl::appDefined(uint16 result)
else if (result == 0) // Error else if (result == 0) // Error
{ {
LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); LOG_ERROR("Error in ACC. Stops CEP application and releases VB.");
itsCepApplication.quit(0); finishController(CT_RESULT_UNSPECIFIED);
// _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY);
} }
} }
...@@ -602,8 +644,7 @@ void OnlineControl::appInitialized(uint16 result) ...@@ -602,8 +644,7 @@ void OnlineControl::appInitialized(uint16 result)
else if (result == 0) // Error else if (result == 0) // Error
{ {
LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); LOG_ERROR("Error in ACC. Stops CEP application and releases VB.");
itsCepApplication.quit(0); finishController(CT_RESULT_UNSPECIFIED);
// _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY);
} }
} }
...@@ -616,8 +657,7 @@ void OnlineControl::appRunDone(uint16 result) ...@@ -616,8 +657,7 @@ void OnlineControl::appRunDone(uint16 result)
else if (result == 0) // Error else if (result == 0) // Error
{ {
LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); LOG_ERROR("Error in ACC. Stops CEP application and releases VB.");
itsCepApplication.quit(0); finishController(CT_RESULT_UNSPECIFIED);
// _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY);
} }
} }
...@@ -627,10 +667,14 @@ void OnlineControl::appPaused(uint16 /*result*/) ...@@ -627,10 +667,14 @@ void OnlineControl::appPaused(uint16 /*result*/)
void OnlineControl::appQuitDone(uint16 result) void OnlineControl::appQuitDone(uint16 result)
{ {
if (result == AcCmdMaskOk) if (result == (AcCmdMaskOk | AcCmdMaskScheduled))
{ {
//_qualityGuard.stopMonitoring(); // not in this increment //_qualityGuard.stopMonitoring(); // not in this increment
} }
else
{
finishController(CT_RESULT_NO_ERROR);
}
} }
void OnlineControl::appSnapshotDone(uint16 /*result*/) void OnlineControl::appSnapshotDone(uint16 /*result*/)
......
...@@ -86,6 +86,10 @@ public: ...@@ -86,6 +86,10 @@ public:
GCFEvent::TResult active_state (GCFEvent& e, GCFEvent::TResult active_state (GCFEvent& e,
GCFPortInterface& p); GCFPortInterface& p);
// Finishing mode.
GCFEvent::TResult finished_state(GCFEvent& event,
GCFPortInterface& port);
protected: // implemenation of abstract CEPApplicationManagerInterface methods protected: // implemenation of abstract CEPApplicationManagerInterface methods
void appBooted(uint16 result); void appBooted(uint16 result);
void appDefined(uint16 result); void appDefined(uint16 result);
...@@ -108,7 +112,8 @@ private: ...@@ -108,7 +112,8 @@ private:
uint16_t doClaim(const string& cntlrName); uint16_t doClaim(const string& cntlrName);
uint16_t doPrepare(const string& cntlrName); uint16_t doPrepare(const string& cntlrName);
void doRelease(GCFEvent& event); void doRelease();
void finishController(uint16_t result);
void _connectedHandler(GCFPortInterface& port); void _connectedHandler(GCFPortInterface& port);
void _disconnectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port);
void setState(CTState::CTstateNr newState); void setState(CTState::CTstateNr newState);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment