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