@Test(expected = HostNotFoundException.class) public void testGetHosts___HostNotFoundException_HostNotAssociatedWithCluster() throws Exception { Injector injector = createInjector(); AmbariManagementController managementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = injector.getInstance(Clusters.class); Cluster cluster = createMock(Cluster.class); Host host = createNiceMock(Host.class); HostRequest request1 = new HostRequest("host1", "cluster1", Collections.<String, String>emptyMap()); Set<HostRequest> setRequests = Collections.singleton(request1); expect(managementController.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getCluster("cluster1")).andReturn(cluster); expect(clusters.getHost("host1")).andReturn(host); expect(cluster.getDesiredConfigs()).andReturn(new HashMap<String, DesiredConfig>()).anyTimes(); expect(host.getHostName()).andReturn("host1").anyTimes(); expect(clusters.getClustersForHost("host1")).andReturn(Collections.<Cluster>emptySet()); replayAll(); SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator()); getHosts(managementController, setRequests); verifyAll(); }
protected Set<HostResponse> getHosts(Set<HostRequest> requests) throws AmbariException { Set<HostResponse> response = new HashSet<HostResponse>(); AmbariManagementController controller = getManagementController(); for (HostRequest request : requests) { try { response.addAll(getHosts(controller, request)); } catch (HostNotFoundException e) { if (requests.size() == 1) { throw e; } } } return response; }
HostResourceProvider extends AbstractControllerResourceProvider { protected Set<HostResponse> getHosts(Set<HostRequest> requests) throws AmbariException { Set<HostResponse> response = new HashSet<HostResponse>(); AmbariManagementController controller = getManagementController(); for (HostRequest request : requests) { try { response.addAll(getHosts(controller, request)); } catch (HostNotFoundException e) { if (requests.size() == 1) { throw e; } } } return response; } }
HostResourceProvider extends AbstractControllerResourceProvider { protected Set<HostResponse> getHosts(Set<HostRequest> requests) throws AmbariException { Set<HostResponse> response = new HashSet<HostResponse>(); AmbariManagementController controller = getManagementController(); for (HostRequest request : requests) { try { response.addAll(getHosts(controller, request)); } catch (HostNotFoundException e) { if (requests.size() == 1) { throw e; } } } return response; } @AssistedInject  HostResourceProvider(@Assisted Set<String> propertyIds,
                       @Assisted Map<Resource.Type, String> keyPropertyIds,
                       @Assisted AmbariManagementController managementController); }
HostResourceProvider extends AbstractControllerResourceProvider { protected Set<HostResponse> getHosts(Set<HostRequest> requests) throws AmbariException { Set<HostResponse> response = new HashSet<HostResponse>(); AmbariManagementController controller = getManagementController(); for (HostRequest request : requests) { try { response.addAll(getHosts(controller, request)); } catch (HostNotFoundException e) { if (requests.size() == 1) { throw e; } } } return response; } @AssistedInject  HostResourceProvider(@Assisted Set<String> propertyIds,
                       @Assisted Map<Resource.Type, String> keyPropertyIds,
                       @Assisted AmbariManagementController managementController); @Override Set<String> checkPropertyIds(Set<String> propertyIds); synchronized void createHosts(Request request); RequestStatusResponse install(final String cluster, final String hostname, Collection<String> skipInstallForComponents, Collection<String> dontSkipInstallForComponents, final boolean skipFailure); RequestStatusResponse start(final String cluster, final String hostname); static void setTopologyManager(TopologyManager topologyManager); }
HostResourceProvider extends AbstractControllerResourceProvider { protected Set<HostResponse> getHosts(Set<HostRequest> requests) throws AmbariException { Set<HostResponse> response = new HashSet<HostResponse>(); AmbariManagementController controller = getManagementController(); for (HostRequest request : requests) { try { response.addAll(getHosts(controller, request)); } catch (HostNotFoundException e) { if (requests.size() == 1) { throw e; } } } return response; } @AssistedInject  HostResourceProvider(@Assisted Set<String> propertyIds,
                       @Assisted Map<Resource.Type, String> keyPropertyIds,
                       @Assisted AmbariManagementController managementController); @Override Set<String> checkPropertyIds(Set<String> propertyIds); synchronized void createHosts(Request request); RequestStatusResponse install(final String cluster, final String hostname, Collection<String> skipInstallForComponents, Collection<String> dontSkipInstallForComponents, final boolean skipFailure); RequestStatusResponse start(final String cluster, final String hostname); static void setTopologyManager(TopologyManager topologyManager); static final String HOST_CLUSTER_NAME_PROPERTY_ID; static final String HOST_NAME_PROPERTY_ID; static final String HOST_PUBLIC_NAME_PROPERTY_ID; static final String HOST_IP_PROPERTY_ID; static final String HOST_TOTAL_MEM_PROPERTY_ID; static final String HOST_CPU_COUNT_PROPERTY_ID; static final String HOST_PHYSICAL_CPU_COUNT_PROPERTY_ID; static final String HOST_OS_ARCH_PROPERTY_ID; static final String HOST_OS_TYPE_PROPERTY_ID; static final String HOST_OS_FAMILY_PROPERTY_ID; static final String HOST_RACK_INFO_PROPERTY_ID; static final String HOST_LAST_HEARTBEAT_TIME_PROPERTY_ID; static final String HOST_LAST_REGISTRATION_TIME_PROPERTY_ID; static final String HOST_DISK_INFO_PROPERTY_ID; static final String HOST_HOST_STATUS_PROPERTY_ID; static final String HOST_MAINTENANCE_STATE_PROPERTY_ID; static final String HOST_HOST_HEALTH_REPORT_PROPERTY_ID; static final String HOST_RECOVERY_REPORT_PROPERTY_ID; static final String HOST_RECOVERY_SUMMARY_PROPERTY_ID; static final String HOST_STATE_PROPERTY_ID; static final String HOST_LAST_AGENT_ENV_PROPERTY_ID; static final String HOST_DESIRED_CONFIGS_PROPERTY_ID; static final String BLUEPRINT_PROPERTY_ID; static final String HOSTGROUP_PROPERTY_ID; static final String HOST_NAME_NO_CATEGORY_PROPERTY_ID; static final String HOST_COUNT_PROPERTY_ID; static final String HOST_PREDICATE_PROPERTY_ID; static final String HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID; }