Search in sources :

Example 1 with ApiParcelList

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

the class ClouderaManagerParcelActivationListenerTask method doStatusCheck.

@Override
protected boolean doStatusCheck(ClouderaManagerCommandPollerObject pollerObject) throws ApiException {
    ApiClient apiClient = pollerObject.getApiClient();
    Stack stack = pollerObject.getStack();
    ApiParcelList parcels = getClouderaManagerParcels(apiClient, stack.getName());
    List<ApiParcel> notActivated = getNotActivatedOrMissingParcels(parcels);
    if (notActivated.isEmpty()) {
        LOGGER.debug("Parcels are activated.");
        return true;
    } else {
        LOGGER.debug("Some parcels are not yet activated: [{}].", getJoinedParcelStages(notActivated));
        return false;
    }
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with ApiParcelList

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

the class ClouderaManagerParcelStatusListenerTask method doStatusCheck.

@Override
protected boolean doStatusCheck(ClouderaManagerCommandPollerObject pollerObject) throws ApiException {
    ApiClient apiClient = pollerObject.getApiClient();
    Stack stack = pollerObject.getStack();
    ApiParcelList parcels = getClouderaManagerParcels(apiClient, stack.getName());
    List<ApiParcel> notInProperStateParcels = getNotInProperStateParcels(parcels);
    if (notInProperStateParcels.isEmpty()) {
        LOGGER.debug("Parcels are in the proper statuses: {}", parcelStatus);
        return true;
    } else {
        LOGGER.debug("Some parcels are not yet in the proper status: [{}].", getJoinedParcelStages(notInProperStateParcels));
        return false;
    }
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 3 with ApiParcelList

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

the class ClouderaManagerParcelsApiListenerTask method pollParcels.

private boolean pollParcels(ClouderaManagerPollerObject pollerObject) throws ApiException {
    ParcelsResourceApi parcelsResourceApi = clouderaManagerApiPojoFactory.getParcelsResourceApi(pollerObject.getApiClient());
    ApiParcelList apiParcelList = parcelsResourceApi.readParcels(pollerObject.getStack().getName(), "");
    return Objects.nonNull(apiParcelList) && CollectionUtils.isNotEmpty(apiParcelList.getItems());
}
Also used : ParcelsResourceApi(com.cloudera.api.swagger.ParcelsResourceApi) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList)

Example 4 with ApiParcelList

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

the class ParcelMockActivatorUtil method getApiParcelListFromSingleParcel.

private ApiParcelList getApiParcelListFromSingleParcel(ApiParcel parcel) {
    ApiParcelList list = new ApiParcelList();
    list.addItemsItem(parcel);
    return list;
}
Also used : ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList)

Example 5 with ApiParcelList

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

the class ClouderaManagerParcelDecommissionServiceTest method testUndistributeUnusedComponents.

@Test
public void testUndistributeUnusedComponents() throws Exception {
    // GIVEN
    Set<String> productsFromImage = Set.of("product1", "product2", "product3");
    Set<String> usedComponents = Set.of("product1", "product2");
    Map<String, String> distributedParcels = Map.of("product1", "version1", "product3", "version3", "customParcel", "customParcelVersion");
    ApiParcelList parcelList = createApiParcelList(distributedParcels, ParcelStatus.DISTRIBUTED);
    when(parcelsResourceApi.readParcels(STACK_NAME, "summary")).thenReturn(parcelList);
    Stack stack = mock(Stack.class);
    when(stack.getName()).thenReturn(STACK_NAME);
    when(clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(eq(stack), eq(apiClient), any(), any())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
    // WHEN
    ParcelOperationStatus operationStatus = underTest.undistributeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, usedComponents, productsFromImage);
    // THEN
    verify(parcelResourceApi, times(1)).startRemovalOfDistributionCommand(STACK_NAME, "product3", "version3");
    verify(parcelResourceApi, times(0)).startRemovalOfDistributionCommand(STACK_NAME, "product1", "version1");
    verify(parcelResourceApi, times(0)).startRemovalOfDistributionCommand(STACK_NAME, "product2", "version2");
    verifyNoMoreInteractions(parcelResourceApi);
    assertEquals(1, operationStatus.getSuccessful().size());
    assertEquals(0, operationStatus.getFailed().size());
    assertTrue(operationStatus.getSuccessful().containsEntry("product3", "version3"));
}
Also used : ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)16 Test (org.junit.jupiter.api.Test)11 ApiParcel (com.cloudera.api.swagger.model.ApiParcel)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)5 ApiClient (com.cloudera.api.swagger.client.ApiClient)4 ApiException (com.cloudera.api.swagger.client.ApiException)4 ClouderaManagerCommandPollerObject (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject)4 ParcelsResourceApi (com.cloudera.api.swagger.ParcelsResourceApi)2 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)1 Multimap (com.google.common.collect.Multimap)1 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 ParcelStatus (com.sequenceiq.cloudbreak.cm.model.ParcelStatus)1 ClouderaManagerPollingServiceProvider (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1