Skip to content

Commit

Permalink
have read-only pixel data thread ignore MissingPyramidMessage
Browse files Browse the repository at this point in the history
also deprecate various PixelDataThread constructors
  • Loading branch information
mtbc committed Jun 29, 2018
1 parent dd52293 commit f73705e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<constructor-arg index="3" ref="uuid"/>
<constructor-arg index="4" value="${omero.pixeldata.threads}"/>
<constructor-arg index="5" ref="metrics"/>
<constructor-arg index="6" ref="readOnlyStatus"/>
</bean>

<bean id="pixelDataHandler" class="ome.services.pixeldata.PixelDataHandler">
Expand Down
62 changes: 56 additions & 6 deletions components/server/src/ome/services/pixeldata/PixelDataThread.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright 2011 Glencoe Software, Inc. All rights reserved.
* Use is subject to license terms supplied in LICENSE.txt
*/
Expand Down Expand Up @@ -31,6 +29,7 @@
import ome.services.sessions.SessionManager;
import ome.services.util.ExecutionThread;
import ome.services.util.Executor;
import ome.services.util.ReadOnlyStatus;
import ome.system.EventContext;
import ome.system.Principal;
import ome.system.ServiceFactory;
Expand Down Expand Up @@ -75,9 +74,12 @@ public class PixelDataThread extends ExecutionThread implements ApplicationListe

private final Timer batchTimer;

private final ReadOnlyStatus readOnly;

/**
* Uses default {@link Principal} for processing
*/
@Deprecated
public PixelDataThread(SessionManager manager, Executor executor,
PixelDataHandler handler, String uuid) {
this(manager, executor, handler, DEFAULT_PRINCIPAL, uuid, DEFAULT_THREADS);
Expand All @@ -87,6 +89,7 @@ public PixelDataThread(SessionManager manager, Executor executor,
* Uses default {@link Principal} for processing and a {@link NullMetrics}
* instance.
*/
@Deprecated
public PixelDataThread(SessionManager manager, Executor executor,
PixelDataHandler handler, String uuid, int numThreads) {
this(manager, executor, handler, DEFAULT_PRINCIPAL, uuid, numThreads,
Expand All @@ -99,6 +102,7 @@ public PixelDataThread(SessionManager manager, Executor executor,
* {@link #PixelDataThread(boolean, SessionManager, Executor, PixelDataHandler, Principal, String, int) the main ctor}
* passing a {@link NullMetrics} as necessary.
*/
@Deprecated
public PixelDataThread(SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads) {
Expand All @@ -112,6 +116,7 @@ public PixelDataThread(SessionManager manager, Executor executor,
* "pixelDataTrigger" and passes all parameters to
* {@link #PixelDataThread(boolean, SessionManager, Executor, PixelDataHandler, Principal, String, int) the main ctor}.
*/
@Deprecated
public PixelDataThread(
SessionManager manager, Executor executor,
PixelDataHandler handler, String uuid,
Expand All @@ -126,38 +131,80 @@ public PixelDataThread(
* "pixelDataTrigger" and passes all parameters to
* {@link #PixelDataThread(boolean, SessionManager, Executor, PixelDataHandler, Principal, String, int) the main ctor}.
*/
public PixelDataThread(
SessionManager manager, Executor executor,
PixelDataHandler handler, String uuid,
int numThreads, Metrics metrics, ReadOnlyStatus readOnly) {
this(executor.getContext().containsBean("pixelDataTrigger"),
manager, executor, handler, DEFAULT_PRINCIPAL,
uuid, numThreads, metrics, readOnly);
}

/**
* Calculates {@link #performProcessing} based on the existence of the
* "pixelDataTrigger" and passes all parameters to
* {@link #PixelDataThread(boolean, SessionManager, Executor, PixelDataHandler, Principal, String, int) the main ctor}.
*/
@Deprecated
public PixelDataThread(
SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads, Metrics metrics) {
this(executor.getContext().containsBean("pixelDataTrigger"),
manager, executor, handler, principal,
manager, executor, handler, principal,
uuid, numThreads, metrics);
}

/**
* Calculates {@link #performProcessing} based on the existence of the
* "pixelDataTrigger" and passes all parameters to
* {@link #PixelDataThread(boolean, SessionManager, Executor, PixelDataHandler, Principal, String, int) the main ctor}.
*/
@Deprecated
public PixelDataThread(
SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads, Metrics metrics, ReadOnlyStatus readOnly) {
this(executor.getContext().containsBean("pixelDataTrigger"),
manager, executor, handler, principal,
uuid, numThreads, metrics, readOnly);
}

/**
* Calls main constructor with {@link NullMetrics}.
*/
public PixelDataThread(boolean performProcessing,
SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads) {
this(performProcessing, manager, executor, handler, principal,
this(performProcessing, manager, executor, handler, principal,
uuid, numThreads, new NullMetrics());
}

/**
* Main constructor. No arguments can be null.
* Calls main constructor with read-only status being all read-write.
*/
public PixelDataThread(boolean performProcessing,
SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads, Metrics metrics) {
this(performProcessing, manager, executor, handler, principal,
uuid, numThreads, metrics, new ReadOnlyStatus(false, false));
}

/**
* Main constructor. No arguments can be null.
*/
public PixelDataThread(boolean performProcessing,
SessionManager manager, Executor executor,
PixelDataHandler handler, Principal principal, String uuid,
int numThreads, Metrics metrics, ReadOnlyStatus readOnly) {
super(manager, executor, handler, principal);
this.performProcessing = performProcessing;
this.uuid = uuid;
this.numThreads = numThreads;
this.batchTimer = metrics.timer(this, "batch");
this.readOnly = readOnly;
}

/**
Expand Down Expand Up @@ -282,7 +329,10 @@ public void stop() {
* {@link EventLog} which will get processed by PixelData-0.
*/
public void onApplicationEvent(final MissingPyramidMessage mpm) {

if (readOnly.isReadOnlyDb()) {
log.debug("Ignored: " + mpm);
return;
}
log.info("Received: " + mpm);
// #5232. If this is called without an active event, then throw
// an exception since a call to Executor should wrap whatever the
Expand Down

0 comments on commit f73705e

Please sign in to comment.