Merge branch 'fix/park-client-on-cachedir-deleted' into 'master'
Fix/park client on cachedir deleted See merge request sheepitrenderfarm/client!362
This commit is contained in:
@@ -54,7 +54,11 @@
|
|||||||
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
|
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
|
||||||
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
|
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
|
||||||
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
|
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
|
||||||
<rule ref="category/java/design.xml/ExcessivePublicCount" />
|
<rule ref="category/java/design.xml/ExcessivePublicCount">
|
||||||
|
<properties>
|
||||||
|
<property name="minimum" value="75" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
<rule ref="category/java/design.xml/InvalidJavaBean" />
|
<rule ref="category/java/design.xml/InvalidJavaBean" />
|
||||||
<rule ref="category/java/design.xml/LogicInversion" />
|
<rule ref="category/java/design.xml/LogicInversion" />
|
||||||
<rule ref="category/java/design.xml/SimplifiedTernary" />
|
<rule ref="category/java/design.xml/SimplifiedTernary" />
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.sheepit.client.datamodel.client.Error.ServerCode;
|
|||||||
import com.sheepit.client.datamodel.client.Error.Type;
|
import com.sheepit.client.datamodel.client.Error.Type;
|
||||||
import com.sheepit.client.datamodel.server.Chunk;
|
import com.sheepit.client.datamodel.server.Chunk;
|
||||||
import com.sheepit.client.exception.SheepItException;
|
import com.sheepit.client.exception.SheepItException;
|
||||||
|
import com.sheepit.client.exception.SheepItExceptionCacheDirDeleted;
|
||||||
import com.sheepit.client.exception.SheepItExceptionNoRendererAvailable;
|
import com.sheepit.client.exception.SheepItExceptionNoRendererAvailable;
|
||||||
import com.sheepit.client.exception.SheepItExceptionNoRightToRender;
|
import com.sheepit.client.exception.SheepItExceptionNoRightToRender;
|
||||||
import com.sheepit.client.exception.SheepItExceptionNoSession;
|
import com.sheepit.client.exception.SheepItExceptionNoSession;
|
||||||
@@ -770,6 +771,9 @@ import okhttp3.HttpUrl;
|
|||||||
else if (e instanceof SheepItExceptionNoWritePermission) {
|
else if (e instanceof SheepItExceptionNoWritePermission) {
|
||||||
return Error.Type.NO_WRITE_PERMISSION;
|
return Error.Type.NO_WRITE_PERMISSION;
|
||||||
}
|
}
|
||||||
|
else if (e instanceof SheepItExceptionCacheDirDeleted) {
|
||||||
|
return Type.CACHE_DIR_DELETED;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return Error.Type.UNKNOWN;
|
return Error.Type.UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -838,6 +842,7 @@ import okhttp3.HttpUrl;
|
|||||||
this.serverRequest,
|
this.serverRequest,
|
||||||
this.gui,
|
this.gui,
|
||||||
this.log,
|
this.log,
|
||||||
|
this.directoryManager,
|
||||||
this.directoryManager.getActualStoragePathFor(chunk),
|
this.directoryManager.getActualStoragePathFor(chunk),
|
||||||
chunk.getMd5(),
|
chunk.getMd5(),
|
||||||
String.format(LOCALE, "%s?chunk=%s", this.serverRequest.getPage("download-chunk"), chunk.getId())
|
String.format(LOCALE, "%s?chunk=%s", this.serverRequest.getPage("download-chunk"), chunk.getId())
|
||||||
@@ -858,14 +863,21 @@ import okhttp3.HttpUrl;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ExecutionException | InterruptedException | TimeoutException e) {
|
catch (ExecutionException e) {
|
||||||
|
if (e.getCause() instanceof SheepItException) {
|
||||||
executor.shutdown();
|
throw (SheepItException)e.getCause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log.error("downloadChunks failed " + e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InterruptedException | TimeoutException e) {
|
||||||
return Type.DOWNLOAD_FILE;
|
return Type.DOWNLOAD_FILE;
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
return Type.OK;
|
return Type.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class Error {
|
|||||||
CANNOT_READ_FILE(30),
|
CANNOT_READ_FILE(30),
|
||||||
DETECT_DEVICE_ERROR(31),
|
DETECT_DEVICE_ERROR(31),
|
||||||
COLOR_MANAGEMENT_ERROR(33),
|
COLOR_MANAGEMENT_ERROR(33),
|
||||||
|
CACHE_DIR_DELETED(35),
|
||||||
|
|
||||||
// internal error handling
|
// internal error handling
|
||||||
NO_SPACE_LEFT_ON_DEVICE(100),
|
NO_SPACE_LEFT_ON_DEVICE(100),
|
||||||
@@ -206,7 +207,7 @@ public class Error {
|
|||||||
case RENDERER_KILLED_BY_USER_INCOMPATIBLE_PROCESS:
|
case RENDERER_KILLED_BY_USER_INCOMPATIBLE_PROCESS:
|
||||||
return "Stopped rendering: The incompatible user-specified process is running.";
|
return "Stopped rendering: The incompatible user-specified process is running.";
|
||||||
case SESSION_DISABLED:
|
case SESSION_DISABLED:
|
||||||
return "The server has disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc).";
|
return "The server has disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc) or your cache directory is not longer available.";
|
||||||
case RENDERER_NOT_AVAILABLE:
|
case RENDERER_NOT_AVAILABLE:
|
||||||
return "The official Blender builds don't support rendering on this hardware.";
|
return "The official Blender builds don't support rendering on this hardware.";
|
||||||
case MISSING_RENDERER:
|
case MISSING_RENDERER:
|
||||||
@@ -237,6 +238,8 @@ public class Error {
|
|||||||
return "There was an error with your GPU or driver. Please ensure you have the latest driver and don't run extreme over/underclockings.";
|
return "There was an error with your GPU or driver. Please ensure you have the latest driver and don't run extreme over/underclockings.";
|
||||||
case COLOR_MANAGEMENT_ERROR:
|
case COLOR_MANAGEMENT_ERROR:
|
||||||
return "There was an error with the Color management. Please ensure you didn't set a weird OCIO config. Or the project might use an unsupported Color management configuration.";
|
return "There was an error with the Color management. Please ensure you didn't set a weird OCIO config. Or the project might use an unsupported Color management configuration.";
|
||||||
|
case CACHE_DIR_DELETED:
|
||||||
|
return "Cache directory is missing, the client is now DEAD";
|
||||||
default:
|
default:
|
||||||
return in.toString();
|
return in.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Laurent CLOUET
|
||||||
|
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sheepit.client.exception;
|
||||||
|
|
||||||
|
public class SheepItExceptionCacheDirDeleted extends SheepItException {
|
||||||
|
public SheepItExceptionCacheDirDeleted() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SheepItExceptionCacheDirDeleted(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,11 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.sheepit.client.network;
|
package com.sheepit.client.network;
|
||||||
|
|
||||||
|
import com.sheepit.client.config.DirectoryManager;
|
||||||
import com.sheepit.client.datamodel.client.Error;
|
import com.sheepit.client.datamodel.client.Error;
|
||||||
|
import com.sheepit.client.exception.SheepItExceptionCacheDirDeleted;
|
||||||
import com.sheepit.client.ui.Gui;
|
import com.sheepit.client.ui.Gui;
|
||||||
import com.sheepit.client.logger.Log;
|
import com.sheepit.client.logger.Log;
|
||||||
import com.sheepit.client.utils.Utils;
|
import com.sheepit.client.utils.Utils;
|
||||||
import com.sheepit.client.exception.SheepItException;
|
import com.sheepit.client.exception.SheepItException;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -33,28 +36,20 @@ import java.nio.file.Path;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class DownloadManager {
|
@AllArgsConstructor public class DownloadManager {
|
||||||
private static int maxDownloadFileAttempts = 5;
|
private static int maxDownloadFileAttempts = 5;
|
||||||
|
|
||||||
// global objects
|
// global objects
|
||||||
private ServerRequest serverRequest;
|
private ServerRequest serverRequest;
|
||||||
private Gui gui;
|
private Gui gui;
|
||||||
private Log log;
|
private Log log;
|
||||||
|
private DirectoryManager directoryManager;
|
||||||
|
|
||||||
// task specific objects
|
// task specific objects
|
||||||
private String local_target;
|
private String local_target;
|
||||||
private String md5; // expected md5 of the file, for check purpose
|
private String md5; // expected md5 of the file, for check purpose
|
||||||
private String remote; // remote url
|
private String remote; // remote url
|
||||||
|
|
||||||
public DownloadManager(ServerRequest serverRequest, Gui gui, Log log, String local_target, String md5, String remote) {
|
|
||||||
this.serverRequest = serverRequest;
|
|
||||||
this.gui = gui;
|
|
||||||
this.log = log;
|
|
||||||
this.local_target = local_target;
|
|
||||||
this.md5 = md5;
|
|
||||||
this.remote = remote;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Error.Type download() throws SheepItException {
|
public Error.Type download() throws SheepItException {
|
||||||
File local_path_file = new File(this.local_target);
|
File local_path_file = new File(this.local_target);
|
||||||
|
|
||||||
@@ -175,7 +170,7 @@ public class DownloadManager {
|
|||||||
return new File(this.local_target + ".partial").exists();
|
return new File(this.local_target + ".partial").exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLock() {
|
private void createLock() throws SheepItExceptionCacheDirDeleted {
|
||||||
try {
|
try {
|
||||||
File file = new File(this.local_target + ".partial");
|
File file = new File(this.local_target + ".partial");
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
@@ -193,6 +188,16 @@ public class DownloadManager {
|
|||||||
this.log.error("DownloadManager::createLock checking path info " + test_path + " exists? " + (new File(test_path).exists() ? "yes" : "no") + " is writeable? " + (Files.isWritable(Path.of(test_path)) ? "yes" : "no"));
|
this.log.error("DownloadManager::createLock checking path info " + test_path + " exists? " + (new File(test_path).exists() ? "yes" : "no") + " is writeable? " + (Files.isWritable(Path.of(test_path)) ? "yes" : "no"));
|
||||||
current_path = test_path;
|
current_path = test_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File cache_dir = new File(this.local_target).getParentFile();
|
||||||
|
if (cache_dir.exists() == false) {
|
||||||
|
this.log.error("DownloadManager::createLock cache-dir has been deleted, it should not happen, park the client");
|
||||||
|
// it shouldn't happen, the client need a cache dir
|
||||||
|
|
||||||
|
// 2 solutions: re-create the cache dir or park the client.
|
||||||
|
// we don't know why the cache dir was deleted so -> park the client
|
||||||
|
throw new SheepItExceptionCacheDirDeleted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user