Author: challngr
Date: Mon Mar 25 17:46:02 2013
New Revision: 1460778
URL: http://svn.apache.org/r1460778
Log:
UIMA-2728
Update countImplementors to use friendly-ids instead of Implementors collection
so it
is more current with respect to Orchestrator publications.
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
URL:
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java?rev=1460778&r1=1460777&r2=1460778&view=diff
==============================================================================
---
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
(original)
+++
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
Mon Mar 25 17:46:02 2013
@@ -429,7 +429,7 @@ public class ServiceSet
if ( stopped ) return; // doing auto, but we've
been manually stopped
// could have more implementors than instances if some were started
dynamically but the count not persisted
- int needed = Math.max(0, instances - friendly_ids.size());
+ int needed = Math.max(0, instances - countImplementors());
logger.debug(methodName, null, "ENFORCE: ", needed);
while ( (needed--) > 0 ) {
@@ -692,9 +692,16 @@ public class ServiceSet
}
}
- public int countImplementors()
+ public synchronized int countImplementors()
{
- return implementors.size();
+ // The implementos and friendly_ids sets track each other carefully.
The former
+ // tracks process state via the remote process's DuccId. The latter
tracks
+ // what we've tried to start, but may not know the actual state for
until we get
+ // Orchestrator publications.
+ //
+ // To avoid ugly races, we consider a process to be an implementor as
soon as we
+ // get the "friendly" id from the Orchestrator.
+ return friendly_ids.size();
}
public synchronized int reference(DuccId id)