Commit e27fcebd authored by legoc's avatar legoc
Browse files

Renamed state ERROR into FAILURE and UNKNOWN into NIL

parent 1ec01e22
......@@ -92,7 +92,7 @@ typedef int32_t State;
/**
* Unknown state.
*/
const State UNKNOWN = 0;
const State NIL = 0;
/**
* Starting state.
......@@ -825,7 +825,7 @@ public:
State getLastState();
/**
* Returns the actual state and UNKNOWN if the instance does not exist anymore.
* Returns the actual state and NIL if the instance does not exist anymore.
* \return The actual state.
*/
State getActualState() const;
......
......@@ -114,8 +114,8 @@ std::unique_ptr<RequestSocket> This::Com::createRequestSocket(const std::string&
State This::parseState(const std::string& value) {
if (value == "UNKNOWN") {
return UNKNOWN;
if (value == "NIL") {
return NIL;
}
else if (value == "STARTING") {
return STARTING;
......@@ -145,7 +145,7 @@ State This::parseState(const std::string& value) {
return KILLED;
}
return UNKNOWN;
return NIL;
}
void This::init(int argc, char *argv[]) {
......@@ -450,8 +450,8 @@ void This::initStarterCheck() {
// Get the actual state. It is necessary to get the actual state after the registration so that we do not miss any events.
State state {m_starterServer->getActualState(m_starterId)};
// Stop this app if the starter is already terminated i.e. the state is UNKNOWN.
if (state == UNKNOWN) {
// Stop this app if the starter is already terminated i.e. the state is NIL.
if (state == NIL) {
stop();
}
else {
......@@ -620,8 +620,8 @@ App::App(Server * server) :
m_id{-1},
m_com{server},
m_pastStates{0},
m_initialState{UNKNOWN},
m_lastState{UNKNOWN},
m_initialState{NIL},
m_lastState{NIL},
m_hasResult{false},
m_exitCode{-1} {
}
......@@ -1055,7 +1055,7 @@ std::string toString(cameo::State applicationStates) {
}
if (states.size() == 0) {
return "UNKNOWN";
return "NIL";
}
if (states.size() == 1) {
......
......@@ -37,8 +37,8 @@ public class App extends EventListener {
private int id = -1;
private OutputStreamSocket outputSocket;
private int pastStates = 0;
private int initialState = State.UNKNOWN;
private int lastState = State.UNKNOWN;
private int initialState = State.NIL;
private int lastState = State.NIL;
private byte[] resultData;
private AppWaiting waiting = new AppWaiting(this);
private Integer exitCode;
......@@ -145,7 +145,7 @@ public class App extends EventListener {
if (state == State.SUCCESS
|| state == State.STOPPED
|| state == State.KILLED
|| state == State.ERROR) {
|| state == State.FAILURE) {
throw new KeyValueGetterException("Application terminated");
}
......@@ -607,7 +607,7 @@ public class App extends EventListener {
if (state == State.SUCCESS
|| state == State.STOPPED
|| state == State.KILLED
|| state == State.ERROR) {
|| state == State.FAILURE) {
// Unregister here.
if (status.getId() == this.id) {
......@@ -627,7 +627,7 @@ public class App extends EventListener {
if (lastState == State.SUCCESS
|| lastState == State.STOPPED
|| lastState == State.KILLED
|| lastState == State.ERROR) {
|| lastState == State.FAILURE) {
// The application is already terminated.
return lastState;
}
......@@ -665,7 +665,7 @@ public class App extends EventListener {
if (state == State.SUCCESS
|| state == State.STOPPED
|| state == State.KILLED
|| state == State.ERROR) {
|| state == State.FAILURE) {
break;
}
......@@ -762,7 +762,7 @@ public class App extends EventListener {
}
/**
* Returns the actual state and UNKNOWN if the instance does not exist anymore.
* Returns the actual state or NIL if the instance does not exist anymore.
* @return The actual state.
*/
public int getActualState() {
......
......@@ -798,8 +798,8 @@ public class Server implements IObject, ITimeoutable {
result.add(State.PROCESSING_ERROR);
}
if ((applicationStates & State.ERROR) != 0) {
result.add(State.ERROR);
if ((applicationStates & State.FAILURE) != 0) {
result.add(State.FAILURE);
}
if ((applicationStates & State.SUCCESS) != 0) {
......
......@@ -27,7 +27,7 @@ public class State {
/**
* Unknown state.
*/
public final static int UNKNOWN = 0;
public final static int NIL = 0;
/**
* Starting state.
......@@ -57,7 +57,7 @@ public class State {
/**
* Failure state.
*/
public final static int ERROR = 32;
public final static int FAILURE = 32;
/**
* Success state.
......@@ -81,8 +81,8 @@ public class State {
*/
public static int parse(String value) {
if (value.equals("UNKNOWN")) {
return State.UNKNOWN;
if (value.equals("NIL")) {
return State.NIL;
} else if (value.equals("STARTING")) {
return State.STARTING;
} else if (value.equals("RUNNING")) {
......@@ -93,8 +93,8 @@ public class State {
return State.KILLING;
} else if (value.equals("PROCESSING_ERROR")) {
return State.PROCESSING_ERROR;
} else if (value.equals("ERROR")) {
return State.ERROR;
} else if (value.equals("FAILURE")) {
return State.FAILURE;
} else if (value.equals("SUCCESS")) {
return State.SUCCESS;
} else if (value.equals("STOPPED")) {
......@@ -103,7 +103,7 @@ public class State {
return State.KILLED;
}
return State.UNKNOWN;
return State.NIL;
}
/**
......@@ -135,8 +135,8 @@ public class State {
states.add("PROCESSING_ERROR");
}
if ((applicationStates & State.ERROR) != 0) {
states.add("ERROR");
if ((applicationStates & State.FAILURE) != 0) {
states.add("FAILURE");
}
if ((applicationStates & State.SUCCESS) != 0) {
......@@ -152,7 +152,7 @@ public class State {
}
if (states.size() == 0) {
return "UNKNOWN";
return "NIL";
}
if (states.size() == 1) {
......
......@@ -30,12 +30,12 @@ public class StatusEvent extends Event {
/**
* Sync event.
*/
public final static StatusEvent SYNC = new StatusEvent(-1, "", State.UNKNOWN, State.UNKNOWN);
public final static StatusEvent SYNC = new StatusEvent(-1, "", State.NIL, State.NIL);
/**
* End event.
*/
public final static StatusEvent END = new StatusEvent(-2, "", State.UNKNOWN, State.UNKNOWN);
public final static StatusEvent END = new StatusEvent(-2, "", State.NIL, State.NIL);
/**
* Constructor.
......
......@@ -668,7 +668,7 @@ public class This {
checkStatesThread = new Thread(new Runnable() {
public void run() {
// Warning, this method is executed in a parallel thread.
int state = State.UNKNOWN;
int state = State.NIL;
while (true) {
// waits for a new incoming status
......@@ -703,7 +703,7 @@ public class This {
state = status.getState();
// Stop this application if it was linked.
if (state == State.STOPPED || state == State.KILLED || state == State.SUCCESS || state == State.ERROR) {
if (state == State.STOPPED || state == State.KILLED || state == State.SUCCESS || state == State.FAILURE) {
stop();
}
}
......@@ -751,8 +751,8 @@ public class This {
// Get the actual state. It is necessary to get the actual state after the registration so that we do not miss any events.
int state = starterServer.getActualState(starterId);
// Stop this app if the starter is already terminated i.e. the state is UNKNOWN.
if (state == State.UNKNOWN) {
// Stop this app if the starter is already terminated i.e. the state is NIL.
if (state == State.NIL) {
stop();
}
else {
......
......@@ -126,7 +126,7 @@ public class SubscriberZmq implements SubscriberImpl {
if (state == State.SUCCESS
|| state == State.STOPPED
|| state == State.KILLED
|| state == State.ERROR) {
|| state == State.FAILURE) {
// Exit because the remote application has terminated.
return null;
}
......@@ -188,7 +188,7 @@ public class SubscriberZmq implements SubscriberImpl {
if (state == State.SUCCESS
|| state == State.STOPPED
|| state == State.KILLED
|| state == State.ERROR) {
|| state == State.FAILURE) {
// Exit because the remote application has terminated.
return null;
}
......
......@@ -549,7 +549,7 @@ public class Console {
int state = app.waitFor(State.SUCCESS
| State.STOPPED
| State.KILLED
| State.ERROR
| State.FAILURE
| State.PROCESSING_ERROR);
if (state == State.PROCESSING_ERROR) {
......@@ -645,7 +645,7 @@ public class Console {
else if (state == State.KILLED) {
System.out.println("The application " + appNameId + " has been killed.");
}
else if (state == State.ERROR) {
else if (state == State.FAILURE) {
if (exitCode != null) {
System.out.println("The application " + appNameId + " terminated with error " + exitCode + ".");
......
......@@ -36,8 +36,8 @@ public abstract class Application extends ApplicationConfig {
protected int id;
protected ProcessHandlerImpl processHandle;
protected int applicationState = ApplicationState.UNKNOWN;
protected int pastApplicationStates = ApplicationState.UNKNOWN;
protected int applicationState = ApplicationState.NIL;
protected int pastApplicationStates = ApplicationState.NIL;
protected ProcessState processState = ProcessState.UNKNOWN;
protected boolean hasStopHandler = false;
protected boolean hasToStop = false;
......
......@@ -23,13 +23,13 @@ package fr.ill.ics.cameo.manager;
*/
public class ApplicationState {
public final static int UNKNOWN = 0;
public final static int NIL = 0;
public final static int STARTING = 1;
public final static int RUNNING = 2;
public final static int STOPPING = 4;
public final static int KILLING = 8;
public final static int PROCESSING_ERROR = 16;
public final static int ERROR = 32;
public final static int FAILURE = 32;
public final static int SUCCESS = 64;
public final static int STOPPED = 128;
public final static int KILLED = 256;
......
......@@ -592,7 +592,7 @@ public class Manager extends ConfigLoader {
public synchronized void setApplicationState(Application application, int applicationState, int exitValue) {
// States are : UNKNOWN, STARTING, RUNNING, STOPPING, KILLING, PROCESSING_ERROR, ERROR, SUCCESS, STOPPED, KILLED.
// States are : NIL, STARTING, RUNNING, STOPPING, KILLING, PROCESSING_ERROR, FAILURE, SUCCESS, STOPPED, KILLED.
// Set the status of the application
application.setState(applicationState);
......@@ -600,7 +600,7 @@ public class Manager extends ConfigLoader {
sendStatus(application.getId(), application.getName(), applicationState, application.getPastApplicationStates(), exitValue);
// Remove the application for terminal states.
if (applicationState == ApplicationState.ERROR
if (applicationState == ApplicationState.FAILURE
|| applicationState == ApplicationState.STOPPED
|| applicationState == ApplicationState.KILLED
|| applicationState == ApplicationState.SUCCESS) {
......@@ -635,7 +635,7 @@ public class Manager extends ConfigLoader {
Application application = applicationMap.get(id);
int currentState = application.getApplicationState();
// States are : UNKNOWN, STARTING, RUNNING, STOPPING, KILLING, PROCESSING_ERROR, ERROR, SUCCESS, STOPPED, KILLED.
// States are: NIL, STARTING, RUNNING, STOPPING, KILLING, PROCESSING_ERROR, FAILURE, SUCCESS, STOPPED, KILLED.
// State that can be set by the client : RUNNING
if (state == ApplicationState.RUNNING) {
// current state can only be STARTING
......@@ -677,7 +677,7 @@ public class Manager extends ConfigLoader {
if (!applicationMap.containsKey(id)) {
status.setName("?");
status.setApplicationState(ApplicationState.UNKNOWN);
status.setApplicationState(ApplicationState.NIL);
status.setPastApplicationStates(0);
}
else {
......
......@@ -27,8 +27,8 @@ public class Converter {
public static String toString(int state) {
if (state == ApplicationState.UNKNOWN) {
return "UNKNOWN";
if (state == ApplicationState.NIL) {
return "NIL";
} else if (state == ApplicationState.STARTING) {
return "STARTING";
} else if (state == ApplicationState.RUNNING) {
......@@ -39,8 +39,8 @@ public class Converter {
return "KILLING";
} else if (state == ApplicationState.PROCESSING_ERROR) {
return "PROCESSING_ERROR";
} else if (state == ApplicationState.ERROR) {
return "ERROR";
} else if (state == ApplicationState.FAILURE) {
return "FAILURE";
} else if (state == ApplicationState.SUCCESS) {
return "SUCCESS";
} else if (state == ApplicationState.STOPPED) {
......@@ -49,7 +49,7 @@ public class Converter {
return "KILLED";
}
return "UNKNOWN";
return "NIL";
}
public static Msg reply(JSONObject response) {
......
......@@ -64,7 +64,7 @@ public class RequestProcessor {
Log.logger().finer("Received Sync message");
// Send sync message for synchronizing subscribers.
manager.sendStatus(-1, "", ApplicationState.UNKNOWN, ApplicationState.UNKNOWN, -1);
manager.sendStatus(-1, "", ApplicationState.NIL, ApplicationState.NIL, -1);
// Return the reply.
JSONObject response = new JSONObject();
......
......@@ -200,7 +200,7 @@ public class LifecycleApplicationThread extends ApplicationThread {
manager.setApplicationState(application, ApplicationState.KILLED);
}
else if (!onTermination()) {
manager.setApplicationState(application, ApplicationState.ERROR);
manager.setApplicationState(application, ApplicationState.FAILURE);
}
else {
manager.setApplicationState(application, ApplicationState.STOPPED);
......@@ -226,7 +226,7 @@ public class LifecycleApplicationThread extends ApplicationThread {
Log.logger().info("Application " + application.getNameId() + " has terminated");
if (!onTermination()) {
manager.setApplicationState(application, ApplicationState.ERROR, exitValue);
manager.setApplicationState(application, ApplicationState.FAILURE, exitValue);
}
else {
if (application.hasToStop()) {
......
......@@ -34,7 +34,7 @@ PYBIND11_MODULE(cameopy, m) {
m.def("toString", &toString, "Function converting numerical state to its string representation");
m.attr("OUTPUTSTREAM") = cameo::OUTPUTSTREAM;
m.attr("UNKNOWN") = UNKNOWN;
m.attr("NIL") = NIL;
m.attr("STARTING") = STARTING;
m.attr("RUNNING") = RUNNING;
m.attr("STOPPING") = STOPPING;
......
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