You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/06/24 20:59:59 UTC
svn commit: r788126 -
/incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
Author: cwiklik
Date: Wed Jun 24 18:59:59 2009
New Revision: 788126
URL: http://svn.apache.org/viewvc?rev=788126&view=rev
Log:
UIMA-1358 synchronized lookup method
Modified:
incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java?rev=788126&r1=788125&r2=788126&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java Wed Jun 24 18:59:59 2009
@@ -86,6 +86,16 @@
private volatile boolean concurrentConsumersOnReplyQueue;
+ private Endpoint notificationEndpoint = null;
+
+ public Endpoint getNotificationEndpoint() {
+ return notificationEndpoint;
+ }
+
+ public void setNotificationEndpoint(Endpoint notificationEndpoint) {
+ this.notificationEndpoint = notificationEndpoint;
+ }
+
public boolean isAwaitingPingReply() {
return awaitingPingReply;
}
@@ -166,6 +176,24 @@
public List<DelegateEntry> getDelegateCasesPendingRepy() {
return outstandingCasList;
}
+
+ public void addNewCasToOutstandingList(String aCasReferenceId) {
+ addNewCasToOutstandingList(aCasReferenceId, false);
+ }
+ public void addNewCasToOutstandingList(String aCasReferenceId, boolean isCasGeneratingChildren ) {
+ synchronized (outstandingCasListMux) {
+ DelegateEntry entry = null;
+ if ( (entry = lookupEntry(aCasReferenceId, outstandingCasList)) == null) {
+ entry = new DelegateEntry(aCasReferenceId);
+ // Remember the command
+ entry.setCommand(AsynchAEMessage.Process);
+ if ( isCasGeneratingChildren ) {
+ entry.setGeneratingChildren(true);
+ }
+ outstandingCasList.add(entry);
+ }
+ }
+ }
/**
* Adds a given Cas ID to the list of CASes pending reply. A new timer will be started to handle
* delegate's timeout if either: 1) the list of CASes pending reply is empty AND delegate timeout
@@ -316,7 +344,7 @@
* - unique id of a CAS to be searched for
* @return
*/
- private DelegateEntry lookupEntry(String aCasReferenceId, List<DelegateEntry> list) {
+ private synchronized DelegateEntry lookupEntry(String aCasReferenceId, List<DelegateEntry> list) {
for (DelegateEntry entry : list) {
if (entry.getCasReferenceId().equals(aCasReferenceId)) {
return entry;
@@ -662,6 +690,29 @@
public boolean hasConcurrentConsumersOnReplyQueue() {
return concurrentConsumersOnReplyQueue;
}
+
+ public boolean isGeneratingChildrenFrom(String aCasReferenceId ) {
+ synchronized( outstandingCasList) {
+ DelegateEntry entry = lookupEntry(aCasReferenceId, outstandingCasList);
+ if ( entry == null ) {
+ return false;
+ } else {
+ return entry.isGeneratingChildren();
+ }
+ }
+ }
+
+ public void setGeneratingChildrenFrom(String aCasReferenceId, boolean tOf ) {
+ synchronized( outstandingCasList) {
+ DelegateEntry entry = lookupEntry(aCasReferenceId, outstandingCasList);
+ if ( entry == null ) {
+ // noop;
+ } else {
+ entry.setGeneratingChildren(tOf);
+ }
+ }
+ }
+
public abstract void handleError(Exception e, ErrorContext errorContext);
public abstract String getComponentName();
@@ -679,10 +730,20 @@
private int retryCount = 0;
+ private volatile boolean generatingChildren = false;
+
public DelegateEntry(String aCasReferenceId) {
casReferenceId = aCasReferenceId;
}
+ public boolean isGeneratingChildren() {
+ return generatingChildren;
+ }
+
+ public void setGeneratingChildren(boolean tOf) {
+ generatingChildren = tOf;
+ }
+
public int getCommand() {
return command;
}