Optimise the retries algorithm for the "no job" server response (#230)
* Implement an optimised retries algorithm for the "no job" server response * formating Co-authored-by: Laurent Clouet <laurent@nopnop.net>
This commit is contained in:
@@ -69,6 +69,7 @@ public class Client {
|
|||||||
|
|
||||||
private int uploadQueueSize;
|
private int uploadQueueSize;
|
||||||
private long uploadQueueVolume;
|
private long uploadQueueVolume;
|
||||||
|
private int noJobRetryIter;
|
||||||
|
|
||||||
public Client(Gui gui_, Configuration configuration, String url_) {
|
public Client(Gui gui_, Configuration configuration, String url_) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
@@ -86,6 +87,7 @@ public class Client {
|
|||||||
|
|
||||||
this.uploadQueueSize = 0;
|
this.uploadQueueSize = 0;
|
||||||
this.uploadQueueVolume = 0;
|
this.uploadQueueVolume = 0;
|
||||||
|
this.noJobRetryIter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -292,8 +294,9 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.renderingJob == null) { // no job
|
if (this.renderingJob == null) { // no job
|
||||||
int wait = ThreadLocalRandom.current().nextInt(10, 30 + 1); // max is exclusive
|
int[] retrySchemeInSeconds = {300000, 480000, 720000, 900000, 1200000}; // 5, 8, 12, 15 and 20 minutes
|
||||||
int time_sleep = 1000 * 60 * wait;
|
|
||||||
|
int time_sleep = retrySchemeInSeconds[(this.noJobRetryIter < retrySchemeInSeconds.length) ? this.noJobRetryIter++ : (retrySchemeInSeconds.length - 1)];
|
||||||
this.gui.status(String.format("No job available. Will try again at %tR",
|
this.gui.status(String.format("No job available. Will try again at %tR",
|
||||||
new Date(new Date().getTime() + time_sleep)));
|
new Date(new Date().getTime() + time_sleep)));
|
||||||
this.suspended = true;
|
this.suspended = true;
|
||||||
@@ -313,6 +316,9 @@ public class Client {
|
|||||||
|
|
||||||
this.log.debug("Got work to do id: " + this.renderingJob.getId() + " frame: " + this.renderingJob.getFrameNumber());
|
this.log.debug("Got work to do id: " + this.renderingJob.getId() + " frame: " + this.renderingJob.getFrameNumber());
|
||||||
|
|
||||||
|
// As the server allocated a new job to this client, reset the no_job waiting algorithm
|
||||||
|
this.noJobRetryIter = 0;
|
||||||
|
|
||||||
ret = this.work(this.renderingJob);
|
ret = this.work(this.renderingJob);
|
||||||
if (ret == Error.Type.RENDERER_KILLED) {
|
if (ret == Error.Type.RENDERER_KILLED) {
|
||||||
this.log.removeCheckPoint(step);
|
this.log.removeCheckPoint(step);
|
||||||
|
|||||||
Reference in New Issue
Block a user