use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException 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.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class PillarConfigUpdateService method configUpdateFinished.
public void configUpdateFinished(StackView stackView) {
try {
transactionService.required(() -> {
stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE, "Config update finished.");
});
flowMessageService.fireEventAndLog(stackView.getId(), AVAILABLE.name(), CLUSTER_PILLAR_CONFIG_UPDATE_FINISHED);
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterCreationService method clusterInstallationFinished.
public void clusterInstallationFinished(StackView stackView, ProvisionType provisionType) {
try {
transactionService.required(() -> {
if (provisionType.isRecovery()) {
stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.CLUSTER_RECOVERY_FINISHED, "Cluster recovery finished.");
flowMessageService.fireEventAndLog(stackView.getId(), AVAILABLE.name(), RECOVERY_FINISHED);
} else {
stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE, "Cluster creation finished.");
flowMessageService.fireEventAndLog(stackView.getId(), AVAILABLE.name(), CLUSTER_BUILT);
}
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException 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.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterStartService method updateInstancesToHealthy.
private void updateInstancesToHealthy(StackView stack) {
try {
transactionService.required(() -> {
Set<InstanceMetaData> instances = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
for (InstanceMetaData metaData : instances) {
metaData.setInstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.SERVICES_HEALTHY);
}
instanceMetaDataService.saveAll(instances);
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations