use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ClusterUpgradeServiceTest method testClusterUpgradeFinishedWhenNeededNoStackDetails.
@ParameterizedTest
@MethodSource("upgradeNeededImages")
public void testClusterUpgradeFinishedWhenNeededNoStackDetails(Image currentIm, Image targetIm) {
// GIVEN
StatedImage currentImage = StatedImage.statedImage(currentIm, null, null);
StatedImage targetImage = StatedImage.statedImage(targetIm, null, null);
// WHEN
underTest.clusterUpgradeFinished(STACK_ID, currentImage, targetImage);
// THEN
verify(flowMessageService).fireEventAndLog(STACK_ID, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, NullUtil.getIfNotNull(targetIm.getStackDetails(), ImageStackDetails::getVersion));
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ClusterUpgradeServiceTest method testClusterUpgradeFinishedWhenNotNeeded.
@Test
public void testClusterUpgradeFinishedWhenNotNeeded() {
// GIVEN
Image currentImmage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER);
StatedImage currentImage = StatedImage.statedImage(currentImmage, null, null);
Image targetImmage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER);
StatedImage targetImage = StatedImage.statedImage(targetImmage, null, null);
// WHEN
underTest.clusterUpgradeFinished(STACK_ID, currentImage, targetImage);
// THEN
verify(flowMessageService).fireEventAndLog(STACK_ID, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackCreatorService method getImageCatalog.
private StatedImage getImageCatalog(Future<StatedImage> imgFromCatalogFuture) {
int time = 1;
TimeUnit unit = TimeUnit.MINUTES;
return Optional.ofNullable(imgFromCatalogFuture).map(f -> {
try {
return f.get(time, unit);
} catch (ExecutionException e) {
if (e.getCause() instanceof RuntimeException) {
if (e.getCause().getCause() instanceof CloudbreakImageNotFoundException) {
throw new BadRequestException("Image id settings are incorrect: " + e.getMessage(), e);
}
if (e.getCause().getCause() instanceof CloudbreakImageCatalogException) {
throw new BadRequestException("Image or image catalog settings are incorrect: " + ExceptionUtils.getRootCauseMessage(e), e.getCause());
}
}
throw new RuntimeException("Unknown error happened when determining image from image catalog:" + e.getMessage(), e);
} catch (InterruptedException e) {
throw new RuntimeException("Determining image from image catalog interrupted", e);
} catch (TimeoutException e) {
throw new RuntimeException(String.format("Could not determine image from image catalog in %d %s", time, unit), e);
}
}).orElse(null);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ImageCatalogV4Controller method getImageByImageId.
@Override
@DisableCheckPermissions
public ImagesV4Response getImageByImageId(Long workspaceId, String imageId, @AccountId String accountId) throws Exception {
StatedImage statedImage = imageCatalogService.getImageByCatalogName(restRequestThreadLocalService.getRequestedWorkspaceId(), imageId, "");
Images images = new Images(List.of(), List.of(statedImage.getImage()), List.of(), Set.of());
return imagesToImagesV4ResponseConverter.convert(images);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ImageCatalogV4Controller method getImageByCatalogNameAndImageId.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG)
public ImagesV4Response getImageByCatalogNameAndImageId(Long workspaceId, @ResourceName String name, String imageId, @AccountId String accountId) throws Exception {
StatedImage statedImage = imageCatalogService.getImageByCatalogName(restRequestThreadLocalService.getRequestedWorkspaceId(), imageId, name);
Images images = new Images(List.of(), List.of(statedImage.getImage()), List.of(), Set.of());
return imagesToImagesV4ResponseConverter.convert(images);
}
Aggregations