Detect when computer is runnout of free space on hard drive
This commit is contained in:
@@ -35,6 +35,7 @@ import com.sheepit.client.Error.Type;
|
|||||||
import com.sheepit.client.exception.FermeException;
|
import com.sheepit.client.exception.FermeException;
|
||||||
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
|
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
|
||||||
import com.sheepit.client.exception.FermeExceptionNoSession;
|
import com.sheepit.client.exception.FermeExceptionNoSession;
|
||||||
|
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
|
||||||
import com.sheepit.client.exception.FermeExceptionServerInMaintenance;
|
import com.sheepit.client.exception.FermeExceptionServerInMaintenance;
|
||||||
import com.sheepit.client.exception.FermeExceptionServerOverloaded;
|
import com.sheepit.client.exception.FermeExceptionServerOverloaded;
|
||||||
import com.sheepit.client.exception.FermeExceptionSessionDisabled;
|
import com.sheepit.client.exception.FermeExceptionSessionDisabled;
|
||||||
@@ -284,6 +285,15 @@ public class Client {
|
|||||||
continue;
|
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) {
|
if (ret != Error.Type.OK) {
|
||||||
Job frame_to_reset = this.renderingJob; // copy it because the sendError will take ~5min to execute
|
Job frame_to_reset = this.renderingJob; // copy it because the sendError will take ~5min to execute
|
||||||
this.renderingJob = null;
|
this.renderingJob = null;
|
||||||
@@ -522,22 +532,27 @@ public class Client {
|
|||||||
public Error.Type work(Job ajob) {
|
public Error.Type work(Job ajob) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = this.downloadExecutable(ajob);
|
try {
|
||||||
if (ret != 0) {
|
ret = this.downloadExecutable(ajob);
|
||||||
this.log.error("Client::work problem with downloadExecutable (ret " + ret + ")");
|
if (ret != 0) {
|
||||||
return Error.Type.DOWNLOAD_FILE;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (FermeExceptionNoSpaceLeftOnDevice e) {
|
||||||
ret = this.downloadSceneFile(ajob);
|
return Error.Type.NO_SPACE_LEFT_ON_DEVICE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File scene_file = new File(ajob.getScenePath());
|
File scene_file = new File(ajob.getScenePath());
|
||||||
@@ -631,7 +646,7 @@ public class Client {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int prepareWorkingDirectory(Job ajob) {
|
protected int prepareWorkingDirectory(Job ajob) throws FermeExceptionNoSpaceLeftOnDevice {
|
||||||
int ret;
|
int ret;
|
||||||
String renderer_archive = ajob.getRendererArchivePath();
|
String renderer_archive = ajob.getRendererArchivePath();
|
||||||
String renderer_path = ajob.getRendererDirectory();
|
String renderer_path = ajob.getRendererDirectory();
|
||||||
|
|||||||
7
src/com/sheepit/client/Error.java
Executable file → Normal file
7
src/com/sheepit/client/Error.java
Executable file → Normal file
@@ -44,7 +44,10 @@ public class Error {
|
|||||||
FAILED_TO_EXECUTE(16),
|
FAILED_TO_EXECUTE(16),
|
||||||
OS_NOT_SUPPORTED(17),
|
OS_NOT_SUPPORTED(17),
|
||||||
CPU_NOT_SUPPORTED(18),
|
CPU_NOT_SUPPORTED(18),
|
||||||
GPU_NOT_SUPPORTED(19);
|
GPU_NOT_SUPPORTED(19),
|
||||||
|
|
||||||
|
NO_SPACE_LEFT_ON_DEVICE(100),
|
||||||
|
;
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
@@ -166,6 +169,8 @@ public class Error {
|
|||||||
return "Operating System not supported.";
|
return "Operating System not supported.";
|
||||||
case CPU_NOT_SUPPORTED:
|
case CPU_NOT_SUPPORTED:
|
||||||
return "CPU not supported.";
|
return "CPU not supported.";
|
||||||
|
case NO_SPACE_LEFT_ON_DEVICE:
|
||||||
|
return "No space left on hard disk";
|
||||||
default:
|
default:
|
||||||
return in.toString();
|
return in.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
import com.sheepit.client.Error.ServerCode;
|
import com.sheepit.client.Error.ServerCode;
|
||||||
|
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
|
||||||
|
|
||||||
public class Utils {
|
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_);
|
File rootdir = new File(jiniHomeParentDirName_);
|
||||||
try {
|
try {
|
||||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName_));
|
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName_));
|
||||||
@@ -78,6 +79,15 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
fos.close();
|
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) {
|
catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -91,6 +101,9 @@ public class Utils {
|
|||||||
zis.closeEntry();
|
zis.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (FermeExceptionNoSpaceLeftOnDevice e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
Log logger = Log.getInstance(null); // might not print the log since the config is null
|
Log logger = Log.getInstance(null); // might not print the log since the config is null
|
||||||
logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e);
|
logger.error("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + jiniHomeParentDirName_ + ") exception " + e);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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 FermeExceptionNoSpaceLeftOnDevice extends FermeException {
|
||||||
|
public FermeExceptionNoSpaceLeftOnDevice() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FermeExceptionNoSpaceLeftOnDevice(String message_) {
|
||||||
|
super(message_);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user