SLIDER-149 RegistryRetriever broken; add sleep to make test more robust to race 
conditions


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/9708292b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/9708292b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/9708292b

Branch: refs/heads/feature/SLIDER-149_Support_a_YARN_service_registry
Commit: 9708292b45189ab26c04d4fec31fd082c7a2e0b9
Parents: 5fad493
Author: Steve Loughran <[email protected]>
Authored: Thu Aug 28 16:18:52 2014 +0100
Committer: Steve Loughran <[email protected]>
Committed: Thu Aug 28 16:18:52 2014 +0100

----------------------------------------------------------------------
 .../registry/retrieve/RegistryRetriever.java    | 20 +++++++++++++++-----
 .../agent/standalone/TestYarnRegistryAM.groovy  |  5 ++++-
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/9708292b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
 
b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
index 377b0b0..a05d5be 100644
--- 
a/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
+++ 
b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
@@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
 import javax.ws.rs.core.MediaType;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.List;
 
 /**
  * Registry retriever. 
@@ -78,14 +79,23 @@ public class RegistryRetriever {
   public RegistryRetriever(ServiceRecord record) throws InvalidRecordException 
{
     Endpoint internal = record.getInternalEndpoint(
         CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API);
-    
-    internalConfigurationURL = RegistryTypeUtils.retrieveAddressesUriType(
-        internal).get(0);
+    List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(
+        internal);
+    if (addresses != null && !addresses.isEmpty()) {
+      internalConfigurationURL = addresses.get(0);
+    } else {
+      internalConfigurationURL = "";
+    }
     Endpoint external = record.getExternalEndpoint(
         CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API);
 
-    externalConfigurationURL = RegistryTypeUtils.retrieveAddressesUriType(
-        external).get(0);
+    addresses = RegistryTypeUtils.retrieveAddressesUriType(external);
+    if (addresses != null && !addresses.isEmpty()) {
+      externalConfigurationURL = addresses.get(0);
+    } else {
+      externalConfigurationURL = "";
+    }
+
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/9708292b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestYarnRegistryAM.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestYarnRegistryAM.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestYarnRegistryAM.groovy
index 8ab5c6c..bdb5b27 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestYarnRegistryAM.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestYarnRegistryAM.groovy
@@ -125,8 +125,11 @@ class TestYarnRegistryAM extends AgentMiniClusterTestBase {
     logReport(instance)
     assert instance != null
 
-    //switch to the ZK-based registry
+    // sleep to allow registration to complete
+    sleep(5000)
+    
 
+    
 
     try {
       def yarnRegistryDump = client.dumpYarnRegistry(true).toString()

Reply via email to