Search in sources :

Example 76 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariHostsLeaveStatusCheckerTask method checkStatus.

@Override
public boolean checkStatus(AmbariHostsWithNames hosts) {
    try {
        AmbariClient ambariClient = hosts.getAmbariClient();
        List<String> hostNames = hosts.getHostNames();
        Map<String, String> hostStatuses = ambariClient.getHostStatuses();
        for (String hostName : hostNames) {
            String status = hostStatuses.get(hostName);
            if (!LEFT_STATE.equals(status)) {
                LOGGER.info("{} didn't leave the cluster yet", hostName);
                return false;
            }
        }
    } catch (Exception e) {
        LOGGER.error("Failed to check the left hosts", e);
        return false;
    }
    return true;
}
Also used : AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 77 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class ScalingUtil method getNodeCountAmbari.

public static int getNodeCountAmbari(StackEndpoint stackV1Endpoint, String port, String stackId, String ambariUser, String ambariPassword, IntegrationTestContext itContext) {
    String ambariIp = CloudbreakUtil.getAmbariIp(stackV1Endpoint, stackId, itContext);
    ServiceAndHostService ambariClient = new AmbariClient(ambariIp, port, ambariUser, ambariPassword);
    return ambariClient.getClusterHosts().size();
}
Also used : ServiceAndHostService(com.sequenceiq.ambari.client.services.ServiceAndHostService) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 78 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class ScalingUtil method checkClusterScaled.

private static void checkClusterScaled(String ambariIp, String port, String ambariUser, String ambariPassword, int expectedNodeCount, StackResponse stackResponse) {
    Assert.assertEquals(stackResponse.getCluster().getStatus(), Status.AVAILABLE, "The cluster hasn't been started!");
    Assert.assertEquals(stackResponse.getStatus(), Status.AVAILABLE, "The stack hasn't been started!");
    AmbariClient ambariClient = new AmbariClient(ambariIp, port, ambariUser, ambariPassword);
    Assert.assertEquals(ambariClient.healthCheck(), "RUNNING", "The Ambari server is not running!");
    Assert.assertEquals(expectedNodeCount, ambariClient.getClusterHosts().size(), "After scaling, the number of the nodes registered in ambari differs from the expected number!");
}
Also used : AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Aggregations

AmbariClient (com.sequenceiq.ambari.client.AmbariClient)78 Test (org.junit.Test)39 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)37 Stack (com.sequenceiq.cloudbreak.domain.Stack)32 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)23 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)16 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)16 HashMap (java.util.HashMap)16 PollingResult (com.sequenceiq.cloudbreak.service.PollingResult)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)14 Matchers.anyString (org.mockito.Matchers.anyString)14 Map (java.util.Map)13 AmbariConnectionException (com.sequenceiq.ambari.client.AmbariConnectionException)10 Collections.singletonMap (java.util.Collections.singletonMap)9 HashSet (java.util.HashSet)9 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)6 Status (com.sequenceiq.cloudbreak.api.model.Status)6 List (java.util.List)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)6