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;
}
}
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;
}
}
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());
}
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;
}
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"));
}
Aggregations