Skip to content

Commit

Permalink
Insight has to keep track of rend. engines in use itself
Browse files Browse the repository at this point in the history
With ome#5513 the java gateway removes stale connectors (e.g. after
server restart). So Insight can't use the gateway any longer to
provide the information which images are currently viewed, the
stale references are removed after server restart / reconnect.
  • Loading branch information
dominikl committed Feb 7, 2018
1 parent 2f5952d commit 23a1a6f
Showing 1 changed file with 22 additions and 3 deletions.
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2017 University of Dundee. All rights reserved.
* Copyright (C) 2006-2018 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -387,6 +387,9 @@ class OMEROGateway

private Gateway gw;

// Keep track of the rendering engines currently in use
private Map<SecurityContext, Set<Long>> renderingEngines = new HashMap<SecurityContext, Set<Long>>();

/**
* Creates the query to load the file set corresponding to a given image.
*
Expand Down Expand Up @@ -514,7 +517,17 @@ private ScriptCallback runScript(SecurityContext ctx, long scriptID,
void closeService(SecurityContext ctx,
StatefulServiceInterfacePrx svc)
{
if (ctx == null || svc == null) return;
if (ctx == null || svc == null)
return;
if (svc instanceof RenderingEnginePrx && renderingEngines.containsKey(ctx)) {
try {
renderingEngines.get(ctx).remove(
((RenderingEnginePrx) svc).getPixels().getId()
.getValue());
} catch (ServerError e) {
// do nothing
}
}
gw.closeService(ctx, svc);
}

Expand Down Expand Up @@ -1602,7 +1615,7 @@ String lookupLdapAuthExperimenter(SecurityContext ctx, long userID)
*/
Map<SecurityContext, Set<Long>> getRenderingEngines()
{
return gw.getRenderingEngines();
return renderingEngines;
}

boolean joinSession() {
Expand Down Expand Up @@ -2397,6 +2410,12 @@ private RenderingEnginePrx generateRenderingEngine(
service.lookupPixels(pixelsID);
needDefault(pixelsID, service);
service.load();
Set<Long> pixIds = renderingEngines.get(ctx);
if (pixIds == null) {
pixIds = new HashSet<Long>();
renderingEngines.put(ctx, pixIds);
}
pixIds.add(pixelsID);
return service;
} catch (Throwable t) {
log(t.getMessage());
Expand Down

0 comments on commit 23a1a6f

Please sign in to comment.