use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackUtilTest method testGetUptimeForCluster.
@Test
public void testGetUptimeForCluster() {
Cluster cluster = new Cluster();
int minutes = 10;
cluster.setUptime(Duration.ofMinutes(minutes).toString());
cluster.setStatus(Status.AVAILABLE);
cluster.setUpSince(new Date().getTime());
long uptime = stackUtil.getUptimeForCluster(cluster, true);
assertTrue(uptime >= Duration.ofMinutes(minutes).toMillis());
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class UptimeNotifierTest method notificationSendingWhenEverythingWorkFine.
@Test
public void notificationSendingWhenEverythingWorkFine() {
doNothing().when(notificationSender).send(any(Notification.class));
List<Cluster> clusters = TestUtil.generateCluster(1);
when(clusterRepository.findByStatuses(any())).thenReturn(Collections.singletonList(clusters.get(0)));
Stack stack1 = TestUtil.stack();
when(stackRepository.findStackForCluster(anyLong())).thenReturn(stack1);
underTest.sendUptime();
ArgumentCaptor<Notification> argument1 = ArgumentCaptor.forClass(Notification.class);
verify(notificationSender).send(argument1.capture());
Notification<CloudbreakEventsJson> notification = argument1.getValue();
assertEquals(GCP, notification.getNotification().getCloud());
assertEquals("null", notification.getNotification().getBlueprintName());
assertEquals(null, notification.getNotification().getBlueprintId());
verify(notificationSender, times(1)).send(any(Notification.class));
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackToBlueprintPreparationObjectConverter method convert.
@Override
public BlueprintPreparationObject convert(Stack source) {
try {
Optional<SmartSenseSubscription> aDefault = smartSenseSubscriptionService.getDefault();
Cluster cluster = clusterService.getById(source.getCluster().getId());
FileSystem fileSystem = cluster.getFileSystem();
LdapConfig ldapConfig = cluster.getLdapConfig();
StackRepoDetails hdpRepo = clusterComponentConfigProvider.getHDPRepo(cluster.getId());
String stackRepoDetailsHdpVersion = hdpRepo != null ? hdpRepo.getHdpVersion() : null;
Map<String, List<InstanceMetaData>> groupInstances = instanceGroupMetadataCollector.collectMetadata(source);
HdfConfigs hdfConfigs = hdfConfigProvider.createHdfConfig(cluster.getHostGroups(), groupInstances, cluster.getBlueprint().getBlueprintText());
BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(cluster.getBlueprint().getBlueprintText());
FileSystemConfigurationView fileSystemConfigurationView = null;
if (source.getCluster().getFileSystem() != null) {
fileSystemConfigurationView = new FileSystemConfigurationView(fileSystemConfigurationProvider.fileSystemConfiguration(fileSystem, source), fileSystem == null ? false : fileSystem.isDefaultFs());
}
IdentityUser identityUser = userDetailsService.getDetails(cluster.getOwner(), UserFilterField.USERID);
return BlueprintPreparationObject.Builder.builder().withFlexSubscription(source.getFlexSubscription()).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withHostgroups(hostGroupService.getByCluster(cluster.getId())).withGateway(cluster.getGateway()).withBlueprintView(new BlueprintView(cluster, blueprintStackInfo)).withStackRepoDetailsHdpVersion(stackRepoDetailsHdpVersion).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigsProvider.generalClusterConfigs(source, cluster, identityUser)).withSmartSenseSubscriptionId(aDefault.isPresent() ? aDefault.get().getSubscriptionId() : null).withLdapConfig(ldapConfig).withHdfConfigs(hdfConfigs).withKerberosConfig(cluster.isSecure() ? cluster.getKerberosConfig() : null).build();
} catch (BlueprintProcessingException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
} catch (IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class ClusterServiceRunner method updateSaltState.
public void updateSaltState(Long stackId) throws CloudbreakException {
Stack stack = stackService.getByIdWithLists(stackId);
Orchestrator orchestrator = stack.getOrchestrator();
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(orchestrator.getType());
if (orchestratorType.containerOrchestrator()) {
LOGGER.info("Container orchestrator is not supported for this action.");
} else {
Cluster cluster = clusterService.retrieveClusterByStackId(stack.getId());
hostRunner.runAmbariServices(stack, cluster);
}
}
use of com.sequenceiq.cloudbreak.domain.Cluster 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 CloudbreakException, CloudbreakOrchestratorException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Cluster cluster = stack.getCluster();
Boolean enableKnox = cluster.getGateway().getEnableGateway();
for (InstanceMetaData gateway : stack.getGatewayInstanceMetadata()) {
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
PollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithTimeoutSingleFailure(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(bootstrapApiPolling, "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);
}
}
hostOrchestrator.bootstrapNewNodes(allGatewayConfigs, nodes, allNodes, stateZip, clusterDeletionBasedModel(stack.getId(), null));
InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
PollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithTimeoutSingleFailure(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(allNodesAvailabilityPolling, "Polling of new nodes availability was cancelled.");
if (TIMEOUT.equals(allNodesAvailabilityPolling)) {
clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
}
}
Aggregations