diff --git a/protocol.txt b/protocol.txt index 3e12b65..82f8848 100644 --- a/protocol.txt +++ b/protocol.txt @@ -90,6 +90,8 @@ where X: * 202 => Client's session is dead. Client should do a config request before requesting a new job. * 203 => Client's session have been disabled (usually because the client is sending broken frame). The client warms the end user and logout. * 205 => No renderer is available for Client's hardware (pair of OS and architecture). For example Blender is not available for MacOS 32bits. + * 206 => Server is in maintenance mode, it will not give frame to do (but it will keep the session alive). + * 207 => Server is too busy to run the scheduler, it will not give frame to do (but it will keep the session alive). * something else => unknown error Answer with no error: diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 022159f..9597fe0 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -35,6 +35,8 @@ import com.sheepit.client.Error.Type; import com.sheepit.client.exception.FermeException; import com.sheepit.client.exception.FermeExceptionNoRightToRender; import com.sheepit.client.exception.FermeExceptionNoSession; +import com.sheepit.client.exception.FermeExceptionServerInMaintenance; +import com.sheepit.client.exception.FermeExceptionServerOverloaded; import com.sheepit.client.exception.FermeExceptionSessionDisabled; import com.sheepit.client.exception.FermeServerDown; import com.sheepit.client.os.OS; @@ -220,6 +222,30 @@ public class Client { } continue; // go back to ask job } + catch (FermeExceptionServerOverloaded e) { + int wait = 15; + int time_sleep = 1000 * 60 * wait; + this.gui.status(String.format("Server is overloaded and cannot give frame to render. Will retry in %s minutes", wait)); + try { + Thread.sleep(time_sleep); + } + catch (InterruptedException e1) { + return -3; + } + continue; // go back to ask job + } + catch (FermeExceptionServerInMaintenance e) { + int wait = 15; + int time_sleep = 1000 * 60 * wait; + this.gui.status(String.format("Server is in maintenance and cannot give frame to render. Will retry in %s minutes", wait)); + try { + Thread.sleep(time_sleep); + } + catch (InterruptedException e1) { + return -3; + } + continue; // go back to ask job + } catch (FermeException e) { this.gui.error("Client::renderingManagement exception requestJob (1) " + e.getMessage()); StringWriter sw = new StringWriter(); diff --git a/src/com/sheepit/client/Error.java b/src/com/sheepit/client/Error.java old mode 100644 new mode 100755 index ff963f4..2822dca --- a/src/com/sheepit/client/Error.java +++ b/src/com/sheepit/client/Error.java @@ -72,6 +72,8 @@ public class Error { JOB_REQUEST_ERROR_SESSION_DISABLED(203), JOB_REQUEST_ERROR_INTERNAL_ERROR(204), JOB_REQUEST_ERROR_RENDERER_NOT_AVAILABLE(205), + JOB_REQUEST_SERVER_IN_MAINTENANCE(206), + JOB_REQUEST_SERVER_OVERLOADED(207), JOB_VALIDATION_ERROR_MISSING_PARAMETER(300), JOB_VALIDATION_ERROR_BROKEN_MACHINE(301), // in GPU the generated frame is black diff --git a/src/com/sheepit/client/Server.java b/src/com/sheepit/client/Server.java index 231a895..72159c9 100644 --- a/src/com/sheepit/client/Server.java +++ b/src/com/sheepit/client/Server.java @@ -77,6 +77,8 @@ import com.sheepit.client.Error.ServerCode; import com.sheepit.client.exception.FermeException; import com.sheepit.client.exception.FermeExceptionNoRightToRender; import com.sheepit.client.exception.FermeExceptionNoSession; +import com.sheepit.client.exception.FermeExceptionServerInMaintenance; +import com.sheepit.client.exception.FermeExceptionServerOverloaded; import com.sheepit.client.exception.FermeExceptionSessionDisabled; import com.sheepit.client.exception.FermeServerDown; import com.sheepit.client.os.OS; @@ -330,6 +332,12 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager else if (ret == ServerCode.JOB_REQUEST_ERROR_SESSION_DISABLED) { throw new FermeExceptionSessionDisabled(); } + else if (ret == ServerCode.JOB_REQUEST_SERVER_IN_MAINTENANCE) { + throw new FermeExceptionServerInMaintenance(); + } + else if (ret == ServerCode.JOB_REQUEST_SERVER_OVERLOADED) { + throw new FermeExceptionServerOverloaded(); + } this.log.error("Server::requestJob: Utils.statusIsOK(document, 'jobrequest') -> ret " + ret); throw new FermeException("error requestJob: status is not ok (it's " + ret + ")"); } diff --git a/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java b/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java new file mode 100644 index 0000000..74c64c5 --- /dev/null +++ b/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java @@ -0,0 +1,11 @@ +package com.sheepit.client.exception; + +public class FermeExceptionServerInMaintenance extends FermeException { + public FermeExceptionServerInMaintenance() { + super(); + } + + public FermeExceptionServerInMaintenance(String message_) { + super(message_); + } +} diff --git a/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java b/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java new file mode 100644 index 0000000..69fd9aa --- /dev/null +++ b/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java @@ -0,0 +1,11 @@ +package com.sheepit.client.exception; + +public class FermeExceptionServerOverloaded extends FermeException { + public FermeExceptionServerOverloaded() { + super(); + } + + public FermeExceptionServerOverloaded(String message_) { + super(message_); + } +}