From ce58f5cbb3754b60bff2def83da808488c666fcf Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 6 Jul 2021 17:47:49 +0100 Subject: [PATCH 1/3] add entry to look up server status --- .../java/org/openmicroscopy/shoola/env/LookupNames.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/openmicroscopy/shoola/env/LookupNames.java b/src/main/java/org/openmicroscopy/shoola/env/LookupNames.java index 1f8b91f27..d7e482b18 100644 --- a/src/main/java/org/openmicroscopy/shoola/env/LookupNames.java +++ b/src/main/java/org/openmicroscopy/shoola/env/LookupNames.java @@ -447,4 +447,11 @@ public class LookupNames /** Lookup name for characters which need to escaped for the login username / password */ public static final String LOGIN_ESCAPE_CHARACTERS="omero.client.login_escape_characters"; + + /** Lookup name for read-only status of server.*/ + public static final String SERVER_DB = "omero.cluster.read_only.runtime.db"; + + /** Lookup name for read-only status of server.*/ + public static final String SERVER_REPO = "omero.cluster.read_only.runtime.repo"; + } From 9253b226f7a3768e797456c7e7acb633f54fecc1 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 6 Jul 2021 17:48:26 +0100 Subject: [PATCH 2/3] retrieve read-only status of server --- .../shoola/env/data/DataServicesFactory.java | 21 ++++++++++++++++++ .../shoola/env/data/OMEROGateway.java | 22 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openmicroscopy/shoola/env/data/DataServicesFactory.java b/src/main/java/org/openmicroscopy/shoola/env/data/DataServicesFactory.java index d2f5e95fa..1cbd3ff7e 100644 --- a/src/main/java/org/openmicroscopy/shoola/env/data/DataServicesFactory.java +++ b/src/main/java/org/openmicroscopy/shoola/env/data/DataServicesFactory.java @@ -552,6 +552,27 @@ public void connect(UserCredentials uc) msg = new LogMessage("Could not load omero client properties from the server", e1); registry.getLogger().warn(this, msg); } + + try { + // Load the omero server properties from the server + List agents = (List) registry.lookup(LookupNames.AGENTS); + Map props = omeroGateway.getServerProperties(exp.getGroupId()); + for (String key : props.keySet()) { + if (registry.lookup(key) == null) + registry.bind(key, props.get(key)); + + Registry agentReg; + for (Object agent : agents) { + agentReg = ((AgentInfo) agent).getRegistry(); + if (agentReg != null && agentReg.lookup(key) == null) + agentReg.bind(key, props.get(key)); + } + } + } catch (DSAccessException e1) { + msg = new LogMessage("Could not load omero client properties from the server", e1); + registry.getLogger().warn(this, msg); + } + Collection groups; Set available; diff --git a/src/main/java/org/openmicroscopy/shoola/env/data/OMEROGateway.java b/src/main/java/org/openmicroscopy/shoola/env/data/OMEROGateway.java index 2836b5dec..910b98075 100644 --- a/src/main/java/org/openmicroscopy/shoola/env/data/OMEROGateway.java +++ b/src/main/java/org/openmicroscopy/shoola/env/data/OMEROGateway.java @@ -1448,7 +1448,7 @@ Map getOmeroClientProperties(long groupId) throws DSOutOfServiceException, DSAccessException { if (isConnected()) { try { - return gw.getConfigService(new SecurityContext(groupId)).getClientConfigValues(); + return gw.getConfigService(new SecurityContext(groupId)).getClientConfigValues(); } catch (Exception e) { handleException(e, "Cannot access config service. "); } @@ -1456,6 +1456,26 @@ Map getOmeroClientProperties(long groupId) return null; } + /** + * Get the server properties from the server + * @param The groupId for the {@link SecurityContext} + * @return See above. + * @throws DSAccessException + * @throws DSOutOfServiceException + */ + Map getServerProperties(long groupId) + throws DSOutOfServiceException, DSAccessException { + if (isConnected()) { + try { + String regex = "^omero\\.cluster"; + return gw.getConfigService(new SecurityContext(groupId)).getConfigValues(regex); + } catch (Exception e) { + handleException(e, "Cannot access config service. "); + } + } + return null; + } + /** * Retrieves the system view hosting the repositories. * From 7dc659d8c4ab498271ab8b2dbbcb6ed34bf490a2 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 6 Jul 2021 17:48:44 +0100 Subject: [PATCH 3/3] check status of server --- .../env/data/views/calls/ThumbnailLoader.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/openmicroscopy/shoola/env/data/views/calls/ThumbnailLoader.java b/src/main/java/org/openmicroscopy/shoola/env/data/views/calls/ThumbnailLoader.java index 51af78fe3..c8752ebe3 100644 --- a/src/main/java/org/openmicroscopy/shoola/env/data/views/calls/ThumbnailLoader.java +++ b/src/main/java/org/openmicroscopy/shoola/env/data/views/calls/ThumbnailLoader.java @@ -46,6 +46,7 @@ import java.awt.Dimension; import java.awt.Image; +import java.lang.StackTraceElement; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -112,6 +113,16 @@ public class ThumbnailLoader extends BatchCallTree { */ private boolean asImage = false; + private boolean readOnly = false; + + private boolean isReadOnly() { + String b = (String) context.lookup(LookupNames.SERVER_DB); + if (b != null) { + return Boolean.valueOf(b).booleanValue(); + } + return false; + } + /** * Creates a new instance. * If bad arguments are passed, we throw a runtime exception so to fail @@ -146,6 +157,7 @@ public ThumbnailLoader(SecurityContext ctx, Collection imgs, this.userIDs = userIDs; this.ctx = ctx; this.service = context.getImageService(); + this.readOnly = isReadOnly(); } public ThumbnailLoader(SecurityContext ctx, Collection imgs, long userID) { @@ -335,6 +347,9 @@ private byte[] loadThumbnail(ThumbnailStorePrx store, PixelsData pxd, long userI store.setRenderingDefId(rndDefId); } + if (readOnly) { + return store.getThumbnail(omero.rtypes.rint(sizeX), omero.rtypes.rint(sizeY)); + } return store.getThumbnailWithoutDefault(omero.rtypes.rint(sizeX), omero.rtypes.rint(sizeY)); }