Search in sources :

Example 11 with ApiParcel

use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.

the class ClouderaManagerUpgradeParcelDistributeListenerTaskTest method testDoStatusCheckWhenParcelIsInState.

private void testDoStatusCheckWhenParcelIsInState(ParcelStatus parcelStatus, boolean expected) throws ApiException {
    ApiClient apiClient = mock(ApiClient.class);
    ParcelResourceApi parcelResourceApi = mock(ParcelResourceApi.class);
    when(clouderaManagerApiPojoFactory.getParcelResourceApi(apiClient)).thenReturn(parcelResourceApi);
    when(parcelResource.getProduct()).thenReturn("CDH");
    when(parcelResource.getClusterName()).thenReturn("clusterName");
    when(parcelResource.getVersion()).thenReturn("7.2.8");
    ApiParcel apiParcel = mock(ApiParcel.class);
    when(parcelResourceApi.readParcel("clusterName", "CDH", "7.2.8")).thenReturn(apiParcel);
    when(apiParcel.getStage()).thenReturn(parcelStatus.name());
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(null, apiClient, BigDecimal.ONE);
    boolean result = underTest.doStatusCheck(pollerObject);
    Assertions.assertEquals(expected, result);
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 12 with ApiParcel

use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.

the class ClouderaManagerUpgradeParcelDownloadListenerTaskTest method testDoStatusCheckWithParcelStatusShouldReturnTrue.

private void testDoStatusCheckWithParcelStatusShouldReturnTrue(ParcelStatus parcelStatus, boolean expected) throws ApiException {
    ApiClient apiClient = mock(ApiClient.class);
    ParcelResourceApi parcelResourceApi = mock(ParcelResourceApi.class);
    when(clouderaManagerApiPojoFactory.getParcelResourceApi(apiClient)).thenReturn(parcelResourceApi);
    when(parcelResource.getProduct()).thenReturn("CDH");
    when(parcelResource.getClusterName()).thenReturn("clusterName");
    when(parcelResource.getVersion()).thenReturn("7.2.8");
    ApiParcel apiParcel = mock(ApiParcel.class);
    when(parcelResourceApi.readParcel("clusterName", "CDH", "7.2.8")).thenReturn(apiParcel);
    when(apiParcel.getStage()).thenReturn(parcelStatus.name());
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(null, apiClient, BigDecimal.ONE);
    boolean result = underTest.doStatusCheck(pollerObject);
    Assertions.assertEquals(expected, result);
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 13 with ApiParcel

use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.

the class ClouderaManagerUpgradeParcelDistributeListenerTask method doStatusCheck.

@Override
protected boolean doStatusCheck(ClouderaManagerCommandPollerObject pollerObject) throws ApiException {
    ApiClient apiClient = pollerObject.getApiClient();
    ParcelResourceApi parcelResourceApi = clouderaManagerApiPojoFactory.getParcelResourceApi(apiClient);
    ApiParcel apiParcel = parcelResourceApi.readParcel(parcelResource.getClusterName(), parcelResource.getProduct(), parcelResource.getVersion());
    String parcelStage = apiParcel.getStage();
    if (!ParcelStatus.DISTRIBUTED.name().equals(parcelStage) && !ParcelStatus.ACTIVATED.name().equals(parcelStage) && !ParcelStatus.ACTIVATING.name().equals(parcelStage)) {
        LOGGER.warn("Expected parcel status is {}, received status is: {}", ParcelStatus.DISTRIBUTED.name(), parcelStage);
        return false;
    } else {
        return true;
    }
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 14 with ApiParcel

use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.

the class ClouderaManagerUpgradeParcelDownloadListenerTask method doStatusCheck.

@Override
protected boolean doStatusCheck(ClouderaManagerCommandPollerObject pollerObject) throws ApiException {
    ApiParcel apiParcel = getApiParcel(pollerObject);
    String parcelStage = apiParcel.getStage();
    if (!ParcelStatus.DOWNLOADED.name().equals(parcelStage) && !ParcelStatus.DISTRIBUTED.name().equals(parcelStage) && !ParcelStatus.DISTRIBUTING.name().equals(parcelStage) && !ParcelStatus.ACTIVATED.name().equals(parcelStage) && !ParcelStatus.ACTIVATING.name().equals(parcelStage)) {
        LOGGER.warn("Expected parcel status is {}, received status is: {}", ParcelStatus.DOWNLOADED.name(), parcelStage);
        return false;
    } else {
        return true;
    }
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel)

Example 15 with ApiParcel

use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.

the class ClouderaManagerUpgradeParcelDownloadListenerTask method handleTimeout.

@Override
public void handleTimeout(ClouderaManagerCommandPollerObject pollerObject) {
    // when downloading, progress and totalProgress will show the current number of bytes downloaded
    // and the total number of bytes needed to be downloaded respectively.
    String baseMessage = "Operation timed out. Failed to download parcel in time.";
    try {
        ApiParcel apiParcel = getApiParcel(pollerObject);
        ApiParcelState parcelState = apiParcel.getState();
        String progress = FileUtils.byteCountToDisplaySize(parcelState.getProgress().toBigInteger());
        String totalProgress = FileUtils.byteCountToDisplaySize(parcelState.getTotalProgress().toBigInteger());
        String progressMessage = String.format(" %s out of total %s has been downloaded!", progress, totalProgress);
        throw new ClouderaManagerOperationFailedException(baseMessage + progressMessage);
    } catch (ApiException e) {
        throw new ClouderaManagerOperationFailedException(baseMessage);
    }
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) ApiParcelState(com.cloudera.api.swagger.model.ApiParcelState) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

ApiParcel (com.cloudera.api.swagger.model.ApiParcel)20 ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)9 ApiClient (com.cloudera.api.swagger.client.ApiClient)7 ClouderaManagerCommandPollerObject (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject)6 Test (org.junit.jupiter.api.Test)6 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)4 ApiParcelState (com.cloudera.api.swagger.model.ApiParcelState)3 Description (com.sequenceiq.it.cloudbreak.context.Description)3 Test (org.testng.annotations.Test)3 ApiException (com.cloudera.api.swagger.client.ApiException)2 Multimap (com.google.common.collect.Multimap)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)2 TestCaseDescription (com.sequenceiq.it.cloudbreak.context.TestCaseDescription)2 ClouderaManagerProductTestDto (com.sequenceiq.it.cloudbreak.dto.ClouderaManagerProductTestDto)2 ClouderaManagerTestDto (com.sequenceiq.it.cloudbreak.dto.ClouderaManagerTestDto)2 ClusterTestDto (com.sequenceiq.it.cloudbreak.dto.ClusterTestDto)2 InstanceGroupTestDto (com.sequenceiq.it.cloudbreak.dto.InstanceGroupTestDto)2 StackTestDto (com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto)2