use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterComponentUpdaterTest method testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsNoComponentToDeleteAndAnExtraComponentIsPresent.
@Test
public void testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsNoComponentToDeleteAndAnExtraComponentIsPresent() {
Set<ClusterComponent> clusterComponentsByBlueprint = createComponents(Set.of(CDH, FLINK));
Set<ClusterComponent> clusterComponentsFromDb = createComponents(Set.of(CDH, FLINK));
clusterComponentsFromDb.add(createImageComponent());
when(clusterComponentConfigProvider.getComponentsByClusterId(CLUSTER_ID)).thenReturn(clusterComponentsFromDb);
underTest.removeUnusedCdhProductsFromClusterComponents(CLUSTER_ID, clusterComponentsByBlueprint, new ParcelOperationStatus(Map.of(), Map.of()));
verify(clusterComponentConfigProvider).getComponentsByClusterId(CLUSTER_ID);
verifyNoMoreInteractions(clusterComponentConfigProvider);
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterComponentUpdaterTest method testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsNoComponentToDelete.
@Test
public void testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsNoComponentToDelete() {
Set<ClusterComponent> clusterComponentsByBlueprint = createComponents(Set.of(CDH, FLINK));
Set<ClusterComponent> clusterComponentsFromDb = createComponents(Set.of(CDH, FLINK));
when(clusterComponentConfigProvider.getComponentsByClusterId(CLUSTER_ID)).thenReturn(clusterComponentsFromDb);
underTest.removeUnusedCdhProductsFromClusterComponents(CLUSTER_ID, clusterComponentsByBlueprint, new ParcelOperationStatus(Map.of(), Map.of()));
verify(clusterComponentConfigProvider).getComponentsByClusterId(CLUSTER_ID);
verifyNoMoreInteractions(clusterComponentConfigProvider);
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method removeUnusedParcels.
@Override
public ParcelOperationStatus removeUnusedParcels(Set<ClusterComponent> usedParcelComponents, Set<String> parcelNamesFromImage) {
ParcelsResourceApi parcelsResourceApi = clouderaManagerApiFactory.getParcelsResourceApi(apiClient);
ParcelResourceApi parcelResourceApi = clouderaManagerApiFactory.getParcelResourceApi(apiClient);
Set<String> usedParcelComponentNames = usedParcelComponents.stream().map(component -> component.getAttributes().getSilent(ClouderaManagerProduct.class).getName()).collect(Collectors.toSet());
ParcelOperationStatus deactivateStatus = clouderaManagerParcelDecommissionService.deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, stack.getName(), usedParcelComponentNames, parcelNamesFromImage);
ParcelOperationStatus undistributeStatus = clouderaManagerParcelDecommissionService.undistributeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
ParcelOperationStatus removalStatus = clouderaManagerParcelDecommissionService.removeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, usedParcelComponentNames, parcelNamesFromImage);
ParcelOperationStatus result = removalStatus.merge(deactivateStatus).merge(undistributeStatus);
LOGGER.info("Result of the parcel removal: {}", result);
return result;
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionService method runSingleParcelCommand.
private ParcelOperationStatus runSingleParcelCommand(String commandName, String stackName, Entry<String, String> parcelForCommand, ParcelCommand parcelCommand) {
Parcel parcel = new Parcel(parcelForCommand.getKey(), parcelForCommand.getValue());
try {
LOGGER.debug("[{}] Start for {} parcel", commandName, parcel);
parcelCommand.apply(stackName, parcel.getName(), parcel.getVersion());
LOGGER.info("[{}] Successful for parcel: {}", commandName, parcel);
return new ParcelOperationStatus().withSuccessful(parcel.getName(), parcel.getVersion());
} catch (ApiException e) {
LOGGER.info(String.format("[%s] Failed for parcel: %s", commandName, parcel), e);
return new ParcelOperationStatus().withFailed(parcel.getName(), parcel.getVersion());
}
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesOnNewHostWithRestart.
@Test
public void testInstallServicesOnNewHostWithRestart() 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.SERVICES_HEALTHY);
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(1)).restartAll(false);
verify(parcelService).removeUnusedParcelComponents(stack);
}
Aggregations