@Test public void testDeleteHost() throws Exception { String clusterName = "TEST_DELETE_HOST"; String hostName1 = "HOSTNAME1", hostName2 = "HOSTNAME2"; String hostToDelete = hostName2; clusters.addCluster(clusterName, new StackId("HDP-2.1.1")); Cluster cluster = clusters.getCluster(clusterName); clusters.addHost(hostName1); clusters.addHost(hostName2); Host host1 = clusters.getHost(hostName1); host1.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0")); Host host2 = clusters.getHost(hostName2); host2.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0")); clusters.mapAndPublishHostsToCluster(Sets.newHashSet(hostName1, hostName2), clusterName); clusters.deleteHost(hostToDelete); assertTrue(clusters.getClustersForHost(hostToDelete).isEmpty()); assertFalse(clusters.getHostsForCluster(clusterName).containsKey(hostToDelete)); assertFalse(cluster.getHosts().contains(hostToDelete)); try { clusters.getHost(hostToDelete); fail("getHost(hostName) should throw Exception when invoked for deleted host !"); } catch(HostNotFoundException e){ } }
@Override public Set<String> getHosts(String serviceName, String componentName) { Map<String, Service> clusterServices = getServices(); if (!clusterServices.containsKey(serviceName)) { return Collections.emptySet(); } Service service = clusterServices.get(serviceName); Map<String, ServiceComponent> components = service.getServiceComponents(); if (!components.containsKey(componentName) || components.get(componentName).getServiceComponentHosts().size() == 0) { return Collections.emptySet(); } return components.get(componentName).getServiceComponentHosts().keySet(); }
ClusterImpl implements Cluster { @Override public Set<String> getHosts(String serviceName, String componentName) { Map<String, Service> clusterServices = getServices(); if (!clusterServices.containsKey(serviceName)) { return Collections.emptySet(); } Service service = clusterServices.get(serviceName); Map<String, ServiceComponent> components = service.getServiceComponents(); if (!components.containsKey(componentName) || components.get(componentName).getServiceComponentHosts().size() == 0) { return Collections.emptySet(); } return components.get(componentName).getServiceComponentHosts().keySet(); } }
ClusterImpl implements Cluster { @Override public Set<String> getHosts(String serviceName, String componentName) { Map<String, Service> clusterServices = getServices(); if (!clusterServices.containsKey(serviceName)) { return Collections.emptySet(); } Service service = clusterServices.get(serviceName); Map<String, ServiceComponent> components = service.getServiceComponents(); if (!components.containsKey(componentName) || components.get(componentName).getServiceComponentHosts().size() == 0) { return Collections.emptySet(); } return components.get(componentName).getServiceComponentHosts().keySet(); } @Inject  ClusterImpl(@Assisted ClusterEntity clusterEntity, Injector injector,
      AmbariEventPublisher eventPublisher); }
