use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterService method updateClusterMetadata.
public Cluster updateClusterMetadata(Long stackId) {
Stack stack = stackService.getById(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
if (!connector.clusterStatusService().isClusterManagerRunning()) {
Set<InstanceMetaData> notTerminatedInstanceMetaDatas = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stackId);
InstanceMetaData cmInstance = updateClusterManagerHostStatus(notTerminatedInstanceMetaDatas);
eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), CLUSTER_HOST_STATUS_UPDATED, Arrays.asList(cmInstance.getDiscoveryFQDN(), cmInstance.getInstanceStatus().name()));
return stack.getCluster();
} else {
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(stack.getCluster().getId()));
updateClusterCertExpirationState(stack.getCluster(), extendedHostStatuses.isAnyCertExpiring());
try {
return transactionService.required(() -> {
Set<InstanceMetaData> notTerminatedInstanceMetaDatas = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stackId);
List<InstanceMetaData> updatedInstanceMetaData = updateInstanceStatuses(notTerminatedInstanceMetaDatas, extendedHostStatuses);
instanceMetaDataService.saveAll(updatedInstanceMetaData);
fireHostStatusUpdateNotification(stack, updatedInstanceMetaData);
return stack.getCluster();
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterService method updateInstancesToRunning.
public void updateInstancesToRunning(Long stackId, Set<Node> reachableNodes) {
try {
transactionService.required(() -> {
List<InstanceMetaData> createdInstances = instanceMetaDataService.findNotTerminatedForStack(stackId).stream().filter(InstanceMetaData::isCreated).collect(Collectors.toList());
for (InstanceMetaData instanceMetaData : createdInstances) {
if (reachableNodes.stream().anyMatch(node -> node.getHostname().equals(instanceMetaData.getDiscoveryFQDN()))) {
instanceMetaData.setInstanceStatus(SERVICES_RUNNING);
instanceMetaDataService.save(instanceMetaData);
}
}
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class StackService method getAllForAutoscale.
public Set<AutoscaleStackV4Response> getAllForAutoscale() {
try {
return transactionService.required(() -> {
Set<AutoscaleStack> aliveOnes = stackRepository.findAliveOnesWithClusterManager();
Set<AutoscaleStack> aliveNotUnderDeletion = Optional.ofNullable(aliveOnes).orElse(Set.of()).stream().filter(stack -> !DELETE_IN_PROGRESS.equals(stack.getStackStatus())).collect(Collectors.toSet());
return aliveNotUnderDeletion.stream().map(a -> autoscaleStackToAutoscaleStackResponseJsonConverter.convert(a)).collect(Collectors.toSet());
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class StackService method getJsonById.
public StackV4Response getJsonById(Long id, Collection<String> entry) {
try {
return transactionService.required(() -> {
Stack stack = getByIdWithLists(id);
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack);
stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entry);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class StackService method getByNameInWorkspaceWithEntries.
public StackV4Response getByNameInWorkspaceWithEntries(String name, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByNameAndWorkspaceIdWithLists(name, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format(STACK_NOT_FOUND_BY_NAME_EXCEPTION_MESSAGE, name));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations