Ref: remove duplicate handle code
This commit is contained in:
@@ -41,25 +41,21 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.sheepit.client.Error.ServerCode;
|
||||
import com.sheepit.client.Error.Type;
|
||||
import com.sheepit.client.datamodel.Chunk;
|
||||
import com.sheepit.client.exception.SheepItException;
|
||||
import com.sheepit.client.exception.SheepItExceptionBadResponseFromServer;
|
||||
import com.sheepit.client.exception.SheepItExceptionNoRendererAvailable;
|
||||
import com.sheepit.client.exception.SheepItExceptionNoRightToRender;
|
||||
import com.sheepit.client.exception.SheepItExceptionNoSession;
|
||||
import com.sheepit.client.exception.SheepItExceptionNoSpaceLeftOnDevice;
|
||||
import com.sheepit.client.exception.SheepItExceptionPathInvalid;
|
||||
import com.sheepit.client.exception.SheepItExceptionNoWritePermission;
|
||||
import com.sheepit.client.exception.SheepItExceptionServerInMaintenance;
|
||||
import com.sheepit.client.exception.SheepItExceptionServerOverloaded;
|
||||
import com.sheepit.client.exception.SheepItExceptionSessionDisabled;
|
||||
import com.sheepit.client.exception.SheepItExceptionSessionDisabledDenoisingNotSupported;
|
||||
import com.sheepit.client.exception.SheepItServerDown;
|
||||
import com.sheepit.client.exception.SheepItExceptionWithRequiredWait;
|
||||
import com.sheepit.client.hardware.cpu.CPU;
|
||||
import com.sheepit.client.os.OS;
|
||||
|
||||
@@ -267,11 +263,15 @@ import okhttp3.HttpUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SheepItServerDown e) {
|
||||
int wait = ThreadLocalRandom.current().nextInt(10, 30 + 1); // max is exclusive
|
||||
int time_sleep = 1000 * 60 * wait;
|
||||
this.gui.status(String.format("Cannot connect to the server. Please check your connectivity. Will try again at %tR",
|
||||
new Date(new Date().getTime() + time_sleep)));
|
||||
catch (SheepItExceptionWithRequiredWait e) {
|
||||
// exception example:
|
||||
// SheepItExceptionServerInMaintenance
|
||||
// SheepItExceptionServerOverloaded
|
||||
// SheepItServerDown
|
||||
// SheepItExceptionBadResponseFromServer
|
||||
|
||||
int time_sleep = e.getWaitDuration();
|
||||
this.gui.status(String.format(e.getHumanText(), new Date(new Date().getTime() + time_sleep)));
|
||||
|
||||
if (this.activeSleep(time_sleep) == false) {
|
||||
return -3;
|
||||
@@ -279,43 +279,6 @@ import okhttp3.HttpUrl;
|
||||
this.log.removeCheckPoint(step);
|
||||
continue; // go back to ask job
|
||||
}
|
||||
catch (SheepItExceptionServerOverloaded e) {
|
||||
int wait = ThreadLocalRandom.current().nextInt(10, 30 + 1); // max is exclusive
|
||||
int time_sleep = 1000 * 60 * wait;
|
||||
this.gui.status(String.format("The server is overloaded and cannot allocate a job. Will try again at %tR",
|
||||
new Date(new Date().getTime() + time_sleep)));
|
||||
|
||||
if (this.activeSleep(time_sleep) == false) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
this.log.removeCheckPoint(step);
|
||||
continue; // go back to ask job
|
||||
}
|
||||
catch (SheepItExceptionServerInMaintenance e) {
|
||||
int wait = ThreadLocalRandom.current().nextInt(20, 30 + 1); // max is exclusive
|
||||
int time_sleep = 1000 * 60 * wait;
|
||||
this.gui.status(String.format("The server is under maintenance and cannot allocate a job. Will try again at %tR",
|
||||
new Date(new Date().getTime() + time_sleep)));
|
||||
|
||||
if (this.activeSleep(time_sleep) == false) {
|
||||
return -3;
|
||||
}
|
||||
this.log.removeCheckPoint(step);
|
||||
continue; // go back to ask job
|
||||
}
|
||||
catch (SheepItExceptionBadResponseFromServer e) {
|
||||
int wait = ThreadLocalRandom.current().nextInt(15, 30 + 1); // max is exclusive
|
||||
int time_sleep = 1000 * 60 * wait;
|
||||
this.gui.status(String.format("Bad answer from the server. Will try again at %tR", new Date(new Date().getTime() + time_sleep)));
|
||||
|
||||
if (this.activeSleep(time_sleep) == false) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
this.log.removeCheckPoint(step);
|
||||
continue; // go back to ask job
|
||||
}
|
||||
catch (SheepItException e) {
|
||||
this.gui.error("Client::run exception requestJob (1) " + e.getMessage());
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
Reference in New Issue
Block a user