Ref: Use Lombok annot's to minimize code.

This commit is contained in:
DaCool
2023-10-16 18:05:29 +00:00
committed by Sheepit Renderfarm
parent e0991622bf
commit dd0d50582f
4 changed files with 9 additions and 39 deletions

View File

@@ -659,7 +659,7 @@ import okhttp3.HttpUrl;
StringBuilder logHeader = new StringBuilder() StringBuilder logHeader = new StringBuilder()
.append("====================================================================================================\n") .append("====================================================================================================\n")
.append(String.format("%s / %s / %s / SheepIt v%s\n", conf.getLogin(), conf.getHostname(), OS.getOS().name(), Configuration.jarVersion)) .append(String.format("%s / %s / %s / SheepIt v%s\n", conf.getLogin(), conf.getHostname(), OS.getOS().name(), Configuration.jarVersion))
.append(String.format("%s x%d %.1f GB RAM\n", cpu.name(), conf.getNbCores(), conf.getMaxAllowedMemory() / 1024.0 / 1024.0)); .append(String.format("%s x%d %.1f GB RAM\n", cpu.getName(), conf.getNbCores(), conf.getMaxAllowedMemory() / 1024.0 / 1024.0));
if (conf.getComputeMethod() == Configuration.ComputeType.GPU || conf.getComputeMethod() == Configuration.ComputeType.CPU_GPU) { if (conf.getComputeMethod() == Configuration.ComputeType.GPU || conf.getComputeMethod() == Configuration.ComputeType.CPU_GPU) {
logHeader.append(String.format("%s %s %.1f GB VRAM\n", conf.getGPUDevice().getId(), conf.getGPUDevice().getModel(), logHeader.append(String.format("%s %s %.1f GB VRAM\n", conf.getGPUDevice().getId(), conf.getGPUDevice().getModel(),

View File

@@ -203,14 +203,14 @@ public class Server extends Thread {
FormBody formBody = new FormBody.Builder() FormBody formBody = new FormBody.Builder()
.add("login", user_config.getLogin()) .add("login", user_config.getLogin())
.add("password", user_config.getPassword()) .add("password", user_config.getPassword())
.add("cpu_family", os.getCPU().family()) .add("cpu_family", os.getCPU().getFamily())
.add("cpu_model", os.getCPU().model()) .add("cpu_model", os.getCPU().getModel())
.add("cpu_model_name", os.getCPU().name()) .add("cpu_model_name", os.getCPU().getName())
.add("cpu_cores", String.valueOf(user_config.getNbCores() == -1 ? os.getCPU().cores() : Math.max(CPU.MIN_CORES, user_config.getNbCores()))) .add("cpu_cores", String.valueOf(user_config.getNbCores() == -1 ? os.getCPU().cores() : Math.max(CPU.MIN_CORES, user_config.getNbCores())))
.add("os", os.name()) .add("os", os.name())
.add("os_version", os.getVersion()) .add("os_version", os.getVersion())
.add("ram", String.valueOf(os.getTotalMemory())) .add("ram", String.valueOf(os.getTotalMemory()))
.add("bits", os.getCPU().arch()) .add("bits", os.getCPU().getArch())
.add("version", Configuration.jarVersion) .add("version", Configuration.jarVersion)
.add("hostname", user_config.getHostname()) .add("hostname", user_config.getHostname())
.add("ui", client.getGui().getClass().getSimpleName()) .add("ui", client.getGui().getClass().getSimpleName())

View File

@@ -22,12 +22,14 @@ package com.sheepit.client.hardware.cpu;
import com.sheepit.client.Log; import com.sheepit.client.Log;
import com.sheepit.client.os.OS; import com.sheepit.client.os.OS;
import com.sheepit.client.os.Windows; import com.sheepit.client.os.Windows;
import lombok.Getter;
import lombok.Setter;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
public class CPU { @Getter @Setter public class CPU {
public static final int MIN_CORES = Runtime.getRuntime().availableProcessors() > 1 ? 2 : 1; public static final int MIN_CORES = Runtime.getRuntime().availableProcessors() > 1 ? 2 : 1;
private String name; private String name;
private String model; private String model;
@@ -43,22 +45,6 @@ public class CPU {
this.generateArch(); this.generateArch();
} }
public String name() {
return this.name;
}
public String model() {
return this.model;
}
public String family() {
return this.family;
}
public String arch() {
return this.arch;
}
public int cores() { public int cores() {
// If logicalCores is -1, then haven't run the core-checking script yet // If logicalCores is -1, then haven't run the core-checking script yet
// Only want to run it once since cores is called multiple times // Only want to run it once since cores is called multiple times
@@ -113,22 +99,6 @@ public class CPU {
return logicalCores; return logicalCores;
} }
public void setName(String name_) {
this.name = name_;
}
public void setModel(String model_) {
this.model = model_;
}
public void setFamily(String family_) {
this.family = family_;
}
public void setArch(String arch_) {
this.arch = arch_;
}
public void generateArch() { public void generateArch() {
String arch = System.getProperty("os.arch").toLowerCase(); String arch = System.getProperty("os.arch").toLowerCase();
switch (arch) { switch (arch) {

View File

@@ -40,7 +40,7 @@ public abstract class OS {
public abstract String name(); public abstract String name();
public boolean isSupported() { return "64bit".equals(getCPU().arch()); } public boolean isSupported() { return "64bit".equals(getCPU().getArch()); }
/** Get the full version of the os. /** Get the full version of the os.
* For example windows, should give "windows 8.1" * For example windows, should give "windows 8.1"