diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 9597fe0..d0bf1e3 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -35,6 +35,7 @@ import com.sheepit.client.Error.Type; import com.sheepit.client.exception.FermeException; import com.sheepit.client.exception.FermeExceptionNoRightToRender; import com.sheepit.client.exception.FermeExceptionNoSession; +import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice; import com.sheepit.client.exception.FermeExceptionServerInMaintenance; import com.sheepit.client.exception.FermeExceptionServerOverloaded; import com.sheepit.client.exception.FermeExceptionSessionDisabled; @@ -284,6 +285,15 @@ public class Client { continue; } + if (ret == Error.Type.NO_SPACE_LEFT_ON_DEVICE) { + Job frame_to_reset = 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.log.removeCheckPoint(step); + return -50; + } + if (ret != Error.Type.OK) { Job frame_to_reset = this.renderingJob; // copy it because the sendError will take ~5min to execute this.renderingJob = null; @@ -522,22 +532,27 @@ public class Client { public Error.Type work(Job ajob) { int ret; - ret = this.downloadExecutable(ajob); - if (ret != 0) { - this.log.error("Client::work problem with downloadExecutable (ret " + ret + ")"); - return Error.Type.DOWNLOAD_FILE; + try { + ret = this.downloadExecutable(ajob); + if (ret != 0) { + this.log.error("Client::work problem with downloadExecutable (ret " + ret + ")"); + return Error.Type.DOWNLOAD_FILE; + } + + ret = this.downloadSceneFile(ajob); + if (ret != 0) { + this.log.error("Client::work problem with downloadSceneFile (ret " + ret + ")"); + return Error.Type.DOWNLOAD_FILE; + } + + ret = this.prepareWorkingDirectory(ajob); // decompress renderer and scene archives + if (ret != 0) { + this.log.error("Client::work problem with this.prepareWorkingDirectory (ret " + ret + ")"); + return Error.Type.CAN_NOT_CREATE_DIRECTORY; + } } - - ret = this.downloadSceneFile(ajob); - if (ret != 0) { - this.log.error("Client::work problem with downloadSceneFile (ret " + ret + ")"); - return Error.Type.DOWNLOAD_FILE; - } - - ret = this.prepareWorkingDirectory(ajob); // decompress renderer and scene archives - if (ret != 0) { - this.log.error("Client::work problem with this.prepareWorkingDirectory (ret " + ret + ")"); - return Error.Type.CAN_NOT_CREATE_DIRECTORY; + catch (FermeExceptionNoSpaceLeftOnDevice e) { + return Error.Type.NO_SPACE_LEFT_ON_DEVICE; } File scene_file = new File(ajob.getScenePath()); @@ -631,7 +646,7 @@ public class Client { return true; } - protected int prepareWorkingDirectory(Job ajob) { + protected int prepareWorkingDirectory(Job ajob) throws FermeExceptionNoSpaceLeftOnDevice { int ret; String renderer_archive = ajob.getRendererArchivePath(); String renderer_path = ajob.getRendererDirectory(); diff --git a/src/com/sheepit/client/Error.java b/src/com/sheepit/client/Error.java old mode 100755 new mode 100644 index 474711d..7a11c91 --- a/src/com/sheepit/client/Error.java +++ b/src/com/sheepit/client/Error.java @@ -44,7 +44,10 @@ public class Error { FAILED_TO_EXECUTE(16), OS_NOT_SUPPORTED(17), CPU_NOT_SUPPORTED(18), - GPU_NOT_SUPPORTED(19); + GPU_NOT_SUPPORTED(19), + + NO_SPACE_LEFT_ON_DEVICE(100), + ; private final int id; @@ -166,6 +169,8 @@ public class Error { return "Operating System not supported."; case CPU_NOT_SUPPORTED: return "CPU not supported."; + case NO_SPACE_LEFT_ON_DEVICE: + return "No space left on hard disk"; default: return in.toString(); } diff --git a/src/com/sheepit/client/Utils.java b/src/com/sheepit/client/Utils.java index 9ca63de..1a03efa 100644 --- a/src/com/sheepit/client/Utils.java +++ b/src/com/sheepit/client/Utils.java @@ -44,9 +44,10 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import com.sheepit.client.Error.ServerCode; +import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice; public class Utils { - public static int unzipFileIntoDirectory(String zipFileName_, String jiniHomeParentDirName_) { + public static int unzipFileIntoDirectory(String zipFileName_, String jiniHomeParentDirName_) throws FermeExceptionNoSpaceLeftOnDevice { File rootdir = new File(jiniHomeParentDirName_); try { ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName_)); @@ -78,6 +79,15 @@ public class Utils { } fos.close(); } + catch (IOException e) { + File f = new File(jiniHomeParentDirName_); + if (f.getUsableSpace() == 0) { + throw new FermeExceptionNoSpaceLeftOnDevice(); + } + Log logger = Log.getInstance(null); // might not print the log since the config is null + logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e); + return -3; + } catch (Exception e1) { e1.printStackTrace(); } @@ -91,6 +101,9 @@ public class Utils { zis.closeEntry(); } } + catch (FermeExceptionNoSpaceLeftOnDevice e) { + throw e; + } catch (IllegalArgumentException e) { Log logger = Log.getInstance(null); // might not print the log since the config is null logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e); diff --git a/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java b/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java new file mode 100644 index 0000000..71c048e --- /dev/null +++ b/src/com/sheepit/client/exception/FermeExceptionNoSpaceLeftOnDevice.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 Laurent CLOUET + * Author Laurent CLOUET + * + * 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 FermeExceptionNoSpaceLeftOnDevice extends FermeException { + public FermeExceptionNoSpaceLeftOnDevice() { + super(); + } + + public FermeExceptionNoSpaceLeftOnDevice(String message_) { + super(message_); + } +}