use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class CloudbreakEventHandler method sendNotification.
private void sendNotification(CloudbreakCompositeEvent cloudbreakCompositeEvent) {
String owner = cloudbreakCompositeEvent.getOwner();
StackV4Response stackResponse = cloudbreakCompositeEvent.getStackResponse();
if (stackResponse != null) {
try {
Collection<String> resourceEventMessageArgs = cloudbreakCompositeEvent.getResourceEventMessageArgs();
notificationService.send(cloudbreakCompositeEvent.getResourceEvent(), resourceEventMessageArgs, stackResponse, owner);
} catch (Exception e) {
String msg = String.format("Failed to send notification from structured event, stack('%s')", stackResponse.getId());
LOGGER.warn(msg, e);
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DefaultCloudbreakEventService method fireEventWithPayload.
private void fireEventWithPayload(Stack stack, String eventType, ResourceEvent resourceEvent, Collection<String> eventMessageArgs, String eventMessage, String instanceGroupName) {
StructuredNotificationEvent structuredNotificationEvent = baseLegacyStructuredFlowEventFactory.createStructuredNotificationEvent(stack, eventType, eventMessage, instanceGroupName);
StackV4Response stackV4Response = stackV4ResponseConverter.convert(stack);
stackV4Response = stackResponseDecorator.decorate(stackV4Response, stack, List.of(StackResponseEntries.HARDWARE_INFO.getEntryName()));
CloudbreakCompositeEvent compositeEvent = new CloudbreakCompositeEvent(resourceEvent, eventMessageArgs, structuredNotificationEvent, stackV4Response, stack.getCreator().getUserCrn());
reactor.notify(CLOUDBREAK_EVENT, eventFactory.createEvent(compositeEvent));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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.api.endpoint.v4.stacks.response.StackV4Response 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);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DatalakeService method addSharedServiceResponse.
public void addSharedServiceResponse(Stack stack, StackV4Response stackResponse) {
SharedServiceV4Response sharedServiceResponse = new SharedServiceV4Response();
if (!Strings.isNullOrEmpty(stack.getDatalakeCrn())) {
LOGGER.debug("Checking datalake through the datalakeCrn.");
Optional<ResourceBasicView> resourceBasicView = stackService.getResourceBasicViewByResourceCrn(stack.getDatalakeCrn());
if (resourceBasicView.isPresent()) {
ResourceBasicView s = resourceBasicView.get();
sharedServiceResponse.setSharedClusterId(s.getId());
sharedServiceResponse.setSharedClusterName(s.getName());
} else {
LOGGER.debug("Unable to find datalake with CRN {}", stack.getDatalakeCrn());
}
}
stackResponse.setSharedService(sharedServiceResponse);
}
Aggregations