From 44cf85739c8ec7e3cf4b13a61ae2d5ec7941d11e Mon Sep 17 00:00:00 2001 From: Laurent Clouet Date: Thu, 28 May 2020 13:28:42 +0200 Subject: [PATCH] Code formator (#236) * Re-import code formator --- .editorconfig | 9 ++ .idea/codeStyles/Project.xml | 37 +++++ .idea/codeStyles/codeStyleConfig.xml | 2 +- src/com/sheepit/client/Client.java | 102 ++++++++------ src/com/sheepit/client/Configuration.java | 10 +- src/com/sheepit/client/Error.java | 76 +++------- src/com/sheepit/client/Gui.java | 6 +- src/com/sheepit/client/Job.java | 104 +++++++------- src/com/sheepit/client/Log.java | 2 +- src/com/sheepit/client/Pair.java | 56 ++++---- src/com/sheepit/client/RenderProcess.java | 6 +- src/com/sheepit/client/Server.java | 129 ++++++++--------- src/com/sheepit/client/SettingsLoader.java | 33 +++-- src/com/sheepit/client/ShutdownHook.java | 5 +- src/com/sheepit/client/Stats.java | 8 +- src/com/sheepit/client/Utils.java | 5 +- .../client/datamodel/CacheFileMD5.java | 8 +- src/com/sheepit/client/datamodel/FileMD5.java | 11 +- .../client/datamodel/HeartBeatInfos.java | 8 +- .../sheepit/client/datamodel/JobInfos.java | 20 +-- .../client/datamodel/JobValidation.java | 8 +- .../sheepit/client/datamodel/RenderTask.java | 56 ++------ .../client/datamodel/RendererInfos.java | 18 +-- .../client/datamodel/RequestEndPoint.java | 16 +-- .../client/datamodel/ServerConfig.java | 15 +- .../client/datamodel/SessionStats.java | 30 ++-- .../client/exception/FermeException.java | 2 +- .../FermeExceptionBadResponseFromServer.java | 2 +- .../FermeExceptionNoRendererAvailable.java | 2 +- .../FermeExceptionNoRightToRender.java | 2 +- .../exception/FermeExceptionNoSession.java | 2 +- .../FermeExceptionNoSpaceLeftOnDevice.java | 2 +- .../FermeExceptionServerInMaintenance.java | 2 +- .../FermeExceptionServerOverloaded.java | 2 +- .../FermeExceptionSessionDisabled.java | 2 +- .../client/exception/FermeServerDown.java | 3 +- src/com/sheepit/client/hardware/cpu/CPU.java | 2 +- src/com/sheepit/client/hardware/gpu/GPU.java | 2 +- .../client/hardware/gpu/GPUDevice.java | 7 +- .../client/hardware/gpu/nvidia/CUDA.java | 11 +- .../gpu/nvidia/CUDeviceAttribute.java | 6 +- .../client/hardware/gpu/nvidia/CUresult.java | 32 ++--- .../client/hardware/gpu/nvidia/Nvidia.java | 32 ++--- .../client/hardware/gpu/opencl/OpenCL.java | 13 +- .../client/hardware/gpu/opencl/OpenCLLib.java | 11 +- src/com/sheepit/client/network/Proxy.java | 3 +- .../client/network/ProxyAuthenticator.java | 2 +- src/com/sheepit/client/os/FreeBSD.java | 20 +-- src/com/sheepit/client/os/Linux.java | 28 ++-- src/com/sheepit/client/os/Mac.java | 20 +-- src/com/sheepit/client/os/OS.java | 2 +- src/com/sheepit/client/os/Windows.java | 27 ++-- .../client/os/windows/Kernel32Lib.java | 12 +- .../sheepit/client/os/windows/WinProcess.java | 16 +-- .../sheepit/client/standalone/GuiSwing.java | 122 +++++++--------- .../sheepit/client/standalone/GuiText.java | 61 +++----- .../client/standalone/GuiTextOneLine.java | 75 ++++------ .../standalone/ListGpuParameterHandler.java | 8 +- .../standalone/VersionParameterHandler.java | 8 +- src/com/sheepit/client/standalone/Worker.java | 83 +++++------ .../standalone/swing/activity/Activity.java | 2 +- .../standalone/swing/activity/Settings.java | 131 ++++++++---------- .../standalone/swing/activity/Working.java | 81 +++++------ .../swing/components/CollapsibleJPanel.java | 23 ++- .../text/CLIInputActionHandler.java | 7 +- .../standalone/text/CLIInputListener.java | 2 +- .../standalone/text/CLIInputObserver.java | 2 +- 67 files changed, 697 insertions(+), 955 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4f21ac7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_size = 4 +indent_style = tab diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index c5b1427..1e989f0 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,7 +1,44 @@ + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 7d746eb..79ee123 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 3abcc68..98e2419 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -49,8 +49,7 @@ import com.sheepit.client.os.OS; import lombok.Data; -@Data -public class Client { +@Data public class Client { private Gui gui; private Server server; private Configuration configuration; @@ -164,7 +163,7 @@ public class Client { Thread.sleep(wait); } catch (InterruptedException e3) { - + } catch (IllegalArgumentException e3) { this.log.error("Client::run sleepA failed " + e3); @@ -217,7 +216,7 @@ public class Client { Thread.sleep(next_request.getTimeInMillis() - now.getTime()); } catch (InterruptedException e3) { - + } catch (IllegalArgumentException e3) { this.log.error("Client::run sleepB failed " + e3); @@ -273,8 +272,7 @@ public class Client { catch (FermeExceptionBadResponseFromServer 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))); + this.gui.status(String.format("Bad answer from the server. Will try again at %tR", new Date(new Date().getTime() + time_sleep))); try { Thread.sleep(time_sleep); } @@ -294,11 +292,12 @@ public class Client { } if (this.renderingJob == null) { // no job - int[] retrySchemeInSeconds = {300000, 480000, 720000, 900000, 1200000}; // 5, 8, 12, 15 and 20 minutes + int[] retrySchemeInSeconds = { 300000, 480000, 720000, 900000, 1200000 }; // 5, 8, 12, 15 and 20 minutes - 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", - new Date(new Date().getTime() + time_sleep))); + 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", new Date(new Date().getTime() + time_sleep))); this.suspended = true; int time_slept = 0; while (time_slept < time_sleep && this.running == true) { @@ -344,9 +343,7 @@ public class Client { } if (this.renderingJob.isSynchronousUpload() == true) { // power or compute_method job, need to upload right away - this.gui.status(String.format("Uploading frame (%.2fMB)", - (this.renderingJob.getOutputImageSize() / 1024.0 / 1024.0) - )); + this.gui.status(String.format("Uploading frame (%.2fMB)", (this.renderingJob.getOutputImageSize() / 1024.0 / 1024.0))); ret = confirmJob(this.renderingJob); if (ret != Error.Type.OK) { @@ -355,9 +352,7 @@ public class Client { } } else { - this.gui.status(String.format("Queuing frame for upload (%.2fMB)", - (this.renderingJob.getOutputImageSize() / 1024.0 / 1024.0) - )); + this.gui.status(String.format("Queuing frame for upload (%.2fMB)", (this.renderingJob.getOutputImageSize() / 1024.0 / 1024.0))); this.jobsToValidate.add(this.renderingJob); @@ -395,7 +390,8 @@ public class Client { // This loop will remain valid until all the background uploads have // finished (unless the stop() method has been triggered) - } while (this.uploadQueueSize > 0); + } + while (this.uploadQueueSize > 0); } catch (Exception e1) { // no exception should be raised in the actual launcher (applet or standalone) @@ -416,7 +412,7 @@ public class Client { if (this.renderingJob != null) { this.gui.status("Stopping"); - + if (this.renderingJob.getProcessRender().getProcess() != null) { this.renderingJob.setAskForRendererKill(true); OS.getOS().kill(this.renderingJob.getProcessRender().getProcess()); @@ -429,10 +425,10 @@ public class Client { if (this.server == null) { return 0; } - + if (this.server.getPage("logout").isEmpty() == false) { this.gui.status("Disconnecting from SheepIt server"); - + try { this.server.HTTPRequest(this.server.getPage("logout")); } @@ -480,7 +476,7 @@ public class Client { try { job_to_send = jobsToValidate.take(); this.log.debug("will validate " + job_to_send); - + ret = confirmJob(job_to_send); if (ret != Error.Type.OK) { this.gui.error(Error.humanString(ret)); @@ -495,7 +491,7 @@ public class Client { if (job_to_send != null) { this.uploadQueueVolume -= job_to_send.getOutputImageSize(); } - + this.gui.displayUploadQueueStats(this.uploadQueueSize, this.uploadQueueVolume); } } @@ -527,7 +523,8 @@ public class Client { writer.close(); String args = "?type=" + (error == null ? "" : error.getValue()); if (job_to_reset_ != null) { - args += "&frame=" + job_to_reset_.getFrameNumber() + "&job=" + job_to_reset_.getId() + "&render_time=" + job_to_reset_.getProcessRender().getDuration() + "&memoryused=" + job_to_reset_.getProcessRender().getMemoryUsed(); + args += "&frame=" + job_to_reset_.getFrameNumber() + "&job=" + job_to_reset_.getId() + "&render_time=" + job_to_reset_.getProcessRender() + .getDuration() + "&memoryused=" + job_to_reset_.getProcessRender().getMemoryUsed(); if (job_to_reset_.getExtras() != null && job_to_reset_.getExtras().isEmpty() == false) { args += "&extras=" + job_to_reset_.getExtras(); } @@ -543,7 +540,8 @@ public class Client { // no exception should be raised to actual launcher (applet or standalone) } - if (error != null && (error == Error.Type.RENDERER_CRASHED || error == Error.Type.RENDERER_KILLED_BY_USER || error == Error.Type.RENDERER_KILLED_BY_SERVER)) { + if (error != null && (error == Error.Type.RENDERER_CRASHED || error == Error.Type.RENDERER_KILLED_BY_USER + || error == Error.Type.RENDERER_KILLED_BY_SERVER)) { // do nothing, we can ask for a job right away } else { @@ -625,27 +623,28 @@ 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.log.error("Client::work job preparation failed (scene file '" + scene_file.getAbsolutePath() + + "' does not exist), cleaning directory in hope to recover"); 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.log.error("Client::work job preparation failed (renderer file '" + renderer_file.getAbsolutePath() + + "' does not exist), cleaning directory in hope to recover"); this.configuration.cleanWorkingDirectory(); return Error.Type.MISSING_RENDERER; } - + Observer removeSceneDirectoryOnceRenderHasStartedObserver = new Observer() { - @Override - public void update(Observable observable, Object o) { + @Override public void update(Observable observable, Object o) { // only remove the .blend since it's most important data // and it's the only file we are sure will not be needed anymore scene_file.delete(); } }; - + Error.Type err = ajob.render(removeSceneDirectoryOnceRenderHasStartedObserver); gui.setRenderingProjectName(""); gui.setRemainingTime(""); @@ -659,18 +658,20 @@ public class Client { } return err; } - + removeSceneDirectory(ajob); return Error.Type.OK; } protected int downloadSceneFile(Job ajob_) throws FermeExceptionNoSpaceLeftOnDevice { - return this.downloadFile(ajob_, ajob_.getSceneArchivePath(), ajob_.getSceneMD5(), String.format("%s?type=job&job=%s", this.server.getPage("download-archive"), ajob_.getId()), "project"); + return this.downloadFile(ajob_, ajob_.getSceneArchivePath(), ajob_.getSceneMD5(), + String.format("%s?type=job&job=%s", this.server.getPage("download-archive"), ajob_.getId()), "project"); } protected int downloadExecutable(Job ajob) throws FermeExceptionNoSpaceLeftOnDevice { - return this.downloadFile(ajob, ajob.getRendererArchivePath(), ajob.getRendererMD5(), 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 { @@ -707,7 +708,8 @@ public class Client { attempts++; if ((ret != 0 || md5_check == false) && attempts >= this.maxDownloadFileAttempts) { - this.log.debug("Client::downloadFile failed after " + this.maxDownloadFileAttempts + " attempts, removing local file (path: " + local_path + "), stopping..."); + this.log.debug("Client::downloadFile failed after " + this.maxDownloadFileAttempts + " attempts, removing local file (path: " + local_path + + "), stopping..."); local_path_file.delete(); return -9; } @@ -727,13 +729,15 @@ public class Client { String md5_local = Utils.md5(local_path); if (md5_local.equals(md5_server) == false) { - this.log.error("Client::checkFile mismatch on md5 local: '" + md5_local + "' server: '" + md5_server + "' (local size: " + new File(local_path).length() + ")"); + this.log.error( + "Client::checkFile mismatch on md5 local: '" + md5_local + "' server: '" + md5_server + "' (local size: " + new File(local_path).length() + + ")"); return false; } return true; } - + protected void removeSceneDirectory(Job ajob) { Utils.delete(new File(ajob.getSceneDirectory())); } @@ -755,7 +759,9 @@ public class Client { // unzip the archive ret = Utils.unzipFileIntoDirectory(renderer_archive, renderer_path, null, log); if (ret != 0) { - this.log.error("Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + renderer_archive + ", " + renderer_path + ") returned " + ret); + this.log.error( + "Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + renderer_archive + ", " + renderer_path + ") returned " + + ret); this.gui.error(String.format("Unable to extract the renderer (error %d)", ret)); return -1; } @@ -783,7 +789,9 @@ public class Client { // unzip the archive 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.log.error( + "Client::prepareWorkingDirectory, error(2) with Utils.unzipFileIntoDirectory(" + scene_archive + ", " + scene_path + ") returned " + + ret); this.gui.error(String.format("Unable to extract the scene (error %d)", ret)); return -2; } @@ -793,7 +801,8 @@ public class Client { } protected Error.Type confirmJob(Job ajob) { - String url_real = String.format("%s&rendertime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getDuration(), ajob.getProcessRender().getMemoryUsed()); + String url_real = String.format("%s&rendertime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getDuration(), + ajob.getProcessRender().getMemoryUsed()); this.log.debug("Client::confirmeJob url " + url_real); this.log.debug("path frame " + ajob.getOutputImagePath()); @@ -802,7 +811,8 @@ public class Client { int max_try = 3; ServerCode ret = ServerCode.UNKNOWN; Type confirmJobReturnCode = Error.Type.OK; - retryLoop: while (nb_try < max_try && ret != ServerCode.OK) { + retryLoop: + while (nb_try < max_try && ret != ServerCode.OK) { ret = this.server.HTTPSendFile(url_real, ajob.getOutputImagePath()); switch (ret) { case OK: @@ -813,12 +823,12 @@ public class Client { case JOB_VALIDATION_ERROR_BROKEN_MACHINE: confirmJobReturnCode = Error.Type.SESSION_DISABLED; break retryLoop; - + case JOB_VALIDATION_ERROR_MISSING_PARAMETER: // no point to retry the request confirmJobReturnCode = Error.Type.UNKNOWN; break retryLoop; - + default: // do nothing, try to do a request on the next loop break; @@ -835,10 +845,10 @@ public class Client { } } } - + this.isValidatingJob = false; this.previousJob = ajob; - + if (confirmJobReturnCode == Error.Type.OK) { gui.AddFrameRendered(); } @@ -847,7 +857,7 @@ public class Client { File frame = new File(ajob.getOutputImagePath()); frame.delete(); ajob.setOutputImagePath(null); - + return confirmJobReturnCode; } diff --git a/src/com/sheepit/client/Configuration.java b/src/com/sheepit/client/Configuration.java index 9c3cf6a..dea54b4 100644 --- a/src/com/sheepit/client/Configuration.java +++ b/src/com/sheepit/client/Configuration.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -36,8 +36,7 @@ import com.sheepit.client.hardware.gpu.GPUDevice; import com.sheepit.client.os.OS; import lombok.Data; -@Data -public class Configuration { +@Data public class Configuration { public enum ComputeType { CPU_GPU, CPU, GPU } // accept job for ... @@ -95,11 +94,10 @@ public class Configuration { this.theme = null; } - public String toString() { return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath()); } - + public void setUsePriority(int priority) { if (priority > 19) priority = 19; @@ -125,7 +123,7 @@ public class Configuration { this.workingDirectory.mkdir(); this.workingDirectory.deleteOnExit(); - // since there is no working directory and the client will be working in the system temp directory, + // since there is no working directory and the client will be working in the system temp directory, // we can also set up a 'permanent' directory for immutable files (like renderer binary) this.storageDirectory = new File(this.workingDirectory.getParent() + File.separator + "sheepit_binary_cache"); diff --git a/src/com/sheepit/client/Error.java b/src/com/sheepit/client/Error.java index 52c2c13..5389b81 100644 --- a/src/com/sheepit/client/Error.java +++ b/src/com/sheepit/client/Error.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -22,37 +22,14 @@ package com.sheepit.client; public class Error { public enum Type { // id have to be kept synchronised with the server side. - OK(0), - UNKNOWN(99), - WRONG_CONFIGURATION(1), - AUTHENTICATION_FAILED(2), - TOO_OLD_CLIENT(3), - SESSION_DISABLED(4), - RENDERER_NOT_AVAILABLE(5), - MISSING_RENDERER(6), - MISSING_SCENE(7), - NOOUTPUTFILE(8), - DOWNLOAD_FILE(9), - CAN_NOT_CREATE_DIRECTORY(10), - NETWORK_ISSUE(11), - RENDERER_CRASHED(12), - RENDERER_CRASHED_PYTHON_ERROR(24), - RENDERER_OUT_OF_VIDEO_MEMORY(13), - RENDERER_OUT_OF_MEMORY(21), - RENDERER_KILLED(14), - RENDERER_KILLED_BY_USER(20), - RENDERER_KILLED_BY_USER_OVER_TIME(23), - RENDERER_KILLED_BY_SERVER(22), - RENDERER_MISSING_LIBRARIES(15), - FAILED_TO_EXECUTE(16), - OS_NOT_SUPPORTED(17), - CPU_NOT_SUPPORTED(18), - GPU_NOT_SUPPORTED(19), - VALIDATION_FAILED(25), + OK(0), UNKNOWN(99), WRONG_CONFIGURATION(1), AUTHENTICATION_FAILED(2), TOO_OLD_CLIENT(3), SESSION_DISABLED(4), RENDERER_NOT_AVAILABLE( + 5), MISSING_RENDERER(6), MISSING_SCENE(7), NOOUTPUTFILE(8), DOWNLOAD_FILE(9), CAN_NOT_CREATE_DIRECTORY(10), NETWORK_ISSUE(11), RENDERER_CRASHED( + 12), RENDERER_CRASHED_PYTHON_ERROR(24), RENDERER_OUT_OF_VIDEO_MEMORY(13), RENDERER_OUT_OF_MEMORY(21), RENDERER_KILLED( + 14), RENDERER_KILLED_BY_USER(20), RENDERER_KILLED_BY_USER_OVER_TIME(23), RENDERER_KILLED_BY_SERVER(22), RENDERER_MISSING_LIBRARIES( + 15), FAILED_TO_EXECUTE(16), OS_NOT_SUPPORTED(17), CPU_NOT_SUPPORTED(18), GPU_NOT_SUPPORTED(19), VALIDATION_FAILED(25), // internal error handling - NO_SPACE_LEFT_ON_DEVICE(100), - ERROR_BAD_RESPONSE(101), + NO_SPACE_LEFT_ON_DEVICE(100), ERROR_BAD_RESPONSE(101), ; private final int id; @@ -67,36 +44,23 @@ public class Error { } public enum ServerCode { - OK(0), - UNKNOWN(999), + OK(0), UNKNOWN(999), - CONFIGURATION_ERROR_NO_CLIENT_VERSION_GIVEN(100), - CONFIGURATION_ERROR_CLIENT_TOO_OLD(101), - CONFIGURATION_ERROR_AUTH_FAILED(102), - CONFIGURATION_ERROR_WEB_SESSION_EXPIRED(103), - CONFIGURATION_ERROR_MISSING_PARAMETER(104), + CONFIGURATION_ERROR_NO_CLIENT_VERSION_GIVEN(100), CONFIGURATION_ERROR_CLIENT_TOO_OLD(101), CONFIGURATION_ERROR_AUTH_FAILED( + 102), CONFIGURATION_ERROR_WEB_SESSION_EXPIRED(103), CONFIGURATION_ERROR_MISSING_PARAMETER(104), - JOB_REQUEST_NOJOB(200), - JOB_REQUEST_ERROR_NO_RENDERING_RIGHT(201), - JOB_REQUEST_ERROR_DEAD_SESSION(202), - 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_REQUEST_NOJOB(200), JOB_REQUEST_ERROR_NO_RENDERING_RIGHT(201), JOB_REQUEST_ERROR_DEAD_SESSION(202), 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 - JOB_VALIDATION_ERROR_FRAME_IS_NOT_IMAGE(302), - JOB_VALIDATION_ERROR_UPLOAD_FAILED(303), - JOB_VALIDATION_ERROR_SESSION_DISABLED(304), // missing heartbeat or broken machine + JOB_VALIDATION_ERROR_MISSING_PARAMETER(300), JOB_VALIDATION_ERROR_BROKEN_MACHINE(301), // in GPU the generated frame is black + JOB_VALIDATION_ERROR_FRAME_IS_NOT_IMAGE(302), JOB_VALIDATION_ERROR_UPLOAD_FAILED(303), JOB_VALIDATION_ERROR_SESSION_DISABLED( + 304), // missing heartbeat or broken machine KEEPMEALIVE_STOP_RENDERING(400), // internal error handling - ERROR_NO_ROOT(2), - ERROR_BAD_RESPONSE(3), - ERROR_REQUEST_FAILED(5); + ERROR_NO_ROOT(2), ERROR_BAD_RESPONSE(3), ERROR_REQUEST_FAILED(5); private final int id; @@ -129,15 +93,15 @@ public class Error { return Type.TOO_OLD_CLIENT; case CONFIGURATION_ERROR_AUTH_FAILED: return Type.AUTHENTICATION_FAILED; - + case CONFIGURATION_ERROR_NO_CLIENT_VERSION_GIVEN: case CONFIGURATION_ERROR_WEB_SESSION_EXPIRED: return Type.WRONG_CONFIGURATION; - + case JOB_REQUEST_ERROR_SESSION_DISABLED: case JOB_VALIDATION_ERROR_SESSION_DISABLED: return Type.SESSION_DISABLED; - + case JOB_REQUEST_ERROR_RENDERER_NOT_AVAILABLE: return Type.RENDERER_NOT_AVAILABLE; diff --git a/src/com/sheepit/client/Gui.java b/src/com/sheepit/client/Gui.java index 1ab52ba..3403bf9 100644 --- a/src/com/sheepit/client/Gui.java +++ b/src/com/sheepit/client/Gui.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -27,9 +27,9 @@ public interface Gui { public void status(String msg_); public void status(String msg_, boolean overwriteSuspendedMsg); - + public void updateTrayIcon(Integer percentage_); - + public void setRenderingProjectName(String name_); public void setRemainingTime(String time_); diff --git a/src/com/sheepit/client/Job.java b/src/com/sheepit/client/Job.java index e6eb7f2..8a8d6e4 100644 --- a/src/com/sheepit/client/Job.java +++ b/src/com/sheepit/client/Job.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -51,20 +51,19 @@ import com.sheepit.client.os.OS; import lombok.Data; import lombok.Getter; -@Data -public class Job { +@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"; - + public static final int SHOW_BASE_ICON = -1; - + private String frameNumber; private String sceneMD5; private String rendererMD5; private String id; private String outputImagePath; - private long outputImageSize; + private long outputImageSize; private String path; // path inside of the archive private String rendererCommand; private String validationUrl; @@ -83,7 +82,9 @@ public class Job { 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 validationUrl_, 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 validationUrl_, + String script_, String sceneMd5_, String rendererMd5_, String name_, String password_, String extras_, boolean synchronous_upload_, + String update_method_) { configuration = config_; id = id_; frameNumber = frame_; @@ -123,7 +124,9 @@ 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)", frameNumber, sceneMD5, rendererMD5, id, outputImagePath, path, useGPU, name, extras, updateRenderingStatusMethod, render); + 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() { @@ -162,17 +165,14 @@ public class Job { // When sending Ctrl+C to the terminal it also get's sent to all subprocesses e.g. also the render process. // The java program handles Ctrl+C but the renderer quits on Ctrl+C. // This script causes the renderer to ignore Ctrl+C. - String ignore_signal_script= "import signal\n" - + "def hndl(signum, frame):\n" - + " pass\n" - + "signal.signal(signal.SIGINT, hndl)\n"; + String ignore_signal_script = "import signal\n" + "def hndl(signum, frame):\n" + " pass\n" + "signal.signal(signal.SIGINT, hndl)\n"; if (isUseGPU() && configuration.getGPUDevice() != null && configuration.getComputeMethod() != ComputeType.CPU) { // If using a GPU, check the proper tile size int tileSize = configuration.getGPUDevice().getRenderbucketSize(); - - core_script = "sheepit_set_compute_device(\"" + configuration.getGPUDevice().getType() + "\", \"GPU\", \"" + configuration.getGPUDevice().getId() + "\")\n"; - core_script += String.format("bpy.context.scene.render.tile_x = %1$d\nbpy.context.scene.render.tile_y = %1$d\n", - tileSize); + + core_script = "sheepit_set_compute_device(\"" + configuration.getGPUDevice().getType() + "\", \"GPU\", \"" + configuration.getGPUDevice().getId() + + "\")\n"; + core_script += String.format("bpy.context.scene.render.tile_x = %1$d\nbpy.context.scene.render.tile_y = %1$d\n", tileSize); log.debug(String.format("Rendering bucket size set to %1$dx%1$d pixels", tileSize)); gui.setComputeMethod("GPU"); @@ -203,7 +203,8 @@ public class Job { 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 (isUseGPU() && configuration.getGPUDevice() != null && configuration.getComputeMethod() != ComputeType.CPU && OpenCL.TYPE.equals(configuration.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 } @@ -270,12 +271,11 @@ public class Job { if (configuration.getMaxRenderTime() > 0) { timerOfMaxRenderTime = new Timer(); timerOfMaxRenderTime.schedule(new TimerTask() { - @Override - public void run() { + @Override public void run() { RenderProcess process = getProcessRender(); if (process != null) { - long duration = (new Date().getTime() - process.getStartTime() ) / 1000; // in seconds - if (configuration.getMaxRenderTime() > 0 && duration > configuration.getMaxRenderTime()) { + long duration = (new Date().getTime() - process.getStartTime()) / 1000; // in seconds + if (configuration.getMaxRenderTime() > 0 && duration > configuration.getMaxRenderTime()) { log.debug("Killing render because process duration"); OS.getOS().kill(process.getProcess()); setAskForRendererKill(true); @@ -288,30 +288,31 @@ public class Job { log.debug("renderer output"); try { int progress = -1; - - Pattern tilePattern = Pattern.compile(" ([0-9]+)\\s?\\/\\s?([0-9]+) "); - + + Pattern tilePattern = Pattern.compile(" ([0-9]+)\\s?\\/\\s?([0-9]+) "); + // Initialise the progress bar in the icon (0% completed at this time) gui.updateTrayIcon(0); - + while ((line = input.readLine()) != null) { log.debug(line); - + progress = computeRenderingProgress(line, tilePattern, progress); - + updateRenderingMemoryPeak(line); 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)"); + 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) { script_file.delete(); } - + // Once the process is finished (either finished successfully or with an error) move back to // base icon (isolated S with no progress bar) gui.updateTrayIcon(Job.SHOW_BASE_ICON); - + return Error.Type.RENDERER_OUT_OF_MEMORY; } @@ -321,13 +322,13 @@ public class Job { if (script_file != null) { script_file.delete(); } - + // Put back base icon gui.updateTrayIcon(Job.SHOW_BASE_ICON); - + return error; } - + if (event.isStarted() == false && (process.getMemoryUsed() > 0 || process.getRemainingDuration() > 0)) { event.doNotifyIsStarted(); } @@ -338,10 +339,10 @@ public class Job { // most likely The handle is invalid log.error("Job::render exception(B) (silent error) " + err1); } - + // Put back base icon gui.updateTrayIcon(Job.SHOW_BASE_ICON); - + log.debug("end of rendering"); } catch (Exception err) { @@ -374,11 +375,11 @@ public class Job { }; 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 + long duration = (new Date().getTime() - process.getStartTime()) / 1000; // in seconds 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; @@ -423,7 +424,7 @@ public class Job { else { setOutputImagePath(files[0].getAbsolutePath()); this.outputImageSize = new File(getOutputImagePath()).length(); - log.debug(String.format("Job::render pictureFilename: %s, size: %d'",getOutputImagePath(), this.outputImageSize)); + log.debug(String.format("Job::render pictureFilename: %s, size: %d'", getOutputImagePath(), this.outputImageSize)); } File scene_dir = new File(getSceneDirectory()); @@ -436,26 +437,26 @@ public class Job { return Error.Type.OK; } - + private int computeRenderingProgress(String line, Pattern tilePattern, int currentProgress) { Matcher standardTileInfo = tilePattern.matcher(line); int newProgress = currentProgress; - + if (standardTileInfo.find()) { int tileJustProcessed = Integer.parseInt(standardTileInfo.group(1)); - int totalTilesInJob = Integer.parseInt(standardTileInfo.group(2)); - + int totalTilesInJob = Integer.parseInt(standardTileInfo.group(2)); + newProgress = Math.abs((tileJustProcessed * 100) / totalTilesInJob); } - + // Only update the tray icon if percentage has changed if (newProgress != currentProgress) { gui.updateTrayIcon(newProgress); } - + return newProgress; } - + private void updateRenderingStatus(String line) { if (getUpdateRenderingStatusMethod() != null && getUpdateRenderingStatusMethod().equals(Job.UPDATE_METHOD_BLENDER_INTERNAL_BY_PART)) { String search = " Part "; @@ -574,7 +575,7 @@ public class Job { } } } - + private Type detectError(String line) { if (line.contains("CUDA error: Out of memory")) { @@ -819,17 +820,16 @@ public class Job { } return Type.OK; } - + public static class renderStartedObservable extends Observable { - - @Getter - private boolean isStarted; - + + @Getter private boolean isStarted; + public renderStartedObservable(Observer observer) { super(); addObserver(observer); } - + public void doNotifyIsStarted() { setChanged(); notifyObservers(); diff --git a/src/com/sheepit/client/Log.java b/src/com/sheepit/client/Log.java index 2cdf286..50f2a9a 100644 --- a/src/com/sheepit/client/Log.java +++ b/src/com/sheepit/client/Log.java @@ -2,7 +2,7 @@ * Copyright (C) 2011-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/Pair.java b/src/com/sheepit/client/Pair.java index 47643d0..5b4fee8 100644 --- a/src/com/sheepit/client/Pair.java +++ b/src/com/sheepit/client/Pair.java @@ -19,35 +19,34 @@ package com.sheepit.client; import java.util.Objects; /** -* Container to ease passing around a pair of two objects. This object provides a sensible -* implementation of equals(), returning true if equals() is true on each of the contained -* objects. -*/ + * Container to ease passing around a pair of two objects. This object provides a sensible + * implementation of equals(), returning true if equals() is true on each of the contained + * objects. + */ public class Pair { public final F first; public final S second; /** - * Constructor for a Pair. - * - * @param first the first object in the Pair - * @param second the second object in the pair - */ + * Constructor for a Pair. + * + * @param first the first object in the Pair + * @param second the second object in the pair + */ public Pair(F first, S second) { this.first = first; this.second = second; } /** - * Checks the two objects for equality by delegating to their respective - * {@link Object#equals(Object)} methods. - * - * @param o the {@link Pair} to which this one is to be checked for equality - * @return true if the underlying objects of the Pair are both considered - * equal - */ - @Override - public boolean equals(Object o) { + * Checks the two objects for equality by delegating to their respective + * {@link Object#equals(Object)} methods. + * + * @param o the {@link Pair} to which this one is to be checked for equality + * @return true if the underlying objects of the Pair are both considered + * equal + */ + @Override public boolean equals(Object o) { if (!(o instanceof Pair)) { return false; } @@ -56,22 +55,21 @@ public class Pair { } /** - * Compute a hash code using the hash codes of the underlying objects - * - * @return a hashcode of the Pair - */ - @Override - public int hashCode() { + * Compute a hash code using the hash codes of the underlying objects + * + * @return a hashcode of the Pair + */ + @Override public int hashCode() { return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode()); } /** - * Convenience method for creating an appropriately typed pair. + * Convenience method for creating an appropriately typed pair. * - * @param a the first object in the Pair - * @param b the second object in the pair - * @return a Pair that is templatized with the types of a and b - */ + * @param a the first object in the Pair + * @param b the second object in the pair + * @return a Pair that is templatized with the types of a and b + */ public static Pair create(A a, B b) { return new Pair(a, b); } diff --git a/src/com/sheepit/client/RenderProcess.java b/src/com/sheepit/client/RenderProcess.java index ac3bb34..105f445 100644 --- a/src/com/sheepit/client/RenderProcess.java +++ b/src/com/sheepit/client/RenderProcess.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -23,8 +23,7 @@ import lombok.Data; import java.util.Date; -@Data -public class RenderProcess { +@Data public class RenderProcess { private long startTime; private long endTime; private int remainingDuration; // in seconds @@ -42,7 +41,6 @@ public class RenderProcess { } /** - * * @return duration in seconds */ public int getDuration() { diff --git a/src/com/sheepit/client/Server.java b/src/com/sheepit/client/Server.java index 97dfcff..53ce7a7 100644 --- a/src/com/sheepit/client/Server.java +++ b/src/com/sheepit/client/Server.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -84,10 +84,9 @@ import com.sheepit.client.os.OS; public class Server extends Thread implements HostnameVerifier, X509TrustManager { private String base_url; - - @Getter - private ServerConfig serverConfig; - + + @Getter private ServerConfig serverConfig; + private Configuration user_config; private Client client; private Log log; @@ -138,7 +137,8 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager if (serverCode == ServerCode.KEEPMEALIVE_STOP_RENDERING) { this.log.debug("Server::stayAlive server asked to kill local render process"); // kill the current process, it will generate an error but it's okay - if (this.client != null && this.client.getRenderingJob() != null && this.client.getRenderingJob().getProcessRender().getProcess() != null) { + if (this.client != null && this.client.getRenderingJob() != null + && this.client.getRenderingJob().getProcessRender().getProcess() != null) { this.client.getRenderingJob().setServerBlockJob(true); this.client.getRenderingJob().setAskForRendererKill(true); OS.getOS().kill(this.client.getRenderingJob().getProcessRender().getProcess()); @@ -185,20 +185,15 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager String publickey = null; 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.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"), - ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), - URLEncoder.encode(os.name(), "UTF-8"), - os.getMemory(), - URLEncoder.encode(os.getCPU().arch(), "UTF-8"), - this.user_config.getJarVersion(), - URLEncoder.encode(this.user_config.getHostname(), "UTF-8"), - this.client.getGui().getClass().getSimpleName(), - this.user_config.getExtras()); + 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.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"), + ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), + URLEncoder.encode(os.name(), "UTF-8"), os.getMemory(), URLEncoder.encode(os.getCPU().arch(), "UTF-8"), + this.user_config.getJarVersion(), URLEncoder.encode(this.user_config.getHostname(), "UTF-8"), + this.client.getGui().getClass().getSimpleName(), this.user_config.getExtras()); this.log.debug("Server::getConfiguration url " + url_remote); connection = this.HTTPRequest(url_remote, parameters); @@ -268,7 +263,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager else if (freeMemory > 0 && maxMemory > 0) { maxMemory = Math.min(maxMemory, freeMemory); } - String url = String.format("%s?computemethod=%s&cpu_cores=%s&ram_max=%s&rendertime_max=%s", this.getPage("request-job"), this.user_config.computeMethodToInt(), ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), maxMemory, this.user_config.getMaxRenderTime()); + String url = String + .format("%s?computemethod=%s&cpu_cores=%s&ram_max=%s&rendertime_max=%s", this.getPage("request-job"), this.user_config.computeMethodToInt(), + ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), maxMemory, + this.user_config.getMaxRenderTime()); if (this.user_config.getComputeMethod() != ComputeType.CPU && this.user_config.getGPUDevice() != null) { String gpu_model = ""; try { @@ -276,7 +274,8 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager } catch (UnsupportedEncodingException e) { } - url += "&gpu_model=" + gpu_model + "&gpu_ram=" + this.user_config.getGPUDevice().getMemory() + "&gpu_type=" + this.user_config.getGPUDevice().getType(); + url += "&gpu_model=" + gpu_model + "&gpu_ram=" + this.user_config.getGPUDevice().getMemory() + "&gpu_type=" + this.user_config.getGPUDevice() + .getType(); } connection = this.HTTPRequest(url, this.generateXMLForMD5cache()); @@ -286,21 +285,18 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager if (r == HttpURLConnection.HTTP_OK && contentType.startsWith("text/xml")) { DataInputStream in = new DataInputStream(connection.getInputStream()); - + JobInfos jobData = new Persister().read(JobInfos.class, in); - + handleFileMD5DeleteDocument(jobData.getFileMD5s()); if (jobData.getSessionStats() != null) { - this.client.getGui().displayStats(new Stats( - jobData.getSessionStats().getRemainingFrames(), - jobData.getSessionStats().getPointsEarnedByUser(), - jobData.getSessionStats().getPointsEarnedOnSession(), - jobData.getSessionStats().getRenderableProjects(), - jobData.getSessionStats().getWaitingProjects(), - jobData.getSessionStats().getConnectedMachines())); + this.client.getGui().displayStats( + new Stats(jobData.getSessionStats().getRemainingFrames(), jobData.getSessionStats().getPointsEarnedByUser(), + jobData.getSessionStats().getPointsEarnedOnSession(), jobData.getSessionStats().getRenderableProjects(), + jobData.getSessionStats().getWaitingProjects(), jobData.getSessionStats().getConnectedMachines())); } - + ServerCode serverCode = ServerCode.fromInt(jobData.getStatus()); if (serverCode != ServerCode.OK) { switch (serverCode) { @@ -324,49 +320,38 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager throw new FermeException("error requestJob: status is not ok (it's " + serverCode + ")"); } } - + String script = "import bpy\n"; // blender 2.7x script += "try:\n"; - script += "\tbpy.context.user_preferences.filepaths.temporary_directory = \"" + this.user_config.getWorkingDirectory().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.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\") + "\"\n"; + script += "\tbpy.context.preferences.filepaths.temporary_directory = \"" + this.user_config.getWorkingDirectory().getAbsolutePath() + .replace("\\", "\\\\") + "\"\n"; script += "except AttributeError:\n"; script += "\tpass\n"; script += jobData.getRenderTask().getScript(); - + String validationUrl = URLDecoder.decode(jobData.getRenderTask().getValidationUrl(), "UTF-8"); - - Job a_job = new Job( - this.user_config, - this.client.getGui(), - this.client.getLog(), - jobData.getRenderTask().getId(), - jobData.getRenderTask().getFrame(), - jobData.getRenderTask().getPath().replace("/", File.separator), - jobData.getRenderTask().getUseGpu() == 1, - jobData.getRenderTask().getRendererInfos().getCommandline(), - validationUrl, - script, - jobData.getRenderTask().getArchive_md5(), - jobData.getRenderTask().getRendererInfos().getMd5(), - jobData.getRenderTask().getName(), - jobData.getRenderTask().getPassword(), - jobData.getRenderTask().getExtras(), - jobData.getRenderTask().getSynchronous_upload().equals("1"), - jobData.getRenderTask().getRendererInfos().getUpdate_method() - ); + + Job a_job = new Job(this.user_config, this.client.getGui(), this.client.getLog(), jobData.getRenderTask().getId(), + jobData.getRenderTask().getFrame(), jobData.getRenderTask().getPath().replace("/", File.separator), + jobData.getRenderTask().getUseGpu() == 1, jobData.getRenderTask().getRendererInfos().getCommandline(), validationUrl, script, + jobData.getRenderTask().getArchive_md5(), jobData.getRenderTask().getRendererInfos().getMd5(), jobData.getRenderTask().getName(), + jobData.getRenderTask().getPassword(), jobData.getRenderTask().getExtras(), jobData.getRenderTask().getSynchronous_upload().equals("1"), + jobData.getRenderTask().getRendererInfos().getUpdate_method()); return a_job; } else { System.out.println("Server::requestJob url " + url_contents + " r " + r + " contentType " + contentType); - if (r == HttpURLConnection.HTTP_UNAVAILABLE || r == HttpURLConnection. HTTP_CLIENT_TIMEOUT) { + if (r == HttpURLConnection.HTTP_UNAVAILABLE || r == HttpURLConnection.HTTP_CLIENT_TIMEOUT) { // most likely varnish is up but apache down throw new FermeServerDown(); } @@ -404,7 +389,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager } throw new FermeException("error requestJob, end of function"); } - + public HttpURLConnection HTTPRequest(String url_) throws IOException { return this.HTTPRequest(url_, null); } @@ -558,7 +543,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager fileInputStream.close(); } catch (Exception e1) { - + } return ServerCode.UNKNOWN; } @@ -568,7 +553,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager fileInputStream.close(); } catch (Exception e1) { - + } return ServerCode.UNKNOWN; } @@ -652,12 +637,12 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager this.log.debug("Server::HTTPSendFile IOException " + e + " stacktrace: " + sw.toString()); return ServerCode.UNKNOWN; } - + try { JobValidation jobValidation = new Persister().read(JobValidation.class, in); this.lastRequestTime = new Date().getTime(); - + ServerCode serverCode = ServerCode.fromInt(jobValidation.getStatus()); if (serverCode != ServerCode.OK) { this.log.error("Server::HTTPSendFile wrong status (is " + serverCode + ")"); @@ -707,10 +692,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager catch (StringIndexOutOfBoundsException e) { // because the file does not have an . its path } } - + CacheFileMD5 cache = new CacheFileMD5(); cache.setMd5s(md5s); - + final Persister persister = new Persister(); try (StringWriter writer = new StringWriter()) { persister.write(cache, writer); @@ -721,10 +706,10 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager return ""; } } - + private void handleFileMD5DeleteDocument(List fileMD5s) { if (fileMD5s != null && fileMD5s.isEmpty() == false) { - for(FileMD5 fileMD5 : fileMD5s) { + for (FileMD5 fileMD5 : fileMD5s) { if ("delete".equals(fileMD5.getAction()) && fileMD5.getMd5() != null && fileMD5.getMd5().isEmpty() == false) { String path = this.user_config.getWorkingDirectory().getAbsolutePath() + File.separatorChar + fileMD5.getMd5(); this.log.debug("Server::handleFileMD5DeleteDocument delete old file " + path); @@ -746,21 +731,17 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager return ""; } - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } - @Override - public X509Certificate[] getAcceptedIssuers() { + @Override public X509Certificate[] getAcceptedIssuers() { return null; } - @Override - public boolean verify(String arg0, SSLSession arg1) { + @Override public boolean verify(String arg0, SSLSession arg1) { return true; // trust every ssl certificate } } diff --git a/src/com/sheepit/client/SettingsLoader.java b/src/com/sheepit/client/SettingsLoader.java index 030c222..6a13e60 100644 --- a/src/com/sheepit/client/SettingsLoader.java +++ b/src/com/sheepit/client/SettingsLoader.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -43,8 +43,7 @@ public class SettingsLoader { private String login; - @Setter - private String password; + @Setter private String password; private String proxy; private String hostname; @@ -58,7 +57,7 @@ public class SettingsLoader { private String autoSignIn; private String ui; private String theme; - private int priority; + private int priority; public SettingsLoader(String path_) { if (path_ == null) { @@ -69,7 +68,9 @@ public class SettingsLoader { } } - public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int renderbucketSize_, int cores_, long maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String theme_, int priority_) { + public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, + int renderbucketSize_, int cores_, long maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String theme_, + int priority_) { if (path_ == null) { path = getDefaultFilePath(); } @@ -85,7 +86,7 @@ public class SettingsLoader { ui = ui_; priority = priority_; theme = theme_; - + if (cores_ > 0) { cores = String.valueOf(cores_); } @@ -178,7 +179,7 @@ public class SettingsLoader { if (ui != null) { prop.setProperty("ui", ui); } - + if (theme != null) { prop.setProperty("theme", theme); } @@ -300,7 +301,7 @@ public class SettingsLoader { if (prop.containsKey("theme")) { this.theme = prop.getProperty("theme"); } - + if (prop.containsKey("priority")) { this.priority = Integer.parseInt(prop.getProperty("priority")); } @@ -350,7 +351,8 @@ public class SettingsLoader { config.setUsePriority(priority); } try { - if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType.valueOf(computeMethod))) { + if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType + .valueOf(computeMethod))) { config.setComputeMethod(ComputeType.valueOf(computeMethod)); } } @@ -402,20 +404,21 @@ public class SettingsLoader { if (config.getUIType() == null && ui != null) { config.setUIType(ui); } - + if (config.getTheme() == null) { if (this.theme != null) { config.setTheme(this.theme); - } else { + } + else { config.setTheme("light"); } } - + config.setAutoSignIn(Boolean.valueOf(autoSignIn)); } - @Override - public String toString() { - return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + ", renderbucket-size=" + renderbucketSize + ", cacheDir=" + cacheDir + ", theme=" + theme + ", priority=" + priority + "]"; + @Override public String toString() { + return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + + ", renderbucket-size=" + renderbucketSize + ", cacheDir=" + cacheDir + ", theme=" + theme + ", priority=" + priority + "]"; } } diff --git a/src/com/sheepit/client/ShutdownHook.java b/src/com/sheepit/client/ShutdownHook.java index 7b8ac75..79744a8 100644 --- a/src/com/sheepit/client/ShutdownHook.java +++ b/src/com/sheepit/client/ShutdownHook.java @@ -2,7 +2,7 @@ * Copyright (C) 2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -28,8 +28,7 @@ public class ShutdownHook { public void attachShutDownHook() { Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { + @Override public void run() { _client.stop(); } }); diff --git a/src/com/sheepit/client/Stats.java b/src/com/sheepit/client/Stats.java index 932513d..c14d81a 100644 --- a/src/com/sheepit/client/Stats.java +++ b/src/com/sheepit/client/Stats.java @@ -2,7 +2,7 @@ * Copyright (C) 2016 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -69,8 +69,8 @@ public class Stats { return connectedMachine; } - @Override - public String toString() { - return "Stats [remainingFrame=" + remainingFrame + ", creditsEarned=" + creditsEarned + ", creditsEarnedSession=" + creditsEarnedSession + ", renderableProject=" + renderableProject + ", waitingProject=" + waitingProject + ", connectedMachine=" + connectedMachine + "]"; + @Override public String toString() { + return "Stats [remainingFrame=" + remainingFrame + ", creditsEarned=" + creditsEarned + ", creditsEarnedSession=" + creditsEarnedSession + + ", renderableProject=" + renderableProject + ", waitingProject=" + waitingProject + ", connectedMachine=" + connectedMachine + "]"; } } diff --git a/src/com/sheepit/client/Utils.java b/src/com/sheepit/client/Utils.java index 52b609f..46f24f8 100644 --- a/src/com/sheepit/client/Utils.java +++ b/src/com/sheepit/client/Utils.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -51,7 +51,8 @@ import com.sheepit.client.Error.ServerCode; import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice; public class Utils { - public static int unzipFileIntoDirectory(String zipFileName_, String destinationDirectory, String password, Log log) throws FermeExceptionNoSpaceLeftOnDevice { + public static int unzipFileIntoDirectory(String zipFileName_, String destinationDirectory, String password, Log log) + throws FermeExceptionNoSpaceLeftOnDevice { try { ZipFile zipFile = new ZipFile(zipFileName_); UnzipParameters unzipParameters = new UnzipParameters(); diff --git a/src/com/sheepit/client/datamodel/CacheFileMD5.java b/src/com/sheepit/client/datamodel/CacheFileMD5.java index 0662634..8cd91d6 100644 --- a/src/com/sheepit/client/datamodel/CacheFileMD5.java +++ b/src/com/sheepit/client/datamodel/CacheFileMD5.java @@ -7,13 +7,9 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "cache") -@Data -@ToString -public class CacheFileMD5 { +@Root(strict = false, name = "cache") @Data @ToString public class CacheFileMD5 { - @ElementList(inline = true) - private List md5s; + @ElementList(inline = true) private List md5s; public CacheFileMD5() { } diff --git a/src/com/sheepit/client/datamodel/FileMD5.java b/src/com/sheepit/client/datamodel/FileMD5.java index f3e661f..7469e17 100644 --- a/src/com/sheepit/client/datamodel/FileMD5.java +++ b/src/com/sheepit/client/datamodel/FileMD5.java @@ -5,16 +5,11 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "file") -@Data -@ToString -public class FileMD5 { +@Root(strict = false, name = "file") @Data @ToString public class FileMD5 { - @Attribute - private String md5; + @Attribute private String md5; - @Attribute(required = false) - private String action; + @Attribute(required = false) private String action; public FileMD5() { } diff --git a/src/com/sheepit/client/datamodel/HeartBeatInfos.java b/src/com/sheepit/client/datamodel/HeartBeatInfos.java index ecacdca..950f135 100644 --- a/src/com/sheepit/client/datamodel/HeartBeatInfos.java +++ b/src/com/sheepit/client/datamodel/HeartBeatInfos.java @@ -5,10 +5,6 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "keepmealive") -@ToString -public class HeartBeatInfos { - @Attribute - @Getter - private int status; +@Root(strict = false, name = "keepmealive") @ToString public class HeartBeatInfos { + @Attribute @Getter private int status; } diff --git a/src/com/sheepit/client/datamodel/JobInfos.java b/src/com/sheepit/client/datamodel/JobInfos.java index e833d9e..b4c879a 100644 --- a/src/com/sheepit/client/datamodel/JobInfos.java +++ b/src/com/sheepit/client/datamodel/JobInfos.java @@ -9,25 +9,15 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "jobrequest") -@ToString -public class JobInfos { +@Root(strict = false, name = "jobrequest") @ToString public class JobInfos { - @Attribute - @Getter - private int status; + @Attribute @Getter private int status; - @Element(name = "stats", required = false) - @Getter - private SessionStats sessionStats; + @Element(name = "stats", required = false) @Getter private SessionStats sessionStats; - @Element(name = "job", required = false) - @Getter() - private RenderTask renderTask; + @Element(name = "job", required = false) @Getter() private RenderTask renderTask; - @ElementList(name = "file", inline = true, required = false) - @Getter - private List fileMD5s; + @ElementList(name = "file", inline = true, required = false) @Getter private List fileMD5s; public JobInfos() { } diff --git a/src/com/sheepit/client/datamodel/JobValidation.java b/src/com/sheepit/client/datamodel/JobValidation.java index 9d1307d..01749a5 100644 --- a/src/com/sheepit/client/datamodel/JobValidation.java +++ b/src/com/sheepit/client/datamodel/JobValidation.java @@ -5,13 +5,9 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "jobvalidate") -@ToString -public class JobValidation { +@Root(strict = false, name = "jobvalidate") @ToString public class JobValidation { - @Attribute - @Getter - private int status; + @Attribute @Getter private int status; public JobValidation() { } diff --git a/src/com/sheepit/client/datamodel/RenderTask.java b/src/com/sheepit/client/datamodel/RenderTask.java index b18457b..c1e3438 100644 --- a/src/com/sheepit/client/datamodel/RenderTask.java +++ b/src/com/sheepit/client/datamodel/RenderTask.java @@ -6,59 +6,33 @@ import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Element; import org.simpleframework.xml.Root; -@Root(strict = false, name = "job") -@ToString -public class RenderTask { +@Root(strict = false, name = "job") @ToString public class RenderTask { - @Attribute(name = "id") - @Getter - private String id; + @Attribute(name = "id") @Getter private String id; - @Attribute(name = "use_gpu") - @Getter - private int useGpu; + @Attribute(name = "use_gpu") @Getter private int useGpu; - @Attribute(name = "archive_md5") - @Getter - private String archive_md5; + @Attribute(name = "archive_md5") @Getter private String archive_md5; - @Attribute(name = "path") - @Getter - private String path; + @Attribute(name = "path") @Getter private String path; - @Attribute(name = "frame") - @Getter - private String frame; + @Attribute(name = "frame") @Getter private String frame; - @Attribute(name = "synchronous_upload") - @Getter - private String synchronous_upload; + @Attribute(name = "synchronous_upload") @Getter private String synchronous_upload; - @Attribute(name = "extras") - @Getter - private String extras; - - @Attribute(name = "validation_url") - @Getter - private String validationUrl; + @Attribute(name = "extras") @Getter private String extras; - @Attribute(name = "name") - @Getter - private String name; + @Attribute(name = "validation_url") @Getter private String validationUrl; - @Attribute(name = "password") - @Getter - private String password; + @Attribute(name = "name") @Getter private String name; - @Element(name = "renderer") - @Getter - private RendererInfos rendererInfos; + @Attribute(name = "password") @Getter private String password; - @Element(name = "script", data = true) - @Getter - private String script; + @Element(name = "renderer") @Getter private RendererInfos rendererInfos; + + @Element(name = "script", data = true) @Getter private String script; public RenderTask() { - + } } diff --git a/src/com/sheepit/client/datamodel/RendererInfos.java b/src/com/sheepit/client/datamodel/RendererInfos.java index 5662c6e..c352a9b 100644 --- a/src/com/sheepit/client/datamodel/RendererInfos.java +++ b/src/com/sheepit/client/datamodel/RendererInfos.java @@ -5,23 +5,15 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "renderer") -@ToString -public class RendererInfos { +@Root(strict = false, name = "renderer") @ToString public class RendererInfos { - @Attribute(name = "md5") - @Getter - private String md5; + @Attribute(name = "md5") @Getter private String md5; - @Attribute(name = "commandline") - @Getter - private String commandline; + @Attribute(name = "commandline") @Getter private String commandline; - @Attribute(name = "update_method") - @Getter - private String update_method; + @Attribute(name = "update_method") @Getter private String update_method; public RendererInfos() { - + } } diff --git a/src/com/sheepit/client/datamodel/RequestEndPoint.java b/src/com/sheepit/client/datamodel/RequestEndPoint.java index 59083bf..6c51292 100644 --- a/src/com/sheepit/client/datamodel/RequestEndPoint.java +++ b/src/com/sheepit/client/datamodel/RequestEndPoint.java @@ -5,21 +5,13 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "request") -@ToString -public class RequestEndPoint { +@Root(strict = false, name = "request") @ToString public class RequestEndPoint { - @Attribute - @Getter - private String type; + @Attribute @Getter private String type; - @Attribute - @Getter - private String path; + @Attribute @Getter private String path; - @Attribute(name = "max-period", required = false) - @Getter - private int maxPeriod; + @Attribute(name = "max-period", required = false) @Getter private int maxPeriod; public RequestEndPoint() { } diff --git a/src/com/sheepit/client/datamodel/ServerConfig.java b/src/com/sheepit/client/datamodel/ServerConfig.java index 54afc1a..71b84be 100644 --- a/src/com/sheepit/client/datamodel/ServerConfig.java +++ b/src/com/sheepit/client/datamodel/ServerConfig.java @@ -8,20 +8,13 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "config") -@ToString -public class ServerConfig { +@Root(strict = false, name = "config") @ToString public class ServerConfig { - @Attribute - @Getter - private int status; + @Attribute @Getter private int status; - @Attribute(required = false) - @Getter - private String publickey; + @Attribute(required = false) @Getter private String publickey; - @ElementList(name = "request", inline = true, required = false) - private List requestEndPoints; + @ElementList(name = "request", inline = true, required = false) private List requestEndPoints; public ServerConfig() { } diff --git a/src/com/sheepit/client/datamodel/SessionStats.java b/src/com/sheepit/client/datamodel/SessionStats.java index 296792c..ae03c19 100644 --- a/src/com/sheepit/client/datamodel/SessionStats.java +++ b/src/com/sheepit/client/datamodel/SessionStats.java @@ -5,35 +5,21 @@ import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "stats") -@ToString -public class SessionStats { +@Root(strict = false, name = "stats") @ToString public class SessionStats { - @Attribute(name = "credits_session") - @Getter - private int pointsEarnedOnSession; + @Attribute(name = "credits_session") @Getter private int pointsEarnedOnSession; - @Attribute(name = "credits_total") - @Getter - private int pointsEarnedByUser; + @Attribute(name = "credits_total") @Getter private int pointsEarnedByUser; - @Attribute(name = "frame_remaining") - @Getter - private int remainingFrames; + @Attribute(name = "frame_remaining") @Getter private int remainingFrames; - @Attribute(name = "waiting_project") - @Getter - private int waitingProjects; + @Attribute(name = "waiting_project") @Getter private int waitingProjects; - @Attribute(name = "renderable_project", required = false) - @Getter - private int renderableProjects; + @Attribute(name = "renderable_project", required = false) @Getter private int renderableProjects; - @Attribute(name = "connected_machine") - @Getter - private int connectedMachines; + @Attribute(name = "connected_machine") @Getter private int connectedMachines; public SessionStats() { - + } } diff --git a/src/com/sheepit/client/exception/FermeException.java b/src/com/sheepit/client/exception/FermeException.java index 6eda682..c0799b9 100644 --- a/src/com/sheepit/client/exception/FermeException.java +++ b/src/com/sheepit/client/exception/FermeException.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionBadResponseFromServer.java b/src/com/sheepit/client/exception/FermeExceptionBadResponseFromServer.java index 010aeed..1e5347f 100644 --- a/src/com/sheepit/client/exception/FermeExceptionBadResponseFromServer.java +++ b/src/com/sheepit/client/exception/FermeExceptionBadResponseFromServer.java @@ -2,7 +2,7 @@ * Copyright (C) 2016 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionNoRendererAvailable.java b/src/com/sheepit/client/exception/FermeExceptionNoRendererAvailable.java index 054ef0f..7682444 100644 --- a/src/com/sheepit/client/exception/FermeExceptionNoRendererAvailable.java +++ b/src/com/sheepit/client/exception/FermeExceptionNoRendererAvailable.java @@ -2,7 +2,7 @@ * Copyright (C) 2017 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionNoRightToRender.java b/src/com/sheepit/client/exception/FermeExceptionNoRightToRender.java index 3d5ec6e..fdfad57 100644 --- a/src/com/sheepit/client/exception/FermeExceptionNoRightToRender.java +++ b/src/com/sheepit/client/exception/FermeExceptionNoRightToRender.java @@ -2,7 +2,7 @@ * Copyright (C) 2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionNoSession.java b/src/com/sheepit/client/exception/FermeExceptionNoSession.java index 4b6e17e..08eaf3d 100644 --- a/src/com/sheepit/client/exception/FermeExceptionNoSession.java +++ b/src/com/sheepit/client/exception/FermeExceptionNoSession.java @@ -2,7 +2,7 @@ * Copyright (C) 2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java b/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java index 71c048e..abd557f 100644 --- a/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java +++ b/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java @@ -2,7 +2,7 @@ * Copyright (C) 2016 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java b/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java index 6779ef8..13804ce 100644 --- a/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java +++ b/src/com/sheepit/client/exception/FermeExceptionServerInMaintenance.java @@ -2,7 +2,7 @@ * Copyright (C) 2016 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java b/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java index a41a67e..22d6eba 100644 --- a/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java +++ b/src/com/sheepit/client/exception/FermeExceptionServerOverloaded.java @@ -2,7 +2,7 @@ * Copyright (C) 2016 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeExceptionSessionDisabled.java b/src/com/sheepit/client/exception/FermeExceptionSessionDisabled.java index 3997ec1..81733c1 100644 --- a/src/com/sheepit/client/exception/FermeExceptionSessionDisabled.java +++ b/src/com/sheepit/client/exception/FermeExceptionSessionDisabled.java @@ -2,7 +2,7 @@ * Copyright (C) 2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/exception/FermeServerDown.java b/src/com/sheepit/client/exception/FermeServerDown.java index 00f3295..9ccd534 100644 --- a/src/com/sheepit/client/exception/FermeServerDown.java +++ b/src/com/sheepit/client/exception/FermeServerDown.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -21,7 +21,6 @@ package com.sheepit.client.exception; /** * Server down (server side error) or unreachable (client side error) - * */ public class FermeServerDown extends FermeException { public FermeServerDown() { diff --git a/src/com/sheepit/client/hardware/cpu/CPU.java b/src/com/sheepit/client/hardware/cpu/CPU.java index 0d4ea7c..49f5972 100644 --- a/src/com/sheepit/client/hardware/cpu/CPU.java +++ b/src/com/sheepit/client/hardware/cpu/CPU.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/hardware/gpu/GPU.java b/src/com/sheepit/client/hardware/gpu/GPU.java index e7df2d6..08dd275 100644 --- a/src/com/sheepit/client/hardware/gpu/GPU.java +++ b/src/com/sheepit/client/hardware/gpu/GPU.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/hardware/gpu/GPUDevice.java b/src/com/sheepit/client/hardware/gpu/GPUDevice.java index 4624916..58d1513 100644 --- a/src/com/sheepit/client/hardware/gpu/GPUDevice.java +++ b/src/com/sheepit/client/hardware/gpu/GPUDevice.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -48,7 +48,7 @@ public class GPUDevice { public String getType() { return type; } - + public void setType(String type) { this.type = type; } @@ -120,8 +120,7 @@ public class GPUDevice { this.renderBucketSize = renderBucketSize; } - @Override - public String toString() { + @Override public String toString() { return "GPUDevice [type=" + type + ", model='" + model + "', memory=" + memory + ", id=" + id + ", renderbucketSize=" + renderBucketSize + "]"; } } diff --git a/src/com/sheepit/client/hardware/gpu/nvidia/CUDA.java b/src/com/sheepit/client/hardware/gpu/nvidia/CUDA.java index fbf17f8..38129f1 100644 --- a/src/com/sheepit/client/hardware/gpu/nvidia/CUDA.java +++ b/src/com/sheepit/client/hardware/gpu/nvidia/CUDA.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -27,17 +27,18 @@ public interface CUDA extends Library { public int cuInit(int flags); /* - * @return: CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE - */ + * @return: CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE + */ public int cuDeviceGetCount(IntByReference count); public int cuDeviceGetName(byte[] name, int len, int dev); - public int cuDeviceGet (IntByReference device, int ordinal); + public int cuDeviceGet(IntByReference device, int ordinal); - public int cuDeviceGetAttribute (IntByReference pi, int attrib, int dev ); + public int cuDeviceGetAttribute(IntByReference pi, int attrib, int dev); public int cuDeviceTotalMem_v2(LongByReference bytes, int dev); + public int cuDeviceTotalMem(LongByReference bytes, int dev); } diff --git a/src/com/sheepit/client/hardware/gpu/nvidia/CUDeviceAttribute.java b/src/com/sheepit/client/hardware/gpu/nvidia/CUDeviceAttribute.java index 2529e35..20256d5 100644 --- a/src/com/sheepit/client/hardware/gpu/nvidia/CUDeviceAttribute.java +++ b/src/com/sheepit/client/hardware/gpu/nvidia/CUDeviceAttribute.java @@ -2,7 +2,7 @@ * Copyright (C) 2018 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -28,12 +28,12 @@ public class CUDeviceAttribute { * PCI bus ID of the device */ public static final int CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33; - + /** * PCI device ID of the device */ public static final int CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34; - + /** * PCI domain ID of the device */ diff --git a/src/com/sheepit/client/hardware/gpu/nvidia/CUresult.java b/src/com/sheepit/client/hardware/gpu/nvidia/CUresult.java index cca5d4c..70c42b9 100644 --- a/src/com/sheepit/client/hardware/gpu/nvidia/CUresult.java +++ b/src/com/sheepit/client/hardware/gpu/nvidia/CUresult.java @@ -66,18 +66,18 @@ public class CUresult { /** * This indicates profiling APIs are called while application is running - * in visual profiler mode. + * in visual profiler mode. */ public static final int CUDA_ERROR_PROFILER_DISABLED = 5; /** - * This indicates profiling has not been initialized for this context. - * Call cuProfilerInitialize() to resolve this. + * This indicates profiling has not been initialized for this context. + * Call cuProfilerInitialize() to resolve this. * - * @deprecated This error return is deprecated as of CUDA 5.0. - * It is no longer an error to attempt to enable/disable the - * profiling via ::cuProfilerStart or ::cuProfilerStop without - * initialization. + * @deprecated This error return is deprecated as of CUDA 5.0. + * It is no longer an error to attempt to enable/disable the + * profiling via ::cuProfilerStart or ::cuProfilerStop without + * initialization. */ public static final int CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6; @@ -85,8 +85,8 @@ public class CUresult { * This indicates profiler has already been started and probably * cuProfilerStart() is incorrectly called. * - * @deprecated This error return is deprecated as of CUDA 5.0. - * It is no longer an error to call cuProfilerStart() when + * @deprecated This error return is deprecated as of CUDA 5.0. + * It is no longer an error to call cuProfilerStart() when * profiling is already enabled. */ public static final int CUDA_ERROR_PROFILER_ALREADY_STARTED = 7; @@ -95,8 +95,8 @@ public class CUresult { * This indicates profiler has already been stopped and probably * cuProfilerStop() is incorrectly called. * - * @deprecated This error return is deprecated as of CUDA 5.0. - * It is no longer an error to call cuProfilerStop() when + * @deprecated This error return is deprecated as of CUDA 5.0. + * It is no longer an error to call cuProfilerStop() when * profiling is already disabled. */ public static final int CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8; @@ -203,7 +203,7 @@ public class CUresult { /** * This indicates that the ::CUcontext passed to the API call can - * only be bound to a single CPU thread at a time but is already + * only be bound to a single CPU thread at a time but is already * bound to a CPU thread. */ public static final int CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216; @@ -307,7 +307,7 @@ public class CUresult { /** * This error indicates that a call to ::cuMemPeerRegister is trying to * register memory from a context which has not had peer access - * enabled yet via ::cuCtxEnablePeerAccess(), or that + * enabled yet via ::cuCtxEnablePeerAccess(), or that * ::cuCtxDisablePeerAccess() is trying to disable peer access * which has not been enabled yet. */ @@ -347,15 +347,15 @@ public class CUresult { /** * A device-side assert triggered during kernel execution. The context - * cannot be used anymore, and must be destroyed. All existing device - * memory allocations from this context are invalid and must be + * cannot be used anymore, and must be destroyed. All existing device + * memory allocations from this context are invalid and must be * reconstructed if the program is to continue using CUDA. */ public static final int CUDA_ERROR_ASSERT = 710; /** * This error indicates that the hardware resources required to enable - * peer access have been exhausted for one or more of the devices + * peer access have been exhausted for one or more of the devices * passed to ::cuCtxEnablePeerAccess(). */ public static final int CUDA_ERROR_TOO_MANY_PEERS = 711; diff --git a/src/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java b/src/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java index de388f0..a146027 100644 --- a/src/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java +++ b/src/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java @@ -13,8 +13,7 @@ import com.sun.jna.ptr.LongByReference; public class Nvidia implements GPULister { public static String TYPE = "CUDA"; - @Override - public List getGpus() { + @Override public List getGpus() { OS os = OS.getOS(); String path = os.getCUDALib(); if (path == null) { @@ -62,11 +61,11 @@ public class Nvidia implements GPULister { } List devices = new ArrayList<>(count.getValue()); - + for (int num = 0; num < count.getValue(); num++) { IntByReference aDevice = new IntByReference(); - result = cudalib.cuDeviceGet(aDevice, num); + result = cudalib.cuDeviceGet(aDevice, num); if (result != CUresult.CUDA_SUCCESS) { System.out.println("Nvidia::getGpus cuDeviceGet failed (ret: " + CUresult.stringFor(result) + ")"); continue; @@ -75,19 +74,21 @@ public class Nvidia implements GPULister { IntByReference pciDomainId = new IntByReference(); IntByReference pciBusId = new IntByReference(); IntByReference pciDeviceId = new IntByReference(); - result = cudalib.cuDeviceGetAttribute(pciDomainId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, aDevice.getValue()); + result = cudalib.cuDeviceGetAttribute(pciDomainId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, aDevice.getValue()); if (result != CUresult.CUDA_SUCCESS) { - System.out.println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID failed (ret: " + CUresult.stringFor(result) + ")"); + System.out + .println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID failed (ret: " + CUresult.stringFor(result) + ")"); continue; } - result = cudalib.cuDeviceGetAttribute(pciBusId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, aDevice.getValue()); + result = cudalib.cuDeviceGetAttribute(pciBusId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, aDevice.getValue()); if (result != CUresult.CUDA_SUCCESS) { System.out.println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_PCI_BUS_ID failed (ret: " + CUresult.stringFor(result) + ")"); continue; } - result = cudalib.cuDeviceGetAttribute(pciDeviceId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, aDevice.getValue()); + result = cudalib.cuDeviceGetAttribute(pciDeviceId, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, aDevice.getValue()); if (result != CUresult.CUDA_SUCCESS) { - System.out.println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID failed (ret: " + CUresult.stringFor(result) + ")"); + System.out + .println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID failed (ret: " + CUresult.stringFor(result) + ")"); continue; } @@ -113,11 +114,8 @@ public class Nvidia implements GPULister { return null; } - String blenderId = String.format("CUDA_%s_%04x:%02x:%02x", - new String(name).trim(), - pciDomainId.getValue(), - pciBusId.getValue(), - pciDeviceId.getValue()); + String blenderId = String + .format("CUDA_%s_%04x:%02x:%02x", new String(name).trim(), pciDomainId.getValue(), pciBusId.getValue(), pciDeviceId.getValue()); GPUDevice gpu = new GPUDevice(TYPE, new String(name).trim(), ram.getValue(), blenderId); // for backward compatibility generate a CUDA_N id gpu.setOldId(TYPE + "_" + num); @@ -127,14 +125,12 @@ public class Nvidia implements GPULister { return devices; } - @Override - public int getRecommendedRenderBucketSize(long memory) { + @Override public int getRecommendedRenderBucketSize(long memory) { // Optimal CUDA-based GPUs Renderbucket algorithm return (memory > 1073741824L) ? 256 : 128; } - @Override - public int getMaximumRenderBucketSize(long memory) { + @Override public int getMaximumRenderBucketSize(long memory) { return (memory > 1073741824L) ? 512 : 128; } } diff --git a/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java b/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java index e5ab91d..e9fd149 100644 --- a/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java +++ b/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -34,8 +34,7 @@ import com.sun.jna.ptr.IntByReference; public class OpenCL implements GPULister { public static String TYPE = "OPENCL"; - @Override - public List getGpus() { + @Override public List getGpus() { OpenCLLib lib = null; String path = "OpenCL"; @@ -123,14 +122,12 @@ public class OpenCL implements GPULister { return available_devices; } - @Override - public int getRecommendedRenderBucketSize(long memory) { + @Override public int getRecommendedRenderBucketSize(long memory) { // Optimal CUDA-based GPUs Renderbucket algorithm return (memory > 1073741824L) ? 256 : 128; } - @Override - public int getMaximumRenderBucketSize(long memory) { + @Override public int getMaximumRenderBucketSize(long memory) { return (memory > 1073741824L) ? 2048 : 128; } @@ -181,7 +178,7 @@ public class OpenCL implements GPULister { System.out.println("OpenCL::getBlenderId failed(I) status: " + status); return ""; } - + return String.format("%s_%s_%s_%02x:%02x.%01x", TYPE, platform, name, topology[21], topology[22], topology[23]); } } diff --git a/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java b/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java index 1b8b363..5ef585b 100644 --- a/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java +++ b/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java @@ -2,7 +2,7 @@ * Copyright (C) 2013-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -55,7 +55,8 @@ public interface OpenCLLib extends Library { public int clGetPlatformInfo(CLPlatformId.ByReference platform, int param_name, long param_value_size, byte[] destination, long size_ret[]); - public int clGetDeviceIDs(CLPlatformId.ByReference platform, int param_name, int num_entries, CLDeviceId.ByReference[] devices, IntByReference device_count); + public int clGetDeviceIDs(CLPlatformId.ByReference platform, int param_name, int num_entries, CLDeviceId.ByReference[] devices, + IntByReference device_count); public int clGetDeviceInfo(CLDeviceId.ByReference device, int param_name, long param_value_size, byte[] destination, long size_ret[]); @@ -65,8 +66,7 @@ public interface OpenCLLib extends Library { public int id; - @Override - protected List getFieldOrder() { + @Override protected List getFieldOrder() { return Arrays.asList(new String[] { "id" }); } } @@ -77,8 +77,7 @@ public interface OpenCLLib extends Library { public int id; - @Override - protected List getFieldOrder() { + @Override protected List getFieldOrder() { return Arrays.asList(new String[] { "id" }); } } diff --git a/src/com/sheepit/client/network/Proxy.java b/src/com/sheepit/client/network/Proxy.java index 4a580dc..76106bc 100644 --- a/src/com/sheepit/client/network/Proxy.java +++ b/src/com/sheepit/client/network/Proxy.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -22,6 +22,7 @@ package com.sheepit.client.network; import java.net.MalformedURLException; import java.net.URL; import java.net.Authenticator; + import com.sheepit.client.network.Proxy; import com.sheepit.client.network.ProxyAuthenticator; diff --git a/src/com/sheepit/client/network/ProxyAuthenticator.java b/src/com/sheepit/client/network/ProxyAuthenticator.java index 196cba4..ca2aca1 100644 --- a/src/com/sheepit/client/network/ProxyAuthenticator.java +++ b/src/com/sheepit/client/network/ProxyAuthenticator.java @@ -2,7 +2,7 @@ * Copyright (C) 2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/os/FreeBSD.java b/src/com/sheepit/client/os/FreeBSD.java index ebfe3dc..fd8bea4 100644 --- a/src/com/sheepit/client/os/FreeBSD.java +++ b/src/com/sheepit/client/os/FreeBSD.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -42,13 +42,11 @@ public class FreeBSD extends OS { return "freebsd"; } - @Override - public String getRenderBinaryPath() { + @Override public String getRenderBinaryPath() { return "rend.exe"; } - @Override - public CPU getCPU() { + @Override public CPU getCPU() { CPU ret = new CPU(); try { Runtime r = Runtime.getRuntime(); @@ -110,8 +108,7 @@ public class FreeBSD extends OS { return ret; } - @Override - public long getMemory() { + @Override public long getMemory() { try { Runtime r = Runtime.getRuntime(); Process p = r.exec("sysctl -n hw.usermem"); @@ -133,18 +130,15 @@ public class FreeBSD extends OS { return 0; } - @Override - public long getFreeMemory() { + @Override public long getFreeMemory() { return -1; } - @Override - public String getCUDALib() { + @Override public String getCUDALib() { return "cuda"; } - @Override - public Process exec(List command, Map env_overight) throws IOException { + @Override public Process exec(List command, Map env_overight) throws IOException { // the renderer have a lib directory so add to the LD_LIBRARY_PATH // (even if we are not sure that it is the renderer who is launch diff --git a/src/com/sheepit/client/os/Linux.java b/src/com/sheepit/client/os/Linux.java index fbdd045..66a0262 100644 --- a/src/com/sheepit/client/os/Linux.java +++ b/src/com/sheepit/client/os/Linux.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -43,13 +43,11 @@ public class Linux extends OS { return "linux"; } - @Override - public String getRenderBinaryPath() { + @Override public String getRenderBinaryPath() { return "rend.exe"; } - @Override - public CPU getCPU() { + @Override public CPU getCPU() { CPU ret = new CPU(); try { String filePath = "/proc/cpuinfo"; @@ -89,8 +87,7 @@ public class Linux extends OS { return ret; } - @Override - public long getMemory() { + @Override public long getMemory() { try { String filePath = "/proc/meminfo"; Scanner scanner = new Scanner(new File(filePath)); @@ -118,8 +115,7 @@ public class Linux extends OS { return 0; } - @Override - public long getFreeMemory() { + @Override public long getFreeMemory() { try { String filePath = "/proc/meminfo"; Scanner scanner = new Scanner(new File(filePath)); @@ -138,7 +134,8 @@ public class Linux extends OS { scanner.close(); } catch (java.lang.NoClassDefFoundError e) { - System.err.println("OS::Linux::getFreeMemory error " + e + " mostly because Scanner class was introducted by Java 5 and you are running a lower version"); + System.err.println( + "OS::Linux::getFreeMemory error " + e + " mostly because Scanner class was introducted by Java 5 and you are running a lower version"); } catch (Exception e) { e.printStackTrace(); @@ -147,13 +144,11 @@ public class Linux extends OS { return 0; } - @Override - public String getCUDALib() { + @Override public String getCUDALib() { return "cuda"; } - @Override - public Process exec(List command, Map env_overight) throws IOException { + @Override public Process exec(List command, Map env_overight) throws IOException { Map new_env = new HashMap(); new_env.putAll(java.lang.System.getenv()); // clone the env @@ -201,13 +196,12 @@ public class Linux extends OS { return builder.start(); } - @Override - public boolean getSupportHighPriority() { + @Override public boolean getSupportHighPriority() { // only the root user can create process with high (negative nice) value String logname = System.getenv("LOGNAME"); String user = System.getenv("USER"); - if ((logname != null && logname.equals("root")) || (user != null && user.equals("root"))) { + if ((logname != null && logname.equals("root")) || (user != null && user.equals("root"))) { return true; } diff --git a/src/com/sheepit/client/os/Mac.java b/src/com/sheepit/client/os/Mac.java index da75483..a24c3e3 100644 --- a/src/com/sheepit/client/os/Mac.java +++ b/src/com/sheepit/client/os/Mac.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -41,13 +41,11 @@ public class Mac extends OS { return "mac"; } - @Override - public String getRenderBinaryPath() { + @Override public String getRenderBinaryPath() { return "Blender" + File.separator + "blender.app" + File.separator + "Contents" + File.separator + "MacOS" + File.separator + "blender"; } - @Override - public CPU getCPU() { + @Override public CPU getCPU() { CPU ret = new CPU(); String command = "sysctl machdep.cpu.family machdep.cpu.brand_string"; @@ -97,8 +95,7 @@ public class Mac extends OS { return ret; } - @Override - public long getMemory() { + @Override public long getMemory() { String command = "sysctl hw.memsize"; Process p = null; @@ -140,13 +137,11 @@ public class Mac extends OS { return -1; } - @Override - public long getFreeMemory() { + @Override public long getFreeMemory() { return -1; } - @Override - public Process exec(List command, Map env) throws IOException { + @Override public Process exec(List command, Map env) throws IOException { List actual_command = command; if (this.hasNiceBinary == null) { this.checkNiceAvailability(); @@ -173,8 +168,7 @@ public class Mac extends OS { return builder.start(); } - @Override - public String getCUDALib() { + @Override public String getCUDALib() { return "/usr/local/cuda/lib/libcuda.dylib"; } diff --git a/src/com/sheepit/client/os/OS.java b/src/com/sheepit/client/os/OS.java index 55e48d6..0551f08 100644 --- a/src/com/sheepit/client/os/OS.java +++ b/src/com/sheepit/client/os/OS.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/os/Windows.java b/src/com/sheepit/client/os/Windows.java index 16c7433..52cd01e 100644 --- a/src/com/sheepit/client/os/Windows.java +++ b/src/com/sheepit/client/os/Windows.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -37,13 +37,11 @@ public class Windows extends OS { return "windows"; } - @Override - public String getRenderBinaryPath() { + @Override public String getRenderBinaryPath() { return "rend.exe"; } - @Override - public CPU getCPU() { + @Override public CPU getCPU() { CPU ret = new CPU(); try { String[] identifier = java.lang.System.getenv("PROCESSOR_IDENTIFIER").split(" "); @@ -88,8 +86,7 @@ public class Windows extends OS { return ret; } - @Override - public long getMemory() { + @Override public long getMemory() { try { MEMORYSTATUSEX _memory = new MEMORYSTATUSEX(); if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) { @@ -102,8 +99,7 @@ public class Windows extends OS { return 0; } - @Override - public long getFreeMemory() { + @Override public long getFreeMemory() { try { MEMORYSTATUSEX _memory = new MEMORYSTATUSEX(); if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) { @@ -112,18 +108,16 @@ public class Windows extends OS { } catch (Exception e) { e.printStackTrace(); - } - + } + return -1; } - @Override - public String getCUDALib() { + @Override public String getCUDALib() { return "nvcuda"; } - @Override - public Process exec(List command, Map env) throws IOException { + @Override public Process exec(List command, Map env) throws IOException { // disable a popup because the renderer might crash (seg fault) Kernel32Lib kernel32lib = null; try { @@ -216,8 +210,7 @@ public class Windows extends OS { return process_class; } - @Override - public boolean kill(Process process) { + @Override public boolean kill(Process process) { if (process != null) { WinProcess wproc = new WinProcess(process); wproc.kill(); diff --git a/src/com/sheepit/client/os/windows/Kernel32Lib.java b/src/com/sheepit/client/os/windows/Kernel32Lib.java index 81178d4..78805c9 100644 --- a/src/com/sheepit/client/os/windows/Kernel32Lib.java +++ b/src/com/sheepit/client/os/windows/Kernel32Lib.java @@ -1,6 +1,6 @@ /* This file was originally taken from JNA project (https://github.com/twall/jna) * filename: contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -61,7 +61,8 @@ public interface Kernel32Lib extends Library { /** * Includes all processes and threads in the system, plus the heaps and modules of the process specified in th32ProcessID. */ - WinDef.DWORD TH32CS_SNAPALL = new WinDef.DWORD((TH32CS_SNAPHEAPLIST.intValue() | TH32CS_SNAPPROCESS.intValue() | TH32CS_SNAPTHREAD.intValue() | TH32CS_SNAPMODULE.intValue())); + WinDef.DWORD TH32CS_SNAPALL = new WinDef.DWORD( + (TH32CS_SNAPHEAPLIST.intValue() | TH32CS_SNAPPROCESS.intValue() | TH32CS_SNAPTHREAD.intValue() | TH32CS_SNAPMODULE.intValue())); /** * Indicates that the snapshot handle is to be inheritable. @@ -151,9 +152,10 @@ public interface Kernel32Lib extends Library { */ public char[] szExeFile = new char[WinDef.MAX_PATH]; - @Override - protected List getFieldOrder() { - return Arrays.asList("dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile"); + @Override protected List getFieldOrder() { + return Arrays + .asList("dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", + "dwFlags", "szExeFile"); } } diff --git a/src/com/sheepit/client/os/windows/WinProcess.java b/src/com/sheepit/client/os/windows/WinProcess.java index b074eba..36c6123 100644 --- a/src/com/sheepit/client/os/windows/WinProcess.java +++ b/src/com/sheepit/client/os/windows/WinProcess.java @@ -2,7 +2,7 @@ * Copyright (C) 2013 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -84,13 +84,14 @@ public class WinProcess { private static WinNT.HANDLE getHandleByPid(int pid_) throws IOException { WinNT.HANDLE handle = Kernel32.INSTANCE.OpenProcess(0x0400 | // PROCESS_QUERY_INFORMATION - 0x0800 | // PROCESS_SUSPEND_RESUME - 0x0001 | // PROCESS_TERMINATE - 0x0200 | // PROCESS_SET_INFORMATION - 0x00100000, // SYNCHRONIZE + 0x0800 | // PROCESS_SUSPEND_RESUME + 0x0001 | // PROCESS_TERMINATE + 0x0200 | // PROCESS_SET_INFORMATION + 0x00100000, // SYNCHRONIZE false, pid_); if (handle == null) { - throw new IOException("OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()) + " (pid: " + pid_ + ")"); + throw new IOException( + "OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()) + " (pid: " + pid_ + ")"); } return handle; } @@ -130,8 +131,7 @@ public class WinProcess { this.pid = pid_; } - @Override - protected void finalize() throws Throwable { + @Override protected void finalize() throws Throwable { if (this.handle != null) { // Kernel32.INSTANCE.CloseHandle(this.handle); // do not close the handle because the parent Process object might still be alive this.handle = null; diff --git a/src/com/sheepit/client/standalone/GuiSwing.java b/src/com/sheepit/client/standalone/GuiSwing.java index f48273e..2368624 100644 --- a/src/com/sheepit/client/standalone/GuiSwing.java +++ b/src/com/sheepit/client/standalone/GuiSwing.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -56,13 +56,13 @@ import com.sheepit.client.standalone.swing.activity.Working; import lombok.Getter; import lombok.Setter; -import com.formdev.flatlaf.FlatLightLaf; // Required for dark & light mode +import com.formdev.flatlaf.FlatLightLaf; // Required for dark & light mode import com.formdev.flatlaf.FlatDarkLaf; import com.formdev.flatlaf.FlatLaf; public class GuiSwing extends JFrame implements Gui { public static final String type = "swing"; - + public enum ActivityType { WORKING, SETTINGS } @@ -79,13 +79,11 @@ public class GuiSwing extends JFrame implements Gui { private boolean waitingForAuthentication; private Client client; - + private BufferedImage iconSprites; private BufferedImage[] trayIconSprites; - - @Getter - @Setter - private SettingsLoader settingsLoader; + + @Getter @Setter private SettingsLoader settingsLoader; private ThreadClient threadClient; @@ -96,8 +94,7 @@ public class GuiSwing extends JFrame implements Gui { waitingForAuthentication = true; new Timer().scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { + @Override public void run() { if (activityWorking != null) { activityWorking.updateTime(); } @@ -105,8 +102,7 @@ public class GuiSwing extends JFrame implements Gui { }, 2 * 1000, 2 * 1000); } - @Override - public void start() { + @Override public void start() { if (useSysTray) { try { sysTray = SystemTray.getSystemTray(); @@ -124,21 +120,22 @@ public class GuiSwing extends JFrame implements Gui { sysTray = null; } } - + // load the images sprite and split into individual images URL spriteSequenceUrl = getClass().getResource("/icon-sprites.png"); - + if (spriteSequenceUrl != null) { try { iconSprites = ImageIO.read(spriteSequenceUrl); - trayIconSprites = new BufferedImage[101 * 1]; // sprite sheet has 101 images in 1 column - - setIconImage(extractImageFromSprite(-1)); // sprite 0 is standard Sheep It! icon - } catch (IOException e) { + trayIconSprites = new BufferedImage[101 * 1]; // sprite sheet has 101 images in 1 column + + setIconImage(extractImageFromSprite(-1)); // sprite 0 is standard Sheep It! icon + } + catch (IOException e) { e.printStackTrace(); } } - + setTitle(title); setSize(520, 760); @@ -157,17 +154,18 @@ public class GuiSwing extends JFrame implements Gui { try { if (client.getConfiguration().getTheme().equals("light")) { UIManager.setLookAndFeel(new FlatLightLaf()); - } else if (client.getConfiguration().getTheme().equals("dark")) { + } + else if (client.getConfiguration().getTheme().equals("dark")) { UIManager.setLookAndFeel(new FlatDarkLaf()); } - + // Apply the selected theme to swing components FlatLaf.updateUI(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } - + while (waitingForAuthentication) { try { synchronized (this) { @@ -180,51 +178,43 @@ public class GuiSwing extends JFrame implements Gui { } } - @Override - public void stop() { + @Override public void stop() { System.exit(0); } - @Override - public void status(String msg_) { + @Override public void status(String msg_) { status(msg_, false); } - @Override - public void status(String msg_, boolean overwriteSuspendedMsg) { + @Override public void status(String msg_, boolean overwriteSuspendedMsg) { if (activityWorking != null) { this.activityWorking.setStatus(msg_, overwriteSuspendedMsg); } } - - @Override - public void setRenderingProjectName(String name_) { + + @Override public void setRenderingProjectName(String name_) { if (activityWorking != null) { this.activityWorking.setRenderingProjectName(name_); } } - @Override - public void error(String msg_) { + @Override public void error(String msg_) { status(msg_, true); } - @Override - public void setRemainingTime(String time_) { + @Override public void setRemainingTime(String time_) { if (activityWorking != null) { this.activityWorking.setRemainingTime(time_); } } - @Override - public void setRenderingTime(String time_) { + @Override public void setRenderingTime(String time_) { if (activityWorking != null) { this.activityWorking.setRenderingTime(time_); } } - @Override - public void AddFrameRendered() { + @Override public void AddFrameRendered() { framesRendered++; if (activityWorking != null) { @@ -235,41 +225,35 @@ public class GuiSwing extends JFrame implements Gui { } } - @Override - public void displayStats(Stats stats) { + @Override public void displayStats(Stats stats) { if (activityWorking != null) { this.activityWorking.displayStats(stats); } } - @Override - public void displayUploadQueueStats(int queueSize, long queueVolume) { + @Override public void displayUploadQueueStats(int queueSize, long queueVolume) { if (activityWorking != null) { this.activityWorking.displayUploadQueueStats(queueSize, queueVolume); } } - @Override - public Client getClient() { + @Override public Client getClient() { return client; } - @Override - public void setClient(Client cli) { + @Override public void setClient(Client cli) { client = cli; } - @Override - public void setComputeMethod(String computeMethod) { + @Override public void setComputeMethod(String computeMethod) { this.activityWorking.setComputeMethod(computeMethod); } public Configuration getConfiguration() { return client.getConfiguration(); } - - @Override - public void successfulAuthenticationEvent(String publickey) { + + @Override public void successfulAuthenticationEvent(String publickey) { if (settingsLoader != null) { if (publickey != null) { settingsLoader.setPassword(publickey); @@ -341,15 +325,14 @@ public class GuiSwing extends JFrame implements Gui { public TrayIcon getTrayIcon() { final PopupMenu trayMenu = new PopupMenu(); - + // on start, show the base icon Image img = extractImageFromSprite(-1); final TrayIcon icon = new TrayIcon(img); MenuItem exit = new MenuItem("Exit"); exit.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); @@ -357,8 +340,7 @@ public class GuiSwing extends JFrame implements Gui { MenuItem open = new MenuItem("Open..."); open.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { restoreFromTray(); } }); @@ -366,8 +348,7 @@ public class GuiSwing extends JFrame implements Gui { MenuItem settings = new MenuItem("Settings..."); settings.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { restoreFromTray(); showActivity(ActivityType.SETTINGS); } @@ -379,8 +360,7 @@ public class GuiSwing extends JFrame implements Gui { icon.setToolTip("SheepIt! Client"); icon.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { restoreFromTray(); } }); @@ -388,7 +368,7 @@ public class GuiSwing extends JFrame implements Gui { return icon; } - + private Image extractImageFromSprite(int spriteNumber) { // Sprite structure // Image 0: base sprite @@ -398,29 +378,27 @@ public class GuiSwing extends JFrame implements Gui { // -1 turns into 0 (base sprite with no progress bar) // 0 to 101 turns into 1 to 101 (progress sequence starts in sprite 1 and ends on sprite 101) ImageIcon img = new ImageIcon(iconSprites.getSubimage(0, (spriteNumber + 1) * 114, 114, 114)); - + return img.getImage(); } - - @Override - public void updateTrayIcon(Integer percentage) { + + @Override public void updateTrayIcon(Integer percentage) { // update the app icon on the app bar Image img = extractImageFromSprite(percentage); setIconImage(img); - + // if the app supports the system tray, update as well if (sysTray != null && SystemTray.isSupported()) { if (trayIcon != null) { trayIcon.setImage(img); - trayIcon.setImageAutoSize(true); // use this method to ensure that icon is refreshed when on - // the tray + trayIcon.setImageAutoSize(true); // use this method to ensure that icon is refreshed when on + // the tray } } } - + public class ThreadClient extends Thread { - @Override - public void run() { + @Override public void run() { if (GuiSwing.this.client != null) { GuiSwing.this.client.run(); } diff --git a/src/com/sheepit/client/standalone/GuiText.java b/src/com/sheepit/client/standalone/GuiText.java index 1ee286a..7873b1d 100644 --- a/src/com/sheepit/client/standalone/GuiText.java +++ b/src/com/sheepit/client/standalone/GuiText.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -46,8 +46,7 @@ public class GuiText implements Gui { this.log = Log.getInstance(null); } - @Override - public void start() { + @Override public void start() { if (client != null) { CLIInputObserver cli_input_observer = new CLIInputObserver(client); @@ -56,8 +55,7 @@ public class GuiText implements Gui { cli_input_observer_thread.start(); Signal.handle(new Signal("INT"), new SignalHandler() { - @Override - public void handle(Signal signal) { + @Override public void handle(Signal signal) { sigIntCount++; if (sigIntCount == 4) { @@ -84,22 +82,18 @@ public class GuiText implements Gui { } } - @Override - public void stop() { + @Override public void stop() { Runtime.getRuntime().halt(0); } - - @Override - public void updateTrayIcon(Integer percentage) { + + @Override public void updateTrayIcon(Integer percentage) { } - - @Override - public void status(String msg_) { + + @Override public void status(String msg_) { status(msg_, false); } - @Override - public void status(String msg_, boolean overwriteSuspendedMsg) { + @Override public void status(String msg_, boolean overwriteSuspendedMsg) { log.debug("GUI " + msg_); if (client != null && client.isSuspended()) { @@ -112,67 +106,54 @@ public class GuiText implements Gui { } } - @Override - public void error(String err_) { + @Override public void error(String err_) { System.out.println("Error " + err_); log.error("Error " + err_); } - @Override - public void AddFrameRendered() { + @Override public void AddFrameRendered() { this.framesRendered += 1; System.out.println("Frames rendered: " + this.framesRendered); } - @Override - public void displayStats(Stats stats) { + @Override public void displayStats(Stats stats) { System.out.println("Frames remaining: " + stats.getRemainingFrame()); System.out.println("Credits earned: " + stats.getCreditsEarnedDuringSession()); } - @Override - public void displayUploadQueueStats(int queueSize, long queueVolume) { + @Override public void displayUploadQueueStats(int queueSize, long queueVolume) { // No need to check if the queue is not empty to show the volume bc this line is always shown at the end // of the render process in text GUI (unless an error occurred, where the file is uploaded synchronously) - System.out.println(String.format("Queued uploads: %d (%.2fMB)", - queueSize, - (queueVolume / 1024.0 / 1024.0))); + System.out.println(String.format("Queued uploads: %d (%.2fMB)", queueSize, (queueVolume / 1024.0 / 1024.0))); } - @Override - public void setRenderingProjectName(String name_) { + @Override public void setRenderingProjectName(String name_) { if (name_ != null && name_.isEmpty() == false) { System.out.println("Rendering project \"" + name_ + "\""); } } - @Override - public void setRemainingTime(String time_) { + @Override public void setRemainingTime(String time_) { System.out.println("Rendering (remaining " + time_ + ")"); } - @Override - public void setRenderingTime(String time_) { + @Override public void setRenderingTime(String time_) { System.out.println("Rendering " + time_); } - @Override - public void setClient(Client cli) { + @Override public void setClient(Client cli) { client = cli; } - @Override - public void setComputeMethod(String computeMethod) { + @Override public void setComputeMethod(String computeMethod) { System.out.println("Compute method: " + computeMethod); } - @Override - public Client getClient() { + @Override public Client getClient() { return client; } - @Override - public void successfulAuthenticationEvent(String publickey) { + @Override public void successfulAuthenticationEvent(String publickey) { } } diff --git a/src/com/sheepit/client/standalone/GuiTextOneLine.java b/src/com/sheepit/client/standalone/GuiTextOneLine.java index 3b90020..5854b26 100644 --- a/src/com/sheepit/client/standalone/GuiTextOneLine.java +++ b/src/com/sheepit/client/standalone/GuiTextOneLine.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -42,7 +42,7 @@ public class GuiTextOneLine implements Gui { private String status; private String line; - private int uploadQueueSize; + private int uploadQueueSize; private long uploadQueueVolume; private boolean exiting = false; @@ -57,12 +57,11 @@ public class GuiTextOneLine implements Gui { status = ""; computeMethod = ""; line = ""; - uploadQueueSize = 0; + uploadQueueSize = 0; uploadQueueVolume = 0; } - @Override - public void start() { + @Override public void start() { if (client != null) { CLIInputObserver cli_input_observer = new CLIInputObserver(client); @@ -71,8 +70,7 @@ public class GuiTextOneLine implements Gui { cli_input_observer_thread.start(); Signal.handle(new Signal("INT"), new SignalHandler() { - @Override - public void handle(Signal signal) { + @Override public void handle(Signal signal) { sigIntCount++; if (sigIntCount == 5) { @@ -95,22 +93,18 @@ public class GuiTextOneLine implements Gui { } } - @Override - public void stop() { + @Override public void stop() { Runtime.getRuntime().halt(0); } - - @Override - public void updateTrayIcon(Integer percentage) { + + @Override public void updateTrayIcon(Integer percentage) { } - - @Override - public void status(String msg_) { + + @Override public void status(String msg_) { status(msg_, false); } - @Override - public void status(String msg_, boolean overwriteSuspendedMsg) { + @Override public void status(String msg_, boolean overwriteSuspendedMsg) { if (client != null && client.isSuspended()) { if (overwriteSuspendedMsg) { status = msg_; @@ -123,8 +117,7 @@ public class GuiTextOneLine implements Gui { } } - @Override - public void setRenderingProjectName(String name_) { + @Override public void setRenderingProjectName(String name_) { if (name_ == null || name_.isEmpty()) { project = ""; } @@ -134,60 +127,50 @@ public class GuiTextOneLine implements Gui { updateLine(); } - @Override - public void error(String msg_) { + @Override public void error(String msg_) { status = "Error " + msg_; updateLine(); } - @Override - public void AddFrameRendered() { + @Override public void AddFrameRendered() { rendered += 1; updateLine(); } - @Override - public void displayStats(Stats stats) { + @Override public void displayStats(Stats stats) { remaining = stats.getRemainingFrame(); creditsEarned = String.valueOf(stats.getCreditsEarnedDuringSession()); updateLine(); } - @Override - public void displayUploadQueueStats(int queueSize, long queueVolume) { - this.uploadQueueSize = queueSize; + @Override public void displayUploadQueueStats(int queueSize, long queueVolume) { + this.uploadQueueSize = queueSize; this.uploadQueueVolume = queueVolume; } - @Override - public void setRemainingTime(String time_) { + @Override public void setRemainingTime(String time_) { status = "(remaining " + time_ + ")"; updateLine(); } - @Override - public void setRenderingTime(String time_) { + @Override public void setRenderingTime(String time_) { status = "Rendering " + time_; updateLine(); } - @Override - public void setClient(Client cli) { + @Override public void setClient(Client cli) { client = cli; } - @Override - public void setComputeMethod(String computeMethod_) { + @Override public void setComputeMethod(String computeMethod_) { computeMethod = computeMethod_; } - @Override - public Client getClient() { + @Override public Client getClient() { return client; } - @Override - public void successfulAuthenticationEvent(String publickey) { + @Override public void successfulAuthenticationEvent(String publickey) { } @@ -196,15 +179,9 @@ public class GuiTextOneLine implements Gui { System.out.print("\r"); - line = String.format("Frames: %d Points: %s | Queued uploads: %d%s | %s %s %s", - rendered, - creditsEarned != null ? creditsEarned : "unknown", - this.uploadQueueSize, - (this.uploadQueueSize > 0 ? String.format(" (%.2fMB)", (this.uploadQueueVolume / 1024.0 / 1024.0)) : ""), - project, - computeMethod, - status + (exiting ? " (Exiting after all frames are uploaded)" : "") - ); + line = String.format("Frames: %d Points: %s | Queued uploads: %d%s | %s %s %s", rendered, creditsEarned != null ? creditsEarned : "unknown", + this.uploadQueueSize, (this.uploadQueueSize > 0 ? String.format(" (%.2fMB)", (this.uploadQueueVolume / 1024.0 / 1024.0)) : ""), project, + computeMethod, status + (exiting ? " (Exiting after all frames are uploaded)" : "")); System.out.print(line); for (int i = line.length(); i <= charToRemove; i++) { diff --git a/src/com/sheepit/client/standalone/ListGpuParameterHandler.java b/src/com/sheepit/client/standalone/ListGpuParameterHandler.java index 86f8884..c591828 100644 --- a/src/com/sheepit/client/standalone/ListGpuParameterHandler.java +++ b/src/com/sheepit/client/standalone/ListGpuParameterHandler.java @@ -2,7 +2,7 @@ * Copyright (C) 2017 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -37,8 +37,7 @@ public class ListGpuParameterHandler extends OptionHandler { super(parser, option, setter); } - @Override - public int parseArguments(Parameters params) throws CmdLineException { + @Override public int parseArguments(Parameters params) throws CmdLineException { List gpus = GPU.listDevices(new Configuration(null, null, null)); if (gpus != null) { for (GPUDevice gpu : gpus) { @@ -53,8 +52,7 @@ public class ListGpuParameterHandler extends OptionHandler { return 0; } - @Override - public String getDefaultMetaVariable() { + @Override public String getDefaultMetaVariable() { return null; } } diff --git a/src/com/sheepit/client/standalone/VersionParameterHandler.java b/src/com/sheepit/client/standalone/VersionParameterHandler.java index e1de0ac..501b384 100644 --- a/src/com/sheepit/client/standalone/VersionParameterHandler.java +++ b/src/com/sheepit/client/standalone/VersionParameterHandler.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -33,16 +33,14 @@ public class VersionParameterHandler extends OptionHandler { super(parser, option, setter); } - @Override - public int parseArguments(Parameters params) throws CmdLineException { + @Override public int parseArguments(Parameters params) throws CmdLineException { Configuration config = new Configuration(null, "", ""); System.out.println("Version: " + config.getJarVersion()); System.exit(0); return 0; } - @Override - public String getDefaultMetaVariable() { + @Override public String getDefaultMetaVariable() { return null; } } diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index df71ded..5c9a95c 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -30,6 +30,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.LinkedList; + import com.sheepit.client.Client; import com.sheepit.client.Configuration; import com.sheepit.client.Configuration.ComputeType; @@ -46,75 +47,53 @@ import com.sheepit.client.hardware.gpu.opencl.OpenCL; import com.sheepit.client.network.Proxy; public class Worker { - @Option(name = "-server", usage = "Render-farm server, default https://client.sheepit-renderfarm.com", metaVar = "URL", required = false) - private String server = "https://client.sheepit-renderfarm.com"; + @Option(name = "-server", usage = "Render-farm server, default https://client.sheepit-renderfarm.com", metaVar = "URL", required = false) private String server = "https://client.sheepit-renderfarm.com"; - @Option(name = "-login", usage = "User's login", metaVar = "LOGIN", required = false) - private String login = ""; + @Option(name = "-login", usage = "User's login", metaVar = "LOGIN", required = false) private String login = ""; - @Option(name = "-password", usage = "User's password", metaVar = "PASSWORD", required = false) - private String password = ""; + @Option(name = "-password", usage = "User's password", metaVar = "PASSWORD", required = false) private String password = ""; - @Option(name = "-cache-dir", usage = "Cache/Working directory. Caution, everything in it not related to the render-farm will be removed", metaVar = "/tmp/cache", required = false) - private String cache_dir = null; + @Option(name = "-cache-dir", usage = "Cache/Working directory. Caution, everything in it not related to the render-farm will be removed", metaVar = "/tmp/cache", required = false) private String cache_dir = null; - @Option(name = "-gpu", usage = "Name of the GPU used for the render, for example CUDA_0 for Nvidia or OPENCL_0 for AMD/Intel card", metaVar = "CUDA_0", required = false) - private String gpu_device = null; + @Option(name = "-gpu", usage = "Name of the GPU used for the render, for example CUDA_0 for Nvidia or OPENCL_0 for AMD/Intel card", metaVar = "CUDA_0", required = false) private String gpu_device = null; - @Option(name = "--no-gpu", usage = "Don't detect GPUs", required = false) - private boolean no_gpu_detection = false; + @Option(name = "--no-gpu", usage = "Don't detect GPUs", required = false) private boolean no_gpu_detection = false; - @Option(name = "-compute-method", usage = "CPU: only use cpu, GPU: only use gpu, CPU_GPU: can use cpu and gpu (not at the same time) if -gpu is not use it will not use the gpu", metaVar = "CPU", required = false) - private String method = null; + @Option(name = "-compute-method", usage = "CPU: only use cpu, GPU: only use gpu, CPU_GPU: can use cpu and gpu (not at the same time) if -gpu is not use it will not use the gpu", metaVar = "CPU", required = false) private String method = null; - @Option(name = "-cores", usage = "Number of cores/threads to use for the render", metaVar = "3", required = false) - private int nb_cores = -1; + @Option(name = "-cores", usage = "Number of cores/threads to use for the render", metaVar = "3", required = false) private int nb_cores = -1; - @Option(name = "-memory", usage = "Maximum memory allow to be used by renderer, number with unit (800M, 2G, ...)", required = false) - private String max_ram = null; + @Option(name = "-memory", usage = "Maximum memory allow to be used by renderer, number with unit (800M, 2G, ...)", required = false) private String max_ram = null; - @Option(name = "-rendertime", usage = "Maximum time allow for each frame (in minutes)", required = false) - private int max_rendertime = -1; + @Option(name = "-rendertime", usage = "Maximum time allow for each frame (in minutes)", required = false) private int max_rendertime = -1; - @Option(name = "--verbose", usage = "Display log", required = false) - private boolean print_log = false; + @Option(name = "--verbose", usage = "Display log", required = false) private boolean print_log = false; - @Option(name = "-request-time", usage = "H1:M1-H2:M2,H3:M3-H4:M4 Use the 24h format. For example to request job between 2am-8.30am and 5pm-11pm you should do --request-time 2:00-8:30,17:00-23:00 Caution, it's the requesting job time to get a project, not the working time", metaVar = "2:00-8:30,17:00-23:00", required = false) - private String request_time = null; + @Option(name = "-request-time", usage = "H1:M1-H2:M2,H3:M3-H4:M4 Use the 24h format. For example to request job between 2am-8.30am and 5pm-11pm you should do --request-time 2:00-8:30,17:00-23:00 Caution, it's the requesting job time to get a project, not the working time", metaVar = "2:00-8:30,17:00-23:00", required = false) private String request_time = null; - @Option(name = "-proxy", usage = "URL of the proxy", metaVar = "http://login:password@host:port", required = false) - private String proxy = null; + @Option(name = "-proxy", usage = "URL of the proxy", metaVar = "http://login:password@host:port", required = false) private String proxy = null; - @Option(name = "-extras", usage = "Extras data push on the authentication request", required = false) - private String extras = null; + @Option(name = "-extras", usage = "Extras data push on the authentication request", required = false) private String extras = null; - @Option(name = "-ui", usage = "Specify the user interface to use, default '" + GuiSwing.type + "', available '" + GuiTextOneLine.type + "', '" + GuiText.type + "', '" + GuiSwing.type + "' (graphical)", required = false) - private String ui_type = null; + @Option(name = "-ui", usage = "Specify the user interface to use, default '" + GuiSwing.type + "', available '" + GuiTextOneLine.type + "', '" + + GuiText.type + "', '" + GuiSwing.type + "' (graphical)", required = false) private String ui_type = null; - @Option(name = "-config", usage = "Specify the configuration file", required = false) - private String config_file = null; + @Option(name = "-config", usage = "Specify the configuration file", required = false) private String config_file = null; - @Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class) - private VersionParameterHandler versionHandler; + @Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class) private VersionParameterHandler versionHandler; - @Option(name = "--show-gpu", usage = "Print available CUDA devices and exit", required = false, handler = ListGpuParameterHandler.class) - private ListGpuParameterHandler listGpuParameterHandler; + @Option(name = "--show-gpu", usage = "Print available CUDA devices and exit", required = false, handler = ListGpuParameterHandler.class) private ListGpuParameterHandler listGpuParameterHandler; - @Option(name = "--no-systray", usage = "Don't use systray", required = false) - private boolean no_systray = false; + @Option(name = "--no-systray", usage = "Don't use systray", required = false) private boolean no_systray = false; - @Option(name = "-priority", usage = "Set render process priority (19 lowest to -19 highest)", required = false) - private int priority = 19; - - @Option(name = "-title", usage = "Custom title for the GUI Client", required = false) - private String title = "SheepIt Render Farm"; + @Option(name = "-priority", usage = "Set render process priority (19 lowest to -19 highest)", required = false) private int priority = 19; - @Option(name = "-theme", usage = "Specify the theme to use for the graphical client, default 'light', available 'light', 'dark'", required = false) - private String theme = null; + @Option(name = "-title", usage = "Custom title for the GUI Client", required = false) private String title = "SheepIt Render Farm"; + + @Option(name = "-theme", usage = "Specify the theme to use for the graphical client, default 'light', available 'light', 'dark'", required = false) private String theme = null; + + @Option(name = "-renderbucket-size", usage = "Set a custom GPU renderbucket size (32 for 32x32px, 64 for 64x64px, and so on). NVIDIA GPUs support a maximum renderbucket size of 512x512 pixel, while AMD GPUs support a maximum 2048x2048 pixel renderbucket size. Minimum renderbucket size is 32 pixels for all GPUs", required = false) private int renderbucketSize = -1; - @Option(name = "-renderbucket-size", usage = "Set a custom GPU renderbucket size (32 for 32x32px, 64 for 64x64px, and so on). NVIDIA GPUs support a maximum renderbucket size of 512x512 pixel, while AMD GPUs support a maximum 2048x2048 pixel renderbucket size. Minimum renderbucket size is 32 pixels for all GPUs", required = false) - private int renderbucketSize = -1; - public static void main(String[] args) { new Worker().doMain(args); } @@ -137,7 +116,7 @@ public class Worker { Configuration config = new Configuration(null, login, password); config.setPrintLog(print_log); config.setUsePriority(priority); - config.setDetectGPUs(! no_gpu_detection); + config.setDetectGPUs(!no_gpu_detection); if (cache_dir != null) { File a_dir = new File(cache_dir); @@ -297,10 +276,10 @@ public class Worker { System.err.println("Aborting"); System.exit(2); } - + config.setTheme(this.theme); } - + if (config_file != null) { if (new File(config_file).exists() == false) { System.err.println("Configuration file not found."); diff --git a/src/com/sheepit/client/standalone/swing/activity/Activity.java b/src/com/sheepit/client/standalone/swing/activity/Activity.java index 537ad13..15a996f 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Activity.java +++ b/src/com/sheepit/client/standalone/swing/activity/Activity.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 0aba492..3350dcf 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -94,7 +94,7 @@ public class Settings implements Activity { private ButtonGroup themeOptionsGroup; private JRadioButton lightMode; private JRadioButton darkMode; - + private JCheckBox saveFile; private JCheckBox autoSignIn; JButton saveButton; @@ -108,13 +108,12 @@ public class Settings implements Activity { haveAutoStarted = false; } - @Override - public void show() { + @Override public void show() { Configuration config = parent.getConfiguration(); new SettingsLoader(config.getConfigFilePath()).merge(config); - applyTheme(config.getTheme()); // apply the proper theme (light/dark) - + applyTheme(config.getTheme()); // apply the proper theme (light/dark) + List gpus = GPU.listDevices(config); useGPUs.clear(); // Empty the auxiliary list (used in the list of checkboxes) @@ -132,10 +131,10 @@ public class Settings implements Activity { ++currentRow; constraints.gridy = currentRow; - parent.getContentPane().add(new JLabel(" "), constraints); // Add a separator between logo and first panel - + parent.getContentPane().add(new JLabel(" "), constraints); // Add a separator between logo and first panel + currentRow++; - + // authentication CollapsibleJPanel authentication_panel = new CollapsibleJPanel(new GridLayout(2, 2)); authentication_panel.setBorder(BorderFactory.createTitledBorder("Authentication")); @@ -165,33 +164,33 @@ public class Settings implements Activity { // Theme selection panel CollapsibleJPanel themePanel = new CollapsibleJPanel(new GridLayout(1, 3)); themePanel.setBorder(BorderFactory.createTitledBorder("Theme")); - + themeOptionsGroup = new ButtonGroup(); - + lightMode = new JRadioButton("Light"); lightMode.setActionCommand("light"); lightMode.setSelected(config.getTheme().equals("light")); lightMode.addActionListener(new ApplyThemeAction()); - + darkMode = new JRadioButton("Dark"); darkMode.setActionCommand("dark"); darkMode.setSelected(config.getTheme().equals("dark")); darkMode.addActionListener(new ApplyThemeAction()); - + themePanel.add(lightMode); themePanel.add(darkMode); - + // Group both radio buttons to allow only one selected themeOptionsGroup.add(lightMode); themeOptionsGroup.add(darkMode); - + currentRow++; constraints.gridx = 0; constraints.gridy = currentRow; constraints.gridwidth = 2; - + parent.getContentPane().add(themePanel, constraints); - + // directory CollapsibleJPanel directory_panel = new CollapsibleJPanel(new GridLayout(1, 3)); directory_panel.setBorder(BorderFactory.createTitledBorder("Cache")); @@ -260,7 +259,7 @@ public class Settings implements Activity { if (gpus.size() > 0) { renderbucketSizeLabel = new JLabel("Renderbucket size:"); - renderbucketSize = new JSlider(); + renderbucketSize = new JSlider(); renderbucketSize.setMajorTickSpacing(1); renderbucketSize.setMinorTickSpacing(1); renderbucketSize.setPaintTicks(true); @@ -291,7 +290,7 @@ public class Settings implements Activity { // Initialisation values will apply if we are not able to detect the proper GPU technology or // because is a new one (different from CUDA and OPENCL). In that case, move into a safe position // of 32x32 pixel render bucket and a maximum of 128x128 pixel for the "unknown GPU" - int maxRenderbucketSize = 128; + int maxRenderbucketSize = 128; int recommendedBucketSize = 32; if (config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) { @@ -308,7 +307,7 @@ public class Settings implements Activity { recommendedBucketSize = gpu.getRecommendedRenderBucketSize(config.getGPUDevice().getMemory()); } } - + buildRenderBucketSizeSlider(maxRenderbucketSize, config.getRenderbucketSize() != -1 ? ((int) (Math.log(config.getRenderbucketSize()) / Math.log(2))) - 5 : ((int) (Math.log(recommendedBucketSize) / Math.log(2))) - 5); @@ -331,14 +330,14 @@ public class Settings implements Activity { CPU cpu = new CPU(); if (cpu.cores() > 1) { // if only one core is available, no need to show the choice double step = 1; - double display = (double)cpu.cores() / step; + double display = (double) cpu.cores() / step; while (display > 10) { step += 1.0; - display = (double)cpu.cores() / step; + display = (double) cpu.cores() / step; } cpuCores = new JSlider(1, cpu.cores()); - cpuCores.setMajorTickSpacing((int)(step)); + cpuCores.setMajorTickSpacing((int) (step)); cpuCores.setMinorTickSpacing(1); cpuCores.setPaintTicks(true); cpuCores.setPaintLabels(true); @@ -365,10 +364,10 @@ public class Settings implements Activity { int all_ram = (int) os.getMemory(); ram = new JSlider(0, all_ram); int step = 1000000; - double display = (double)all_ram / (double)step; + double display = (double) all_ram / (double) step; while (display > 10) { step += 1000000; - display = (double)all_ram / (double)step; + display = (double) all_ram / (double) step; } Hashtable labelTable = new Hashtable(); for (int g = 0; g < all_ram; g += step) { @@ -378,7 +377,7 @@ public class Settings implements Activity { ram.setLabelTable(labelTable); ram.setPaintTicks(true); ram.setPaintLabels(true); - ram.setValue((int)(config.getMaxMemory() != -1 ? config.getMaxMemory() : os.getMemory())); + ram.setValue((int) (config.getMaxMemory() != -1 ? config.getMaxMemory() : os.getMemory())); JLabel ramLabel = new JLabel("Memory:"); compute_devices_constraints.weightx = 1.0 / gpus.size(); @@ -405,7 +404,7 @@ public class Settings implements Activity { priority.setPaintTicks(true); priority.setPaintLabels(true); priority.setValue(config.getPriority()); - JLabel priorityLabel = new JLabel(high_priority_support ? "Priority (High <-> Low):" : "Priority (Normal <-> Low):" ); + JLabel priorityLabel = new JLabel(high_priority_support ? "Priority (High <-> Low):" : "Priority (Normal <-> Low):"); compute_devices_constraints.weightx = 1.0 / gpus.size(); compute_devices_constraints.gridx = 0; @@ -452,7 +451,7 @@ public class Settings implements Activity { if (parent.getConfiguration().getMaxRenderTime() > 0) { val = parent.getConfiguration().getMaxRenderTime() / 60; } - renderTime = new JSpinner(new SpinnerNumberModel(val,0,1000,1)); + renderTime = new JSpinner(new SpinnerNumberModel(val, 0, 1000, 1)); advanced_panel.add(renderTimeLabel); advanced_panel.add(renderTime); @@ -482,8 +481,8 @@ public class Settings implements Activity { currentRow++; constraints.gridy = currentRow; - parent.getContentPane().add(new JLabel(" "), constraints); // Add a separator between last checkboxes and button - + parent.getContentPane().add(new JLabel(" "), constraints); // Add a separator between last checkboxes and button + currentRow++; String buttonText = "Start"; if (parent.getClient() != null) { @@ -540,19 +539,20 @@ public class Settings implements Activity { if (login.getText().isEmpty() || password.getPassword().length == 0 || Proxy.isValidURL(proxy.getText()) == false) { selected = false; } - + saveButton.setEnabled(selected); return selected; } - + private void applyTheme(String theme_) { try { if (theme_.equals("light")) { UIManager.setLookAndFeel(new FlatLightLaf()); - } else if (theme_.equals("dark")) { + } + else if (theme_.equals("dark")) { UIManager.setLookAndFeel(new FlatDarkLaf()); } - + // Apply the new theme FlatLaf.updateUI(); } @@ -563,9 +563,10 @@ public class Settings implements Activity { class ChooseFileAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent arg0) { - JOptionPane.showMessageDialog(parent.getContentPane(), "The working directory has to be dedicated directory.
Caution, everything not related to SheepIt-Renderfarm will be removed.
You should create a directory specifically for it.", "Warning: files will be removed!", JOptionPane.WARNING_MESSAGE); + @Override public void actionPerformed(ActionEvent arg0) { + JOptionPane.showMessageDialog(parent.getContentPane(), + "The working directory has to be dedicated directory.
Caution, everything not related to SheepIt-Renderfarm will be removed.
You should create a directory specifically for it.", + "Warning: files will be removed!", JOptionPane.WARNING_MESSAGE); int returnVal = cacheDirChooser.showOpenDialog(parent.getContentPane()); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = cacheDirChooser.getSelectedFile(); @@ -577,16 +578,14 @@ public class Settings implements Activity { class CpuChangeAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { checkDisplaySaveButton(); } } class GpuChangeAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { renderbucketSizeLabel.setVisible(false); renderbucketSize.setVisible(false); @@ -597,8 +596,8 @@ public class Settings implements Activity { } else { GPULister gpu; - int maxRenderbucketSize = 128; // Max default render bucket size - int recommendedBucketSize = 32; // Default recommended render bucket size + int maxRenderbucketSize = 128; // Max default render bucket size + int recommendedBucketSize = 32; // Default recommended render bucket size if (useGPUs.get(counter).getGPUDevice().getType().equals("CUDA")) { gpu = new Nvidia(); @@ -631,8 +630,7 @@ public class Settings implements Activity { class AutoSignInChangeAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { if (autoSignIn.isSelected()) { saveFile.setSelected(true); } @@ -640,16 +638,14 @@ public class Settings implements Activity { } class ApplyThemeAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { applyTheme(themeOptionsGroup.getSelection().getActionCommand()); } } - + class SaveAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { if (parent == null) { return; } @@ -658,7 +654,7 @@ public class Settings implements Activity { if (config == null) { return; } - + if (themeOptionsGroup.getSelection().getActionCommand() != null) config.setTheme(themeOptionsGroup.getSelection().getActionCommand()); @@ -720,7 +716,7 @@ public class Settings implements Activity { int max_rendertime = -1; if (renderTime != null) { - max_rendertime = (Integer)renderTime.getValue() * 60; + max_rendertime = (Integer) renderTime.getValue() * 60; config.setMaxRenderTime(max_rendertime); } @@ -752,23 +748,11 @@ public class Settings implements Activity { } if (saveFile.isSelected()) { - parent.setSettingsLoader(new SettingsLoader( - config.getConfigFilePath(), - login.getText(), - new String(password.getPassword()), - proxyText, - hostnameText, - method, - selected_gpu, - renderbucket_size, - cpu_cores, - max_ram, - max_rendertime, - cachePath, - autoSignIn.isSelected(), - GuiSwing.type, - themeOptionsGroup.getSelection().getActionCommand(), // selected theme - priority.getValue())); + parent.setSettingsLoader( + new SettingsLoader(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, + selected_gpu, renderbucket_size, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, + themeOptionsGroup.getSelection().getActionCommand(), // selected theme + priority.getValue())); // wait for successful authentication (to store the public key) // or do we already have one? @@ -794,17 +778,14 @@ public class Settings implements Activity { public class CheckCanStart implements KeyListener { - @Override - public void keyPressed(KeyEvent arg0) { + @Override public void keyPressed(KeyEvent arg0) { } - @Override - public void keyReleased(KeyEvent arg0) { + @Override public void keyReleased(KeyEvent arg0) { checkDisplaySaveButton(); } - @Override - public void keyTyped(KeyEvent arg0) { + @Override public void keyTyped(KeyEvent arg0) { } } diff --git a/src/com/sheepit/client/standalone/swing/activity/Working.java b/src/com/sheepit/client/standalone/swing/activity/Working.java index 7b317db..7808dd3 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Working.java +++ b/src/com/sheepit/client/standalone/swing/activity/Working.java @@ -2,7 +2,7 @@ * Copyright (C) 2015 Laurent CLOUET * Author Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -102,8 +102,7 @@ public class Working implements Activity { log = Log.getInstance(parent_.getConfiguration()); } - @Override - public void show() { + @Override public void show() { // If the stored theme and the UIManager's theme doesn't match is bc the user has changed it if (!currentTheme.equals(UIManager.getLookAndFeel().getName())) { // And, as the user has changed the theme, then we must recreate all the UI elements with session data @@ -127,11 +126,11 @@ public class Working implements Activity { lastRenderTime = new JLabel(lastRenderTime.getText()); lastRender = new JLabel(lastRender.getText()); userInfoQueuedUploadsAndSizeValue = new JLabel(userInfoQueuedUploadsAndSizeValue.getText()); - + // set the new theme as the current one currentTheme = UIManager.getLookAndFeel().getName(); } - + // current project JPanel current_project_panel = new JPanel(new SpringLayout()); current_project_panel.setBorder(BorderFactory.createTitledBorder("Project")); @@ -248,12 +247,12 @@ public class Working implements Activity { global_constraints.weightx = 1; global_constraints.gridx = 0; - parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between logo and first panel + parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between logo and first panel parent.getContentPane().add(current_project_panel, global_constraints); parent.getContentPane().add(global_stats_panel, global_constraints); parent.getContentPane().add(session_info_panel, global_constraints); parent.getContentPane().add(last_frame_panel, global_constraints); - parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between last panel and buttons + parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between last panel and buttons parent.getContentPane().add(buttonsPanel, global_constraints); Spring widthLeftColumn = getBestWidth(current_project_panel, 4, 2); @@ -314,11 +313,9 @@ public class Working implements Activity { } public void displayUploadQueueStats(int queueSize, long queueVolume) { - userInfoQueuedUploadsAndSizeValue.setText(String.format("%d%s%s", - queueSize, - (queueSize > 0 ? String.format(" (%.2fMB) ", (queueVolume / 1024.0 / 1024.0)) : ""), - (queueSize == this.parent.getConfiguration().getMaxUploadingJob() ? "- Queue full!" : "") - )); + userInfoQueuedUploadsAndSizeValue.setText( + String.format("%d%s%s", queueSize, (queueSize > 0 ? String.format(" (%.2fMB) ", (queueVolume / 1024.0 / 1024.0)) : ""), + (queueSize == this.parent.getConfiguration().getMaxUploadingJob() ? "- Queue full!" : ""))); // If the user has requested to exit, then we need to update the JButton with the queue size if (this.exitAfterFrame.getText().startsWith("Cancel")) { @@ -330,20 +327,19 @@ public class Working implements Activity { } } - exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", - queueSize, - (queueSize > 1 ? "s" : "")) - ); + exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", queueSize, (queueSize > 1 ? "s" : ""))); } } public void updateTime() { if (this.parent.getClient().getStartTime() != 0) { - user_info_total_rendertime_this_session_value.setText(Utils.humanDuration(new Date((new Date().getTime() - this.parent.getClient().getStartTime())))); + user_info_total_rendertime_this_session_value + .setText(Utils.humanDuration(new Date((new Date().getTime() - this.parent.getClient().getStartTime())))); } Job job = this.parent.getClient().getRenderingJob(); if (job != null && job.getProcessRender() != null && job.getProcessRender().getStartTime() > 0) { - current_project_duration_value.setText("" + Utils.humanDuration(new Date((new Date().getTime() - job.getProcessRender().getStartTime()))) + ""); + current_project_duration_value + .setText("" + Utils.humanDuration(new Date((new Date().getTime() - job.getProcessRender().getStartTime()))) + ""); } else { current_project_duration_value.setText(""); @@ -371,7 +367,7 @@ public class Working implements Activity { else { try { String path = lastJob.getOutputImagePath(); - + BufferedImage img = ImageIO.read(new File(path)); float width = img.getWidth(); float height = img.getHeight(); @@ -386,16 +382,16 @@ public class Working implements Activity { } catch (IOException e) { log.error(String.format("Working::showLastRender() Unable to load/preview rendered frame [%s]. Exception %s", - lastJob.getOutputImagePath(), - e.getMessage())); + lastJob.getOutputImagePath(), e.getMessage())); } } - + if (icon != null) { lastRender.setIcon(icon); // don't use lastJob.getProcessRender().getDuration() due to timezone if (lastJob.getProcessRender().getDuration() > 1) { - lastRenderTime.setText("Render time : " + Utils.humanDuration(new Date(lastJob.getProcessRender().getEndTime() - lastJob.getProcessRender().getStartTime()))); + lastRenderTime.setText("Render time : " + Utils + .humanDuration(new Date(lastJob.getProcessRender().getEndTime() - lastJob.getProcessRender().getStartTime()))); } } } @@ -463,8 +459,7 @@ public class Working implements Activity { class PauseAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { Client client = parent.getClient(); if (client != null) { if (client.isSuspended()) { @@ -482,8 +477,7 @@ public class Working implements Activity { } class SettingsAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { if (parent != null) { parent.showActivity(ActivityType.SETTINGS); } @@ -491,34 +485,22 @@ public class Working implements Activity { } class ExitAfterAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { Client client = parent.getClient(); if (client != null) { if (client.isRunning()) { - String[] exitJobOptions = {"Exit after current Jobs", "Exit Immediately", "Do Nothing"}; + String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" }; int jobsQueueSize = client.getUploadQueueSize() + (client.isRunning() ? 1 : 0); - - int userDecision = JOptionPane.showOptionDialog( - null, - String.format("You have %d frame%s being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n", - jobsQueueSize , // Add the current frame to the total count ONLY if the client is running - (jobsQueueSize > 1 ? "s" : ""), - (jobsQueueSize > 1 ? (jobsQueueSize + " ") : ""), - (jobsQueueSize > 1 ? "s" : "") - ), - "Exit Now or Later", - JOptionPane.DEFAULT_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - exitJobOptions, + + int userDecision = JOptionPane.showOptionDialog(null, String.format( + "You have %d frame%s being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n", + jobsQueueSize, // Add the current frame to the total count ONLY if the client is running + (jobsQueueSize > 1 ? "s" : ""), (jobsQueueSize > 1 ? (jobsQueueSize + " ") : ""), (jobsQueueSize > 1 ? "s" : "")), + "Exit Now or Later", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions, exitJobOptions[2]); // Make the "Do nothing" button the default one to avoid mistakes if (userDecision == 0) { - exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", - jobsQueueSize, - (jobsQueueSize > 1 ? "s" : "")) - ); + exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", jobsQueueSize, (jobsQueueSize > 1 ? "s" : ""))); client.askForStop(); } @@ -536,8 +518,7 @@ public class Working implements Activity { } class blockJobAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { Client client = parent.getClient(); if (client != null) { Job job = client.getRenderingJob(); diff --git a/src/com/sheepit/client/standalone/swing/components/CollapsibleJPanel.java b/src/com/sheepit/client/standalone/swing/components/CollapsibleJPanel.java index d146266..facd97f 100644 --- a/src/com/sheepit/client/standalone/swing/components/CollapsibleJPanel.java +++ b/src/com/sheepit/client/standalone/swing/components/CollapsibleJPanel.java @@ -1,7 +1,7 @@ /* * Copyright (C) 2015 Laurent CLOUET * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -105,8 +105,7 @@ public class CollapsibleJPanel extends JPanel { setMaximumSize(new Dimension(getMaximumSize().width, height)); } - @Override - public Component add(Component component) { // Need this to get the original height of panel + @Override public Component add(Component component) { // Need this to get the original height of panel Component returnComponent = super.add(component); @@ -115,8 +114,7 @@ public class CollapsibleJPanel extends JPanel { return returnComponent; } - @Override - public void setBorder(Border border) { // Need this to get the border title + @Override public void setBorder(Border border) { // Need this to get the border title if (border instanceof TitledBorder && (borderTitle == "")) { borderTitle = ((TitledBorder) border).getTitle(); @@ -129,27 +127,22 @@ public class CollapsibleJPanel extends JPanel { public class onClickHandler implements MouseListener { - @Override - public void mouseClicked(MouseEvent e) { + @Override public void mouseClicked(MouseEvent e) { } - @Override - public void mousePressed(MouseEvent e) { + @Override public void mousePressed(MouseEvent e) { if (e.getPoint().y < COLLAPSED_HEIGHT) { // Only if click is on top of panel ((CollapsibleJPanel) e.getComponent()).toggleCollapsed(); } } - @Override - public void mouseEntered(MouseEvent e) { + @Override public void mouseEntered(MouseEvent e) { } - @Override - public void mouseExited(MouseEvent e) { + @Override public void mouseExited(MouseEvent e) { } - @Override - public void mouseReleased(MouseEvent e) { + @Override public void mouseReleased(MouseEvent e) { } } diff --git a/src/com/sheepit/client/standalone/text/CLIInputActionHandler.java b/src/com/sheepit/client/standalone/text/CLIInputActionHandler.java index f5d4d84..039bb69 100644 --- a/src/com/sheepit/client/standalone/text/CLIInputActionHandler.java +++ b/src/com/sheepit/client/standalone/text/CLIInputActionHandler.java @@ -2,7 +2,7 @@ * Copyright (C) 2017 Laurent CLOUET * Author Rolf Aretz Lap * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. @@ -25,8 +25,7 @@ import com.sheepit.client.Job; public class CLIInputActionHandler implements CLIInputListener { - @Override - public void commandEntered(Client client, String command) { + @Override public void commandEntered(Client client, String command) { int priorityLength = "priority".length(); //prevent Null Pointer at next step @@ -89,7 +88,7 @@ public class CLIInputActionHandler implements CLIInputListener { } } - + void displayStatus(Client client) { if (client.isSuspended()) { System.out.println("Status: paused"); diff --git a/src/com/sheepit/client/standalone/text/CLIInputListener.java b/src/com/sheepit/client/standalone/text/CLIInputListener.java index 89a67b8..090aacd 100644 --- a/src/com/sheepit/client/standalone/text/CLIInputListener.java +++ b/src/com/sheepit/client/standalone/text/CLIInputListener.java @@ -2,7 +2,7 @@ * Copyright (C) 2017 Laurent CLOUET * Author Rolf Aretz Lap * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. diff --git a/src/com/sheepit/client/standalone/text/CLIInputObserver.java b/src/com/sheepit/client/standalone/text/CLIInputObserver.java index ea70f5f..593e3ec 100644 --- a/src/com/sheepit/client/standalone/text/CLIInputObserver.java +++ b/src/com/sheepit/client/standalone/text/CLIInputObserver.java @@ -2,7 +2,7 @@ * Copyright (C) 2017 Laurent CLOUET * Author Rolf Aretz Lap * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License.