use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterMonitoringEngineTest method createInstanceMetadataSet.
private Set<InstanceMetaData> createInstanceMetadataSet() {
Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setId(1L);
InstanceGroup instanceGroup = new InstanceGroup();
Template template = new Template();
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
instanceMetaDataSet.add(instanceMetaData);
return instanceMetaDataSet;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterBuilderService method finalizeClusterInstall.
public void finalizeClusterInstall(Long stackId) throws CloudbreakException {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Set<HostGroup> hostGroups = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
try {
transactionService.required(() -> {
Set<InstanceMetaData> instanceMetaDatas = loadInstanceMetadataForHostGroups(hostGroups).values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
finalizeClusterInstallHandlerService.finalizeClusterInstall(instanceMetaDatas, stack.getCluster());
});
} catch (TransactionExecutionException e) {
throw new CloudbreakException(e.getCause());
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData 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.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterBootstrapper method collectAndCheckGateways.
private List<GatewayConfig> collectAndCheckGateways(Stack stack) {
LOGGER.info("Collect and check gateways for {}", stack.getName());
List<GatewayConfig> allGatewayConfig = new ArrayList<>();
for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, isKnoxEnabled(stack));
LOGGER.info("Add gateway config: {}", gatewayConfig);
allGatewayConfig.add(gatewayConfig);
ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
}
return allGatewayConfig;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterBootstrapper method bootstrapNewNodesOnHost.
private void bootstrapNewNodesOnHost(Stack stack, List<GatewayConfig> allGatewayConfigs, Set<Node> nodes, Set<Node> allNodes) throws CloudbreakOrchestratorException {
LOGGER.info("Bootstrap new nodes: {}", nodes);
Cluster cluster = stack.getCluster();
Boolean enableKnox = cluster.getGateway() != null;
for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
}
byte[] stateZip = null;
ClusterComponent stateComponent = clusterComponentProvider.getComponent(cluster.getId(), ComponentType.SALT_STATE);
if (stateComponent != null) {
String content = (String) stateComponent.getAttributes().getMap().getOrDefault(ComponentType.SALT_STATE.name(), "");
if (!content.isEmpty()) {
stateZip = Base64.decodeBase64(content);
}
}
BootstrapParams params = createBootstrapParams(stack);
hostOrchestrator.bootstrapNewNodes(allGatewayConfigs, nodes, allNodes, stateZip, params, clusterDeletionBasedModel(stack.getId(), null));
InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
ExtendedPollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(allNodesAvailabilityPolling.getPollingResult(), "Polling of new nodes availability was cancelled.");
if (allNodesAvailabilityPolling.isTimeout()) {
clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
}
}
Aggregations