The code.ill.fr has been recreated and upgraded with the latest version this weekend, If you encounter any problem please inform the Helpdesk.

Commit 1a97832a authored by legoc's avatar legoc
Browse files

(split) Reimplemented getActualState() in Instance by calling request to...

(split) Reimplemented getActualState() in Instance by calling request to GET_STATUS. Added getPastStates() in Instance
parent 8db7a51b
......@@ -229,6 +229,11 @@ public:
*/
State getActualState() const;
/**
* Returns the past states.
*/
std::set<State> getPastStates() const;
bool getBinaryResult(std::string& result);
bool getResult(std::string& result);
......
......@@ -90,6 +90,16 @@ public:
*/
std::vector<application::Info> getApplicationInfos(const std::string& name) const;
/**
* throws ConnectionTimeout
*/
application::State getActualState(int id) const;
/**
* throws ConnectionTimeout
*/
std::set<application::State> getPastStates(int id) const;
/**
* throws ConnectionTimeout
*/
......
......@@ -644,17 +644,11 @@ State Instance::getLastState() {
}
State Instance::getActualState() const {
return m_server->getActualState(m_id);
}
vector<application::Info> infos = m_server->getApplicationInfos();
for (vector<application::Info>::const_iterator i = infos.begin(); i != infos.end(); ++i) {
application::Info const & info = *i;
if (info.getId() == m_id) {
return info.getState();
}
}
return UNKNOWN;
std::set<State> Instance::getPastStates() const {
return m_server->getPastStates(m_id);
}
bool Instance::getBinaryResult(std::string& result) {
......
......@@ -390,6 +390,68 @@ std::vector<application::Info> Server::getApplicationInfos(const std::string& na
return infos;
}
application::State Server::getActualState(int id) const {
unique_ptr<zmq::message_t> reply = m_requestSocket->request(m_impl->createGetStatusRequest(id));
// Get the JSON response.
json::Object response;
json::parse(response, reply.get());
return response[message::StatusEvent::APPLICATION_STATE].GetInt();
}
std::set<application::State> Server::getPastStates(int id) const {
unique_ptr<zmq::message_t> reply = m_requestSocket->request(m_impl->createGetStatusRequest(id));
// Get the JSON response.
json::Object response;
json::parse(response, reply.get());
application::State applicationStates = response[message::StatusEvent::PAST_APPLICATION_STATES].GetInt();
set<application::State> result;
if ((applicationStates & application::STARTING) != 0) {
result.insert(application::STARTING);
}
if ((applicationStates & application::RUNNING) != 0) {
result.insert(application::RUNNING);
}
if ((applicationStates & application::STOPPING) != 0) {
result.insert(application::STOPPING);
}
if ((applicationStates & application::KILLING) != 0) {
result.insert(application::KILLING);
}
if ((applicationStates & application::PROCESSING_ERROR) != 0) {
result.insert(application::PROCESSING_ERROR);
}
if ((applicationStates & application::FAILURE) != 0) {
result.insert(application::FAILURE);
}
if ((applicationStates & application::SUCCESS) != 0) {
result.insert(application::SUCCESS);
}
if ((applicationStates & application::STOPPED) != 0) {
result.insert(application::STOPPED);
}
if ((applicationStates & application::KILLED) != 0) {
result.insert(application::KILLED);
}
return result;
}
std::unique_ptr<EventStreamSocket> Server::openEventStream() {
return Services::openEventStream();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment