summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-12-08 15:23:07 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-12-08 15:23:07 +0000
commit560e6a5073634a19a76f66f9d923e4be2b4ec641 (patch)
tree1d0985f7da78c0a11377227cbce786e4ae08ab1d /sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java
parent080a6c23874a133de067ad62c46bedb957561e07 (diff)
Add code to repeat endpoint reference matching in the failure case only. Gives the distributed map a chance to settle down and means less arbitrary pauses in test cases.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@888442 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java49
1 files changed, 35 insertions, 14 deletions
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
index 9dd98dedfb..9ca5c00d34 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -293,24 +293,45 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi
if (endpointReference.getReference() != null) {
Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
- for (Object v : map.values()) {
- Endpoint endpoint = (Endpoint)v;
- // TODO: implement more complete matching
- logger.fine("Matching against - " + endpoint);
- if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
- MapEntry entry = map.getInternal(endpoint.getURI());
- if (!isLocal(entry)) {
- endpoint.setRemote(true);
+
+ // in the failure case we repeat the look up after a short
+ // delay to take account of tribes replication delays
+ int repeat = 2;
+
+ while (repeat > 0){
+ for (Object v : map.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ // TODO: implement more complete matching
+ logger.fine("Matching against - " + endpoint);
+ if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ if (!isLocal(entry)) {
+ endpoint.setRemote(true);
+ }
+ // if (!entry.isPrimary()) {
+ ((RuntimeEndpoint) endpoint).bind(registry, this);
+ // }
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ repeat = 0;
+ }
+ // else the service name doesn't match
+ }
+
+ if (foundEndpoints.size() == 0) {
+ // the service name doesn't match any endpoints so wait a little and try
+ // again in case this is caused by tribes synch delays
+ logger.info("Repeating endpoint reference match - " + endpointReference);
+ repeat--;
+ try {
+ Thread.sleep(1000);
+ } catch(Exception ex){
+ // do nothing
}
- // if (!entry.isPrimary()) {
- ((RuntimeEndpoint) endpoint).bind(registry, this);
- // }
- foundEndpoints.add(endpoint);
- logger.fine("Found endpoint with matching service - " + endpoint);
}
- // else the service name doesn't match
}
}
+
return foundEndpoints;
}