Skip to content

Commit

Permalink
Handle disk out of space errors better
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikl committed Feb 26, 2024
1 parent cd24a65 commit 59ffe23
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* org.openmicroscopy.shoola.env.data.ConnectionExceptionHandler
*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2013 University of Dundee & Open Microscopy Environment.
* Copyright (C) 2006-2024 University of Dundee & Open Microscopy Environment.
* All rights reserved.
*
*
Expand Down Expand Up @@ -67,6 +67,9 @@ public class ConnectionExceptionHandler
/** Indicates that the network is down. */
public static final int NETWORK = 3;

/** Indicates that the server ran out of disk space **/
public static final int OUT_OF_SPACE = 4;

/** String identifying the connection refused exception.*/
private static final String REFUSED = "Ice::ConnectionRefusedException";

Expand Down Expand Up @@ -139,6 +142,9 @@ else if (cause instanceof UnknownException)
index = handleIceUnknownException(cause);
else if (e instanceof UnknownException)
index = handleIceUnknownException(e);
else if (e.toString().contains("No space")) {
index = OUT_OF_SPACE;
}
return index;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
* Copyright (C) 2006-2024 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -409,7 +409,14 @@ public void sessionExpiredExit(int index, Throwable exc)
connectionDialog = new NotificationDialog(f,
"Connection Refused", message, null);
addListenerAndShow();
}
case ConnectionExceptionHandler.OUT_OF_SPACE:
message = "The server ran out of disk space.\n" +
"Please contact your system administrator.\n" +
"The application will now exit.";
connectionDialog = new NotificationDialog(f,
"Out of disk space.", message, null);
addListenerAndShow();;
}
}

/**
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/org/openmicroscopy/shoola/env/data/OMEROGateway.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
* Copyright (C) 2006-2024 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -248,6 +248,7 @@
import omero.gateway.model.WellSampleData;



/**
* Unified access point to the various <i>OMERO</i> services.
*
Expand Down Expand Up @@ -767,8 +768,11 @@ private void handleException(Throwable t, String message)
} else if (cause instanceof AuthenticationException) {
String s = "Cannot initialize the session. \n";
throw new DSOutOfServiceException(s+message, cause);
} else if (cause instanceof ResourceError) {
}
else if (cause instanceof ResourceError) {
String s = "Fatal error. Please contact the administrator. \n";
if (t.toString().contains("No space"))
s = "Server ran out of disk space. Please contact the administrator. \n";
throw new DSOutOfServiceException(s+message, t);
}
throw new DSAccessException("Cannot access data. \n"+message, t);
Expand Down Expand Up @@ -5671,9 +5675,13 @@ Object importImageFile(SecurityContext ctx, ImportableObject object,
null, 0, srcFiles.length, null, null, null));

for (int i = 0; i < srcFiles.length; i++) {
checksums.add(library. uploadFile(proc, srcFiles, i,
checksumProviderFactory, estimator,
buf));
try {
checksums.add(library.uploadFile(proc, srcFiles, i,
checksumProviderFactory, estimator,
buf));
} catch (Throwable e ){
handleConnectionException(e);
}
}

try {
Expand Down

0 comments on commit 59ffe23

Please sign in to comment.