Use lombok annotation instead of get/set

This commit is contained in:
Laurent Clouet
2019-08-07 22:17:59 +02:00
parent 9b36dcf9b5
commit 9f1f509bb6
12 changed files with 123 additions and 420 deletions

View File

@@ -47,16 +47,19 @@ import com.sheepit.client.exception.FermeExceptionSessionDisabled;
import com.sheepit.client.exception.FermeServerDown;
import com.sheepit.client.os.OS;
import lombok.Data;
@Data
public class Client {
private Gui gui;
private Server server;
private Configuration config;
private Configuration configuration;
private Log log;
private Job renderingJob;
private Job previousJob;
private BlockingQueue<Job> jobsToValidate;
private boolean isValidatingJob;
private long start_time;
private long startTime;
private boolean disableErrorSending;
private boolean running;
@@ -64,10 +67,10 @@ public class Client {
private int maxDownloadFileAttempts = 5;
public Client(Gui gui_, Configuration config, String url_) {
this.config = config;
this.server = new Server(url_, this.config, this);
this.log = Log.getInstance(this.config);
public Client(Gui gui_, Configuration configuration, String url_) {
this.configuration = configuration;
this.server = new Server(url_, this.configuration, this);
this.log = Log.getInstance(this.configuration);
this.gui = gui_;
this.renderingJob = null;
this.previousJob = null;
@@ -80,40 +83,16 @@ public class Client {
}
public String toString() {
return String.format("Client (config %s, server %s)", this.config, this.server);
}
public Job getRenderingJob() {
return this.renderingJob;
}
public Gui getGui() {
return this.gui;
}
public Configuration getConfiguration() {
return this.config;
}
public Server getServer() {
return this.server;
}
public Log getLog() {
return this.log;
}
public long getStartTime() {
return this.start_time;
return String.format("Client (configuration %s, server %s)", this.configuration, this.server);
}
public int run() {
if (this.config.checkOSisSupported() == false) {
if (this.configuration.checkOSisSupported() == false) {
this.gui.error(Error.humanString(Error.Type.OS_NOT_SUPPORTED));
return -3;
}
if (this.config.checkCPUisSupported() == false) {
if (this.configuration.checkCPUisSupported() == false) {
this.gui.error(Error.humanString(Error.Type.CPU_NOT_SUPPORTED));
return -4;
}
@@ -125,7 +104,7 @@ public class Client {
step = this.log.newCheckPoint();
this.gui.status("Starting");
this.config.cleanWorkingDirectory();
this.configuration.cleanWorkingDirectory();
Error.Type ret;
ret = this.server.getConfiguration();
@@ -138,7 +117,7 @@ public class Client {
return -1;
}
this.start_time = new Date().getTime();
this.startTime = new Date().getTime();
this.server.start(); // for staying alive
// create a thread which will send the frame
@@ -215,7 +194,7 @@ public class Client {
this.renderingJob = null;
}
else {
this.start_time = new Date().getTime(); // reset start session time because the server did it
this.startTime = new Date().getTime(); // reset start session time because the server did it
try {
Calendar next_request = this.nextJobRequest();
if (next_request != null) {
@@ -345,7 +324,7 @@ public class Client {
continue;
}
if (this.renderingJob.simultaneousUploadIsAllowed() == false) { // power or compute_method job, need to upload right away
if (this.renderingJob.isSynchronousUpload() == false) { // power or compute_method job, need to upload right away
ret = confirmJob(this.renderingJob);
if (ret != Error.Type.OK) {
gui.error("Client::run problem with confirmJob (returned " + ret + ")");
@@ -403,8 +382,8 @@ public class Client {
}
}
// this.config.workingDirectory.delete();
this.config.removeWorkingDirectory();
// this.configuration.workingDirectory.delete();
this.configuration.removeWorkingDirectory();
if (this.server == null) {
return 0;
@@ -428,10 +407,6 @@ public class Client {
return 0;
}
public boolean isSuspended() {
return this.suspended;
}
public void suspend() {
suspended = true;
}
@@ -451,10 +426,6 @@ public class Client {
this.running = true;
}
public boolean isRunning() {
return this.running;
}
public int senderLoop() {
int step = log.newCheckPoint();
Error.Type ret;
@@ -538,13 +509,13 @@ public class Client {
* @return the date of the next request, or null if there is not delay (null <=> now)
*/
public Calendar nextJobRequest() {
if (this.config.requestTime == null) {
if (this.configuration.getRequestTime() == null) {
return null;
}
else {
Calendar next = null;
Calendar now = Calendar.getInstance();
for (Pair<Calendar, Calendar> interval : this.config.requestTime) {
for (Pair<Calendar, Calendar> interval : this.configuration.getRequestTime()) {
Calendar start = (Calendar) now.clone();
Calendar end = (Calendar) now.clone();
start.set(Calendar.SECOND, 00);
@@ -605,14 +576,14 @@ public class Client {
if (scene_file.exists() == false) {
gui.setRenderingProjectName("");
this.log.error("Client::work job preparation failed (scene file '" + scene_file.getAbsolutePath() + "' does not exist), cleaning directory in hope to recover");
this.config.cleanWorkingDirectory();
this.configuration.cleanWorkingDirectory();
return Error.Type.MISSING_SCENE;
}
if (renderer_file.exists() == false) {
gui.setRenderingProjectName("");
this.log.error("Client::work job preparation failed (renderer file '" + renderer_file.getAbsolutePath() + "' does not exist), cleaning directory in hope to recover");
this.config.cleanWorkingDirectory();
this.configuration.cleanWorkingDirectory();
return Error.Type.MISSING_RENDERER;
}
@@ -631,7 +602,7 @@ public class Client {
this.log.error("Client::work problem with runRenderer (ret " + err + ")");
if (err == Error.Type.RENDERER_CRASHED_PYTHON_ERROR) {
this.log.error("Client::work failed with python error, cleaning directory in hope to recover");
this.config.cleanWorkingDirectory();
this.configuration.cleanWorkingDirectory();
}
return err;
}
@@ -646,7 +617,7 @@ public class Client {
}
protected int downloadExecutable(Job ajob) throws FermeExceptionNoSpaceLeftOnDevice {
return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRenderMd5(), String.format("%s?type=binary&job=%s", this.server.getPage("download-archive"), ajob.getId()), "renderer");
return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRendererMD5(), String.format("%s?type=binary&job=%s", this.server.getPage("download-archive"), ajob.getId()), "renderer");
}
private int downloadFile(Job ajob, String local_path, String md5_server, String url, String download_type) throws FermeExceptionNoSpaceLeftOnDevice {
@@ -757,7 +728,7 @@ public class Client {
scene_path_file.mkdir();
// unzip the archive
ret = Utils.unzipFileIntoDirectory(scene_archive, scene_path, ajob.getSceneArchivePassword(), log);
ret = Utils.unzipFileIntoDirectory(scene_archive, scene_path, ajob.getPassword(), log);
if (ret != 0) {
this.log.error("Client::prepareWorkingDirectory, error(2) with Utils.unzipFileIntoDirectory(" + scene_archive + ", " + scene_path + ") returned " + ret);
this.gui.error("Client::prepareWorkingDirectory, error with Utils.unzipFileIntoDirectory of the scene (returned " + ret + ")");
@@ -825,15 +796,11 @@ public class Client {
return Error.Type.OK;
}
public Job getPreviousJob() {
return this.previousJob;
}
protected boolean shouldWaitBeforeRender() {
int concurrent_job = this.jobsToValidate.size();
if (this.isValidatingJob) {
concurrent_job++;
}
return (concurrent_job >= this.config.maxUploadingJob());
return (concurrent_job >= this.configuration.getMaxUploadingJob());
}
}

View File

@@ -34,17 +34,19 @@ import java.util.List;
import com.sheepit.client.hardware.cpu.CPU;
import com.sheepit.client.hardware.gpu.GPUDevice;
import com.sheepit.client.os.OS;
import lombok.Data;
@Data
public class Configuration {
public enum ComputeType {
CPU_GPU, CPU, GPU
} // accept job for ...
private String configFilePath;
public File workingDirectory;
public File storageDirectory; // for permanent storage (binary archive)
public boolean userHasSpecifiedACacheDir;
public String static_exeDirName;
private File workingDirectory;
private File storageDirectory; // for permanent storage (binary archive)
private boolean userHasSpecifiedACacheDir;
private String static_exeDirName;
private String login;
private String password;
private String proxy;
@@ -57,7 +59,7 @@ public class Configuration {
private GPUDevice GPUDevice;
private boolean detectGPUs;
private boolean printLog;
public List<Pair<Calendar, Calendar>> requestTime;
private List<Pair<Calendar, Calendar>> requestTime;
private String extras;
private boolean autoSignIn;
private String UIType;
@@ -96,78 +98,6 @@ public class Configuration {
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
}
public String getConfigFilePath() {
return this.configFilePath;
}
public void setConfigPath(String val) {
this.configFilePath = val;
}
public String login() {
return this.login;
}
public void setLogin(String login_) {
this.login = login_;
}
public String password() {
return this.password;
}
public void setPassword(String password_) {
this.password = password_;
}
public String getProxy() {
return this.proxy;
}
public void setProxy(String url) {
this.proxy = url;
}
public int maxUploadingJob() {
return this.maxUploadingJob;
}
public GPUDevice getGPUDevice() {
return this.GPUDevice;
}
public boolean getDetectGPUs() {
return this.detectGPUs;
}
public void setMaxUploadingJob(int max) {
this.maxUploadingJob = max;
}
public void setUseNbCores(int nbcores) {
this.nbCores = nbcores;
}
public int getNbCores() {
return this.nbCores;
}
public void setMaxMemory(long max) {
this.maxMemory = max;
}
public long getMaxMemory() {
return this.maxMemory;
}
public void setMaxRenderTime(int max) {
this.maxRenderTime = max;
}
public int getMaxRenderTime() {
return this.maxRenderTime;
}
public void setUsePriority(int priority) {
if (priority > 19)
priority = 19;
@@ -178,38 +108,10 @@ public class Configuration {
}
public int getPriority() {
return this.priority;
}
public void setPrintLog(boolean val) {
this.printLog = val;
}
public boolean getPrintLog() {
return this.printLog;
}
public int computeMethodToInt() {
return this.computeMethod.ordinal();
}
public ComputeType getComputeMethod() {
return this.computeMethod;
}
public void setUseGPU(GPUDevice device) {
this.GPUDevice = device;
}
public void setDetectGPUs(boolean val) {
this.detectGPUs = val;
}
public void setComputeMethod(ComputeType meth) {
this.computeMethod = meth;
}
public void setCacheDir(File cache_dir_) {
removeWorkingDirectory();
if (cache_dir_ == null) {
@@ -259,12 +161,8 @@ public class Configuration {
}
}
public boolean getUserHasSpecifiedACacheDir() {
return this.userHasSpecifiedACacheDir;
}
public File getCacheDirForSettings() {
if (this.getUserHasSpecifiedACacheDir() == false) {
if (this.userHasSpecifiedACacheDir == false) {
return null;
}
else {
@@ -273,46 +171,6 @@ public class Configuration {
}
}
public void setExtras(String str) {
this.extras = str;
}
public String getExtras() {
return this.extras;
}
public void setAutoSignIn(boolean v) {
this.autoSignIn = v;
}
public boolean getAutoSignIn() {
return this.autoSignIn;
}
public void setUIType(String ui) {
this.UIType = ui;
}
public String getUIType() {
return this.UIType;
}
public void setTileSize(int size) {
this.tileSize = size;
}
public int getTileSize() {
return this.tileSize;
}
public void setHostname(String hostname_) {
this.hostname = hostname_;
}
public String getHostname() {
return this.hostname;
}
public String getDefaultHostname() {
try {
return InetAddress.getLocalHost().getHostName();

View File

@@ -46,17 +46,20 @@ import com.sheepit.client.Error.Type;
import com.sheepit.client.hardware.gpu.GPUDevice;
import com.sheepit.client.hardware.gpu.opencl.OpenCL;
import com.sheepit.client.os.OS;
import lombok.Data;
import lombok.Getter;
@Data
public class Job {
public static final String UPDATE_METHOD_BY_REMAINING_TIME = "remainingtime";
public static final String UPDATE_METHOD_BLENDER_INTERNAL_BY_PART = "blenderinternal";
public static final String UPDATE_METHOD_BY_TILE = "by_tile";
private String numFrame;
private String frameNumber;
private String sceneMD5;
private String rendererMD5;
private String id;
private String pictureFilename;
private String outputImagePath;
private String path; // path inside of the archive
private String rendererCommand;
private String script;
@@ -71,13 +74,13 @@ public class Job {
private boolean userBlockJob;
private boolean serverBlockJob;
private Gui gui;
private Configuration config;
private Configuration configuration;
private Log log;
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_;
configuration = config_;
id = id_;
numFrame = frame_;
frameNumber = frame_;
path = path_;
useGPU = use_gpu;
rendererCommand = command_;
@@ -88,7 +91,7 @@ public class Job {
extras = extras_;
synchronousUpload = synchronous_upload_;
gui = gui_;
pictureFilename = null;
outputImagePath = null;
script = script_;
updateRenderingStatusMethod = update_method_;
askForRendererKill = false;
@@ -112,83 +115,7 @@ public class Job {
}
public String toString() {
return String.format("Job (numFrame '%s' sceneMD5 '%s' rendererMD5 '%s' ID '%s' pictureFilename '%s' jobPath '%s' gpu %s name '%s' extras '%s' updateRenderingStatusMethod '%s' render %s)", numFrame, sceneMD5, rendererMD5, id, pictureFilename, path, useGPU, name, extras, updateRenderingStatusMethod, render);
}
public String getId() {
return id;
}
public String getFrameNumber() {
return numFrame;
}
public String getExtras() {
return extras;
}
public String getScript() {
return script;
}
public String getSceneMD5() {
return sceneMD5;
}
public String getRenderMd5() {
return rendererMD5;
}
public String getPath() {
return path;
}
public String getUpdateRenderingStatusMethod() {
return updateRenderingStatusMethod;
}
public void setAskForRendererKill(boolean val) {
askForRendererKill = val;
}
public boolean getAskForRendererKill() {
return askForRendererKill;
}
public void setUserBlockJob(boolean val) {
userBlockJob = val;
}
public boolean getUserBlockJob() {
return userBlockJob;
}
public void setServerBlockJob(boolean val) {
serverBlockJob = val;
}
public boolean getServerBlockJob() {
return serverBlockJob;
}
public String getRenderCommand() {
return rendererCommand;
}
public boolean getUseGPU() {
return useGPU;
}
public String getName() {
return name;
}
public void setOutputImagePath(String path) {
pictureFilename = path;
}
public String getOutputImagePath() {
return pictureFilename;
return String.format("Job (numFrame '%s' sceneMD5 '%s' rendererMD5 '%s' ID '%s' pictureFilename '%s' jobPath '%s' gpu %s name '%s' extras '%s' updateRenderingStatusMethod '%s' render %s)", frameNumber, sceneMD5, rendererMD5, id, outputImagePath, path, useGPU, name, extras, updateRenderingStatusMethod, render);
}
public String getPrefixOutputImage() {
@@ -196,7 +123,7 @@ public class Job {
}
public String getRendererDirectory() {
return config.workingDirectory.getAbsolutePath() + File.separator + rendererMD5;
return configuration.getWorkingDirectory().getAbsolutePath() + File.separator + rendererMD5;
}
public String getRendererPath() {
@@ -204,11 +131,11 @@ public class Job {
}
public String getRendererArchivePath() {
return config.getStorageDir().getAbsolutePath() + File.separator + rendererMD5 + ".zip";
return configuration.getStorageDir().getAbsolutePath() + File.separator + rendererMD5 + ".zip";
}
public String getSceneDirectory() {
return config.workingDirectory.getAbsolutePath() + File.separator + sceneMD5;
return configuration.getWorkingDirectory().getAbsolutePath() + File.separator + sceneMD5;
}
public String getScenePath() {
@@ -216,15 +143,7 @@ public class Job {
}
public String getSceneArchivePath() {
return config.workingDirectory.getAbsolutePath() + File.separator + sceneMD5 + ".zip";
}
public String getSceneArchivePassword() {
return password;
}
public boolean simultaneousUploadIsAllowed() {
return synchronousUpload;
return configuration.getWorkingDirectory().getAbsolutePath() + File.separator + sceneMD5 + ".zip";
}
public Error.Type render(Observer renderStarted) {
@@ -239,8 +158,8 @@ public class Job {
+ "def hndl(signum, frame):\n"
+ " pass\n"
+ "signal.signal(signal.SIGINT, hndl)\n";
if (getUseGPU() && config.getGPUDevice() != null && config.getComputeMethod() != ComputeType.CPU) {
core_script = "sheepit_set_compute_device(\"" + config.getGPUDevice().getType() + "\", \"GPU\", \"" + config.getGPUDevice().getId() + "\")\n";
if (isUseGPU() && configuration.getGPUDevice() != null && configuration.getComputeMethod() != ComputeType.CPU) {
core_script = "sheepit_set_compute_device(\"" + configuration.getGPUDevice().getType() + "\", \"GPU\", \"" + configuration.getGPUDevice().getId() + "\")\n";
gui.setComputeMethod("GPU");
}
else {
@@ -251,10 +170,10 @@ public class Job {
core_script += ignore_signal_script;
core_script += String.format("bpy.context.scene.render.tile_x = %1$d\nbpy.context.scene.render.tile_y = %1$d\n", getTileSize());
File script_file = null;
String command1[] = getRenderCommand().split(" ");
String command1[] = getRendererCommand().split(" ");
int size_command = command1.length + 2; // + 2 for script
if (config.getNbCores() > 0) { // user has specified something
if (configuration.getNbCores() > 0) { // user has specified something
size_command += 2;
}
@@ -262,13 +181,13 @@ public class Job {
Map<String, String> new_env = new HashMap<String, String>();
new_env.put("BLENDER_USER_CONFIG", config.workingDirectory.getAbsolutePath().replace("\\", "\\\\"));
new_env.put("CORES", Integer.toString(config.getNbCores()));
new_env.put("PRIORITY", Integer.toString(config.getPriority()));
new_env.put("BLENDER_USER_CONFIG", configuration.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\"));
new_env.put("CORES", Integer.toString(configuration.getNbCores()));
new_env.put("PRIORITY", Integer.toString(configuration.getPriority()));
new_env.put("PYTHONPATH", ""); // make sure blender is using the embedded python, if not it could create "Fatal Python error: Py_Initialize"
new_env.put("PYTHONHOME", "");// make sure blender is using the embedded python, if not it could create "Fatal Python error: Py_Initialize"
if (getUseGPU() && config.getGPUDevice() != null && config.getComputeMethod() != ComputeType.CPU && OpenCL.TYPE.equals(config.getGPUDevice().getType())) {
if (isUseGPU() && configuration.getGPUDevice() != null && configuration.getComputeMethod() != ComputeType.CPU && OpenCL.TYPE.equals(configuration.getGPUDevice().getType())) {
new_env.put("CYCLES_OPENCL_SPLIT_KERNEL_TEST", "1");
this.updateRenderingStatusMethod = UPDATE_METHOD_BY_TILE; // don't display remaining time
}
@@ -280,7 +199,7 @@ public class Job {
command.add("-P");
try {
script_file = File.createTempFile("script_", "", config.workingDirectory);
script_file = File.createTempFile("script_", "", configuration.getWorkingDirectory());
File file = new File(script_file.getAbsolutePath());
FileWriter txt;
txt = new FileWriter(file);
@@ -305,13 +224,13 @@ public class Job {
case ".e":
command.add(getRendererPath());
// the number of cores has to be put after the binary and before the scene arg
if (config.getNbCores() > 0) {
if (configuration.getNbCores() > 0) {
command.add("-t");
command.add(Integer.toString(config.getNbCores()));
command.add(Integer.toString(configuration.getNbCores()));
}
break;
case ".o":
command.add(config.workingDirectory.getAbsolutePath() + File.separator + getPrefixOutputImage());
command.add(configuration.getWorkingDirectory().getAbsolutePath() + File.separator + getPrefixOutputImage());
break;
case ".f":
command.add(getFrameNumber());
@@ -327,12 +246,12 @@ public class Job {
String line;
log.debug(command.toString());
OS os = OS.getOS();
process.setCoresUsed(config.getNbCores());
process.setCoresUsed(configuration.getNbCores());
process.start();
getProcessRender().setProcess(os.exec(command, new_env));
BufferedReader input = new BufferedReader(new InputStreamReader(getProcessRender().getProcess().getInputStream()));
if (config.getMaxRenderTime() > 0) {
if (configuration.getMaxRenderTime() > 0) {
timerOfMaxRenderTime = new Timer();
timerOfMaxRenderTime.schedule(new TimerTask() {
@Override
@@ -340,14 +259,14 @@ public class Job {
RenderProcess process = getProcessRender();
if (process != null) {
long duration = (new Date().getTime() - process.getStartTime() ) / 1000; // in seconds
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
if (configuration.getMaxRenderTime() > 0 && duration > configuration.getMaxRenderTime()) {
log.debug("Killing render because process duration");
OS.getOS().kill(process.getProcess());
setAskForRendererKill(true);
}
}
}
}, config.getMaxRenderTime() * 1000 + 2000); // +2s to be sure the delay is over
}, configuration.getMaxRenderTime() * 1000 + 2000); // +2s to be sure the delay is over
}
log.debug("renderer output");
@@ -356,8 +275,8 @@ public class Job {
log.debug(line);
updateRenderingMemoryPeak(line);
if (config.getMaxMemory() != -1 && process.getMemoryUsed() > config.getMaxMemory()) {
log.debug("Blocking render because process ram used (" + process.getMemoryUsed() + "k) is over user setting (" + config.getMaxMemory() + "k)");
if (configuration.getMaxMemory() != -1 && process.getMemoryUsed() > configuration.getMaxMemory()) {
log.debug("Blocking render because process ram used (" + process.getMemoryUsed() + "k) is over user setting (" + configuration.getMaxMemory() + "k)");
OS.getOS().kill(process.getProcess());
process.finish();
if (script_file != null) {
@@ -416,24 +335,24 @@ public class Job {
}
};
File[] files = config.workingDirectory.listFiles(textFilter);
if (getAskForRendererKill()) {
File[] files = configuration.getWorkingDirectory().listFiles(textFilter);
if (isAskForRendererKill()) {
log.debug("Job::render been asked to end render");
long duration = (new Date().getTime() - process.getStartTime() ) / 1000; // in seconds
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
log.debug("Render killed because process duration (" + duration + "s) is over user setting (" + config.getMaxRenderTime() + "s)");
if (configuration.getMaxRenderTime() > 0 && duration > configuration.getMaxRenderTime()) {
log.debug("Render killed because process duration (" + duration + "s) is over user setting (" + configuration.getMaxRenderTime() + "s)");
return Error.Type.RENDERER_KILLED_BY_USER_OVER_TIME;
}
if (files.length != 0) {
new File(files[0].getAbsolutePath()).delete();
}
if (getServerBlockJob()) {
if (isServerBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_SERVER;
}
if (getUserBlockJob()) {
if (isUserBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_USER;
}
return Error.Type.RENDERER_KILLED;
@@ -449,7 +368,7 @@ public class Job {
catch (Exception e) {
e.printStackTrace();
}
File crash_file = new File(config.workingDirectory + File.separator + basename + ".crash.txt");
File crash_file = new File(configuration.getWorkingDirectory() + File.separator + basename + ".crash.txt");
if (crash_file.exists()) {
log.error("Job::render crash file found => the renderer crashed");
crash_file.delete();
@@ -844,20 +763,22 @@ public class Job {
}
public int getTileSize() {
if (config.getTileSize() == -1) { // not set
if (configuration.getTileSize() == -1) { // not set
int size = 32; // CPU
GPUDevice gpu = this.config.getGPUDevice();
if (getUseGPU() && gpu != null) {
GPUDevice gpu = this.configuration.getGPUDevice();
if (isUseGPU() && gpu != null) {
return gpu.getRecommandedTileSize();
}
return size;
}
else {
return config.getTileSize();
return configuration.getTileSize();
}
}
public static class renderStartedObservable extends Observable {
@Getter
private boolean isStarted;
public renderStartedObservable(Observer observer) {
@@ -870,9 +791,5 @@ public class Job {
notifyObservers();
isStarted = true;
}
public boolean isStarted() {
return isStarted;
}
}
}

View File

@@ -89,7 +89,7 @@ public class Log {
if (instance == null) {
boolean print = false;
if (config != null) {
print = config.getPrintLog();
print = config.isPrintLog();
}
instance = new Log(print);
}

View File

@@ -19,82 +19,49 @@
package com.sheepit.client;
import lombok.Data;
import java.util.Date;
@Data
public class RenderProcess {
private long start;
private long end;
private int remainingDuration;
private long startTime;
private long endTime;
private int remainingDuration; // in seconds
private long memoryUsed; // in kB
private int coresUsed;
private Process process;
public RenderProcess() {
process = null;
start = -1;
end = -1;
startTime = -1;
endTime = -1;
memoryUsed = 0;
coresUsed = 0;
remainingDuration = 0;
}
public void setMemoryUsed(long val) {
memoryUsed = val;
}
public long getMemoryUsed() {
return memoryUsed;
}
public void setCoresUsed(int val) {
coresUsed = val;
}
public int getCoresUsed() {
return coresUsed;
}
public long getStartTime() {
return start;
}
public long getEndTime() {
return end;
}
/**
*
* @return duration in seconds
*/
public int getDuration() {
if (start != -1 && end != -1) {
return (int) ((end - start) / 1000);
if (startTime != -1 && endTime != -1) {
return (int) ((endTime - startTime) / 1000);
}
else if (start != -1) {
return (int) ((new Date().getTime() - start) / 1000);
else if (startTime != -1) {
return (int) ((new Date().getTime() - startTime) / 1000);
}
return 0;
}
/**
*
* @return duration in seconds
*/
public int getRemainingDuration() {
return remainingDuration;
}
public void setRemainingDuration(int val) {
remainingDuration = val;
}
public void finish() {
end = new Date().getTime();
endTime = new Date().getTime();
process = null;
}
public void start() {
start = new Date().getTime();
startTime = new Date().getTime();
}
public int exitValue() {
@@ -118,12 +85,4 @@ public class RenderProcess {
}
return value;
}
public void setProcess(Process val) {
process = val;
}
public Process getProcess() {
return process;
}
}

View File

@@ -188,8 +188,8 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
try {
String url_remote = this.base_url + "/server/config.php";
String parameters = String.format("login=%s&password=%s&cpu_family=%s&cpu_model=%s&cpu_model_name=%s&cpu_cores=%s&os=%s&ram=%s&bits=%s&version=%s&hostname=%s&ui=%s&extras=%s",
URLEncoder.encode(this.user_config.login(), "UTF-8"),
URLEncoder.encode(this.user_config.password(), "UTF-8"),
URLEncoder.encode(this.user_config.getLogin(), "UTF-8"),
URLEncoder.encode(this.user_config.getPassword(), "UTF-8"),
URLEncoder.encode(os.getCPU().family(), "UTF-8"),
URLEncoder.encode(os.getCPU().model(), "UTF-8"),
URLEncoder.encode(os.getCPU().name(), "UTF-8"),
@@ -407,13 +407,13 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
// blender 2.7x
script += "try:\n";
script += "\tbpy.context.user_preferences.filepaths.temporary_directory = \"" + this.user_config.workingDirectory.getAbsolutePath().replace("\\", "\\\\") + "\"\n";
script += "\tbpy.context.user_preferences.filepaths.temporary_directory = \"" + this.user_config.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\") + "\"\n";
script += "except AttributeError:\n";
script += "\tpass\n";
// blender 2.80
script += "try:\n";
script += "\tbpy.context.preferences.filepaths.temporary_directory = \"" + this.user_config.workingDirectory.getAbsolutePath().replace("\\", "\\\\") + "\"\n";
script += "\tbpy.context.preferences.filepaths.temporary_directory = \"" + this.user_config.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\") + "\"\n";
script += "except AttributeError:\n";
script += "\tpass\n";
@@ -917,7 +917,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
for (int i = 0; i < ns.getLength(); ++i) {
Element file_node = (Element) ns.item(i);
if (file_node.hasAttribute("md5") && file_node.hasAttribute("action") && file_node.getAttribute("action").equals("delete")) {
String path = this.user_config.workingDirectory.getAbsolutePath() + File.separatorChar + file_node.getAttribute("md5");
String path = this.user_config.getWorkingDirectory().getAbsolutePath() + File.separatorChar + file_node.getAttribute("md5");
this.log.debug("Server::handleFileMD5DeleteDocument delete old file " + path);
File file_to_delete = new File(path + ".zip");
file_to_delete.delete();

View File

@@ -312,10 +312,10 @@ public class SettingsLoader {
loadFile();
if (config.login().isEmpty() && login != null) {
if (config.getLogin().isEmpty() && login != null) {
config.setLogin(login);
}
if (config.password().isEmpty() && password != null) {
if (config.getPassword().isEmpty() && password != null) {
config.setPassword(password);
}
@@ -342,11 +342,11 @@ public class SettingsLoader {
if (config.getGPUDevice() == null && gpu != null) {
GPUDevice device = GPU.getGPUDevice(gpu);
if (device != null) {
config.setUseGPU(device);
config.setGPUDevice(device);
}
}
if (config.getNbCores() == -1 && cores != null) {
config.setUseNbCores(Integer.valueOf(cores));
config.setNbCores(Integer.valueOf(cores));
}
if (config.getMaxMemory() == -1 && ram != null) {
@@ -357,7 +357,7 @@ public class SettingsLoader {
config.setMaxRenderTime(Integer.valueOf(renderTime));
}
if (config.getUserHasSpecifiedACacheDir() == false && cacheDir != null) {
if (config.isUserHasSpecifiedACacheDir() == false && cacheDir != null) {
config.setCacheDir(new File(cacheDir));
}

View File

@@ -63,7 +63,7 @@ public class GPU {
public static List<GPUDevice> listDevices(Configuration config) {
if (devices == null) {
if (config.getDetectGPUs()) {
if (config.isDetectGPUs()) {
generate();
}
else {

View File

@@ -167,13 +167,13 @@ public class Worker {
System.err.println("GPU unknown, list of available gpus can be display with --show-gpu");
System.exit(2);
}
config.setUseGPU(gpu);
config.setGPUDevice(gpu);
}
if (request_time != null) {
String[] intervals = request_time.split(",");
if (intervals != null) {
config.requestTime = new LinkedList<Pair<Calendar, Calendar>>();
config.setRequestTime(new LinkedList<Pair<Calendar, Calendar>>());
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
for (String interval : intervals) {
@@ -192,7 +192,7 @@ public class Worker {
}
if (start.before(end)) {
config.requestTime.add(new Pair<Calendar, Calendar>(start, end));
config.getRequestTime().add(new Pair<Calendar, Calendar>(start, end));
}
else {
System.err.println("Error: wrong request time " + times[0] + " is after " + times[1]);
@@ -208,7 +208,7 @@ public class Worker {
return;
}
else {
config.setUseNbCores(nb_cores);
config.setNbCores(nb_cores);
}
if (max_ram != null) {
@@ -274,7 +274,7 @@ public class Worker {
System.exit(2);
}
else if (compute_method == ComputeType.CPU) {
config.setUseGPU(null); // remove the GPU
config.setGPUDevice(null); // remove the GPU
}
config.setComputeMethod(compute_method);
@@ -289,7 +289,7 @@ public class Worker {
System.err.println("Aborting");
System.exit(2);
}
config.setConfigPath(config_file);
config.setConfigFilePath(config_file);
new SettingsLoader(config_file).merge(config);
}
@@ -302,7 +302,7 @@ public class Worker {
}
switch (type) {
case GuiTextOneLine.type:
if (config.getPrintLog()) {
if (config.isPrintLog()) {
System.out.println("OneLine UI can not be used if verbose mode is enabled");
System.exit(2);
}

View File

@@ -121,12 +121,12 @@ public class Settings implements Activity {
JLabel loginLabel = new JLabel("Username:");
login = new JTextField();
login.setText(parent.getConfiguration().login());
login.setText(parent.getConfiguration().getLogin());
login.setColumns(20);
login.addKeyListener(new CheckCanStart());
JLabel passwordLabel = new JLabel("Password:");
password = new JPasswordField();
password.setText(parent.getConfiguration().password());
password.setText(parent.getConfiguration().getPassword());
password.setColumns(10);
password.addKeyListener(new CheckCanStart());
@@ -147,7 +147,7 @@ public class Settings implements Activity {
JLabel cacheLabel = new JLabel("Working directory:");
directory_panel.add(cacheLabel);
String destination = DUMMY_CACHE_DIR;
if (config.getUserHasSpecifiedACacheDir()) {
if (config.isUserHasSpecifiedACacheDir()) {
destination = config.getCacheDirForSettings().getName();
}
@@ -388,7 +388,7 @@ public class Settings implements Activity {
saveFile = new JCheckBox("Save settings", true);
general_panel.add(saveFile);
autoSignIn = new JCheckBox("Auto sign in", config.getAutoSignIn());
autoSignIn = new JCheckBox("Auto sign in", config.isAutoSignIn());
autoSignIn.addActionListener(new AutoSignInChangeAction());
general_panel.add(autoSignIn);
@@ -413,7 +413,7 @@ public class Settings implements Activity {
constraints.gridy = currentRow;
parent.getContentPane().add(saveButton, constraints);
if (haveAutoStarted == false && config.getAutoSignIn() && checkDisplaySaveButton()) {
if (haveAutoStarted == false && config.isAutoSignIn() && checkDisplaySaveButton()) {
// auto start
haveAutoStarted = true;
new SaveAction().actionPerformed(null);
@@ -548,7 +548,7 @@ public class Settings implements Activity {
config.setComputeMethod(method);
if (selected_gpu != null) {
config.setUseGPU(selected_gpu);
config.setGPUDevice(selected_gpu);
}
int cpu_cores = -1;
@@ -557,7 +557,7 @@ public class Settings implements Activity {
}
if (cpu_cores > 0) {
config.setUseNbCores(cpu_cores);
config.setNbCores(cpu_cores);
}
long max_ram = -1;
@@ -609,7 +609,7 @@ public class Settings implements Activity {
parent.setCredentials(login.getText(), new String(password.getPassword()));
String cachePath = null;
if (config.getUserHasSpecifiedACacheDir() && config.getCacheDirForSettings() != null) {
if (config.isUserHasSpecifiedACacheDir() && config.getCacheDirForSettings() != null) {
cachePath = config.getCacheDirForSettings().getAbsolutePath();
}