diff --git a/.editorconfig b/.editorconfig index b8b4994..aef3a34 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,10 @@ charset = utf-8 indent_size = 4 indent_style = tab +[*.yml] +indent_size = 2 +indent_style = space + [*.java] ij_java_class_count_to_use_import_on_demand = 999 ij_java_names_count_to_use_import_on_demand = 999 diff --git a/build.gradle b/build.gradle index d002c6c..26a121c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java-library' id 'application' id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'pmd' } sourceCompatibility = '1.11' @@ -63,3 +64,9 @@ jar { configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) } } } + +pmd { + ignoreFailures = false + ruleSetFiles = files("rulesets/java-sheepit.xml") + ruleSets = [] +} diff --git a/rulesets/java-sheepit.xml b/rulesets/java-sheepit.xml new file mode 100644 index 0000000..17e4a04 --- /dev/null +++ b/rulesets/java-sheepit.xml @@ -0,0 +1,57 @@ + + + + + + SheepIt client custom rules + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/sheepit/client/Client.java b/src/main/java/com/sheepit/client/Client.java index eab0e6d..42fe15a 100644 --- a/src/main/java/com/sheepit/client/Client.java +++ b/src/main/java/com/sheepit/client/Client.java @@ -91,15 +91,15 @@ import okhttp3.HttpUrl; private long uploadQueueVolume; private int noJobRetryIter; - public Client(Gui gui_, Configuration configuration, String url_) { + public Client(Gui gui, Configuration configuration, String url) { this.configuration = configuration; - this.server = new Server(url_, this.configuration, this); + this.server = new Server(url, this.configuration, this); this.log = Log.getInstance(this.configuration); - this.gui = gui_; + this.gui = gui; this.directoryManager = new DirectoryManager(this.configuration, this.log); this.renderingJob = null; this.previousJob = null; - this.jobsToValidate = new ArrayBlockingQueue(5); + this.jobsToValidate = new ArrayBlockingQueue<>(5); this.isValidatingJob = false; this.disableErrorSending = false; @@ -115,7 +115,7 @@ import okhttp3.HttpUrl; this.sessionStarted = false; } - public String toString() { + @Override public String toString() { return String.format("Client (configuration %s, server %s)", this.configuration, this.server); } @@ -155,7 +155,7 @@ import okhttp3.HttpUrl; shuttingdown = true; log.debug("Initiating the computer's shutting down process"); - if (configuration.getShutdownMode().equals("wait")) { + if ("wait".equals(configuration.getShutdownMode())) { // Soft stop. Complete current render (if any), finish uploading frames and then shutdown the computer askForStop(); } @@ -183,13 +183,9 @@ import okhttp3.HttpUrl; this.server.start(); // for staying alive // create a thread which will send the frame - Runnable runnable_sender = new Runnable() { - public void run() { - senderLoop(); - } - }; - Thread thread_sender = new Thread(runnable_sender); - thread_sender.start(); + Runnable runnableSender = this::senderLoop; + Thread threadSender = new Thread(runnableSender); + threadSender.start(); do { while (this.running) { @@ -207,12 +203,12 @@ import okhttp3.HttpUrl; step = this.log.newCheckPoint(); try { - Calendar next_request = this.nextJobRequest(); - if (next_request != null) { + Calendar nextRequest = this.nextJobRequest(); + if (nextRequest != null) { // wait Date now = new Date(); - this.gui.status(String.format("Waiting until %tR before requesting job", next_request)); - long wait = next_request.getTimeInMillis() - now.getTime(); + this.gui.status(String.format("Waiting until %tR before requesting job", nextRequest)); + long wait = nextRequest.getTimeInMillis() - now.getTime(); if (wait < 0) { // it means the client has to wait until the next day wait += 24 * 3600 * 1000; @@ -247,12 +243,12 @@ import okhttp3.HttpUrl; else { this.startTime = new Date().getTime(); // reset start session time because the server did it try { - Calendar next_request = this.nextJobRequest(); - if (next_request != null) { + Calendar nextRequest = this.nextJobRequest(); + if (nextRequest != null) { // wait Date now = new Date(); - this.gui.status(String.format("Waiting until %tR before requesting job", next_request)); - long timeToSleep = next_request.getTimeInMillis() - now.getTime(); + this.gui.status(String.format("Waiting until %tR before requesting job", nextRequest)); + long timeToSleep = nextRequest.getTimeInMillis() - now.getTime(); this.activeSleep(timeToSleep); } @@ -276,10 +272,10 @@ import okhttp3.HttpUrl; // SheepItServerDown // SheepItExceptionBadResponseFromServer - int time_sleep = e.getWaitDuration(); - this.gui.status(String.format(e.getHumanText(), new Date(new Date().getTime() + time_sleep))); + int timeSleep = e.getWaitDuration(); + this.gui.status(String.format(e.getHumanText(), new Date(new Date().getTime() + timeSleep))); - if (this.activeSleep(time_sleep) == false) { + if (this.activeSleep(timeSleep) == false) { return -3; } this.log.removeCheckPoint(step); @@ -297,13 +293,13 @@ import okhttp3.HttpUrl; } if (this.renderingJob == null) { // no job - int[] retrySchemeInMilliSeconds = { 300000, 480000, 720000, 900000, 1200000 }; // 5, 8, 12, 15 and 20 minutes + int[] retrySchemeInMilliSeconds = { 300_000, 480_000, 720_000, 900_000, 1_200_000 }; // 5, 8, 12, 15 and 20 minutes - int time_sleep = retrySchemeInMilliSeconds[(this.noJobRetryIter < retrySchemeInMilliSeconds.length) ? + int timeSleep = retrySchemeInMilliSeconds[(this.noJobRetryIter < retrySchemeInMilliSeconds.length) ? this.noJobRetryIter++ : (retrySchemeInMilliSeconds.length - 1)]; - this.gui.status(String.format("No job available. Will try again at %tR", new Date(new Date().getTime() + time_sleep))); - if (this.activeSleep(time_sleep) == false) { + this.gui.status(String.format("No job available. Will try again at %tR", new Date(new Date().getTime() + timeSleep))); + if (this.activeSleep(timeSleep) == false) { return -3; } this.log.removeCheckPoint(step); @@ -317,10 +313,10 @@ import okhttp3.HttpUrl; ret = this.work(this.renderingJob); if (ret == Error.Type.NO_SPACE_LEFT_ON_DEVICE || ret == Error.Type.PATH_INVALID || ret == Error.Type.NO_WRITE_PERMISSION ) { - Job frame_to_reset = this.renderingJob; // copy it because the sendError will take ~5min to execute + Job frameToReset = this.renderingJob; // copy it because the sendError will take ~5min to execute this.renderingJob = null; this.gui.error(Error.humanString(ret)); - this.sendError(step, frame_to_reset, ret); + this.sendError(step, frameToReset, ret); this.log.removeCheckPoint(step); return -50; } @@ -433,7 +429,7 @@ import okhttp3.HttpUrl; try { this.server.HTTPRequest(this.server.getPage("logout")); } - catch (IOException e) { + catch (IOException ignored) { // nothing to do: if the logout failed that's ok } } @@ -562,11 +558,11 @@ import okhttp3.HttpUrl; } } - protected void sendError(int step_) { - this.sendError(step_, null, null); + protected void sendError(int step) { + this.sendError(step, null, null); } - protected void sendError(int step_, Job job_to_reset_, Error.Type error) { + protected void sendError(int step, Job jobToReset, Error.Type error) { if (this.disableErrorSending) { this.log.debug("Error sending is disabled, do not send log"); return; @@ -574,10 +570,10 @@ import okhttp3.HttpUrl; this.log.debug("Sending error to server (type: " + error + ")"); try { - File temp_file = File.createTempFile("farm_", ".txt"); - temp_file.createNewFile(); - temp_file.deleteOnExit(); - FileOutputStream writer = new FileOutputStream(temp_file); + File tempFile = File.createTempFile("farm_", ".txt"); + tempFile.createNewFile(); + tempFile.deleteOnExit(); + FileOutputStream writer = new FileOutputStream(tempFile); // Create a header with the information summarised for easier admin error analysis Configuration conf = this.configuration; @@ -594,9 +590,9 @@ import okhttp3.HttpUrl; } logHeader.append("====================================================================================================\n"); - if (job_to_reset_ != null) { - logHeader.append(String.format("Project ::: %s\n", job_to_reset_.getName())) - .append(String.format("Project id: %s frame: %s\n", job_to_reset_.getId(), job_to_reset_.getFrameNumber())).append(String.format("blender ::: %s\n\n", job_to_reset_.getBlenderLongVersion())).append(String.format("ERROR Type :: %s\n", error)); + if (jobToReset != null) { + logHeader.append(String.format("Project ::: %s\n", jobToReset.getName())) + .append(String.format("Project id: %s frame: %s\n", jobToReset.getId(), jobToReset.getFrameNumber())).append(String.format("blender ::: %s\n\n", jobToReset.getBlenderLongVersion())).append(String.format("ERROR Type :: %s\n", error)); } else { logHeader.append("Project ::: No project allocated.\n") @@ -607,7 +603,7 @@ import okhttp3.HttpUrl; // Insert the info at the beginning of the error log writer.write(logHeader.toString().getBytes()); - Optional> logs = this.log.getForCheckPoint(step_); + Optional> logs = this.log.getForCheckPoint(step); if (logs.isPresent()) { for (String line : logs.get()) { writer.write(line.getBytes()); @@ -618,14 +614,14 @@ import okhttp3.HttpUrl; writer.close(); HttpUrl.Builder remoteURL = HttpUrl.parse(this.server.getPage("error")).newBuilder(); remoteURL.addQueryParameter("type", error == null ? "" : Integer.toString(error.getValue())); - if (job_to_reset_ != null) { - remoteURL.addQueryParameter("frame", job_to_reset_.getFrameNumber()); - remoteURL.addQueryParameter("job", job_to_reset_.getId()); - remoteURL.addQueryParameter("render_time", Integer.toString(job_to_reset_.getProcessRender().getRenderDuration())); - remoteURL.addQueryParameter("memoryused", Long.toString(job_to_reset_.getProcessRender().getPeakMemoryUsed())); + if (jobToReset != null) { + remoteURL.addQueryParameter("frame", jobToReset.getFrameNumber()); + remoteURL.addQueryParameter("job", jobToReset.getId()); + remoteURL.addQueryParameter("render_time", Integer.toString(jobToReset.getProcessRender().getRenderDuration())); + remoteURL.addQueryParameter("memoryused", Long.toString(jobToReset.getProcessRender().getPeakMemoryUsed())); } - this.server.HTTPSendFile(remoteURL.build().toString(), temp_file.getAbsolutePath(), step_, this.gui); - temp_file.delete(); + this.server.HTTPSendFile(remoteURL.build().toString(), tempFile.getAbsolutePath(), step, this.gui); + tempFile.delete(); } catch (Exception e) { StringWriter sw = new StringWriter(); @@ -735,26 +731,26 @@ import okhttp3.HttpUrl; } } - final File scene_file = new File(ajob.getScenePath()); - File renderer_file = new File(ajob.getRendererPath()); + final File sceneFile = new File(ajob.getScenePath()); + File rendererFile = new File(ajob.getRendererPath()); - if (scene_file.exists() == false) { + if (sceneFile.exists() == false) { gui.setRenderingProjectName(""); for (String logline : configuration.filesystemHealthCheck()) { log.debug(logline); } - this.log.error("Client::work job preparation failed (scene file '" + scene_file.getAbsolutePath() + this.log.error("Client::work job preparation failed (scene file '" + sceneFile.getAbsolutePath() + "' does not exist), cleaning directory in hope to recover"); this.configuration.cleanWorkingDirectory(); return Error.Type.MISSING_SCENE; } - if (renderer_file.exists() == false) { + if (rendererFile.exists() == false) { gui.setRenderingProjectName(""); for (String logline : configuration.filesystemHealthCheck()) { log.debug(logline); } - this.log.error("Client::work job preparation failed (renderer file '" + renderer_file.getAbsolutePath() + this.log.error("Client::work job preparation failed (renderer file '" + rendererFile.getAbsolutePath() + "' does not exist), cleaning directory in hope to recover"); this.configuration.cleanWorkingDirectory(); return Error.Type.MISSING_RENDERER; @@ -764,7 +760,7 @@ import okhttp3.HttpUrl; @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(); + sceneFile.delete(); } }; @@ -782,8 +778,8 @@ import okhttp3.HttpUrl; return err; } - protected Error.Type downloadSceneFile(Job ajob_) throws SheepItException { - int total = ajob_.getArchiveChunks().size(); + protected Error.Type downloadSceneFile(Job ajob) throws SheepItException { + int total = ajob.getArchiveChunks().size(); int threads = Math.max(1, Math.min(total, 12)); // at least one thread, to avoid IllegalArgumentException if total = 0 ExecutorService executor = Executors.newFixedThreadPool(threads); @@ -792,9 +788,8 @@ import okhttp3.HttpUrl; this.gui.getDownloadProgress().reset("Downloading project"); for (int i = 0; i < total; i++) { - Chunk chunk = ajob_.getArchiveChunks().get(i); + Chunk chunk = ajob.getArchiveChunks().get(i); - int finalI = i; Callable downloadTask = () -> { DownloadManager downloadManager = new DownloadManager( this.server, @@ -804,9 +799,7 @@ import okhttp3.HttpUrl; chunk.getMd5(), String.format(LOCALE, "%s?chunk=%s", this.server.getPage("download-chunk"), chunk.getId()) ); - Type ret = null; - ret = downloadManager.download(); - return ret; + return downloadManager.download(); }; tasks.add(downloadTask); @@ -852,31 +845,31 @@ import okhttp3.HttpUrl; protected int prepareWorkingDirectory(Job ajob) { int ret; - String renderer_archive = this.directoryManager.getCacheBinaryPathFor(ajob); - String renderer_path = ajob.getRendererDirectory(); - File renderer_path_file = new File(renderer_path); + String rendererArchive = this.directoryManager.getCacheBinaryPathFor(ajob); + String rendererPath = ajob.getRendererDirectory(); + File rendererPathFile = new File(rendererPath); // file is already downloaded, either on shared directory or cache directory (from this.downloadExecutable) if (this.directoryManager.isSharedEnabled() && new File(this.directoryManager.getSharedBinaryPathFor(ajob)).exists()) { this.gui.status("Copying renderer from shared downloads directory"); this.log.debug("Client::prepareWorkingDirectory Copying renderer from shared downloads directory " + this.directoryManager.getSharedBinaryPathFor(ajob) + " into " + this.directoryManager.getCacheBinaryPathFor(ajob)); if (this.directoryManager.copyBinaryFromSharedToCache(ajob) == false) { - log.error("Error while copying " + renderer_archive + " from shared downloads directory to working dir"); + log.error("Error while copying " + rendererArchive + " from shared downloads directory to working dir"); } } - if (!renderer_path_file.exists()) { + if (!rendererPathFile.exists()) { // we create the directory - renderer_path_file.mkdir(); + rendererPathFile.mkdir(); this.gui.status("Extracting renderer"); - this.log.debug("Client::prepareWorkingDirectory Extracting renderer " + renderer_archive + " into " + renderer_path); + this.log.debug("Client::prepareWorkingDirectory Extracting renderer " + rendererArchive + " into " + rendererPath); // unzip the archive - ret = Utils.unzipFileIntoDirectory(renderer_archive, renderer_path, null, log); + ret = Utils.unzipFileIntoDirectory(rendererArchive, rendererPath, null, log); if (ret != 0) { this.log.error( - "Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + renderer_archive + ", " + renderer_path + ") returned " + "Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + rendererArchive + ", " + rendererPath + ") returned " + ret); this.gui.error(String.format("Unable to extract the renderer (error %d)", ret)); return -1; @@ -890,8 +883,8 @@ import okhttp3.HttpUrl; } } - String scene_path = ajob.getSceneDirectory(); - File scene_path_file = new File(scene_path); + String scenePath = ajob.getSceneDirectory(); + File scenePathFile = new File(scenePath); // chunk files are already downloaded, either on shared directory or cache directory (from this.downloadSceneFile) for (Chunk chunk: ajob.getArchiveChunks()) { @@ -906,18 +899,18 @@ import okhttp3.HttpUrl; /// download the chunks - if (!scene_path_file.exists()) { + if (!scenePathFile.exists()) { // we create the directory - scene_path_file.mkdir(); + scenePathFile.mkdir(); this.gui.status("Extracting project"); - this.log.debug("Client::prepareWorkingDirectory Extracting project into " + scene_path); + this.log.debug("Client::prepareWorkingDirectory Extracting project into " + scenePath); // unzip the archive Instant startUnzip = Instant.now(); ret = Utils.unzipChunksIntoDirectory( ajob.getArchiveChunks().stream().map(chunk -> this.directoryManager.getCachePathFor(chunk)).collect(Collectors.toList()), - scene_path, + scenePath, ajob.getPassword(), log); @@ -936,22 +929,22 @@ import okhttp3.HttpUrl; } protected Error.Type confirmJob(Job ajob, int checkpoint) { - String url_real = String.format(LOCALE, "%s&rendertime=%d&preptime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getRenderDuration(), ajob.getProcessRender().getScenePrepDuration(), + String urlReal = String.format(LOCALE, "%s&rendertime=%d&preptime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getRenderDuration(), ajob.getProcessRender().getScenePrepDuration(), ajob.getProcessRender().getPeakMemoryUsed()); if (ajob.getSpeedSamplesRendered() > 0.0) { - url_real += String.format(LOCALE, "&speedsamples=%s", ajob.getSpeedSamplesRendered()); + urlReal += String.format(LOCALE, "&speedsamples=%s", ajob.getSpeedSamplesRendered()); } - this.log.debug(checkpoint, "Client::confirmeJob url " + url_real); + this.log.debug(checkpoint, "Client::confirmeJob url " + urlReal); this.log.debug(checkpoint, "path frame " + ajob.getOutputImagePath()); this.isValidatingJob = true; - int max_try = 3; - int timeToSleep = 22000; - ServerCode ret = ServerCode.UNKNOWN; + int maxTries = 3; + int timeToSleep = 22_000; + ServerCode ret; Type confirmJobReturnCode = Error.Type.OK; retryLoop: - for (int nb_try = 0; nb_try < max_try; nb_try++) { - if (nb_try >= 1) { + for (int nbTry = 0; nbTry < maxTries; nbTry++) { + if (nbTry >= 1) { // sleep before retrying this.log.debug(checkpoint, "Sleep for " + timeToSleep / 1000 + "s before trying to re-upload the frame, previous error: "+ confirmJobReturnCode); try { @@ -963,7 +956,7 @@ import okhttp3.HttpUrl; timeToSleep *= 2; // exponential backoff } - ret = this.server.HTTPSendFile(url_real, ajob.getOutputImagePath(), checkpoint, this.gui); + ret = this.server.HTTPSendFile(urlReal, ajob.getOutputImagePath(), checkpoint, this.gui); switch (ret) { case OK: // no issue, exit the loop @@ -1024,11 +1017,11 @@ import okhttp3.HttpUrl; } protected boolean shouldWaitBeforeRender() { - int concurrent_job = this.jobsToValidate.size(); + int concurrentJob = this.jobsToValidate.size(); if (this.isValidatingJob) { - concurrent_job++; + concurrentJob++; } - return (concurrent_job >= this.configuration.getMaxUploadingJob()); + return (concurrentJob >= this.configuration.getMaxUploadingJob()); } /**************** @@ -1036,7 +1029,7 @@ import okhttp3.HttpUrl; * @int checkpoint - the checkpoint associated with the job (to add any additional log to the render output) * @Job job - the job to be validated */ - @AllArgsConstructor class QueuedJob { + @AllArgsConstructor private class QueuedJob { final private int checkpoint; final private Job job; } diff --git a/src/main/java/com/sheepit/client/Job.java b/src/main/java/com/sheepit/client/Job.java index e51c163..580f1a4 100644 --- a/src/main/java/com/sheepit/client/Job.java +++ b/src/main/java/com/sheepit/client/Job.java @@ -103,7 +103,7 @@ import java.util.regex.Pattern; archiveChunks = archiveChunks_; rendererMD5 = rendererMd5_; name = name_; - password = password_; + password = password_.clone(); synchronousUpload = synchronous_upload_; gui = gui_; outputImagePath = null; @@ -344,8 +344,7 @@ import java.util.regex.Pattern; getProcessRender().setOsProcess(OS.operatingSystem.getProcess((int) getProcessRender().getProcess().pid())); BufferedReader input = new BufferedReader(new InputStreamReader(getProcessRender().getProcess().getInputStream())); memoryCheck.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { + @Override public void run() { updateProcess(); } }, 0L, 200L); @@ -464,7 +463,7 @@ import java.util.regex.Pattern; return Error.Type.RENDERER_OUT_OF_MEMORY; } - updateSpeedSamplesRendered(line, progress); + updateSpeedSamplesRendered(line); updateRenderingStatus(line, progress); Type error = detectError(line); if (error != Error.Type.OK) { @@ -681,7 +680,7 @@ import java.util.regex.Pattern; return newProgress; } - private void updateSpeedSamplesRendered(String line, int progress) { + private void updateSpeedSamplesRendered(String line) { // Looking for "Rendered 1281 samples in 66.319402 seconds" Pattern pattern = Pattern.compile("^Rendered (\\d+) samples in ([\\d.]+) seconds$"); Matcher matcher = pattern.matcher(line); diff --git a/src/main/java/com/sheepit/client/Log.java b/src/main/java/com/sheepit/client/Log.java index eaa270d..4b2dc85 100644 --- a/src/main/java/com/sheepit/client/Log.java +++ b/src/main/java/com/sheepit/client/Log.java @@ -91,7 +91,7 @@ public class Log { int checkpointToWrite = (point_ > 0 ? point_ : this.lastCheckPoint); if (msg_.equals("") == false) { - line = this.dateFormat.format(new java.util.Date()) + " (" + level_ + ") " + msg_; + line = this.dateFormat.format(new Date()) + " (" + level_ + ") " + msg_; if (this.checkpoints.containsKey(checkpointToWrite) && this.checkpoints.get(checkpointToWrite) != null) { this.checkpoints.get(checkpointToWrite).add(line); } diff --git a/src/main/java/com/sheepit/client/Md5.java b/src/main/java/com/sheepit/client/Md5.java index ee731da..f2e6d09 100644 --- a/src/main/java/com/sheepit/client/Md5.java +++ b/src/main/java/com/sheepit/client/Md5.java @@ -50,8 +50,9 @@ public class Md5 { InputStream is = Files.newInputStream(Paths.get(path)); DigestInputStream dis = new DigestInputStream(is, md); byte[] buffer = new byte[8192]; - while (dis.read(buffer) > 0) - ; // process the entire file + while (dis.read(buffer) > 0) { + // process the entire file + } String data = Utils.convertBinaryToHex(md.digest()); dis.close(); is.close(); diff --git a/src/main/java/com/sheepit/client/Server.java b/src/main/java/com/sheepit/client/Server.java index c609687..d20a34b 100644 --- a/src/main/java/com/sheepit/client/Server.java +++ b/src/main/java/com/sheepit/client/Server.java @@ -314,7 +314,6 @@ public class Server extends Thread { public Job requestJob() throws SheepItException { this.log.debug("Server::requestJob"); - String url_contents = ""; try { OS os = OS.getOS(); @@ -404,7 +403,7 @@ public class Server extends Thread { jobData.getRenderTask().getUseGpu() == 1, jobData.getRenderTask().getRendererInfos().getCommandline(), validationUrl, jobData.getRenderTask().getScript(), jobData.getRenderTask().getChunks(), jobData.getRenderTask().getRendererInfos().getMd5(), jobData.getRenderTask().getName(), jobData.getRenderTask().getPassword(), - jobData.getRenderTask().getSynchronous_upload().equals("1"), jobData.getRenderTask().getRendererInfos().getUpdate_method()); + jobData.getRenderTask().getSynchronousUpload().equals("1"), jobData.getRenderTask().getRendererInfos().getUpdateMethod()); } catch (SheepItException e) { throw e; diff --git a/src/main/java/com/sheepit/client/SettingsLoader.java b/src/main/java/com/sheepit/client/SettingsLoader.java index ef4e750..993cb81 100644 --- a/src/main/java/com/sheepit/client/SettingsLoader.java +++ b/src/main/java/com/sheepit/client/SettingsLoader.java @@ -74,8 +74,7 @@ public class SettingsLoader { this.propertyName = prop; } - @Override - public String toString() { + @Override public String toString() { return propertyName; } @@ -476,8 +475,7 @@ public class SettingsLoader { if (config.getComputeMethod() == null && computeMethod == null) { config.setComputeMethod(ComputeType.CPU); } - else if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType - .valueOf(computeMethod.getValue()))) { + else if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType.valueOf(computeMethod.getValue()))) { if (config.getComputeMethod() == null) { config.setComputeMethod(ComputeType.valueOf(computeMethod.getValue())); } diff --git a/src/main/java/com/sheepit/client/Utils.java b/src/main/java/com/sheepit/client/Utils.java index 3071222..504eb62 100644 --- a/src/main/java/com/sheepit/client/Utils.java +++ b/src/main/java/com/sheepit/client/Utils.java @@ -25,8 +25,6 @@ import net.lingala.zip4j.io.inputstream.ZipInputStream; import net.lingala.zip4j.model.LocalFileHeader; import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -217,12 +215,10 @@ public class Utils { } if (file.isDirectory()) { String[] files = file.list(); - if (files != null) { - if (files.length != 0) { - for (String temp : files) { - File fileDelete = new File(file, temp); - delete(fileDelete); - } + if (files != null && files.length != 0) { + for (String temp : files) { + File fileDelete = new File(file, temp); + delete(fileDelete); } } } diff --git a/src/main/java/com/sheepit/client/datamodel/CacheFileMD5.java b/src/main/java/com/sheepit/client/datamodel/CacheFileMD5.java index 8cd91d6..5bb8fc6 100644 --- a/src/main/java/com/sheepit/client/datamodel/CacheFileMD5.java +++ b/src/main/java/com/sheepit/client/datamodel/CacheFileMD5.java @@ -11,6 +11,4 @@ import java.util.List; @ElementList(inline = true) private List md5s; - public CacheFileMD5() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/Chunk.java b/src/main/java/com/sheepit/client/datamodel/Chunk.java index 22d5588..28d2111 100644 --- a/src/main/java/com/sheepit/client/datamodel/Chunk.java +++ b/src/main/java/com/sheepit/client/datamodel/Chunk.java @@ -11,6 +11,4 @@ import org.simpleframework.xml.Root; @Attribute private String id; - public Chunk() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/FileMD5.java b/src/main/java/com/sheepit/client/datamodel/FileMD5.java index 7469e17..dcb7739 100644 --- a/src/main/java/com/sheepit/client/datamodel/FileMD5.java +++ b/src/main/java/com/sheepit/client/datamodel/FileMD5.java @@ -11,6 +11,4 @@ import org.simpleframework.xml.Root; @Attribute(required = false) private String action; - public FileMD5() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/HeartBeatInfos.java b/src/main/java/com/sheepit/client/datamodel/HeartBeatInfos.java index 950f135..4952ea8 100644 --- a/src/main/java/com/sheepit/client/datamodel/HeartBeatInfos.java +++ b/src/main/java/com/sheepit/client/datamodel/HeartBeatInfos.java @@ -1,10 +1,11 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "keepmealive") @ToString public class HeartBeatInfos { +@NoArgsConstructor @Root(strict = false, name = "keepmealive") @ToString public class HeartBeatInfos { @Attribute @Getter private int status; } diff --git a/src/main/java/com/sheepit/client/datamodel/JobInfos.java b/src/main/java/com/sheepit/client/datamodel/JobInfos.java index b4c879a..63dd63e 100644 --- a/src/main/java/com/sheepit/client/datamodel/JobInfos.java +++ b/src/main/java/com/sheepit/client/datamodel/JobInfos.java @@ -1,6 +1,7 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Element; @@ -9,7 +10,7 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "jobrequest") @ToString public class JobInfos { +@NoArgsConstructor @Root(strict = false, name = "jobrequest") @ToString public class JobInfos { @Attribute @Getter private int status; @@ -19,6 +20,4 @@ import java.util.List; @ElementList(name = "file", inline = true, required = false) @Getter private List fileMD5s; - public JobInfos() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/JobValidation.java b/src/main/java/com/sheepit/client/datamodel/JobValidation.java index 01749a5..f81ed4d 100644 --- a/src/main/java/com/sheepit/client/datamodel/JobValidation.java +++ b/src/main/java/com/sheepit/client/datamodel/JobValidation.java @@ -1,14 +1,13 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "jobvalidate") @ToString public class JobValidation { +@NoArgsConstructor @Root(strict = false, name = "jobvalidate") @ToString public class JobValidation { @Attribute @Getter private int status; - public JobValidation() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/RenderTask.java b/src/main/java/com/sheepit/client/datamodel/RenderTask.java index ce70286..9cee650 100644 --- a/src/main/java/com/sheepit/client/datamodel/RenderTask.java +++ b/src/main/java/com/sheepit/client/datamodel/RenderTask.java @@ -1,6 +1,7 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Element; @@ -9,11 +10,11 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "job") @Getter @ToString public class RenderTask { +@NoArgsConstructor @Root(strict = false, name = "job") @Getter @ToString public class RenderTask { @Attribute(name = "id") private String id; - @Attribute(name = "use_gpu") private int useGpu; + @Attribute(name = "use_gpu") private int useGpu; @ElementList(name = "chunks") private List chunks; @@ -21,7 +22,7 @@ import java.util.List; @Attribute(name = "frame") private String frame; - @Attribute(name = "synchronous_upload") private String synchronous_upload; + @Attribute(name = "synchronous_upload") private String synchronousUpload; @Attribute(name = "validation_url") private String validationUrl; @@ -33,7 +34,4 @@ import java.util.List; @Element(name = "script", data = true) private String script; - public RenderTask() { - - } } diff --git a/src/main/java/com/sheepit/client/datamodel/RendererInfos.java b/src/main/java/com/sheepit/client/datamodel/RendererInfos.java index c352a9b..6486c8e 100644 --- a/src/main/java/com/sheepit/client/datamodel/RendererInfos.java +++ b/src/main/java/com/sheepit/client/datamodel/RendererInfos.java @@ -1,19 +1,17 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "renderer") @ToString public class RendererInfos { +@NoArgsConstructor @Root(strict = false, name = "renderer") @ToString public class RendererInfos { @Attribute(name = "md5") @Getter private String md5; @Attribute(name = "commandline") @Getter private String commandline; - @Attribute(name = "update_method") @Getter private String update_method; + @Attribute(name = "update_method") @Getter private String updateMethod; - public RendererInfos() { - - } } diff --git a/src/main/java/com/sheepit/client/datamodel/RequestEndPoint.java b/src/main/java/com/sheepit/client/datamodel/RequestEndPoint.java index 6c51292..365dbd0 100644 --- a/src/main/java/com/sheepit/client/datamodel/RequestEndPoint.java +++ b/src/main/java/com/sheepit/client/datamodel/RequestEndPoint.java @@ -1,11 +1,12 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "request") @ToString public class RequestEndPoint { +@NoArgsConstructor @Root(strict = false, name = "request") @ToString public class RequestEndPoint { @Attribute @Getter private String type; @@ -13,6 +14,4 @@ import org.simpleframework.xml.Root; @Attribute(name = "max-period", required = false) @Getter private int maxPeriod; - public RequestEndPoint() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/ServerConfig.java b/src/main/java/com/sheepit/client/datamodel/ServerConfig.java index 1b63734..30502ea 100644 --- a/src/main/java/com/sheepit/client/datamodel/ServerConfig.java +++ b/src/main/java/com/sheepit/client/datamodel/ServerConfig.java @@ -1,6 +1,7 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.simpleframework.xml.Attribute; @@ -9,7 +10,7 @@ import org.simpleframework.xml.Root; import java.util.List; -@Root(strict = false, name = "config") @ToString public class ServerConfig { +@NoArgsConstructor @Root(strict = false, name = "config") @ToString public class ServerConfig { @Attribute @Getter private int status; @@ -17,11 +18,7 @@ import java.util.List; @ElementList(name = "request", inline = true, required = false) private List requestEndPoints; - @Getter @Setter - @ElementList(name = "speedtest", required = false) private List speedTestTargets; - - public ServerConfig() { - } + @Getter @Setter @ElementList(name = "speedtest", required = false) private List speedTestTargets; public RequestEndPoint getRequestEndPoint(String type) { if (requestEndPoints != null) { diff --git a/src/main/java/com/sheepit/client/datamodel/SessionStats.java b/src/main/java/com/sheepit/client/datamodel/SessionStats.java index 9bb7052..6690ee8 100644 --- a/src/main/java/com/sheepit/client/datamodel/SessionStats.java +++ b/src/main/java/com/sheepit/client/datamodel/SessionStats.java @@ -1,11 +1,12 @@ package com.sheepit.client.datamodel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Root; -@Root(strict = false, name = "stats") @ToString public class SessionStats { +@NoArgsConstructor @Root(strict = false, name = "stats") @ToString public class SessionStats { @Attribute(name = "credits_session") @Getter private int pointsEarnedOnSession; @@ -19,7 +20,4 @@ import org.simpleframework.xml.Root; @Attribute(name = "connected_machine") @Getter private int connectedMachines; - public SessionStats() { - - } } diff --git a/src/main/java/com/sheepit/client/datamodel/SpeedTestResult.java b/src/main/java/com/sheepit/client/datamodel/SpeedTestResult.java index 5c28ba3..318b14c 100644 --- a/src/main/java/com/sheepit/client/datamodel/SpeedTestResult.java +++ b/src/main/java/com/sheepit/client/datamodel/SpeedTestResult.java @@ -1,6 +1,5 @@ package com.sheepit.client.datamodel; - import lombok.Data; import lombok.ToString; import org.simpleframework.xml.ElementList; @@ -12,7 +11,5 @@ import java.util.List; @ElementList(inline = true) private List results; - public SpeedTestResult() { - } } diff --git a/src/main/java/com/sheepit/client/datamodel/SpeedTestTargetResult.java b/src/main/java/com/sheepit/client/datamodel/SpeedTestTargetResult.java index 09fb3cf..fb4d9c9 100644 --- a/src/main/java/com/sheepit/client/datamodel/SpeedTestTargetResult.java +++ b/src/main/java/com/sheepit/client/datamodel/SpeedTestTargetResult.java @@ -13,6 +13,4 @@ import org.simpleframework.xml.Root; @Attribute private Integer ping; - public SpeedTestTargetResult() { - } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItException.java b/src/main/java/com/sheepit/client/exception/SheepItException.java index 0fbc80e..4c82734 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItException.java +++ b/src/main/java/com/sheepit/client/exception/SheepItException.java @@ -24,7 +24,7 @@ public class SheepItException extends Exception { super(); } - public SheepItException(String message_) { - super(message_); + public SheepItException(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionBadResponseFromServer.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionBadResponseFromServer.java index 30a5793..52f36d2 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionBadResponseFromServer.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionBadResponseFromServer.java @@ -26,15 +26,15 @@ public class SheepItExceptionBadResponseFromServer extends SheepItExceptionWithR super(); } - public SheepItExceptionBadResponseFromServer(String message_) { - super(message_); + public SheepItExceptionBadResponseFromServer(String message) { + super(message); } - public String getHumanText() { + @Override public String getHumanText() { return "Bad answer from the server. Will try again at %tR"; } - public int getWaitDuration() { + @Override public int getWaitDuration() { return 1000 * 60 * ThreadLocalRandom.current().nextInt(15, 30 + 1); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRendererAvailable.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRendererAvailable.java index 953cffa..2cf3d25 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRendererAvailable.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRendererAvailable.java @@ -24,7 +24,7 @@ public class SheepItExceptionNoRendererAvailable extends SheepItException { super(); } - public SheepItExceptionNoRendererAvailable(String message_) { - super(message_); + public SheepItExceptionNoRendererAvailable(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRightToRender.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRightToRender.java index c79d56b..03039ff 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRightToRender.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoRightToRender.java @@ -24,7 +24,7 @@ public class SheepItExceptionNoRightToRender extends SheepItException { super(); } - public SheepItExceptionNoRightToRender(String message_) { - super(message_); + public SheepItExceptionNoRightToRender(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSession.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSession.java index a069fa7..26885f7 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSession.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSession.java @@ -24,7 +24,7 @@ public class SheepItExceptionNoSession extends SheepItException { super(); } - public SheepItExceptionNoSession(String message_) { - super(message_); + public SheepItExceptionNoSession(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSpaceLeftOnDevice.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSpaceLeftOnDevice.java index 3ef845c..e6994e6 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSpaceLeftOnDevice.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoSpaceLeftOnDevice.java @@ -24,7 +24,7 @@ public class SheepItExceptionNoSpaceLeftOnDevice extends SheepItException { super(); } - public SheepItExceptionNoSpaceLeftOnDevice(String message_) { - super(message_); + public SheepItExceptionNoSpaceLeftOnDevice(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoWritePermission.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoWritePermission.java index 9e751d1..6812472 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionNoWritePermission.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionNoWritePermission.java @@ -24,7 +24,7 @@ public class SheepItExceptionNoWritePermission extends SheepItException { super(); } - public SheepItExceptionNoWritePermission(String message_) { - super(message_); + public SheepItExceptionNoWritePermission(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionPathInvalid.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionPathInvalid.java index 60459dd..11720dc 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionPathInvalid.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionPathInvalid.java @@ -24,7 +24,7 @@ public class SheepItExceptionPathInvalid extends SheepItException { super(); } - public SheepItExceptionPathInvalid(String message_) { - super(message_); + public SheepItExceptionPathInvalid(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionServerInMaintenance.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionServerInMaintenance.java index faca6b6..b86dca5 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionServerInMaintenance.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionServerInMaintenance.java @@ -26,15 +26,15 @@ public class SheepItExceptionServerInMaintenance extends SheepItExceptionWithReq super(); } - public SheepItExceptionServerInMaintenance(String message_) { - super(message_); + public SheepItExceptionServerInMaintenance(String message) { + super(message); } - public String getHumanText() { + @Override public String getHumanText() { return "The server is under maintenance and cannot allocate a job. Will try again at %tR"; } - public int getWaitDuration() { + @Override public int getWaitDuration() { return 1000 * 60 * ThreadLocalRandom.current().nextInt(20, 30 + 1); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionServerOverloaded.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionServerOverloaded.java index 9260615..fe1b072 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionServerOverloaded.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionServerOverloaded.java @@ -26,15 +26,15 @@ public class SheepItExceptionServerOverloaded extends SheepItExceptionWithRequir super(); } - public SheepItExceptionServerOverloaded(String message_) { - super(message_); + public SheepItExceptionServerOverloaded(String message) { + super(message); } - public String getHumanText() { + @Override public String getHumanText() { return "The server is overloaded and cannot allocate a job. Will try again at %tR"; } - public int getWaitDuration() { + @Override public int getWaitDuration() { return 1000 * 60 * ThreadLocalRandom.current().nextInt(10, 30 + 1); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabled.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabled.java index e7eaad6..ad18996 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabled.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabled.java @@ -24,7 +24,7 @@ public class SheepItExceptionSessionDisabled extends SheepItException { super(); } - public SheepItExceptionSessionDisabled(String message_) { - super(message_); + public SheepItExceptionSessionDisabled(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabledDenoisingNotSupported.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabledDenoisingNotSupported.java index d75f271..3452fda 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabledDenoisingNotSupported.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionSessionDisabledDenoisingNotSupported.java @@ -24,7 +24,7 @@ public class SheepItExceptionSessionDisabledDenoisingNotSupported extends SheepI super(); } - public SheepItExceptionSessionDisabledDenoisingNotSupported(String message_) { - super(message_); + public SheepItExceptionSessionDisabledDenoisingNotSupported(String message) { + super(message); } } diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionWithRequiredWait.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionWithRequiredWait.java index 22f8b3f..48b41f1 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItExceptionWithRequiredWait.java +++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionWithRequiredWait.java @@ -28,8 +28,8 @@ public class SheepItExceptionWithRequiredWait extends SheepItException { super(); } - public SheepItExceptionWithRequiredWait(String message_) { - super(message_); + public SheepItExceptionWithRequiredWait(String message) { + super(message); } public String getHumanText() { diff --git a/src/main/java/com/sheepit/client/exception/SheepItServerDown.java b/src/main/java/com/sheepit/client/exception/SheepItServerDown.java index 42db027..0f25fc0 100644 --- a/src/main/java/com/sheepit/client/exception/SheepItServerDown.java +++ b/src/main/java/com/sheepit/client/exception/SheepItServerDown.java @@ -29,15 +29,15 @@ public class SheepItServerDown extends SheepItExceptionWithRequiredWait { super(); } - public SheepItServerDown(String message_) { - super(message_); + public SheepItServerDown(String message) { + super(message); } - public String getHumanText() { + @Override public String getHumanText() { return "Cannot connect to the server. Please check your connectivity. Will try again at %tR"; } - public int getWaitDuration() { + @Override public int getWaitDuration() { return 1000 * 60 * ThreadLocalRandom.current().nextInt(10, 30 + 1); } } diff --git a/src/main/java/com/sheepit/client/hardware/gpu/hip/HIP.java b/src/main/java/com/sheepit/client/hardware/gpu/hip/HIP.java index 97c5010..155e4a4 100644 --- a/src/main/java/com/sheepit/client/hardware/gpu/hip/HIP.java +++ b/src/main/java/com/sheepit/client/hardware/gpu/hip/HIP.java @@ -39,10 +39,10 @@ public class HIP { HIPLib hip = (HIPLib) Native.load(HIP_LIBRARY, HIPLib.class); HIP_DEVICES_CACHED = getNumberOfDevices(hip); } - catch (java.lang.UnsatisfiedLinkError e) { + catch (UnsatisfiedLinkError e) { System.out.println("HIP::getGpus failed(A) to load HIP lib (path: " + HIP_LIBRARY + ")"); } - catch (java.lang.ExceptionInInitializerError e) { + catch (ExceptionInInitializerError e) { System.out.println("HIP::getGpus failed(B) ExceptionInInitializerError " + e); } catch (Exception e) { diff --git a/src/main/java/com/sheepit/client/hardware/gpu/nvidia/NVML.java b/src/main/java/com/sheepit/client/hardware/gpu/nvidia/NVML.java index 0075c64..bf65afd 100644 --- a/src/main/java/com/sheepit/client/hardware/gpu/nvidia/NVML.java +++ b/src/main/java/com/sheepit/client/hardware/gpu/nvidia/NVML.java @@ -1,7 +1,6 @@ package com.sheepit.client.hardware.gpu.nvidia; import com.sun.jna.Library; -import com.sun.jna.ptr.IntByReference; //https://docs.nvidia.com/deploy/nvml-api/group__nvmlSystemQueries.html#group__nvmlSystemQueries diff --git a/src/main/java/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java b/src/main/java/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java index 83a3ecc..100dbe2 100644 --- a/src/main/java/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java +++ b/src/main/java/com/sheepit/client/hardware/gpu/nvidia/Nvidia.java @@ -8,7 +8,6 @@ import java.util.Map; import com.sheepit.client.hardware.gpu.GPUDevice; import com.sheepit.client.hardware.gpu.GPULister; import com.sheepit.client.os.OS; -import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; @@ -169,10 +168,10 @@ public class Nvidia implements GPULister { try { cudalib = (CUDA) Native.load(path, CUDA.class); } - catch (java.lang.UnsatisfiedLinkError e) { + catch (UnsatisfiedLinkError e) { return null; } - catch (java.lang.ExceptionInInitializerError e) { + catch (ExceptionInInitializerError e) { System.out.println("Nvidia::getGpus ExceptionInInitializerError " + e); return null; } @@ -220,8 +219,7 @@ public class Nvidia implements GPULister { IntByReference computeCapabilityMajor = new IntByReference(); result = cudalib.cuDeviceGetAttribute(computeCapabilityMajor, CUDeviceAttribute.CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, aDevice.getValue()); if (result != CUresult.CUDA_SUCCESS) { - System.out - .println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR failed (ret: " + CUresult.stringFor(result) + ")"); + System.out.println("Nvidia::getGpus cuDeviceGetAttribute for CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR failed (ret: " + CUresult.stringFor(result) + ")"); continue; } @@ -235,8 +233,7 @@ public class Nvidia implements GPULister { IntByReference pciDeviceId = new IntByReference(); 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()); @@ -246,8 +243,7 @@ public class Nvidia implements GPULister { } 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; } @@ -307,8 +303,7 @@ public class Nvidia implements GPULister { return null; } - String blenderId = String - .format("CUDA_%s_%04x:%02x:%02x_OptiX", new String(name).trim(), pciDomainId.getValue(), pciBusId.getValue(), pciDeviceId.getValue()); + String blenderId = String.format("CUDA_%s_%04x:%02x:%02x_OptiX", new String(name).trim(), pciDomainId.getValue(), pciBusId.getValue(), pciDeviceId.getValue()); GPUDevice gpu = new GPUDevice(TYPE, new String(name).trim(), ram.getValue(), blenderId); gpu.setDriverVersion(driverVersion); // for backward compatibility generate a CUDA_N id diff --git a/src/main/java/com/sheepit/client/hardware/hwid/impl/BaseHWInfoImpl.java b/src/main/java/com/sheepit/client/hardware/hwid/impl/BaseHWInfoImpl.java index 10c42db..7a8b304 100644 --- a/src/main/java/com/sheepit/client/hardware/hwid/impl/BaseHWInfoImpl.java +++ b/src/main/java/com/sheepit/client/hardware/hwid/impl/BaseHWInfoImpl.java @@ -21,8 +21,7 @@ public class BaseHWInfoImpl implements BasicHWInfoStrategy { hardware = new SystemInfo().getHardware(); } - @Override - public Optional getMAC() { + @Override public Optional getMAC() { List macs = new ArrayList<>(); List nics = hardware.getNetworkIFs(); for (NetworkIF nic : nics) { @@ -32,8 +31,7 @@ public class BaseHWInfoImpl implements BasicHWInfoStrategy { return Optional.of(String.join(" ", macs)); } - @Override - public Optional getProcessorName() { + @Override public Optional getProcessorName() { return Optional.of(hardware.getProcessor().getProcessorIdentifier().getName()); } diff --git a/src/main/java/com/sheepit/client/os/Linux.java b/src/main/java/com/sheepit/client/os/Linux.java index 9abae53..6ab8337 100644 --- a/src/main/java/com/sheepit/client/os/Linux.java +++ b/src/main/java/com/sheepit/client/os/Linux.java @@ -33,10 +33,6 @@ public class Linux extends OS { private final String NICE_BINARY_PATH = "nice"; private final String ID_COMMAND_INVOCATION = "id -u"; - public Linux() { - super(); - } - @Override public String name() { return "linux"; } @@ -55,7 +51,7 @@ public class Linux extends OS { @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 + new_env.putAll(System.getenv()); // clone the env // if Blender is already loading an OpenGL library, don't need to load Blender's default one (it will // create system incompatibilities). If no OpenGL library is found, then load the one included in the binary @@ -200,7 +196,7 @@ public class Linux extends OS { try { // Shutdown the computer waiting delayInMinutes minutes to allow all SheepIt threads to close and exit the app ProcessBuilder builder = new ProcessBuilder("shutdown", "-h", String.valueOf(delayInMinutes)); - Process process = builder.inheritIO().start(); + builder.inheritIO().start(); } catch (IOException e) { System.err.println(String.format("Linux::shutdownComputer Unable to execute the 'shutdown -h 1' command. Exception %s", e.getMessage())); diff --git a/src/main/java/com/sheepit/client/os/Mac.java b/src/main/java/com/sheepit/client/os/Mac.java index 63e9a15..efa49e8 100644 --- a/src/main/java/com/sheepit/client/os/Mac.java +++ b/src/main/java/com/sheepit/client/os/Mac.java @@ -32,10 +32,6 @@ public class Mac extends OS { private final String NICE_BINARY_PATH = "nice"; private final String ID_COMMAND_INVOCATION = "id -u"; - public Mac() { - super(); - } - @Override public String name() { return "mac"; } @@ -128,7 +124,7 @@ public class Mac extends OS { try { // Shutdown the computer waiting delayInMinutes minutes to allow all SheepIt threads to close and exit the app ProcessBuilder builder = new ProcessBuilder("shutdown", "-h", String.valueOf(delayInMinutes)); - Process process = builder.inheritIO().start(); + builder.inheritIO().start(); } catch (IOException e) { System.err.println(String.format("Mac::shutdownComputer Unable to execute the 'shutdown -h 1' command. Exception %s", e.getMessage())); diff --git a/src/main/java/com/sheepit/client/os/OS.java b/src/main/java/com/sheepit/client/os/OS.java index fc4e0ac..c9e9974 100644 --- a/src/main/java/com/sheepit/client/os/OS.java +++ b/src/main/java/com/sheepit/client/os/OS.java @@ -153,7 +153,7 @@ public abstract class OS { if (proc.isAlive() == false) { return true; } - java.lang.Thread.sleep(100); + Thread.sleep(100); } proc.destroyForcibly(); diff --git a/src/main/java/com/sheepit/client/os/Windows.java b/src/main/java/com/sheepit/client/os/Windows.java index fdb01d7..027f0d1 100644 --- a/src/main/java/com/sheepit/client/os/Windows.java +++ b/src/main/java/com/sheepit/client/os/Windows.java @@ -53,10 +53,10 @@ public class Windows extends OS { kernel32lib = (Kernel32Lib) Native.load(Kernel32Lib.path, Kernel32Lib.class); kernel32lib.SetErrorMode(Kernel32Lib.SEM_NOGPFAULTERRORBOX); } - catch (java.lang.UnsatisfiedLinkError e) { + catch (UnsatisfiedLinkError e) { System.out.println("OS.Windows::exec failed to load kernel32lib " + e); } - catch (java.lang.ExceptionInInitializerError e) { + catch (ExceptionInInitializerError e) { System.out.println("OS.Windows::exec failed to load kernel32lib " + e); } catch (Exception e) { @@ -192,7 +192,7 @@ public class Windows extends OS { try { // Shutdown the computer, waiting delayInMinutes minutes, force app closure and on the shutdown screen indicate that was initiated by SheepIt app ProcessBuilder builder = new ProcessBuilder("shutdown", "/s", "/f", "/t", String.valueOf(delayInMinutes * 60), "/c", "\"SheepIt App has initiated this computer shutdown.\""); - Process process = builder.inheritIO().start(); + builder.inheritIO().start(); } catch (IOException e) { System.err.println( diff --git a/src/main/java/com/sheepit/client/os/windows/WinProcess.java b/src/main/java/com/sheepit/client/os/windows/WinProcess.java index 36c6123..d7758e7 100644 --- a/src/main/java/com/sheepit/client/os/windows/WinProcess.java +++ b/src/main/java/com/sheepit/client/os/windows/WinProcess.java @@ -51,10 +51,10 @@ public class WinProcess { try { this.kernel32lib = (Kernel32Lib) Native.load(Kernel32Lib.path, Kernel32Lib.class); } - catch (java.lang.UnsatisfiedLinkError e) { + catch (UnsatisfiedLinkError e) { System.out.println("WinProcess::construct " + e); } - catch (java.lang.ExceptionInInitializerError e) { + catch (ExceptionInInitializerError e) { System.out.println("WinProcess::construct " + e); } catch (Exception e) { diff --git a/src/main/java/com/sheepit/client/standalone/GuiSwing.java b/src/main/java/com/sheepit/client/standalone/GuiSwing.java index 8fc410e..be131ba 100644 --- a/src/main/java/com/sheepit/client/standalone/GuiSwing.java +++ b/src/main/java/com/sheepit/client/standalone/GuiSwing.java @@ -136,7 +136,6 @@ public class GuiSwing extends JFrame implements Gui { private DownloadProgress downloadProgress; private BufferedImage iconSprites; - private BufferedImage[] trayIconSprites; @Getter @Setter private SettingsLoader settingsLoader; @@ -183,7 +182,6 @@ public class GuiSwing extends JFrame implements Gui { 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 } @@ -483,12 +481,10 @@ public class GuiSwing extends JFrame implements Gui { 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 - } + if (sysTray != null && SystemTray.isSupported() && trayIcon != null) { + trayIcon.setImage(img); + trayIcon.setImageAutoSize(true); // use this method to ensure that icon is refreshed when on + // the tray } } diff --git a/src/main/java/com/sheepit/client/standalone/GuiTextOneLine.java b/src/main/java/com/sheepit/client/standalone/GuiTextOneLine.java index ef69ea7..37b80d8 100644 --- a/src/main/java/com/sheepit/client/standalone/GuiTextOneLine.java +++ b/src/main/java/com/sheepit/client/standalone/GuiTextOneLine.java @@ -40,7 +40,6 @@ public class GuiTextOneLine implements Gui { private String project; private int rendered; - private int remaining; private String creditsEarned; private int sigIntCount = 0; private DateFormat df; @@ -62,7 +61,6 @@ public class GuiTextOneLine implements Gui { downloadProgress = new DownloadProgress(this); project = ""; rendered = 0; - remaining = 0; creditsEarned = null; status = ""; computeMethod = ""; @@ -162,7 +160,6 @@ public class GuiTextOneLine implements Gui { } @Override public void displayStats(Stats stats) { - remaining = stats.getRemainingFrame(); creditsEarned = String.valueOf(stats.getCreditsEarnedDuringSession()); updateLine(); } diff --git a/src/main/java/com/sheepit/client/standalone/VersionParameterHandler.java b/src/main/java/com/sheepit/client/standalone/VersionParameterHandler.java index 5c123b1..6f44a8f 100644 --- a/src/main/java/com/sheepit/client/standalone/VersionParameterHandler.java +++ b/src/main/java/com/sheepit/client/standalone/VersionParameterHandler.java @@ -34,7 +34,6 @@ public class VersionParameterHandler extends OptionHandler { } @Override public int parseArguments(Parameters params) throws CmdLineException { - Configuration config = new Configuration(null, "", ""); System.out.println("Version: " + Configuration.jarVersion); System.exit(0); return 0; diff --git a/src/main/java/com/sheepit/client/standalone/Worker.java b/src/main/java/com/sheepit/client/standalone/Worker.java index 985ed43..77e6c29 100644 --- a/src/main/java/com/sheepit/client/standalone/Worker.java +++ b/src/main/java/com/sheepit/client/standalone/Worker.java @@ -276,7 +276,7 @@ public class Worker { try { config.setMaxAllowedMemory(Utils.parseNumber(max_ram) / 1024); // internal value is in KiB } - catch (java.lang.IllegalStateException e) { + catch (IllegalStateException e) { System.err.println( String.format("ERROR: The entered value of maximum memory (-memory parameter) doesn't seem to be a valid number [%s]", e.getMessage())); return; diff --git a/src/main/java/com/sheepit/client/standalone/swing/activity/Settings.java b/src/main/java/com/sheepit/client/standalone/swing/activity/Settings.java index 8e3bcac..2d8147d 100644 --- a/src/main/java/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/main/java/com/sheepit/client/standalone/swing/activity/Settings.java @@ -62,8 +62,6 @@ import com.sheepit.client.Configuration.ComputeType; import com.sheepit.client.hardware.cpu.CPU; import com.sheepit.client.hardware.gpu.GPU; import com.sheepit.client.hardware.gpu.GPUDevice; -import com.sheepit.client.hardware.gpu.GPULister; -import com.sheepit.client.hardware.gpu.nvidia.Nvidia; import com.sheepit.client.network.Proxy; import com.sheepit.client.os.OS; import com.sheepit.client.standalone.GuiSwing; @@ -632,25 +630,16 @@ public class Settings implements Activity { class GpuChangeAction implements ActionListener { @Override public void actionPerformed(ActionEvent e) { - int counter = 0; for (JCheckBox box : useGPUs) { if (!box.isSelected()) { box.setSelected(false); } - else { - GPULister gpu; - if (useGPUs.get(counter).getGPUDevice().getType().equals(Nvidia.TYPE)) { - gpu = new Nvidia(); - } - } // Simulate a radio button behavior with check buttons while only 1 GPU // can be selected at a time if (box.equals(e.getSource()) == false) { box.setSelected(false); } - - counter++; } checkDisplaySaveButton(); } diff --git a/src/main/java/com/sheepit/client/standalone/swing/activity/Working.java b/src/main/java/com/sheepit/client/standalone/swing/activity/Working.java index 2f52aca..0d405ca 100644 --- a/src/main/java/com/sheepit/client/standalone/swing/activity/Working.java +++ b/src/main/java/com/sheepit/client/standalone/swing/activity/Working.java @@ -20,7 +20,6 @@ package com.sheepit.client.standalone.swing.activity; import java.awt.Component; -import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; @@ -31,7 +30,6 @@ import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.awt.Image; import java.io.File; -import java.io.IOException; import java.text.DecimalFormat; import java.util.Date; import java.util.Objects; @@ -46,8 +44,6 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.UIManager; -import javax.swing.Spring; -import javax.swing.SpringLayout; import com.sheepit.client.Client; import com.sheepit.client.Job; @@ -370,10 +366,8 @@ public class Working implements Activity { if (this.exitAfterFrame.getText().startsWith("Cancel")) { Client client = parent.getClient(); - if (client != null) { - if (client.isRunning()) { - queueSize++; - } + if (client != null && client.isRunning()) { + queueSize++; } exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", queueSize, (queueSize > 1 ? "s" : ""))); @@ -457,64 +451,6 @@ public class Working implements Activity { } - private void alignPanel(Container parent, int rows, int cols, Spring width) { - SpringLayout layout; - try { - layout = (SpringLayout) parent.getLayout(); - } - catch (ClassCastException exc) { - System.err.println("The first argument to makeCompactGrid must use SpringLayout."); - return; - } - - Spring x = Spring.constant(0); - for (int c = 0; c < cols; c++) { - for (int r = 0; r < rows; r++) { - SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols); - constraints.setX(x); - constraints.setWidth(width); - } - x = Spring.sum(x, width); - } - - Spring y = Spring.constant(0); - for (int r = 0; r < rows; r++) { - Spring height = Spring.constant(0); - for (int c = 0; c < cols; c++) { - height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight()); - } - for (int c = 0; c < cols; c++) { - SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols); - constraints.setY(y); - constraints.setHeight(height); - } - y = Spring.sum(y, height); - } - - SpringLayout.Constraints pCons = layout.getConstraints(parent); - pCons.setConstraint(SpringLayout.SOUTH, y); - pCons.setConstraint(SpringLayout.EAST, x); - - } - - private Spring getBestWidth(Container parent, int rows, int cols) { - Spring x = Spring.constant(0); - Spring width = Spring.constant(0); - for (int c = 0; c < cols; c++) { - - for (int r = 0; r < rows; r++) { - width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth()); - } - } - return width; - } - - private SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) { - SpringLayout layout = (SpringLayout) parent.getLayout(); - Component c = parent.getComponent(row * cols + col); - return layout.getConstraints(c); - } - private int getJobsQueueSize(Client client) { return client.getUploadQueueSize() + (client.getRenderingJob() != null ? 1 : 0); }