Cleaner version of removing project's directory
This commit is contained in:
@@ -27,6 +27,8 @@ import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -565,7 +567,7 @@ public class Client {
|
||||
}
|
||||
}
|
||||
|
||||
public Error.Type work(Job ajob) {
|
||||
public Error.Type work(final Job ajob) {
|
||||
int ret;
|
||||
|
||||
gui.setRenderingProjectName(ajob.getName());
|
||||
@@ -613,8 +615,15 @@ public class Client {
|
||||
this.config.cleanWorkingDirectory();
|
||||
return Error.Type.MISSING_RENDERER;
|
||||
}
|
||||
|
||||
Error.Type err = ajob.render();
|
||||
|
||||
Observer removeSceneDirectoryOnceRenderHasStartedObserver = new Observer() {
|
||||
@Override public void update(Observable observable, Object o) {
|
||||
System.out.println("Client::work got an event");
|
||||
removeSceneDirectory(ajob);
|
||||
}
|
||||
};
|
||||
|
||||
Error.Type err = ajob.render(removeSceneDirectoryOnceRenderHasStartedObserver);
|
||||
gui.setRenderingProjectName("");
|
||||
gui.setRemainingTime("");
|
||||
gui.setRenderingTime("");
|
||||
|
||||
@@ -35,6 +35,8 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -70,14 +72,10 @@ public class Job {
|
||||
private boolean serverBlockJob;
|
||||
private Gui gui;
|
||||
private Configuration config;
|
||||
private Client client;
|
||||
private Log log;
|
||||
|
||||
private boolean directoryRemoved;
|
||||
|
||||
public Job(Configuration config_, Client client_, Gui gui_, Log log_, String id_, String frame_, String path_, boolean use_gpu, String command_, String script_, String sceneMd5_, String rendererMd5_, String name_, String password_, String extras_, boolean synchronous_upload_, String update_method_) {
|
||||
public Job(Configuration config_, Gui gui_, Log log_, String id_, String frame_, String path_, boolean use_gpu, String command_, String script_, String sceneMd5_, String rendererMd5_, String name_, String password_, String extras_, boolean synchronous_upload_, String update_method_) {
|
||||
config = config_;
|
||||
client = client_;
|
||||
id = id_;
|
||||
numFrame = frame_;
|
||||
path = path_;
|
||||
@@ -98,7 +96,6 @@ public class Job {
|
||||
serverBlockJob = false;
|
||||
log = log_;
|
||||
render = new RenderProcess();
|
||||
directoryRemoved = false;
|
||||
}
|
||||
|
||||
public void block() {
|
||||
@@ -230,7 +227,7 @@ public class Job {
|
||||
return synchronousUpload;
|
||||
}
|
||||
|
||||
public Error.Type render() {
|
||||
public Error.Type render(Observer renderStarted) {
|
||||
gui.status("Rendering");
|
||||
RenderProcess process = getProcessRender();
|
||||
Timer timerOfMaxRenderTime = null;
|
||||
@@ -326,6 +323,7 @@ public class Job {
|
||||
}
|
||||
|
||||
try {
|
||||
renderStartedObservable event = new renderStartedObservable(renderStarted);
|
||||
String line;
|
||||
log.debug(command.toString());
|
||||
OS os = OS.getOS();
|
||||
@@ -377,9 +375,8 @@ public class Job {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (directoryRemoved == false && (process.getMemoryUsed() > 0 || process.getRemainingDuration() > 0)) {
|
||||
client.removeSceneDirectory(this);
|
||||
directoryRemoved = true;
|
||||
if (event.isStarted() == false && (process.getMemoryUsed() > 0 || process.getRemainingDuration() > 0)) {
|
||||
event.doNotifyIsStarted();
|
||||
}
|
||||
}
|
||||
input.close();
|
||||
@@ -859,4 +856,23 @@ public class Job {
|
||||
return config.getTileSize();
|
||||
}
|
||||
}
|
||||
|
||||
public static class renderStartedObservable extends Observable {
|
||||
private boolean isStarted;
|
||||
|
||||
public renderStartedObservable(Observer observer) {
|
||||
super();
|
||||
addObserver(observer);
|
||||
}
|
||||
|
||||
public void doNotifyIsStarted() {
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
isStarted = true;
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return isStarted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,7 +464,6 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
|
||||
Job a_job = new Job(
|
||||
this.user_config,
|
||||
this.client,
|
||||
this.client.getGui(),
|
||||
this.client.getLog(),
|
||||
job_node.getAttribute("id"),
|
||||
|
||||
Reference in New Issue
Block a user