AMBARI-21005. Remove GSInstaller code (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fb20c7c5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fb20c7c5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fb20c7c5 Branch: refs/heads/branch-feature-AMBARI-12556 Commit: fb20c7c522a2afbb8ef25743ba770b574bb36ab8 Parents: 8f9786b Author: Lisnichenko Dmitro <[email protected]> Authored: Fri May 12 17:41:21 2017 +0300 Committer: Lisnichenko Dmitro <[email protected]> Committed: Fri May 12 17:41:21 2017 +0300 ---------------------------------------------------------------------- ambari-server/pom.xml | 1 - .../gsinstaller/ClusterDefinition.java | 434 ------------------- .../gsinstaller/GSInstallerClusterProvider.java | 71 --- .../GSInstallerComponentProvider.java | 88 ---- .../GSInstallerHostComponentProvider.java | 99 ----- .../gsinstaller/GSInstallerHostProvider.java | 86 ---- .../gsinstaller/GSInstallerNoOpProvider.java | 60 --- .../gsinstaller/GSInstallerProviderModule.java | 93 ---- .../GSInstallerResourceProvider.java | 234 ---------- .../gsinstaller/GSInstallerServiceProvider.java | 82 ---- .../gsinstaller/GSInstallerStateProvider.java | 35 -- .../GSInstallerClusterProviderTest.java | 104 ----- .../GSInstallerComponentProviderTest.java | 102 ----- .../GSInstallerHostComponentProviderTest.java | 149 ------- .../GSInstallerHostProviderTest.java | 153 ------- .../GSInstallerNoOpProviderTest.java | 46 -- .../GSInstallerServiceProviderTest.java | 166 ------- .../TestGSInstallerStateProvider.java | 36 -- 18 files changed, 2039 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml index 8635608..67a5b4e 100644 --- a/ambari-server/pom.xml +++ b/ambari-server/pom.xml @@ -283,7 +283,6 @@ <exclude>pass.txt</exclude> <exclude>src/test/resources/version</exclude> <exclude>src/test/resources/users.ldif</exclude> - <exclude>src/test/resources/gsInstaller-hosts.txt</exclude> <exclude>src/test/resources/temporal_ganglia_data.txt</exclude> <exclude>src/test/resources/users.ldif</exclude> <exclude>src/test/resources/mpacks_replay.log</exclude> http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java deleted file mode 100644 index 487ebff..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java +++ /dev/null @@ -1,434 +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 distributed 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.controller.gsinstaller; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.ambari.server.utils.Closeables; - -/** - * Defines the cluster created by gsInstaller. - */ -public class ClusterDefinition { - - private static final String CLUSTER_DEFINITION_FILE = "gsInstaller-hosts.txt"; - private static final String DEFAULT_CLUSTER_NAME = "ambari"; - private static final String CLUSTER_NAME_TAG = "CLUSTER="; - private static final String DEFAULT_VERSION_ID = "HDP-1.2.0"; - private static final String VERSION_ID_TAG = "VERSION="; - - private final Set<String> services = new HashSet<>(); - private final Set<String> hosts = new HashSet<>(); - private final Map<String, Set<String>> components = new HashMap<>(); - private final Map<String, Map<String, Set<String>>> hostComponents = new HashMap<>(); - - private final GSInstallerStateProvider stateProvider; - private String clusterName; - private String versionId; - - /** - * Index of host names to host component state. - */ - private final Map<String, Set<HostComponentState>> hostStateMap = new HashMap<>(); - - /** - * Index of service names to host component state. - */ - private final Map<String, Set<HostComponentState>> serviceStateMap = new HashMap<>(); - - /** - * Index of component names to host component state. - */ - private final Map<String, Set<HostComponentState>> componentStateMap = new HashMap<>(); - - /** - * Index of host component names to host component state. - */ - private final Map<String, HostComponentState> hostComponentStateMap = new HashMap<>(); - - /** - * Expiry for the health value. - */ - private static final int DEFAULT_STATE_EXPIRY = 15000; - - /** - * Component name mapping to account for differences in what is provided by the gsInstaller - * and what is expected by the Ambari providers. - */ - private static final Map<String, String> componentNameMap = new HashMap<>(); - - static { - componentNameMap.put("GANGLIA", "GANGLIA_SERVER"); - } - - // ----- Constructors ------------------------------------------------------ - - /** - * Create a cluster definition. - * - * @param stateProvider the state provider - */ - public ClusterDefinition(GSInstallerStateProvider stateProvider) { - this(stateProvider, DEFAULT_STATE_EXPIRY); - } - - /** - * Create a cluster definition. - * - * @param stateProvider the state provider - * @param stateExpiry the state expiry - */ - public ClusterDefinition(GSInstallerStateProvider stateProvider, int stateExpiry) { - this.stateProvider = stateProvider; - this.clusterName = DEFAULT_CLUSTER_NAME; - this.versionId = DEFAULT_VERSION_ID; - readClusterDefinition(); - setHostComponentState(stateExpiry); - } - - // ----- ClusterDefinition ------------------------------------------------- - - /** - * Get the name of the cluster. - * - * @return the cluster name - */ - public String getClusterName() { - return clusterName; - } - - /** - * Get the name of the cluster. - * - * @return the cluster name - */ - public String getVersionId() { - return versionId; - } - - /** - * Get the services for the cluster. - * - * @return the set of service names - */ - public Set<String> getServices() { - return services; - } - - /** - * Get the hosts for the cluster. - * - * @return the set of hosts names - */ - public Set<String> getHosts() { - return hosts; - } - - /** - * Get the components for the given service. - * - * @param service the service name - * - * @return the set of component names for the given service name - */ - public Set<String> getComponents(String service) { - return components.get(service); - } - - /** - * Get the host components for the given service and host. - * - * @param service the service name - * @param host the host name - * - * @return the set of host component names for the given service and host names - */ - public Set<String> getHostComponents(String service, String host) { - Set<String> resultSet = null; - Map<String, Set<String>> serviceHostComponents = hostComponents.get(service); - if (serviceHostComponents != null) { - resultSet = serviceHostComponents.get(host); - } - return resultSet == null ? Collections.<String>emptySet() : resultSet; - } - - /** - * Get the host state from the given host name. - * - * @param hostName the host name - * - * @return the host state - */ - public String getHostState(String hostName) { - return isHealthy(hostStateMap.get(hostName)) ? "HEALTHY" : "INIT"; - } - - /** - * Get the service state from the given service name. - * - * @param serviceName the service name - * - * @return the service state - */ - public String getServiceState(String serviceName) { - return isHealthy(serviceStateMap.get(serviceName)) ? "STARTED" : "INIT"; - } - - /** - * Get the component state from the give service name and component name. - * - * @param serviceName the service name - * @param componentName the component name - * - * @return the component state - */ - public String getComponentState(String serviceName, String componentName) { - return isHealthy(componentStateMap.get(getComponentKey(serviceName, componentName))) ? "STARTED" : "INIT"; - } - - /** - * Get the host component name from the given host name, service name and component name. - * - * @param hostName the host name - * @param serviceName the service name - * @param componentName the component name - * - * @return the host component state - */ - public String getHostComponentState(String hostName, String serviceName, String componentName) { - return isHealthy(hostComponentStateMap.get(getHostComponentKey(hostName, serviceName, componentName))) ? "STARTED" : "INIT"; - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Read the gsInstaller cluster definition file. - */ - private void readClusterDefinition() { - InputStream is = null; - try { - is = this.getClass().getClassLoader().getResourceAsStream(CLUSTER_DEFINITION_FILE); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - - String line; - while ((line = br.readLine()) != null) { - line = line.trim(); - if (line.startsWith(CLUSTER_NAME_TAG)) { - clusterName = line.substring(CLUSTER_NAME_TAG.length()); - } - else if (line.startsWith(VERSION_ID_TAG)) { - versionId = line.substring(VERSION_ID_TAG.length()); - } - else { - String[] parts = line.split("\\s+"); - assert(parts.length == 3); - - String serviceName = parts[0]; - String componentName = parts[1]; - String hostName = parts[2]; - - // translate the component name if required - if (componentNameMap.containsKey(componentName)) { - componentName = componentNameMap.get(componentName); - } - - services.add(serviceName); - Set<String> serviceComponents = components.get(serviceName); - if (serviceComponents == null) { - serviceComponents = new HashSet<>(); - components.put(serviceName, serviceComponents); - } - serviceComponents.add(componentName); - - Map<String, Set<String>> serviceHostComponents = hostComponents.get(serviceName); - if (serviceHostComponents == null) { - serviceHostComponents = new HashMap<>(); - hostComponents.put(serviceName, serviceHostComponents); - } - - Set<String> hostHostComponents = serviceHostComponents.get(hostName); - if (hostHostComponents == null) { - hostHostComponents = new HashSet<>(); - serviceHostComponents.put(hostName, hostHostComponents); - } - hostHostComponents.add(componentName); - hosts.add(hostName); - } - } - } catch (IOException e) { - String msg = "Caught exception reading " + CLUSTER_DEFINITION_FILE + "."; - throw new IllegalStateException(msg, e); - } finally { - Closeables.closeSilently(is); - } - } - - /** - * Set the host component state maps. - */ - private void setHostComponentState(int stateExpiry) { - for (Map.Entry<String, Map<String, Set<String>>> serviceEntry : hostComponents.entrySet()) { - String serviceName = serviceEntry.getKey(); - - for (Map.Entry<String, Set<String>> hostEntry : serviceEntry.getValue().entrySet()) { - String hostName = hostEntry.getKey(); - - for (String componentName : hostEntry.getValue()) { - - HostComponentState state = new HostComponentState(hostName, componentName, stateExpiry); - - // add state to hosts - addState(hostName, hostStateMap, state); - - // add state to services - addState(serviceName, serviceStateMap, state); - - // add state to components - addState(getComponentKey(serviceName, componentName), componentStateMap, state); - - // add state to host components - hostComponentStateMap.put(getHostComponentKey(hostName, serviceName, componentName), state); - } - } - } - } - - /** - * Add the given host component state object to the given map of state objects. - * - * @param hostName the host name - * @param stateMap the map of state objects - * @param state the state - */ - private static void addState(String hostName, Map<String, Set<HostComponentState>> stateMap, HostComponentState state) { - Set<HostComponentState> states = stateMap.get(hostName); - if (states == null) { - states = new HashSet<>(); - stateMap.put(hostName, states); - } - states.add(state); - } - - /** - * Get a key from the given service name and component name. - * - * @param serviceName the service name - * @param componentName the component name - * - * @return the key - */ - private String getComponentKey(String serviceName, String componentName) { - return serviceName + "." + componentName; - } - - /** - * Get a key from the given host name, service name and component name. - * - * @param hostName the host name - * @param serviceName the service name - * @param componentName the component name - * - * @return the key - */ - private String getHostComponentKey(String hostName, String serviceName, String componentName) { - return hostName + "." + serviceName + "." + componentName; - } - - /** - * Determine whether or not the host components associated - * with the given states are healthy. - * - * @param states the states - * - * @return true if the associated host components are healthy - */ - private boolean isHealthy(Set<HostComponentState> states) { - if (states != null) { - for (HostComponentState state : states) { - if (!state.isHealthy()) { - return false; - } - } - } - return true; - } - - /** - * Determine whether or not the host component associated - * with the given state is healthy. - * - * @param state the state - * - * @return true if the associated host component is healthy - */ - private boolean isHealthy(HostComponentState state) { - return state == null || state.isHealthy(); - } - - - // ----- inner classes ----------------------------------------------------- - - /** - * A state object used to check the health of a host component. - */ - private class HostComponentState { - private final String hostName; - private final String componentName; - private final int expiry; - private boolean healthy = true; - private long lastAccess; - - // ----- Constructor ----------------------------------------------------- - - /** - * Constructor. - * - * @param hostName the host name - * @param componentName the component name - */ - HostComponentState(String hostName, String componentName, int expiry) { - this.hostName = hostName; - this.componentName = componentName; - this.expiry = expiry; - } - - /** - * Determine whether or not the associated host component is healthy. - * - * @return true if the associated host component is healthy - */ - public boolean isHealthy() { - if (System.currentTimeMillis() - lastAccess > expiry) { - // health value has expired... get it again - healthy = stateProvider.isHealthy(hostName, componentName); - this.lastAccess = System.currentTimeMillis(); - } - return healthy; - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java deleted file mode 100644 index 784f51c..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java +++ /dev/null @@ -1,71 +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 distributed 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.controller.gsinstaller; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - -/** - * A cluster resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerClusterProvider extends GSInstallerResourceProvider{ - - // Clusters - protected static final String CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("Clusters", "cluster_name"); - protected static final String CLUSTER_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("Clusters", "version"); - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerClusterProvider(ClusterDefinition clusterDefinition) { - super(Resource.Type.Cluster, clusterDefinition); - initClusterResources(); - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - // Do nothing - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Create the resources based on the cluster definition. - */ - private void initClusterResources() { - Resource cluster = new ResourceImpl(Resource.Type.Cluster); - ClusterDefinition clusterDefinition = getClusterDefinition(); - cluster.setProperty(CLUSTER_NAME_PROPERTY_ID, clusterDefinition.getClusterName()); - cluster.setProperty(CLUSTER_VERSION_PROPERTY_ID, clusterDefinition.getVersionId()); - - addResource(cluster); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProvider.java deleted file mode 100644 index b0d953a..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProvider.java +++ /dev/null @@ -1,88 +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 distributed 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.controller.gsinstaller; - -import java.util.Set; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - -/** - * A component resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerComponentProvider extends GSInstallerResourceProvider{ - - // Components - protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"); - protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceComponentInfo", "service_name"); - protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name"); - protected static final String COMPONENT_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceComponentInfo", "state"); - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerComponentProvider(ClusterDefinition clusterDefinition) { - super(Resource.Type.Component, clusterDefinition); - initComponentResources(); - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - - Set<String> propertyIds = getRequestPropertyIds(request, predicate); - if (contains(propertyIds, COMPONENT_STATE_PROPERTY_ID)) { - String serviceName = (String) resource.getPropertyValue(COMPONENT_SERVICE_NAME_PROPERTY_ID); - String componentName = (String) resource.getPropertyValue(COMPONENT_COMPONENT_NAME_PROPERTY_ID); - resource.setProperty(COMPONENT_STATE_PROPERTY_ID, getClusterDefinition().getComponentState(serviceName, componentName)); - } - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Create the resources based on the cluster definition. - */ - private void initComponentResources() { - String clusterName = getClusterDefinition().getClusterName(); - Set<String> services = getClusterDefinition().getServices(); - for (String serviceName : services) { - Set<String> components = getClusterDefinition().getComponents(serviceName); - for (String componentName : components) { - Resource component = new ResourceImpl(Resource.Type.Component); - component.setProperty(COMPONENT_CLUSTER_NAME_PROPERTY_ID, clusterName); - component.setProperty(COMPONENT_SERVICE_NAME_PROPERTY_ID, serviceName); - component.setProperty(COMPONENT_COMPONENT_NAME_PROPERTY_ID, componentName); - - addResource(component); - } - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProvider.java deleted file mode 100644 index d35c2ce..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProvider.java +++ /dev/null @@ -1,99 +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 distributed 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.controller.gsinstaller; - -import java.util.Set; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - -/** - * A host component resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerHostComponentProvider extends GSInstallerResourceProvider{ - - // Host Components - protected static final String HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "cluster_name"); - protected static final String HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "service_name"); - protected static final String HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "component_name"); - protected static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "host_name"); - protected static final String HOST_COMPONENT_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "state"); - protected static final String HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "desired_state"); - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerHostComponentProvider(ClusterDefinition clusterDefinition) { - super(Resource.Type.HostComponent, clusterDefinition); - initHostComponentResources(); - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - Set<String> propertyIds = getRequestPropertyIds(request, predicate); - if (contains(propertyIds, HOST_COMPONENT_STATE_PROPERTY_ID) || - contains(propertyIds, HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID)) { - String serviceName = (String) resource.getPropertyValue(HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID); - String componentName = (String) resource.getPropertyValue(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID); - String hostName = (String) resource.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID); - - String hostComponentState = getClusterDefinition().getHostComponentState(hostName, serviceName, componentName); - - resource.setProperty(HOST_COMPONENT_STATE_PROPERTY_ID, hostComponentState); - resource.setProperty(HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, hostComponentState); - } - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Create the resources based on the cluster definition. - */ - private void initHostComponentResources() { - String clusterName = getClusterDefinition().getClusterName(); - Set<String> services = getClusterDefinition().getServices(); - for (String serviceName : services) { - Set<String> hosts = getClusterDefinition().getHosts(); - for (String hostName : hosts) { - Set<String> hostComponents = getClusterDefinition().getHostComponents(serviceName, hostName); - for (String componentName : hostComponents) { - Resource hostComponent = new ResourceImpl(Resource.Type.HostComponent); - hostComponent.setProperty(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, clusterName); - hostComponent.setProperty(HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID, serviceName); - hostComponent.setProperty(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, componentName); - hostComponent.setProperty(HOST_COMPONENT_HOST_NAME_PROPERTY_ID, hostName); - - addResource(hostComponent); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProvider.java deleted file mode 100644 index 5b69da4..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProvider.java +++ /dev/null @@ -1,86 +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 distributed 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.controller.gsinstaller; - -import java.util.Set; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - -/** - * A host resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerHostProvider extends GSInstallerResourceProvider{ - - // Hosts - protected static final String HOST_CLUSTER_NAME_PROPERTY_ID = - PropertyHelper.getPropertyId("Hosts", "cluster_name"); - protected static final String HOST_NAME_PROPERTY_ID = - PropertyHelper.getPropertyId("Hosts", "host_name"); - protected static final String HOST_STATE_PROPERTY_ID = - PropertyHelper.getPropertyId("Hosts", "host_state"); - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerHostProvider(ClusterDefinition clusterDefinition) { - super(Resource.Type.Host, clusterDefinition); - initHostResources(); - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - Set<String> propertyIds = getRequestPropertyIds(request, predicate); - if (contains(propertyIds, HOST_STATE_PROPERTY_ID)) { - String hostName = (String) resource.getPropertyValue(HOST_NAME_PROPERTY_ID); - resource.setProperty(HOST_STATE_PROPERTY_ID, getClusterDefinition().getHostState(hostName)); - } - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Create the resources based on the cluster definition. - */ - private void initHostResources() { - ClusterDefinition clusterDefinition = getClusterDefinition(); - String clusterName = clusterDefinition.getClusterName(); - Set<String> hosts = clusterDefinition.getHosts(); - - for (String hostName : hosts) { - Resource host = new ResourceImpl(Resource.Type.Host); - host.setProperty(HOST_CLUSTER_NAME_PROPERTY_ID, clusterName); - host.setProperty(HOST_NAME_PROPERTY_ID, hostName); - - addResource(host); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProvider.java deleted file mode 100644 index af7ab29..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProvider.java +++ /dev/null @@ -1,60 +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 distributed 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.controller.gsinstaller; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; - -/** - * A NO-OP resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerNoOpProvider extends GSInstallerResourceProvider{ - - private final Map<Resource.Type, String> keyPropertyIds = new HashMap<>(); - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - // Do nothing - } - - // ----- Constructors ------------------------------------------------------ - - public GSInstallerNoOpProvider(Resource.Type type, ClusterDefinition clusterDefinition) { - super(type, clusterDefinition); - keyPropertyIds.put(type, "id"); - } - - - @Override - public Map<Resource.Type, String> getKeyPropertyIds() { - return keyPropertyIds; - } - - @Override - public Set<String> checkPropertyIds(Set<String> propertyIds) { - return Collections.emptySet(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerProviderModule.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerProviderModule.java deleted file mode 100644 index 018ae19..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerProviderModule.java +++ /dev/null @@ -1,93 +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 distributed 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.controller.gsinstaller; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.apache.ambari.server.controller.internal.AbstractProviderModule; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.spi.ResourceProvider; - -/** - * A provider module implementation that uses the GSInstaller resource provider. - */ -public class GSInstallerProviderModule extends AbstractProviderModule implements GSInstallerStateProvider{ - - private final ClusterDefinition clusterDefinition; - - private static final Map<String, String> PORTS = new HashMap<>(); - - static { - PORTS.put("NAMENODE", "50070"); - PORTS.put("DATANODE", "50075"); - PORTS.put("JOBTRACKER", "50030"); - PORTS.put("TASKTRACKER", "50060"); - PORTS.put("HBASE_MASTER", "60010"); - PORTS.put("HBASE_REGIONSERVER", "60030"); - } - - private static final int TIMEOUT = 5000; - - - // ----- Constructors ------------------------------------------------------ - - public GSInstallerProviderModule() { - clusterDefinition = new ClusterDefinition(this); - } - - - // ----- GSInstallerStateProvider ------------------------------------------ - - @Override - public boolean isHealthy(String hostName, String componentName) { - String port = PORTS.get(componentName); - if (port != null) { - StringBuilder sb = new StringBuilder(); - sb.append("http://").append(hostName); - sb.append(":").append(port); - - try { - HttpURLConnection connection = (HttpURLConnection) new URL(sb.toString()).openConnection(); - - connection.setRequestMethod("HEAD"); - connection.setConnectTimeout(TIMEOUT); - connection.setReadTimeout(TIMEOUT); - - int code = connection.getResponseCode(); - - return code >= 200 && code <= 399; - } catch (IOException exception) { - return false; - } - } - return true; - } - - - // ----- utility methods --------------------------------------------------- - - @Override - protected ResourceProvider createResourceProvider(Resource.Type type) { - return GSInstallerResourceProvider.getResourceProvider(type, clusterDefinition); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerResourceProvider.java deleted file mode 100644 index 7b76cb9..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerResourceProvider.java +++ /dev/null @@ -1,234 +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 distributed 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.controller.gsinstaller; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -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.PredicateHelper; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - - -/** - * An abstract resource provider for a gsInstaller defined cluster. - */ -public abstract class GSInstallerResourceProvider implements ResourceProvider { - - private final ClusterDefinition clusterDefinition; - - private final Set<Resource> resources = new HashSet<>(); - - private final Resource.Type type; - - private final Set<String> propertyIds; - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerResourceProvider(Resource.Type type, ClusterDefinition clusterDefinition) { - this.type = type; - this.clusterDefinition = clusterDefinition; - - Set<String> propertyIds = PropertyHelper.getPropertyIds(type); - this.propertyIds = new HashSet<>(propertyIds); - this.propertyIds.addAll(PropertyHelper.getCategories(propertyIds)); - } - - - // ----- ResourceProvider -------------------------------------------------- - - @Override - public RequestStatus createResources(Request request) - throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { - throw new UnsupportedOperationException("Management operations are not supported"); - } - - @Override - public Set<Resource> getResources(Request request, Predicate predicate) - throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - - Set<Resource> resultSet = new HashSet<>(); - - for (Resource resource : resources) { - if (predicate == null || predicate.evaluate(resource)) { - ResourceImpl newResource = new ResourceImpl(resource); - updateProperties(newResource, request, predicate); - resultSet.add(newResource); - } - } - return resultSet; - } - - @Override - public RequestStatus updateResources(Request request, Predicate predicate) - throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - throw new UnsupportedOperationException("Management operations are not supported"); - } - - @Override - public RequestStatus deleteResources(Request request, Predicate predicate) - throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - throw new UnsupportedOperationException("Management operations are not supported"); - } - - @Override - public Map<Resource.Type, String> getKeyPropertyIds() { - return PropertyHelper.getKeyPropertyIds(type); - } - - @Override - public Set<String> checkPropertyIds(Set<String> propertyIds) { - propertyIds = new HashSet<>(propertyIds); - propertyIds.removeAll(this.propertyIds); - return propertyIds; - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - /** - * Update the resource with any properties handled by the resource provider. - * - * @param resource the resource to update - * @param request the request - * @param predicate the predicate - */ - public abstract void updateProperties(Resource resource, Request request, Predicate predicate); - - - // ----- accessors --------------------------------------------------------- - - /** - * Get the configuration provider. - * - * @return the configuration provider - */ - protected ClusterDefinition getClusterDefinition() { - return clusterDefinition; - } - - /** - * Get the resource provider type. - * - * @return the type - */ - public Resource.Type getType() { - return type; - } - - -// ----- helper methods ---------------------------------------------------- - - /** - * Get the set of property ids required to satisfy the given request. - * - * @param request the request - * @param predicate the predicate - * - * @return the set of property ids needed to satisfy the request - */ - protected Set<String> getRequestPropertyIds(Request request, Predicate predicate) { - Set<String> propertyIds = request.getPropertyIds(); - - // if no properties are specified, then return them all - if (propertyIds == null || propertyIds.isEmpty()) { - return new HashSet<>(this.propertyIds); - } - - propertyIds = new HashSet<>(propertyIds); - - if (predicate != null) { - propertyIds.addAll(PredicateHelper.getPropertyIds(predicate)); - } - return propertyIds; - } - - /** - * Check to see if the given set contains a property or category id that matches the given property id. - * - * @param ids the set of property/category ids - * @param propertyId the property id - * - * @return true if the given set contains a property id or category that matches the given property id - */ - protected static boolean contains(Set<String> ids, String propertyId) { - boolean contains = ids.contains(propertyId); - - if (!contains) { - String category = PropertyHelper.getPropertyCategory(propertyId); - while (category != null && !contains) { - contains = ids.contains(category); - category = PropertyHelper.getPropertyCategory(category); - } - } - return contains; - } - - /** - * Add a resource to the set of resources provided by this provider. - * - * @param resource the resource to add - */ - protected void addResource(Resource resource) { - resources.add(resource); - } - - /** - * Factory method for obtaining a resource provider based on a given type. - * - * @param type the resource type - * @param clusterDefinition the cluster definition - * - * @return a new resource provider - */ - public static ResourceProvider getResourceProvider(Resource.Type type, - ClusterDefinition clusterDefinition) { - switch (type.getInternalType()) { - case Cluster: - return new GSInstallerClusterProvider(clusterDefinition); - case Service: - return new GSInstallerServiceProvider(clusterDefinition); - case Component: - return new GSInstallerComponentProvider(clusterDefinition); - case Host: - return new GSInstallerHostProvider(clusterDefinition); - case HostComponent: - return new GSInstallerHostComponentProvider(clusterDefinition); - default: - return new GSInstallerNoOpProvider(type, clusterDefinition); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerServiceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerServiceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerServiceProvider.java deleted file mode 100644 index 2438273..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerServiceProvider.java +++ /dev/null @@ -1,82 +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 distributed 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.controller.gsinstaller; - -import java.util.Set; - -import org.apache.ambari.server.controller.internal.ResourceImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Request; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; - -/** - * A service resource provider for a gsInstaller defined cluster. - */ -public class GSInstallerServiceProvider extends GSInstallerResourceProvider{ - - // Services - protected static final String SERVICE_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "cluster_name"); - protected static final String SERVICE_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "service_name"); - protected static final String SERVICE_SERVICE_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "state"); - - - // ----- Constructors ------------------------------------------------------ - - /** - * Construct a resource provider based on the given cluster definition. - * - * @param clusterDefinition the cluster definition - */ - public GSInstallerServiceProvider(ClusterDefinition clusterDefinition) { - super(Resource.Type.Service, clusterDefinition); - initServiceResources(); - } - - - // ----- GSInstallerResourceProvider --------------------------------------- - - @Override - public void updateProperties(Resource resource, Request request, Predicate predicate) { - Set<String> propertyIds = getRequestPropertyIds(request, predicate); - if (contains(propertyIds, SERVICE_SERVICE_STATE_PROPERTY_ID)) { - String serviceName = (String) resource.getPropertyValue(SERVICE_SERVICE_NAME_PROPERTY_ID); - resource.setProperty(SERVICE_SERVICE_STATE_PROPERTY_ID, getClusterDefinition().getServiceState(serviceName)); - } - } - - - // ----- helper methods ---------------------------------------------------- - - /** - * Create the resources based on the cluster definition. - */ - private void initServiceResources() { - String clusterName = getClusterDefinition().getClusterName(); - Set<String> services = getClusterDefinition().getServices(); - - for (String serviceName : services) { - Resource service = new ResourceImpl(Resource.Type.Service); - service.setProperty(SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName); - service.setProperty(SERVICE_SERVICE_NAME_PROPERTY_ID, serviceName); - - addResource(service); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerStateProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerStateProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerStateProvider.java deleted file mode 100644 index 3f9e272..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerStateProvider.java +++ /dev/null @@ -1,35 +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 distributed 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.controller.gsinstaller; - -/** - * Interface to provide component state to the gsInstaller resource provider. - */ -public interface GSInstallerStateProvider { - /** - * Determine whether or not the host component identified by the given host name - * and component name is healthy. - * - * @param hostName the host name - * @param componentName the component name - * - * @return true if the host component is healthy - */ - boolean isHealthy(String hostName, String componentName); -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProviderTest.java deleted file mode 100644 index 7583e66..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProviderTest.java +++ /dev/null @@ -1,104 +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 distributed 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.controller.gsinstaller; - -import java.util.HashMap; -import java.util.Set; - -import org.apache.ambari.server.controller.internal.RequestImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PredicateBuilder; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.junit.Test; - -import junit.framework.Assert; - -/** - * Tests for GSInstallerClusterProvider - */ -public class GSInstallerClusterProviderTest { - - @Test - public void testGetResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - - GSInstallerResourceProvider provider = new GSInstallerClusterProvider(clusterDefinition); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), null); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals("ambari", resources.iterator().next().getPropertyValue(GSInstallerClusterProvider.CLUSTER_NAME_PROPERTY_ID)); - } - - @Test - public void testGetResourcesWithPredicate() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - - GSInstallerResourceProvider provider = new GSInstallerClusterProvider(clusterDefinition); - - Predicate predicate = new PredicateBuilder().property(GSInstallerClusterProvider.CLUSTER_NAME_PROPERTY_ID).equals("ambari").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - Resource next = resources.iterator().next(); - Assert.assertEquals("ambari", next.getPropertyValue(GSInstallerClusterProvider.CLUSTER_NAME_PROPERTY_ID)); - Assert.assertEquals("HDP-1.2.0", next.getPropertyValue(GSInstallerClusterProvider.CLUSTER_VERSION_PROPERTY_ID)); - - predicate = new PredicateBuilder().property(GSInstallerClusterProvider.CLUSTER_NAME_PROPERTY_ID).equals("non-existent Cluster").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertTrue(resources.isEmpty()); - } - - @Test - public void testCreateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerClusterProvider(clusterDefinition); - - try { - provider.createResources(PropertyHelper.getReadRequest()); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testUpdateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerClusterProvider(clusterDefinition); - - try { - provider.updateResources(PropertyHelper.getUpdateRequest(new HashMap<String, Object>(), null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testDeleteResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerClusterProvider(clusterDefinition); - - try { - provider.deleteResources(new RequestImpl(null, null, null, null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProviderTest.java deleted file mode 100644 index 2e26ec9..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerComponentProviderTest.java +++ /dev/null @@ -1,102 +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 distributed 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.controller.gsinstaller; - -import java.util.HashMap; -import java.util.Set; - -import org.apache.ambari.server.controller.internal.RequestImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PredicateBuilder; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.junit.Test; - -import junit.framework.Assert; - -/** - * Tests for GSInstallerComponentProvider. - */ -public class GSInstallerComponentProviderTest { - - @Test - public void testGetResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerComponentProvider(clusterDefinition); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), null); - Assert.assertEquals(24, resources.size()); - } - - @Test - public void testGetResourcesWithPredicate() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerComponentProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerComponentProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("TASKTRACKER").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - - predicate = new PredicateBuilder().property(GSInstallerComponentProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("TASKTRACKER").or(). - property(GSInstallerComponentProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("GANGLIA_MONITOR").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(2, resources.size()); - - predicate = new PredicateBuilder().property(GSInstallerComponentProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("BadComponent").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertTrue(resources.isEmpty()); - } - - @Test - public void testCreateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerComponentProvider(clusterDefinition); - - try { - provider.createResources(PropertyHelper.getReadRequest()); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testUpdateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerComponentProvider(clusterDefinition); - - try { - provider.updateResources(PropertyHelper.getUpdateRequest(new HashMap<String, Object>(), null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testDeleteResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerComponentProvider(clusterDefinition); - - try { - provider.deleteResources(new RequestImpl(null, null, null, null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProviderTest.java deleted file mode 100644 index 2552fa4..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostComponentProviderTest.java +++ /dev/null @@ -1,149 +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 distributed 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.controller.gsinstaller; - -import java.util.HashMap; -import java.util.Set; - -import org.apache.ambari.server.controller.internal.RequestImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PredicateBuilder; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.junit.Test; - -import junit.framework.Assert; - -/** - * - */ -public class GSInstallerHostComponentProviderTest { - - @Test - public void testGetResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), null); - Assert.assertEquals(32, resources.size()); - } - - @Test - public void testGetResourcesWithPredicate() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostComponentProvider.HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID).equals("MAPREDUCE").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(5, resources.size()); - - predicate = new PredicateBuilder().property(GSInstallerHostComponentProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID).equals("UnknownHost").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertTrue(resources.isEmpty()); - } - - @Test - public void testGetResourcesCheckState() throws Exception { - TestGSInstallerStateProvider stateProvider = new TestGSInstallerStateProvider(); - ClusterDefinition clusterDefinition = new ClusterDefinition(stateProvider, 500); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostComponentProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("HBASE_REGIONSERVER").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(3, resources.size()); - - for (Resource resource : resources) { - Assert.assertEquals("STARTED", resource.getPropertyValue(GSInstallerHostComponentProvider.HOST_COMPONENT_STATE_PROPERTY_ID)); - } - - stateProvider.setHealthy(false); - - // need to wait for old state value to expire - Thread.sleep(501); - - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(3, resources.size()); - - for (Resource resource : resources) { - Assert.assertEquals("INIT", resource.getPropertyValue(GSInstallerHostComponentProvider.HOST_COMPONENT_STATE_PROPERTY_ID)); - } - } - - @Test - public void testGetResourcesCheckStateFromCategory() throws Exception { - TestGSInstallerStateProvider stateProvider = new TestGSInstallerStateProvider(); - ClusterDefinition clusterDefinition = new ClusterDefinition(stateProvider, 500); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostComponentProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("HBASE_REGIONSERVER").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest("HostRoles"), predicate); - Assert.assertEquals(3, resources.size()); - - for (Resource resource : resources) { - Assert.assertEquals("STARTED", resource.getPropertyValue(GSInstallerHostComponentProvider.HOST_COMPONENT_STATE_PROPERTY_ID)); - } - - stateProvider.setHealthy(false); - - // need to wait for old state value to expire - Thread.sleep(501); - - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(3, resources.size()); - - for (Resource resource : resources) { - Assert.assertEquals("INIT", resource.getPropertyValue(GSInstallerHostComponentProvider.HOST_COMPONENT_STATE_PROPERTY_ID)); - } - } - - @Test - public void testCreateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - - try { - provider.createResources(PropertyHelper.getReadRequest()); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testUpdateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - - try { - provider.updateResources(PropertyHelper.getUpdateRequest(new HashMap<String, Object>(), null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testDeleteResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostComponentProvider(clusterDefinition); - - try { - provider.deleteResources(new RequestImpl(null, null, null, null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProviderTest.java deleted file mode 100644 index beacc72..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerHostProviderTest.java +++ /dev/null @@ -1,153 +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 distributed 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.controller.gsinstaller; - -import java.util.HashMap; -import java.util.Set; - -import org.apache.ambari.server.controller.internal.RequestImpl; -import org.apache.ambari.server.controller.spi.Predicate; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PredicateBuilder; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.junit.Test; - -import junit.framework.Assert; - -/** - * - */ -public class GSInstallerHostProviderTest { - - @Test - public void testGetResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), null); - Assert.assertEquals(5, resources.size()); - } - - @Test - public void testGetResourcesWithPredicate() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("ip-10-190-97-104.ec2.internal").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - - predicate = new PredicateBuilder().property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("ip-10-190-97-104.ec2.internal").or(). - property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("ip-10-8-113-183.ec2.internal").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(2, resources.size()); - - predicate = new PredicateBuilder().property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("unknownHost").toPredicate(); - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertTrue(resources.isEmpty()); - } - - @Test - public void testGetResourcesCheckState() throws Exception { - TestGSInstallerStateProvider stateProvider = new TestGSInstallerStateProvider(); - ClusterDefinition clusterDefinition = new ClusterDefinition(stateProvider, 500); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("ip-10-190-97-104.ec2.internal").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - - Resource resource = resources.iterator().next(); - - Assert.assertEquals("HEALTHY", resource.getPropertyValue(GSInstallerHostProvider.HOST_STATE_PROPERTY_ID)); - - stateProvider.setHealthy(false); - - // need to wait for old state value to expire - Thread.sleep(501); - - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - - resource = resources.iterator().next(); - Assert.assertEquals("INIT", resource.getPropertyValue(GSInstallerHostProvider.HOST_STATE_PROPERTY_ID)); - } - - @Test - public void testGetResourcesCheckStateFromCategory() throws Exception { - TestGSInstallerStateProvider stateProvider = new TestGSInstallerStateProvider(); - ClusterDefinition clusterDefinition = new ClusterDefinition(stateProvider, 500); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - Predicate predicate = new PredicateBuilder().property(GSInstallerHostProvider.HOST_NAME_PROPERTY_ID).equals("ip-10-190-97-104.ec2.internal").toPredicate(); - Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest("Hosts"), predicate); - Assert.assertEquals(1, resources.size()); - - Resource resource = resources.iterator().next(); - - Assert.assertEquals("HEALTHY", resource.getPropertyValue(GSInstallerHostProvider.HOST_STATE_PROPERTY_ID)); - - stateProvider.setHealthy(false); - - // need to wait for old state value to expire - Thread.sleep(501); - - resources = provider.getResources(PropertyHelper.getReadRequest(), predicate); - Assert.assertEquals(1, resources.size()); - - resource = resources.iterator().next(); - Assert.assertEquals("INIT", resource.getPropertyValue(GSInstallerHostProvider.HOST_STATE_PROPERTY_ID)); - } - - @Test - public void testCreateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - - try { - provider.createResources(PropertyHelper.getReadRequest()); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testUpdateResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - - try { - provider.updateResources(PropertyHelper.getUpdateRequest(new HashMap<String, Object>(), null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } - - @Test - public void testDeleteResources() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerResourceProvider provider = new GSInstallerHostProvider(clusterDefinition); - - try { - provider.deleteResources(new RequestImpl(null, null, null, null), null); - Assert.fail("Expected UnsupportedOperationException."); - } catch (UnsupportedOperationException e) { - //expected - } - } -} - http://git-wip-us.apache.org/repos/asf/ambari/blob/fb20c7c5/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProviderTest.java deleted file mode 100644 index 9d1f053..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerNoOpProviderTest.java +++ /dev/null @@ -1,46 +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 distributed 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.controller.gsinstaller; - -import java.util.Collections; - -import org.apache.ambari.server.controller.spi.Resource; -import org.junit.Test; - -import junit.framework.Assert; - -/** - * GSInstallerNoOpProvider tests. - */ -public class GSInstallerNoOpProviderTest { - - @Test - public void testGetKeyPropertyIds() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerNoOpProvider provider = new GSInstallerNoOpProvider(Resource.Type.Workflow, clusterDefinition); - Assert.assertNotNull(provider.getKeyPropertyIds()); - } - - @Test - public void testCheckPropertyIds() throws Exception { - ClusterDefinition clusterDefinition = new ClusterDefinition(new TestGSInstallerStateProvider()); - GSInstallerNoOpProvider provider = new GSInstallerNoOpProvider(Resource.Type.Workflow, clusterDefinition); - Assert.assertTrue(provider.checkPropertyIds(Collections.singleton("id")).isEmpty()); - } -}
