You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/11/24 12:40:08 UTC

[26/39] ambari git commit: AMBARI-22325 Rename ProvisionClusterTemplate to TopologyTemplate (benyoka)

AMBARI-22325 Rename ProvisionClusterTemplate to TopologyTemplate (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: b49f78ab3a68993c4925b94511dc32b5915c5d75
Parents: 3a016f8
Author: Balazs Bence Sari <be...@apache.org>
Authored: Tue Nov 21 11:27:42 2017 +0100
Committer: Doroszlai, Attila <ad...@hortonworks.com>
Committed: Fri Nov 24 13:30:46 2017 +0100

----------------------------------------------------------------------
 .../topology/ProvisionClusterTemplate.java      | 263 -------------------
 .../ProvisionClusterTemplateFactory.java        |  63 -----
 .../server/topology/TopologyTemplate.java       | 263 +++++++++++++++++++
 .../topology/TopologyTemplateFactory.java       |  63 +++++
 .../topology/ProvisionClusterTemplateTest.java  |  94 -------
 .../topology/TopologyTemplateFactoryTest.java   |  94 +++++++
 6 files changed, 420 insertions(+), 420 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplate.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplate.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplate.java
deleted file mode 100644
index 90da776..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplate.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distribut
- * ed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.topology;
-
-import static java.util.stream.Collectors.toMap;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-import org.apache.ambari.server.controller.internal.ProvisionAction;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Preconditions;
-
-public class ProvisionClusterTemplate {
-
-  private String blueprint = null;
-
-  @JsonProperty("default_password")
-  private String defaultPassword = null;
-
-  @JsonProperty("config_recommendation_strategy")
-  private ConfigRecommendationStrategy configRecommendationStrategy;
-
-  @JsonProperty("provision_action")
-  private ProvisionAction provisionAction;
-
-  private Map<ServiceId, ProvisionClusterTemplate.Service> servicesById = Collections.emptyMap();
-
-  private Map<String, ProvisionClusterTemplate.HostGroup> hostGroups = Collections.emptyMap();
-
-  private Collection<Credential> credentials;
-
-  @JsonProperty("security")
-  private SecurityConfiguration securityConfiguration;
-
-  public String getBlueprint() {
-    return blueprint;
-  }
-
-  public void setBlueprint(String blueprint) {
-    this.blueprint = blueprint;
-  }
-
-  public String getDefaultPassword() {
-    return defaultPassword;
-  }
-
-  public void setDefaultPassword(String defaultPassword) {
-    this.defaultPassword = defaultPassword;
-  }
-
-  public @Nullable Service getServiceById(ServiceId serviceId) {
-    return servicesById.get(serviceId);
-  }
-
-  @JsonProperty("services")
-  public Collection<Service> getServices() {
-    return servicesById.values();
-  }
-
-  @JsonProperty("services")
-  public void setServices(Collection<Service> services) {
-    this.servicesById = services.stream().collect(toMap(
-      s -> s.getId(),
-      s -> s
-    ));
-  }
-
-  public Collection<Credential> getCredentials() {
-    return credentials;
-  }
-
-  public void setCredentials(Collection<Credential> credentials) {
-    this.credentials = credentials;
-  }
-
-  public SecurityConfiguration getSecurityConfiguration() {
-    return securityConfiguration;
-  }
-
-  public void setSecurityConfiguration(SecurityConfiguration securityConfiguration) {
-    this.securityConfiguration = securityConfiguration;
-  }
-
-  public ConfigRecommendationStrategy getConfigRecommendationStrategy() {
-    return configRecommendationStrategy;
-  }
-
-  public void setConfigRecommendationStrategy(ConfigRecommendationStrategy configRecommendationStrategy) {
-    this.configRecommendationStrategy = configRecommendationStrategy;
-  }
-
-  public ProvisionAction getProvisionAction() {
-    return provisionAction;
-  }
-
-  public void setProvisionAction(ProvisionAction provisionAction) {
-    this.provisionAction = provisionAction;
-  }
-
-  @JsonProperty("host_groups")
-  public Collection<HostGroup> getHostGroups() {
-    return hostGroups.values();
-  }
-
-  public HostGroup getHostGroupByName(String name) {
-    return hostGroups.get(name);
-  }
-
-  @JsonProperty("host_groups")
-  public void setHostGroups(Collection<HostGroup> hostGroups) {
-    this.hostGroups = hostGroups.stream().collect(toMap(
-      hg -> hg.getName(),
-      hg -> hg
-    ));
-  }
-
-  public void validate() throws IllegalStateException {
-    getHostGroups().forEach(HostGroup::validate);
-  }
-
-  public static class HostGroup implements Configurable {
-    private String name;
-    @JsonIgnore
-    private Configuration configuration;
-    private Collection<Host> hosts = Collections.emptyList();
-    @JsonProperty("host_count")
-    private int hostCount = 0;
-    @JsonProperty("host_predicate")
-    private String hostPredicate;
-
-    public String getName() {
-      return name;
-    }
-
-    public void setName(String name) {
-      this.name = name;
-    }
-
-    @Override
-    public Configuration getConfiguration() {
-      return configuration;
-    }
-
-    @Override
-    public void setConfiguration(Configuration configuration) {
-      this.configuration = configuration;
-    }
-
-    public Collection<Host> getHosts() {
-      return hosts;
-    }
-
-    public void setHosts(Collection<Host> hosts) {
-      this.hosts = hosts;
-    }
-
-    public int getHostCount() {
-      return hostCount;
-    }
-
-    public void setHostCount(int hostCount) {
-      this.hostCount = hostCount;
-    }
-
-    public String getHostPredicate() {
-      return hostPredicate;
-    }
-
-    public void setHostPredicate(String hostPredicate) {
-      this.hostPredicate = hostPredicate;
-    }
-
-    void validate() throws IllegalStateException {
-      Preconditions.checkState((hostCount == 0 && null == hostPredicate) || getHosts().isEmpty(),
-        "Invalid custer topology template. Host group %s must have either declatere its hosts or " +
-          "hostcount (and optionally host predicate)", name);
-    }
-  }
-
-  public static class Service implements Configurable {
-    private String name;
-    @JsonProperty("service_group")
-    private String serviceGroup;
-    @JsonIgnore
-    private Configuration configuration;
-
-    @Override
-    public Configuration getConfiguration() {
-      return configuration;
-    }
-
-    @Override
-    public void setConfiguration(Configuration configuration) {
-      this.configuration = configuration;
-    }
-
-    @JsonIgnore
-    public ServiceId getId() {
-      return new ServiceId(name, serviceGroup);
-    }
-
-    public String getName() {
-      return name;
-    }
-
-    public void setName(String name) {
-      this.name = name;
-    }
-
-    public String getServiceGroup() {
-      return serviceGroup;
-    }
-
-    public void setServiceGroup(String serviceGroup) {
-      this.serviceGroup = serviceGroup;
-    }
-  }
-
-  public static class Host {
-    private String fqdn;
-    @JsonProperty("rack_info")
-    private String  rackInfo;
-
-    public String getFqdn() {
-      return fqdn;
-    }
-
-    public void setFqdn(String fqdn) {
-      this.fqdn = fqdn;
-    }
-
-    public String getRackInfo() {
-      return rackInfo;
-    }
-
-    public void setRackInfo(String rackInfo) {
-      this.rackInfo = rackInfo;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplateFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplateFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplateFactory.java
deleted file mode 100644
index cd99fa1..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ProvisionClusterTemplateFactory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distribut
- * ed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.topology;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-public class ProvisionClusterTemplateFactory {
-
-  private ObjectMapper objectMapper;
-
-  public ProvisionClusterTemplateFactory() {
-    createObjectMapper();
-  }
-
-  public boolean isPrettyPrintJson() {
-    return objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT);
-  }
-
-  public void setPrettyPrintJson(boolean prettyPrintJson) {
-    if (prettyPrintJson) {
-      objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
-    }
-    else {
-      objectMapper.disable(SerializationFeature.INDENT_OUTPUT);
-    }
-  }
-
-  public ObjectMapper getObjectMapper() {
-    return objectMapper;
-  }
-
-  private void createObjectMapper() {
-    objectMapper = new ObjectMapper();
-    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-  }
-
-  public ProvisionClusterTemplate convertFromJson(String clusterTemplateJson) throws IOException {
-    ProvisionClusterTemplate template = objectMapper.readValue(clusterTemplateJson, ProvisionClusterTemplate.class);
-    template.validate();
-    return template;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplate.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplate.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplate.java
new file mode 100644
index 0000000..fabd846
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplate.java
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distribut
+ * ed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.topology;
+
+import static java.util.stream.Collectors.toMap;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+import org.apache.ambari.server.controller.internal.ProvisionAction;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+
+public class TopologyTemplate {
+
+  private String blueprint = null;
+
+  @JsonProperty("default_password")
+  private String defaultPassword = null;
+
+  @JsonProperty("config_recommendation_strategy")
+  private ConfigRecommendationStrategy configRecommendationStrategy;
+
+  @JsonProperty("provision_action")
+  private ProvisionAction provisionAction;
+
+  private Map<ServiceId, TopologyTemplate.Service> servicesById = Collections.emptyMap();
+
+  private Map<String, TopologyTemplate.HostGroup> hostGroups = Collections.emptyMap();
+
+  private Collection<Credential> credentials;
+
+  @JsonProperty("security")
+  private SecurityConfiguration securityConfiguration;
+
+  public String getBlueprint() {
+    return blueprint;
+  }
+
+  public void setBlueprint(String blueprint) {
+    this.blueprint = blueprint;
+  }
+
+  public String getDefaultPassword() {
+    return defaultPassword;
+  }
+
+  public void setDefaultPassword(String defaultPassword) {
+    this.defaultPassword = defaultPassword;
+  }
+
+  public @Nullable Service getServiceById(ServiceId serviceId) {
+    return servicesById.get(serviceId);
+  }
+
+  @JsonProperty("services")
+  public Collection<Service> getServices() {
+    return servicesById.values();
+  }
+
+  @JsonProperty("services")
+  public void setServices(Collection<Service> services) {
+    this.servicesById = services.stream().collect(toMap(
+      s -> s.getId(),
+      s -> s
+    ));
+  }
+
+  public Collection<Credential> getCredentials() {
+    return credentials;
+  }
+
+  public void setCredentials(Collection<Credential> credentials) {
+    this.credentials = credentials;
+  }
+
+  public SecurityConfiguration getSecurityConfiguration() {
+    return securityConfiguration;
+  }
+
+  public void setSecurityConfiguration(SecurityConfiguration securityConfiguration) {
+    this.securityConfiguration = securityConfiguration;
+  }
+
+  public ConfigRecommendationStrategy getConfigRecommendationStrategy() {
+    return configRecommendationStrategy;
+  }
+
+  public void setConfigRecommendationStrategy(ConfigRecommendationStrategy configRecommendationStrategy) {
+    this.configRecommendationStrategy = configRecommendationStrategy;
+  }
+
+  public ProvisionAction getProvisionAction() {
+    return provisionAction;
+  }
+
+  public void setProvisionAction(ProvisionAction provisionAction) {
+    this.provisionAction = provisionAction;
+  }
+
+  @JsonProperty("host_groups")
+  public Collection<HostGroup> getHostGroups() {
+    return hostGroups.values();
+  }
+
+  public HostGroup getHostGroupByName(String name) {
+    return hostGroups.get(name);
+  }
+
+  @JsonProperty("host_groups")
+  public void setHostGroups(Collection<HostGroup> hostGroups) {
+    this.hostGroups = hostGroups.stream().collect(toMap(
+      hg -> hg.getName(),
+      hg -> hg
+    ));
+  }
+
+  public void validate() throws IllegalStateException {
+    getHostGroups().forEach(HostGroup::validate);
+  }
+
+  public static class HostGroup implements Configurable {
+    private String name;
+    @JsonIgnore
+    private Configuration configuration;
+    private Collection<Host> hosts = Collections.emptyList();
+    @JsonProperty("host_count")
+    private int hostCount = 0;
+    @JsonProperty("host_predicate")
+    private String hostPredicate;
+
+    public String getName() {
+      return name;
+    }
+
+    public void setName(String name) {
+      this.name = name;
+    }
+
+    @Override
+    public Configuration getConfiguration() {
+      return configuration;
+    }
+
+    @Override
+    public void setConfiguration(Configuration configuration) {
+      this.configuration = configuration;
+    }
+
+    public Collection<Host> getHosts() {
+      return hosts;
+    }
+
+    public void setHosts(Collection<Host> hosts) {
+      this.hosts = hosts;
+    }
+
+    public int getHostCount() {
+      return hostCount;
+    }
+
+    public void setHostCount(int hostCount) {
+      this.hostCount = hostCount;
+    }
+
+    public String getHostPredicate() {
+      return hostPredicate;
+    }
+
+    public void setHostPredicate(String hostPredicate) {
+      this.hostPredicate = hostPredicate;
+    }
+
+    void validate() throws IllegalStateException {
+      Preconditions.checkState((hostCount == 0 && null == hostPredicate) || getHosts().isEmpty(),
+        "Invalid custer topology template. Host group %s must have either declatere its hosts or " +
+          "hostcount (and optionally host predicate)", name);
+    }
+  }
+
+  public static class Service implements Configurable {
+    private String name;
+    @JsonProperty("service_group")
+    private String serviceGroup;
+    @JsonIgnore
+    private Configuration configuration;
+
+    @Override
+    public Configuration getConfiguration() {
+      return configuration;
+    }
+
+    @Override
+    public void setConfiguration(Configuration configuration) {
+      this.configuration = configuration;
+    }
+
+    @JsonIgnore
+    public ServiceId getId() {
+      return new ServiceId(name, serviceGroup);
+    }
+
+    public String getName() {
+      return name;
+    }
+
+    public void setName(String name) {
+      this.name = name;
+    }
+
+    public String getServiceGroup() {
+      return serviceGroup;
+    }
+
+    public void setServiceGroup(String serviceGroup) {
+      this.serviceGroup = serviceGroup;
+    }
+  }
+
+  public static class Host {
+    private String fqdn;
+    @JsonProperty("rack_info")
+    private String  rackInfo;
+
+    public String getFqdn() {
+      return fqdn;
+    }
+
+    public void setFqdn(String fqdn) {
+      this.fqdn = fqdn;
+    }
+
+    public String getRackInfo() {
+      return rackInfo;
+    }
+
+    public void setRackInfo(String rackInfo) {
+      this.rackInfo = rackInfo;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplateFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplateFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplateFactory.java
new file mode 100644
index 0000000..93765de
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyTemplateFactory.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distribut
+ * ed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.topology;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+public class TopologyTemplateFactory {
+
+  private ObjectMapper objectMapper;
+
+  public TopologyTemplateFactory() {
+    createObjectMapper();
+  }
+
+  public boolean isPrettyPrintJson() {
+    return objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT);
+  }
+
+  public void setPrettyPrintJson(boolean prettyPrintJson) {
+    if (prettyPrintJson) {
+      objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
+    }
+    else {
+      objectMapper.disable(SerializationFeature.INDENT_OUTPUT);
+    }
+  }
+
+  public ObjectMapper getObjectMapper() {
+    return objectMapper;
+  }
+
+  private void createObjectMapper() {
+    objectMapper = new ObjectMapper();
+    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+  }
+
+  public TopologyTemplate convertFromJson(String clusterTemplateJson) throws IOException {
+    TopologyTemplate template = objectMapper.readValue(clusterTemplateJson, TopologyTemplate.class);
+    template.validate();
+    return template;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/test/java/org/apache/ambari/server/topology/ProvisionClusterTemplateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ProvisionClusterTemplateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ProvisionClusterTemplateTest.java
deleted file mode 100644
index 3bb6ea4..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ProvisionClusterTemplateTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distribut
- * ed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.topology;
-
-import static java.util.stream.Collectors.toSet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.junit.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Resources;
-
-public class ProvisionClusterTemplateTest {
-
-  public static final String CLUSTER_TEMPLATE =
-    getResource("blueprintv2/cluster_template_v2.json");
-  public static final String CLUSTER_TEMPLATE_INVALID =
-    getResource("blueprintv2/cluster_template_v2_invalid_hostgroup.json");
-
-
-  @Test
-  public void testProvisionClusterTemplate() throws Exception {
-    ProvisionClusterTemplateFactory factory = new ProvisionClusterTemplateFactory();
-    ProvisionClusterTemplate template = factory.convertFromJson(CLUSTER_TEMPLATE);
-    verifyClusterTemplate(template);
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void testProvisionClusterTemplateInvalidTemplate() throws Exception {
-    ProvisionClusterTemplateFactory factory = new ProvisionClusterTemplateFactory();
-    ProvisionClusterTemplate template = factory.convertFromJson(CLUSTER_TEMPLATE_INVALID);
-  }
-
-
-  private void verifyClusterTemplate(ProvisionClusterTemplate template) {
-    ProvisionClusterTemplate.Service zk1 = template.getServiceById(ServiceId.of("ZK1", "CORE_SG"));
-    assertNotNull(zk1);
-    Map<String, Map<String, String>> expectedZkProperties = ImmutableMap.of(
-      "zoo.cfg", ImmutableMap.of("dataDir", "/zookeeper1"));
-    assertEquals(expectedZkProperties, zk1.getConfiguration().getProperties());
-
-    ProvisionClusterTemplate.Service hdfs = template.getServiceById(ServiceId.of("HDFS", "CORE_SG"));
-    Map<String, Map<String, String>> expectedHdfsProperties = ImmutableMap.of(
-      "hdfs-site", ImmutableMap.of("property-name", "property-value"));
-    assertNotNull(hdfs);
-    assertEquals(expectedHdfsProperties, hdfs.getConfiguration().getProperties());
-
-    ProvisionClusterTemplate.HostGroup hostGroup1 = template.getHostGroupByName("host-group-1");
-    assertNotNull(hostGroup1);
-    assertEquals(2, hostGroup1.getHosts().size());
-    assertEquals(0, hostGroup1.getHostCount());
-    assertEquals(ImmutableSet.of("host.domain.com", "host2.domain.com"),
-      hostGroup1.getHosts().stream().map(host -> host.getFqdn()).collect(toSet()));
-    hostGroup1.getHosts().forEach(host -> assertEquals("/dc1/rack1", host.getRackInfo()));
-
-    ProvisionClusterTemplate.HostGroup hostGroup2 = template.getHostGroupByName("host-group-2");
-    assertNotNull(hostGroup2);
-    assertEquals(0, hostGroup2.getHosts().size());
-    assertEquals(2, hostGroup2.getHostCount());
-    assertEquals("Hosts/os_type=centos6&Hosts/cpu_count=2", hostGroup2.getHostPredicate());
-  }
-
-
-  private static String getResource(String fileName) {
-    try {
-      return Resources.toString(Resources.getResource(fileName), Charsets.UTF_8);
-    }
-    catch (IOException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b49f78ab/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyTemplateFactoryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyTemplateFactoryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyTemplateFactoryTest.java
new file mode 100644
index 0000000..17f443b
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyTemplateFactoryTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distribut
+ * ed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.topology;
+
+import static java.util.stream.Collectors.toSet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Resources;
+
+public class TopologyTemplateFactoryTest {
+
+  public static final String CLUSTER_TEMPLATE =
+    getResource("blueprintv2/cluster_template_v2.json");
+  public static final String CLUSTER_TEMPLATE_INVALID =
+    getResource("blueprintv2/cluster_template_v2_invalid_hostgroup.json");
+
+
+  @Test
+  public void testProvisionClusterTemplate() throws Exception {
+    TopologyTemplateFactory factory = new TopologyTemplateFactory();
+    TopologyTemplate template = factory.convertFromJson(CLUSTER_TEMPLATE);
+    verifyClusterTemplate(template);
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void testProvisionClusterTemplateInvalidTemplate() throws Exception {
+    TopologyTemplateFactory factory = new TopologyTemplateFactory();
+    TopologyTemplate template = factory.convertFromJson(CLUSTER_TEMPLATE_INVALID);
+  }
+
+
+  private void verifyClusterTemplate(TopologyTemplate template) {
+    TopologyTemplate.Service zk1 = template.getServiceById(ServiceId.of("ZK1", "CORE_SG"));
+    assertNotNull(zk1);
+    Map<String, Map<String, String>> expectedZkProperties = ImmutableMap.of(
+      "zoo.cfg", ImmutableMap.of("dataDir", "/zookeeper1"));
+    assertEquals(expectedZkProperties, zk1.getConfiguration().getProperties());
+
+    TopologyTemplate.Service hdfs = template.getServiceById(ServiceId.of("HDFS", "CORE_SG"));
+    Map<String, Map<String, String>> expectedHdfsProperties = ImmutableMap.of(
+      "hdfs-site", ImmutableMap.of("property-name", "property-value"));
+    assertNotNull(hdfs);
+    assertEquals(expectedHdfsProperties, hdfs.getConfiguration().getProperties());
+
+    TopologyTemplate.HostGroup hostGroup1 = template.getHostGroupByName("host-group-1");
+    assertNotNull(hostGroup1);
+    assertEquals(2, hostGroup1.getHosts().size());
+    assertEquals(0, hostGroup1.getHostCount());
+    assertEquals(ImmutableSet.of("host.domain.com", "host2.domain.com"),
+      hostGroup1.getHosts().stream().map(host -> host.getFqdn()).collect(toSet()));
+    hostGroup1.getHosts().forEach(host -> assertEquals("/dc1/rack1", host.getRackInfo()));
+
+    TopologyTemplate.HostGroup hostGroup2 = template.getHostGroupByName("host-group-2");
+    assertNotNull(hostGroup2);
+    assertEquals(0, hostGroup2.getHosts().size());
+    assertEquals(2, hostGroup2.getHostCount());
+    assertEquals("Hosts/os_type=centos6&Hosts/cpu_count=2", hostGroup2.getHostPredicate());
+  }
+
+
+  private static String getResource(String fileName) {
+    try {
+      return Resources.toString(Resources.getResource(fileName), Charsets.UTF_8);
+    }
+    catch (IOException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+}