use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode.
@Test
public void testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode() throws CloudbreakException {
Stack stack = new Stack();
stack.setId(1L);
Cluster cluster = new Cluster();
cluster.setId(2L);
stack.setCluster(cluster);
when(stackService.getByIdWithClusterInTransaction(eq(1L))).thenReturn(stack);
ClusterApi clusterApi = mock(ClusterApi.class);
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
HostGroup hostGroup = new HostGroup();
InstanceGroup instanceGroup = new InstanceGroup();
InstanceMetaData im1 = new InstanceMetaData();
im1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
InstanceMetaData im2 = new InstanceMetaData();
im2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
InstanceMetaData im3 = new InstanceMetaData();
im3.setInstanceStatus(InstanceStatus.DELETED_BY_PROVIDER);
stack.setInstanceGroups(Set.of(instanceGroup));
instanceGroup.setInstanceMetaData(Set.of(im1, im2, im3));
hostGroup.setInstanceGroup(instanceGroup);
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Collections.emptyMap(), Collections.emptyMap()));
underTest.installServicesOnNewHosts(1L, Set.of("master"), true, true);
verify(clusterApi, times(1)).upscaleCluster(any());
verify(clusterApi, times(0)).restartAll(false);
verify(parcelService).removeUnusedParcelComponents(stack);
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterUpgradeHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeRequest> event) {
LOGGER.debug("Accepting Cluster upgrade event..");
ClusterUpgradeRequest request = event.getData();
Long stackId = request.getResourceId();
Selectable result;
try {
Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
Optional<String> remoteDataContext = getRemoteDataContext(stack);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
Set<ClusterComponent> components = parcelService.getParcelComponentsByBlueprint(stack);
connector.upgradeClusterRuntime(components, request.isPatchUpgrade(), remoteDataContext);
ParcelOperationStatus parcelOperationStatus = parcelService.removeUnusedParcelComponents(stack, components);
if (parcelOperationStatus.getFailed().isEmpty()) {
result = new ClusterUpgradeSuccess(request.getResourceId());
} else {
LOGGER.info("There are failed parcel removals: {}", parcelOperationStatus);
CloudbreakException exception = new CloudbreakException(format("Failed to remove the following parcels: %s", parcelOperationStatus.getFailed()));
result = new ClusterUpgradeFailedEvent(request.getResourceId(), exception, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
}
} catch (Exception e) {
LOGGER.error("Cluster upgrade event failed", e);
result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
}
return result;
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ParcelService method removeUnusedParcelComponents.
public ParcelOperationStatus removeUnusedParcelComponents(Stack stack, Set<ClusterComponent> clusterComponentsByBlueprint) throws CloudbreakException {
LOGGER.debug("Starting to remove unused parcels from the cluster.");
Set<String> parcelsFromImage = imageReaderService.getParcelNames(stack.getId());
ParcelOperationStatus removalStatus = clusterApiConnectors.getConnector(stack).removeUnusedParcels(clusterComponentsByBlueprint, parcelsFromImage);
clusterComponentUpdater.removeUnusedCdhProductsFromClusterComponents(stack.getCluster().getId(), clusterComponentsByBlueprint, removalStatus);
return removalStatus;
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus 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.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus 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;
}
Aggregations