Search in sources :

Example 1 with FlowsAlreadyRunningException

use of com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException in project cloudbreak by hortonworks.

the class ReactorFlowManager method notify.

private void notify(String selector, Acceptable acceptable) {
    Event<Acceptable> event = eventFactory.createEventWithErrHandler(acceptable);
    reactor.notify(selector, event);
    try {
        Boolean accepted = true;
        if (event.getData().accepted() != null) {
            accepted = event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
        }
        if (accepted == null || !accepted) {
            Stack stack = stackService.get(event.getData().getStackId());
            throw new FlowsAlreadyRunningException(String.format("Stack %s has flows under operation, request not allowed.", stack.getName()));
        }
    } catch (InterruptedException e) {
        throw new CloudbreakApiException(e.getMessage());
    }
}
Also used : FlowsAlreadyRunningException(com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 2 with FlowsAlreadyRunningException

use of com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException in project cloudbreak by hortonworks.

the class CloudbreakCleanupService method triggerSyncs.

private void triggerSyncs(Iterable<Stack> stacksToSync, Iterable<Cluster> clustersToSync) {
    try {
        for (Stack stack : stacksToSync) {
            LOGGER.info("Triggering full sync on stack [name: {}, id: {}].", stack.getName(), stack.getId());
            fireEvent(stack);
            flowManager.triggerFullSync(stack.getId());
        }
        for (Cluster cluster : clustersToSync) {
            Stack stack = cluster.getStack();
            LOGGER.info("Triggering sync on cluster [name: {}, id: {}].", cluster.getName(), cluster.getId());
            fireEvent(stack);
            flowManager.triggerClusterSync(stack.getId());
        }
    } catch (OptimisticLockingFailureException | FlowsAlreadyRunningException e) {
        LOGGER.error("Cannot trigger sync on stacks. Maybe another node is already syncing them?", e);
    }
}
Also used : OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) FlowsAlreadyRunningException(com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

FlowsAlreadyRunningException (com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 Acceptable (com.sequenceiq.cloudbreak.cloud.Acceptable)1 CloudbreakApiException (com.sequenceiq.cloudbreak.controller.CloudbreakApiException)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)1