ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject [3/5] git commit: Revert "AMBARI-3987 - Resource providers are set with wrong stack version."
Date Wed, 18 Dec 2013 22:15:59 GMT
Revert "AMBARI-3987 - Resource providers are set with wrong stack version."

This reverts commit ba83fbf7f7a5219fd287128799bbed1b8b75bc96.


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

Branch: refs/heads/branch-1.4
Commit: b21fa0c4c46a9c657e86404f546a15508c84f780
Parents: 389279b
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Thu Dec 5 14:54:13 2013 -0800
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Wed Dec 18 14:13:13 2013 -0800

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        |  27 +----
 .../internal/AbstractProviderModuleTest.java    | 121 -------------------
 2 files changed, 4 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b21fa0c4/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 4011f4d..0f392d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -43,12 +43,11 @@ import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.State;
+import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * An abstract provider module implementation.
@@ -316,18 +315,6 @@ public abstract class AbstractProviderModule implements ProviderModule,
Resource
 
   // ----- utility methods ---------------------------------------------------
 
-  /**
-   * Get the metrics version for the given cluster name.
-   *
-   * @param clusterName  the cluster name
-   *
-   * @return the metrics version for the given cluster name
-   */
-  protected PropertyHelper.MetricsVersion getMetricsVersion(String clusterName) {
-    updateClusterVersion();
-    return clusterVersionsMap.get(clusterName);
-  }
-
   protected abstract ResourceProvider createResourceProvider(Resource.Type type);
 
   protected void registerResourceProvider(Resource.Type type) {
@@ -457,15 +444,9 @@ public abstract class AbstractProviderModule implements ProviderModule,
Resource
 
         for (Resource cluster : clusters) {
           String clusterVersion = (String) cluster.getPropertyValue(CLUSTER_VERSION_PROPERTY_ID);
-          PropertyHelper.MetricsVersion version = PropertyHelper.MetricsVersion.HDP2;
-
-          Matcher m = Pattern.compile("[0-9]+(\\.[0-9]+)+").matcher(clusterVersion);
-          if (m.find()) {
-            clusterVersion = m.group(0);
-            if (clusterVersion.equals("1") || clusterVersion.startsWith("1.")) {
-              version = PropertyHelper.MetricsVersion.HDP1;
-            }
-          }
+
+          PropertyHelper.MetricsVersion version =  clusterVersion.startsWith("HDP-1") ?
+              PropertyHelper.MetricsVersion.HDP1 : PropertyHelper.MetricsVersion.HDP2;
 
           clusterVersionsMap.put(
               (String) cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID),

http://git-wip-us.apache.org/repos/asf/ambari/blob/b21fa0c4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractProviderModuleTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractProviderModuleTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractProviderModuleTest.java
deleted file mode 100644
index 36410c9..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractProviderModuleTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.apache.ambari.server.controller.internal;
-
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * AbstractProviderModule tests.
- */
-public class AbstractProviderModuleTest {
-  @Test
-  public void testGetMetricsVersion() throws Exception {
-
-    TestAbstractProviderModule module = new TestAbstractProviderModule("HDP-1.0");
-    PropertyHelper.MetricsVersion version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP1, version);
-    version = module.getMetricsVersion("c2");
-    Assert.assertNull(version);
-
-    module = new TestAbstractProviderModule("HDPLocal-1.3.2");
-    version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP1, version);
-
-    module = new TestAbstractProviderModule("HDP-2.0.1");
-    version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP2, version);
-
-    module = new TestAbstractProviderModule("HDP-2.0.1.x");
-    version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP2, version);
-
-    module = new TestAbstractProviderModule("HDP-9.9.9");
-    version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP2, version);
-
-    module = new TestAbstractProviderModule("HDPLocal-2.0.0");
-    version = module.getMetricsVersion("c1");
-    Assert.assertEquals(PropertyHelper.MetricsVersion.HDP2, version);
-  }
-
-  private static class TestAbstractProviderModule extends AbstractProviderModule {
-    private final String clusterVersion;
-
-    private TestAbstractProviderModule(String clusterVersion) {
-      this.clusterVersion = clusterVersion;
-    }
-
-    @Override
-    protected ResourceProvider createResourceProvider(Resource.Type type) {
-      return new TestResourceProvider(type, clusterVersion);
-    }
-  }
-
-  private static class TestResourceProvider implements ResourceProvider {
-    private final Resource.Type type;
-    private final String clusterVersion;
-
-    private TestResourceProvider(Resource.Type type, String clusterVersion) {
-      this.type = type;
-      this.clusterVersion = clusterVersion;
-    }
-
-    @Override
-    public RequestStatus createResources(Request request)
-        throws SystemException, UnsupportedPropertyException,
-        ResourceAlreadyExistsException, NoSuchParentResourceException {
-      return null;
-    }
-
-    @Override
-    public Set<Resource> getResources(Request request, Predicate predicate)
-        throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
{
-
-      if (type == Resource.Type.Cluster) {
-        Resource cluster = new ResourceImpl(Resource.Type.Cluster);
-        cluster.setProperty(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 1);
-        cluster.setProperty(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "c1");
-        cluster.setProperty(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, clusterVersion);
-
-        return Collections.singleton(cluster);
-      }
-      return Collections.emptySet();
-    }
-
-    @Override
-    public RequestStatus updateResources(Request request, Predicate predicate)
-        throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
{
-      return null;
-    }
-
-    @Override
-    public RequestStatus deleteResources(Predicate predicate)
-        throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
{
-      return null;
-    }
-
-    @Override
-    public Map<Resource.Type, String> getKeyPropertyIds() {
-      return null;
-    }
-
-    @Override
-    public Set<String> checkPropertyIds(Set<String> propertyIds) {
-      return null;
-    }
-  }
-}


Mime
View raw message