Search in sources :

Example 1 with HostGroupResponse

use of com.sequenceiq.cloudbreak.api.model.HostGroupResponse in project cloudbreak by hortonworks.

the class HostGroupToJsonEntityConverterTest method testConvert.

@Test
public void testConvert() {
    // GIVEN
    // WHEN
    HostGroupResponse result = underTest.convert(getSource());
    // THEN
    assertEquals(1, result.getMetadata().size());
    assertTrue(result.getRecipeIds().contains(1L));
    assertEquals("dummyName", result.getName());
    assertAllFieldsNotNull(result);
}
Also used : HostGroupResponse(com.sequenceiq.cloudbreak.api.model.HostGroupResponse) Test(org.junit.Test)

Example 2 with HostGroupResponse

use of com.sequenceiq.cloudbreak.api.model.HostGroupResponse in project cloudbreak by hortonworks.

the class HostGroupToJsonEntityConverterTest method testConvertWithoutRecipes.

@Test
public void testConvertWithoutRecipes() {
    // GIVEN
    getSource().setRecipes(new HashSet<>());
    // WHEN
    HostGroupResponse result = underTest.convert(getSource());
    // THEN
    assertEquals(1, result.getMetadata().size());
    assertFalse(result.getRecipeIds().contains(1L));
    assertEquals("dummyName", result.getName());
    assertAllFieldsNotNull(result);
}
Also used : HostGroupResponse(com.sequenceiq.cloudbreak.api.model.HostGroupResponse) Test(org.junit.Test)

Example 3 with HostGroupResponse

use of com.sequenceiq.cloudbreak.api.model.HostGroupResponse in project cloudbreak by hortonworks.

the class CloudbreakUtil method waitForHostStatusStack.

public static WaitResult waitForHostStatusStack(StackEndpoint stackV1Endpoint, String stackId, String hostGroup, String desiredStatus) {
    WaitResult waitResult = WaitResult.SUCCESSFUL;
    Boolean found = FALSE;
    int retryCount = 0;
    do {
        LOGGER.info("Waiting for host status {} in hostgroup {} ...", desiredStatus, hostGroup);
        sleep();
        StackResponse stackResponse = stackV1Endpoint.get(Long.valueOf(stackId), new HashSet<>());
        Set<HostGroupResponse> hostGroupResponse = stackResponse.getCluster().getHostGroups();
        for (HostGroupResponse hr : hostGroupResponse) {
            if (hr.getName().equals(hostGroup)) {
                Set<HostMetadataResponse> hostMetadataResponses = hr.getMetadata();
                for (HostMetadataResponse hmr : hostMetadataResponses) {
                    if (hmr.getState().equals(desiredStatus)) {
                        found = Boolean.TRUE;
                    }
                }
            }
        }
        retryCount++;
    } while (!found && (retryCount < MAX_RETRY));
    if (retryCount == MAX_RETRY) {
        waitResult = WaitResult.TIMEOUT;
    }
    return waitResult;
}
Also used : HostMetadataResponse(com.sequenceiq.cloudbreak.api.model.HostMetadataResponse) HostGroupResponse(com.sequenceiq.cloudbreak.api.model.HostGroupResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) StackEndpoint(com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint) HistoryEndpoint(com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint) EventEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)

Example 4 with HostGroupResponse

use of com.sequenceiq.cloudbreak.api.model.HostGroupResponse in project cloudbreak by hortonworks.

the class HostGroupToHostGroupResponseConverter method convert.

@Override
public HostGroupResponse convert(HostGroup source) {
    HostGroupResponse hostGroupBase = new HostGroupResponse();
    hostGroupBase.setId(source.getId());
    hostGroupBase.setName(source.getName());
    hostGroupBase.setConstraint(getConversionService().convert(source.getConstraint(), ConstraintJson.class));
    hostGroupBase.setRecipeIds(getRecipeIds(source.getRecipes()));
    hostGroupBase.setMetadata(getHostMetadata(source.getHostMetadata()));
    hostGroupBase.setRecoveryMode(source.getRecoveryMode());
    hostGroupBase.setRecipes(getRecipes(source.getRecipes()));
    return hostGroupBase;
}
Also used : HostGroupResponse(com.sequenceiq.cloudbreak.api.model.HostGroupResponse) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson)

Aggregations

HostGroupResponse (com.sequenceiq.cloudbreak.api.model.HostGroupResponse)4 Test (org.junit.Test)2 StackEndpoint (com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)1 EventEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)1 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)1 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)1 HostMetadataResponse (com.sequenceiq.cloudbreak.api.model.HostMetadataResponse)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 HistoryEndpoint (com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint)1