Repository: incubator-slider
Updated Branches:
  refs/heads/develop fe6a72062 -> d38b31a7a


SLIDER-312 Jenkins NPE in TestFreezeThawMasterlessAM


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

Branch: refs/heads/develop
Commit: 7091397447ab8c8c7a8f82465c3520f76b2a7a75
Parents: fe6a720
Author: Steve Loughran <ste...@apache.org>
Authored: Tue Aug 12 16:04:49 2014 +0100
Committer: Steve Loughran <ste...@apache.org>
Committed: Tue Aug 12 16:04:49 2014 +0100

----------------------------------------------------------------------
 .../apache/slider/common/tools/SliderUtils.java |  3 +++
 .../server/appmaster/SliderAppMaster.java       | 22 +++-----------------
 .../slider/server/appmaster/state/AppState.java |  6 +++---
 .../TestFreezeThawMasterlessAM.groovy           |  5 ++++-
 4 files changed, 13 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/70913974/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java 
b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
index 33782f1..edbf2b2 100644
--- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
+++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
@@ -18,6 +18,7 @@
 
 package org.apache.slider.common.tools;
 
+import com.google.common.base.Preconditions;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.apache.commons.io.output.ByteArrayOutputStream;
@@ -616,6 +617,8 @@ public final class SliderUtils {
    */
   public static <T1, T2> Map<T1, T2> mergeMapsIgnoreDuplicateKeys(Map<T1, T2> 
first,
                                                                   Map<T1, T2> 
second) {
+    Preconditions.checkArgument(first != null, "Null 'first' value");
+    Preconditions.checkArgument(second != null, "Null 'second' value");
     for (Map.Entry<T1, T2> entry : second.entrySet()) {
       T1 key = entry.getKey();
       if (!first.containsKey(key)) {

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/70913974/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
index b2b0304..9f4567d 100644
--- 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
+++ 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
@@ -111,7 +111,6 @@ import 
org.apache.slider.server.appmaster.rpc.SliderClusterProtocolPBImpl;
 import org.apache.slider.server.appmaster.operations.AbstractRMOperation;
 import org.apache.slider.server.appmaster.state.AppState;
 import org.apache.slider.server.appmaster.state.ContainerAssignment;
-import org.apache.slider.server.appmaster.state.ContainerPriority;
 import org.apache.slider.server.appmaster.operations.ContainerReleaseOperation;
 import org.apache.slider.server.appmaster.state.ProviderAppState;
 import org.apache.slider.server.appmaster.operations.RMOperationHandler;
@@ -153,7 +152,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.Condition;
@@ -1332,8 +1330,7 @@ public class SliderAppMaster extends 
AbstractSliderLaunchedService
     String result;
     //quick update
     //query and json-ify
-    ClusterDescription cd;
-    cd = getCurrentClusterStatus();
+    ClusterDescription cd = updateClusterStatus();
     result = cd.toJsonString();
     String stat = result;
     return Messages.GetJSONClusterStatusResponseProto.newBuilder()
@@ -1341,19 +1338,6 @@ public class SliderAppMaster extends 
AbstractSliderLaunchedService
       .build();
   }
 
-  /**
-   * Get the current cluster status, including any provider-specific info
-   * @return a status document
-   */
-  public ClusterDescription getCurrentClusterStatus() {
-    ClusterDescription cd;
-    synchronized (this) {
-      updateClusterStatus();
-      cd = getClusterDescription();
-    }
-    return cd;
-  }
-
 
   @Override
   public Messages.GetInstanceDefinitionResponseProto getInstanceDefinition(
@@ -1485,10 +1469,10 @@ public class SliderAppMaster extends 
AbstractSliderLaunchedService
   /**
    * Update the cluster description with anything interesting
    */
-  public synchronized void updateClusterStatus() {
+  public synchronized ClusterDescription updateClusterStatus() {
     Map<String, String> providerStatus = providerService.buildProviderStatus();
     assert providerStatus != null : "null provider status";
-    appState.refreshClusterStatus(providerStatus);
+    return appState.refreshClusterStatus(providerStatus);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/70913974/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
index 30687d5..48f97bb 100644
--- 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
+++ 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
@@ -1379,7 +1379,7 @@ public class AppState {
    * Update the cluster description with anything interesting
    * @param providerStatus status from the provider for the cluster info 
section
    */
-  public void refreshClusterStatus(Map<String, String> providerStatus) {
+  public synchronized ClusterDescription refreshClusterStatus(Map<String, 
String> providerStatus) {
     ClusterDescription cd = getClusterStatus();
     long now = now();
     cd.setInfoTime(StatusKeys.INFO_STATUS_TIME_HUMAN,
@@ -1390,7 +1390,7 @@ public class AppState {
         cd.setInfo(entry.getKey(),entry.getValue());
       }
     }
-    MapOperations infoOps = new MapOperations("info",cd.info);
+    MapOperations infoOps = new MapOperations("info", cd.info);
     infoOps.mergeWithoutOverwrite(applicationInfo);
     SliderUtils.addBuildInfo(infoOps, "status");
     cd.statistics = new HashMap<>();
@@ -1436,7 +1436,7 @@ public class AppState {
     sliderstats.put(StatusKeys.STATISTICS_CONTAINERS_UNKNOWN_COMPLETED,
         completionOfUnknownContainerEvent.get());
     cd.statistics.put(SliderKeys.COMPONENT_AM, sliderstats);
-    
+    return cd;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/70913974/slider-core/src/test/groovy/org/apache/slider/agent/freezethaw/TestFreezeThawMasterlessAM.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/agent/freezethaw/TestFreezeThawMasterlessAM.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/agent/freezethaw/TestFreezeThawMasterlessAM.groovy
index 59db5f7..04be7c0 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/agent/freezethaw/TestFreezeThawMasterlessAM.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/agent/freezethaw/TestFreezeThawMasterlessAM.groovy
@@ -22,6 +22,7 @@ import groovy.transform.CompileStatic
 import groovy.util.logging.Slf4j
 import org.apache.hadoop.fs.FileSystem as HadoopFS
 import org.apache.hadoop.fs.Path
+import org.apache.hadoop.yarn.api.records.ApplicationReport
 import org.apache.hadoop.yarn.conf.YarnConfiguration
 import org.apache.slider.agent.AgentMiniClusterTestBase
 import org.apache.slider.client.SliderClient
@@ -76,8 +77,10 @@ class TestFreezeThawMasterlessAM extends 
AgentMiniClusterTestBase {
     //now start the cluster
     ServiceLauncher launcher2 = thawCluster(clustername, [], true);
     SliderClient newCluster = launcher2.service
+    addToTeardown(newCluster);
+
+//    ApplicationReport report = waitForClusterLive(newCluster)
     newCluster.getClusterDescription(clustername);
-    
     //freeze
     assert 0 == clusterActionFreeze(sliderClient, clustername)
 

Reply via email to