use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class FlowCancelServiceTest method testCancelFlowSilentlyIgnoresException.
@Test
public void testCancelFlowSilentlyIgnoresException() throws TransactionExecutionException {
doThrow(new TransactionExecutionException("asdf", new RuntimeException())).when(flow2Handler).cancelFlow(anyLong(), anyString());
FlowLog flowLog = new FlowLog();
flowLog.setFlowId("asdf");
flowLog.setResourceId(1L);
underTest.cancelFlowSilently(flowLog);
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterBuilderService method finalizeClusterInstall.
public void finalizeClusterInstall(Stack stack) throws CloudbreakException {
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 ClusterBootstrapper method bootstrapOnHostInternal.
private void bootstrapOnHostInternal(Stack stack, Consumer<Stack> saveOrUpdateSaltComponent) throws CloudbreakException {
try {
Set<Node> nodes = transactionService.required(() -> collectNodesForBootstrap(stack));
List<GatewayConfig> allGatewayConfig = collectAndCheckGateways(stack);
saveOrUpdateSaltComponent.accept(stack);
BootstrapParams params = createBootstrapParams(stack);
hostOrchestrator.bootstrap(allGatewayConfig, nodes, params, clusterDeletionBasedModel(stack.getId(), null));
InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
saveOrchestrator(stack, primaryGateway);
checkIfAllNodesAvailable(stack, nodes, primaryGateway);
} catch (TransactionExecutionException e) {
throw new CloudbreakException(e.getCause());
} catch (CloudbreakOrchestratorFailedException e) {
checkIfAnyInstanceIsNotInStartedState(stack, e);
throw new CloudbreakException(e);
} catch (Exception e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterBootstrapper method bootstrapNewNodes.
public void bootstrapNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException {
LOGGER.info("Bootstrap new nodes: {}", upscaleCandidateAddresses);
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Set<Node> nodes = new HashSet<>();
Set<Node> allNodes = new HashSet<>();
try {
transactionService.required(() -> collectNodes(stackId, upscaleCandidateAddresses, stack, nodes, allNodes));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
cleanupOldSaltState(allGatewayConfigs, nodes);
bootstrapNewNodesOnHost(stack, allGatewayConfigs, nodes, allNodes);
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException e) {
throw new CloudbreakException(e);
} catch (TransactionExecutionException e) {
throw new CloudbreakException(e.getCause());
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class HostMetadataSetup method setupHostMetadata.
public void setupHostMetadata(Long stackId) {
try {
transactionService.required(() -> {
LOGGER.debug("Setting up host metadata for the cluster.");
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Set<InstanceMetaData> allInstanceMetadataByStackId = instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(stackId);
updateWithHostData(stack, allInstanceMetadataByStackId);
instanceMetaDataService.saveAll(allInstanceMetadataByStackId);
});
} catch (TransactionExecutionException e) {
throw new CloudbreakRuntimeException(e.getCause());
}
}
Aggregations