ClusterImpl implements Cluster { @Override public Set<String> getHosts(String serviceName, String componentName) { Map<String, Service> clusterServices = getServices(); if (!clusterServices.containsKey(serviceName)) { return Collections.emptySet(); } Service service = clusterServices.get(serviceName); Map<String, ServiceComponent> components = service.getServiceComponents(); if (!components.containsKey(componentName) || components.get(componentName).getServiceComponentHosts().size() == 0) { return Collections.emptySet(); } return components.get(componentName).getServiceComponentHosts().keySet(); } @Inject  ClusterImpl(@Assisted ClusterEntity clusterEntity, Injector injector,
      AmbariEventPublisher eventPublisher); @Override void addConfigGroup(ConfigGroup configGroup); @Override Map<Long, ConfigGroup> getConfigGroups(); @Override Map<Long, ConfigGroup> getConfigGroupsByHostname(String hostname); @Override void addRequestExecution(RequestExecution requestExecution); @Override Map<Long, RequestExecution> getAllRequestExecutions(); @Override void deleteRequestExecution(Long id); @Override void deleteConfigGroup(Long id); ServiceComponentHost getServiceComponentHost(String serviceName,
      String serviceComponentName, String hostname); @Override String getClusterName(); @Override void setClusterName(String clusterName); @Override Long getResourceId(); @Override @Transactional void addServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts); void addServiceComponentHost(ServiceComponentHost svcCompHost); @Override void removeServiceComponentHost(ServiceComponentHost svcCompHost); @Override long getClusterId(); @Override List<ServiceComponentHost> getServiceComponentHosts(String hostname); @Override Map<String, Set<String>> getServiceComponentHostMap(Set<String> hostNames, Set<String> serviceNames); @Override List<ServiceComponentHost> getServiceComponentHosts(String serviceName, String componentName); @Override void addService(Service service); @Override Service addService(String serviceName); @Override Service getService(String serviceName); @Override Map<String, Service> getServices(); @Override StackId getDesiredStackVersion(); @Override void setDesiredStackVersion(StackId stackId); @Override void setDesiredStackVersion(StackId stackId, boolean cascade); @Override StackId getCurrentStackVersion(); @Override State getProvisioningState(); @Override void setProvisioningState(State provisioningState); @Override SecurityType getSecurityType(); @Override void setSecurityType(SecurityType securityType); @Override ClusterVersionEntity getCurrentClusterVersion(); @Override UpgradeEntity getUpgradeInProgress(); @Override ClusterVersionEntity getEffectiveClusterVersion(); @Override Collection<ClusterVersionEntity> getAllClusterVersions(); @Override void mapHostVersions(Set<String> hostNames, ClusterVersionEntity currentClusterVersion, RepositoryVersionState desiredState); @Override void transitionHosts(ClusterVersionEntity sourceClusterVersion,
      RepositoryVersionState state); @Override void recalculateClusterVersionState(RepositoryVersionEntity repositoryVersion); @Override @Transactional HostVersionEntity transitionHostVersionState(HostEntity host, final RepositoryVersionEntity repositoryVersion, final StackId stack); @Override void recalculateAllClusterVersionStates(); @Override void createClusterVersion(StackId stackId, String version,
      String userName, RepositoryVersionState state); @Override @Transactional void transitionClusterVersion(StackId stackId, String version,
      RepositoryVersionState state); @Override @Transactional void setCurrentStackVersion(StackId stackId); @Override Map<String, Config> getConfigsByType(String configType); @Override Config getConfig(String configType, String versionTag); @Override Config getConfigByVersion(String configType, Long configVersion); @Override void addConfig(Config config); @Override Collection<Config> getAllConfigs(); @Override ClusterResponse convertToResponse(); @Override void debugDump(StringBuilder sb); @Override @Transactional void refresh(); @Override @Transactional void deleteAllServices(); @Override void deleteService(String serviceName); @Override boolean canBeRemoved(); @Override @Transactional void delete(); @Override ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs); @Override ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote); @Override Map<String, Set<DesiredConfig>> getAllDesiredConfigVersions(); @Override Map<String, DesiredConfig> getDesiredConfigs(); @Override ServiceConfigVersionResponse createServiceConfigVersion(
      String serviceName, String user, String note, ConfigGroup configGroup); @Override String getServiceForConfigTypes(Collection<String> configTypes); @Override String getServiceByConfigType(String configType); @Override ServiceConfigVersionResponse setServiceConfigVersion(String serviceName, Long version, String user, String note); @Override Map<String, Collection<ServiceConfigVersionResponse>> getActiveServiceConfigVersions(); @Override List<ServiceConfigVersionResponse> getServiceConfigVersions(); @Override List<ServiceConfigVersionResponse> getActiveServiceConfigVersionResponse(String serviceName); @Override Config getDesiredConfigByType(String configType); @Override boolean isConfigTypeExists(String configType); @Override Map<Long, Map<String, DesiredConfig>> getHostsDesiredConfigs(Collection<Long> hostIds); @Override Map<Long, Map<String, DesiredConfig>> getAllHostsDesiredConfigs(); @Override Long getNextConfigVersion(String type); @Override Map<ServiceComponentHostEvent, String> processServiceComponentHostEvents(ListMultimap<String, ServiceComponentHostEvent> eventMap); @Override Set<String> getHosts(String serviceName, String componentName); @Override Collection<Host> getHosts(); @Override boolean checkPermission(PrivilegeEntity privilegeEntity, boolean readOnly); @Override void addSessionAttributes(Map<String, Object> attributes); @Override void setSessionAttribute(String key, Object value); @Override void removeSessionAttribute(String key); @Override Map<String, Object> getSessionAttributes(); @Override @Transactional void applyLatestConfigurations(StackId stackId); @Override Map<PropertyInfo.PropertyType, Set<String>> getConfigPropertiesTypes(String configType); @Override void removeConfigurations(StackId stackId); @Override boolean isBluePrintDeployed(); @Override int getClusterSize(); @Override UpgradeEntity getUpgradeEntity(); @Override @Transactional void setUpgradeEntity(UpgradeEntity upgradeEntity); @Override boolean isUpgradeSuspended(); @Override String getClusterProperty(String propertyName, String defaultValue); @Subscribe void handleClusterEnvConfigChangedEvent(ClusterConfigChangedEvent event); @Override RoleCommandOrder getRoleCommandOrder(); @Override void addSuspendedUpgradeParameters(Map<String, String> commandParams,
      Map<String, String> roleParams); }
ClusterImpl implements Cluster { @Override public Set<String> getHosts(String serviceName, String componentName) { Map<String, Service> clusterServices = getServices(); if (!clusterServices.containsKey(serviceName)) { return Collections.emptySet(); } Service service = clusterServices.get(serviceName); Map<String, ServiceComponent> components = service.getServiceComponents(); if (!components.containsKey(componentName) || components.get(componentName).getServiceComponentHosts().size() == 0) { return Collections.emptySet(); } return components.get(componentName).getServiceComponentHosts().keySet(); } @Inject  ClusterImpl(@Assisted ClusterEntity clusterEntity, Injector injector,
      AmbariEventPublisher eventPublisher); @Override void addConfigGroup(ConfigGroup configGroup); @Override Map<Long, ConfigGroup> getConfigGroups(); @Override Map<Long, ConfigGroup> getConfigGroupsByHostname(String hostname); @Override void addRequestExecution(RequestExecution requestExecution); @Override Map<Long, RequestExecution> getAllRequestExecutions(); @Override void deleteRequestExecution(Long id); @Override void deleteConfigGroup(Long id); ServiceComponentHost getServiceComponentHost(String serviceName,
      String serviceComponentName, String hostname); @Override String getClusterName(); @Override void setClusterName(String clusterName); @Override Long getResourceId(); @Override @Transactional void addServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts); void addServiceComponentHost(ServiceComponentHost svcCompHost); @Override void removeServiceComponentHost(ServiceComponentHost svcCompHost); @Override long getClusterId(); @Override List<ServiceComponentHost> getServiceComponentHosts(String hostname); @Override Map<String, Set<String>> getServiceComponentHostMap(Set<String> hostNames, Set<String> serviceNames); @Override List<ServiceComponentHost> getServiceComponentHosts(String serviceName, String componentName); @Override void addService(Service service); @Override Service addService(String serviceName); @Override Service getService(String serviceName); @Override Map<String, Service> getServices(); @Override StackId getDesiredStackVersion(); @Override void setDesiredStackVersion(StackId stackId); @Override void setDesiredStackVersion(StackId stackId, boolean cascade); @Override StackId getCurrentStackVersion(); @Override State getProvisioningState(); @Override void setProvisioningState(State provisioningState); @Override SecurityType getSecurityType(); @Override void setSecurityType(SecurityType securityType); @Override ClusterVersionEntity getCurrentClusterVersion(); @Override UpgradeEntity getUpgradeInProgress(); @Override ClusterVersionEntity getEffectiveClusterVersion(); @Override Collection<ClusterVersionEntity> getAllClusterVersions(); @Override void mapHostVersions(Set<String> hostNames, ClusterVersionEntity currentClusterVersion, RepositoryVersionState desiredState); @Override void transitionHosts(ClusterVersionEntity sourceClusterVersion,
      RepositoryVersionState state); @Override void recalculateClusterVersionState(RepositoryVersionEntity repositoryVersion); @Override @Transactional HostVersionEntity transitionHostVersionState(HostEntity host, final RepositoryVersionEntity repositoryVersion, final StackId stack); @Override void recalculateAllClusterVersionStates(); @Override void createClusterVersion(StackId stackId, String version,
      String userName, RepositoryVersionState state); @Override @Transactional void transitionClusterVersion(StackId stackId, String version,
      RepositoryVersionState state); @Override @Transactional void setCurrentStackVersion(StackId stackId); @Override Map<String, Config> getConfigsByType(String configType); @Override Config getConfig(String configType, String versionTag); @Override Config getConfigByVersion(String configType, Long configVersion); @Override void addConfig(Config config); @Override Collection<Config> getAllConfigs(); @Override ClusterResponse convertToResponse(); @Override void debugDump(StringBuilder sb); @Override @Transactional void refresh(); @Override @Transactional void deleteAllServices(); @Override void deleteService(String serviceName); @Override boolean canBeRemoved(); @Override @Transactional void delete(); @Override ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs); @Override ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote); @Override Map<String, Set<DesiredConfig>> getAllDesiredConfigVersions(); @Override Map<String, DesiredConfig> getDesiredConfigs(); @Override ServiceConfigVersionResponse createServiceConfigVersion(
      String serviceName, String user, String note, ConfigGroup configGroup); @Override String getServiceForConfigTypes(Collection<String> configTypes); @Override String getServiceByConfigType(String configType); @Override ServiceConfigVersionResponse setServiceConfigVersion(String serviceName, Long version, String user, String note); @Override Map<String, Collection<ServiceConfigVersionResponse>> getActiveServiceConfigVersions(); @Override List<ServiceConfigVersionResponse> getServiceConfigVersions(); @Override List<ServiceConfigVersionResponse> getActiveServiceConfigVersionResponse(String serviceName); @Override Config getDesiredConfigByType(String configType); @Override boolean isConfigTypeExists(String configType); @Override Map<Long, Map<String, DesiredConfig>> getHostsDesiredConfigs(Collection<Long> hostIds); @Override Map<Long, Map<String, DesiredConfig>> getAllHostsDesiredConfigs(); @Override Long getNextConfigVersion(String type); @Override Map<ServiceComponentHostEvent, String> processServiceComponentHostEvents(ListMultimap<String, ServiceComponentHostEvent> eventMap); @Override Set<String> getHosts(String serviceName, String componentName); @Override Collection<Host> getHosts(); @Override boolean checkPermission(PrivilegeEntity privilegeEntity, boolean readOnly); @Override void addSessionAttributes(Map<String, Object> attributes); @Override void setSessionAttribute(String key, Object value); @Override void removeSessionAttribute(String key); @Override Map<String, Object> getSessionAttributes(); @Override @Transactional void applyLatestConfigurations(StackId stackId); @Override Map<PropertyInfo.PropertyType, Set<String>> getConfigPropertiesTypes(String configType); @Override void removeConfigurations(StackId stackId); @Override boolean isBluePrintDeployed(); @Override int getClusterSize(); @Override UpgradeEntity getUpgradeEntity(); @Override @Transactional void setUpgradeEntity(UpgradeEntity upgradeEntity); @Override boolean isUpgradeSuspended(); @Override String getClusterProperty(String propertyName, String defaultValue); @Subscribe void handleClusterEnvConfigChangedEvent(ClusterConfigChangedEvent event); @Override RoleCommandOrder getRoleCommandOrder(); @Override void addSuspendedUpgradeParameters(Map<String, String> commandParams,
      Map<String, String> roleParams);  }