use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayService method primaryGatewayChanged.
public void primaryGatewayChanged(long stackId, String newPrimaryGatewayFQDN) throws CloudbreakException, TransactionExecutionException {
LOGGER.info("Update primary gateway ip");
Set<InstanceMetaData> imds = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stackId);
Optional<InstanceMetaData> formerPrimaryGateway = imds.stream().filter(imd -> imd.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).findFirst();
Optional<InstanceMetaData> newPrimaryGateway = imds.stream().filter(imd -> imd.getDiscoveryFQDN() != null && imd.getDiscoveryFQDN().equals(newPrimaryGatewayFQDN)).findFirst();
if (newPrimaryGateway.isPresent() && formerPrimaryGateway.isPresent()) {
InstanceMetaData fpg = formerPrimaryGateway.get();
fpg.setInstanceMetadataType(InstanceMetadataType.GATEWAY);
fpg.setServer(Boolean.FALSE);
transactionService.required(() -> {
instanceMetaDataService.save(fpg);
InstanceMetaData npg = newPrimaryGateway.get();
npg.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
npg.setServer(Boolean.TRUE);
instanceMetaDataService.save(npg);
Stack updatedStack = stackService.getByIdWithListsInTransaction(stackId);
String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(updatedStack);
Cluster cluster = updatedStack.getCluster();
cluster.setClusterManagerIp(gatewayIp);
LOGGER.info("Primary gateway IP has been updated to: '{}'", gatewayIp);
clusterService.save(cluster);
clusterPublicEndpointManagementService.changeGateway(updatedStack);
return null;
});
} else {
throw new CloudbreakException("Primary gateway change was not successful.");
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClusterStartService method clusterStartFinished.
public void clusterStartFinished(StackView stack) {
Cluster cluster = clusterService.retrieveClusterByStackIdWithoutAuth(stack.getId()).orElseThrow(NotFoundException.notFound("cluster", stack.getId()));
cluster.setUpSince(new Date().getTime());
clusterService.updateCluster(cluster);
updateInstancesToHealthy(stack);
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.AVAILABLE, "Cluster started.");
flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), CLUSTER_STARTED);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClusterStopService method updateClusterUptime.
private void updateClusterUptime(long stackId) {
Cluster cluster = clusterService.retrieveClusterByStackIdWithoutAuth(stackId).orElseThrow(NotFoundException.notFound("cluster", stackId));
cluster.setUptime(Duration.ofMillis(stackUtil.getUptimeForCluster(cluster, true)).toString());
clusterService.updateCluster(cluster);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClusterCredentialChangeService method finishCredentialUpdate.
public void finishCredentialUpdate(Long stackId, Long clusterId, String password) {
Cluster cluster = clusterService.getById(clusterId);
cluster.setPassword(password);
finishCredentialChange(stackId, cluster);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ExternalDatabaseService method getDatabaseRequest.
private AllocateDatabaseServerV4Request getDatabaseRequest(DetailedEnvironmentResponse environment, DatabaseAvailabilityType externalDatabase, Cluster cluster) {
AllocateDatabaseServerV4Request req = new AllocateDatabaseServerV4Request();
req.setEnvironmentCrn(environment.getCrn());
CloudPlatform cloudPlatform = CloudPlatform.valueOf(environment.getCloudPlatform().toUpperCase(Locale.US));
String databaseEngineVersion = Optional.ofNullable(cluster).map(Cluster::getStack).map(Stack::getExternalDatabaseEngineVersion).orElse(null);
req.setDatabaseServer(getDatabaseServerStackRequest(cloudPlatform, externalDatabase, databaseEngineVersion));
if (cluster.getStack() != null) {
req.setClusterCrn(cluster.getStack().getResourceCrn());
req.setTags(getUserDefinedTags(cluster.getStack()));
}
return req;
}
Aggregations