use of com.cloudera.api.swagger.ParcelResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionService method removeParcels.
private ParcelOperationStatus removeParcels(ApiClient apiClient, ParcelResourceApi parcelResourceApi, Stack stack, Multimap<String, String> parcels) {
ParcelOperationStatus removalStatus = parcels.entries().stream().map(parcel -> runSingleParcelCommand("REMOVE", stack.getName(), parcel, parcelResourceApi::removeDownloadCommand)).reduce(new ParcelOperationStatus(), ParcelOperationStatus::merge);
Multimap<String, String> pollableParcels = filterForPollableParcels(parcels, removalStatus);
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmParcelDelete(stack, apiClient, pollableParcels);
if (pollingResult.isExited()) {
throw new CancellationException("Cluster was terminated while waiting for parcels deletion");
} else if (pollingResult.isTimeout()) {
throw new ClouderaManagerOperationFailedException("Timeout while Cloudera Manager deletes parcels.");
}
return removalStatus;
}
use of com.cloudera.api.swagger.ParcelResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionService method undistributeParcels.
private ParcelOperationStatus undistributeParcels(ApiClient apiClient, ParcelResourceApi parcelResourceApi, Stack stack, Multimap<String, String> parcels) {
ParcelOperationStatus undistributeStatus = parcels.entries().stream().map(parcel -> runSingleParcelCommand("UNDISTRIBUTE", stack.getName(), parcel, parcelResourceApi::startRemovalOfDistributionCommand)).reduce(new ParcelOperationStatus(), ParcelOperationStatus::merge);
Multimap<String, String> pollableParcels = filterForPollableParcels(parcels, undistributeStatus);
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(stack, apiClient, pollableParcels, ParcelStatus.DOWNLOADED);
if (pollingResult.isExited()) {
throw new CancellationException("Cluster was terminated while waiting for parcels undistribution");
} else if (pollingResult.isTimeout()) {
throw new ClouderaManagerOperationFailedException("Timeout while Cloudera Manager undistribute parcels.");
}
return undistributeStatus;
}
use of com.cloudera.api.swagger.ParcelResourceApi 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);
}
use of com.cloudera.api.swagger.ParcelResourceApi 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);
}
use of com.cloudera.api.swagger.ParcelResourceApi 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;
}
}
Aggregations