Package com.sequenceiq.cloudbreak.service.stack.event

Examples of com.sequenceiq.cloudbreak.service.stack.event.StackDeleteRequest


        LOGGER.info("Stack delete requested.");
        if (stack == null) {
            throw new NotFoundException(String.format("Stack '%s' not found", id));
        }
        LOGGER.info("Publishing {} event.", ReactorConfig.DELETE_REQUEST_EVENT);
        reactor.notify(ReactorConfig.DELETE_REQUEST_EVENT, Event.wrap(new StackDeleteRequest(stack.getTemplate().cloudPlatform(), stack.getId())));
    }
View Full Code Here


    @javax.annotation.Resource
    private ConcurrentTaskExecutor resourceBuilderExecutor;

    @Override
    public void accept(Event<StackDeleteRequest> stackDeleteRequest) {
        final StackDeleteRequest data = stackDeleteRequest.getData();
        retryingStackUpdater.updateStackStatus(data.getStackId(), Status.DELETE_IN_PROGRESS);
        Stack stack = stackRepository.findOneWithLists(data.getStackId());
        MDCBuilder.buildMdcContext(stack);
        LOGGER.info("Accepted {} event.", ReactorConfig.DELETE_REQUEST_EVENT);
        try {
            if (!data.getCloudPlatform().isWithTemplate()) {
                ResourceBuilderInit resourceBuilderInit = resourceBuilderInits.get(data.getCloudPlatform());
                final DeleteContextObject dCO = resourceBuilderInit.deleteInit(stack);

                for (int i = instanceResourceBuilders.get(data.getCloudPlatform()).size() - 1; i >= 0; i--) {
                    List<Future<Boolean>> futures = new ArrayList<>();
                    final int index = i;
                    List<Resource> resourceByType = stack.getResourcesByType(instanceResourceBuilders.get(data.getCloudPlatform()).get(i).resourceType());
                    for (final Resource resource : resourceByType) {
                        Future<Boolean> submit = resourceBuilderExecutor.submit(new Callable<Boolean>() {
                            @Override
                            public Boolean call() throws Exception {
                                return instanceResourceBuilders.get(data.getCloudPlatform()).get(index).delete(resource, dCO);
                            }
                        });
                        futures.add(submit);
                    }
                    for (Future<Boolean> future : futures) {
                        future.get();
                    }
                }
                for (int i = instanceResourceBuilders.get(data.getCloudPlatform()).size() - 1; i >= 0; i--) {
                    for (Resource resource : stack.getResourcesByType(networkResourceBuilders.get(data.getCloudPlatform()).get(i).resourceType())) {
                        networkResourceBuilders.get(data.getCloudPlatform()).get(i).delete(resource, dCO);
                    }
                }
                reactor.notify(ReactorConfig.DELETE_COMPLETE_EVENT, Event.wrap(new StackDeleteComplete(dCO.getStackId())));
            } else {
                cloudPlatformConnectors.get(data.getCloudPlatform()).deleteStack(stack, stack.getCredential());
            }
        } catch (Exception ex) {
            LOGGER.error(String.format("Stack delete failed on {} stack: ", stack.getId()), ex);
            retryingStackUpdater.updateStackStatus(data.getStackId(), Status.DELETE_FAILED);
        }
    }
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.service.stack.event.StackDeleteRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.