Search in sources :

Example 1 with ApiParcelState

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

the class ParcelGeneratorUtil method getActivatedCDHParcelWithVersion.

public ApiParcel getActivatedCDHParcelWithVersion(String version) {
    ApiParcel parcel = new ApiParcel();
    ApiParcelState state = new ApiParcelState();
    state.setCount(new BigDecimal(0));
    parcel.setProduct("CDH");
    parcel.setState(state);
    parcel.setVersion(version);
    parcel.setStage("ACTIVATED");
    return parcel;
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) BigDecimal(java.math.BigDecimal) ApiParcelState(com.cloudera.api.swagger.model.ApiParcelState)

Example 2 with ApiParcelState

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

the class ParcelMockActivatorUtil method getDefaultApiParcels.

private List<ApiParcel> getDefaultApiParcels(MockedTestContext testContext) {
    String blueprintCdhVersion = testContext.getCloudProvider().getBlueprintCdhVersion();
    DefaultCDHInfo defaultCDHInfo = inTestCdhParcelProvider.getParcels(blueprintCdhVersion).get(blueprintCdhVersion);
    return defaultCDHInfo.getParcels().stream().map(product -> {
        ApiParcel apiParcel = new ApiParcel();
        apiParcel.setVersion(product.getVersion());
        apiParcel.setProduct(product.getName());
        apiParcel.setStage("ACTIVATED");
        ApiParcelState state = new ApiParcelState();
        state.setCount(new BigDecimal(0));
        apiParcel.setState(state);
        return apiParcel;
    }).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) Logger(org.slf4j.Logger) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) ApiParcel(com.cloudera.api.swagger.model.ApiParcel) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Inject(javax.inject.Inject) BigDecimal(java.math.BigDecimal) InTestCdhParcelProvider(com.sequenceiq.it.config.InTestCdhParcelProvider) List(java.util.List) Component(org.springframework.stereotype.Component) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) ApiParcelState(com.cloudera.api.swagger.model.ApiParcelState) ApiParcel(com.cloudera.api.swagger.model.ApiParcel) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) BigDecimal(java.math.BigDecimal) ApiParcelState(com.cloudera.api.swagger.model.ApiParcelState)

Example 3 with ApiParcelState

use of com.cloudera.api.swagger.model.ApiParcelState 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)3 ApiParcelState (com.cloudera.api.swagger.model.ApiParcelState)3 BigDecimal (java.math.BigDecimal)2 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)1 DefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo)1 ClouderaManagerOperationFailedException (com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException)1 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 InTestCdhParcelProvider (com.sequenceiq.it.config.InTestCdhParcelProvider)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Component (org.springframework.stereotype.Component)1