Package com.sequenceiq.cloudbreak.domain

Examples of com.sequenceiq.cloudbreak.domain.Stack


        return Arrays.asList(new Resource(resourceType(), name, stack));
    }

    @Override
    public Boolean delete(Resource resource, GccDeleteContextObject d) throws Exception {
        Stack stack = stackRepository.findById(d.getStackId());
        try {
            GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
            GccCredential gccCredential = (GccCredential) stack.getCredential();
            Operation execute = d.getCompute().disks()
                    .delete(gccCredential.getProjectId(), gccTemplate.getGccZone().getValue(), resource.getResourceName()).execute();
            Compute.ZoneOperations.Get zoneOperations = createZoneOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            Compute.GlobalOperations.Get globalOperations = createGlobalOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            GccRemoveReadyPollerObject gccRemoveReady =
View Full Code Here


        return true;
    }

    @Override
    public Optional<String> describe(Resource resource, GccDescribeContextObject dco) throws Exception {
        Stack stack = stackRepository.findById(dco.getStackId());
        GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
        GccCredential gccCredential = (GccCredential) stack.getCredential();
        try {
            Compute.Disks.Get getDisk =
                    dco.getCompute().disks().get(gccCredential.getProjectId(), gccTemplate.getGccZone().getValue(), resource.getResourceName());
            return Optional.fromNullable(getDisk.execute().toPrettyString());
        } catch (IOException e) {
View Full Code Here

    @Autowired
    private StackRepository stackRepository;

    public void waitForAmbariServer(Long stackId, String ambariIp) {
        Stack stack = stackRepository.findById(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            boolean ambariRunning = false;
            AmbariClient ambariClient = createAmbariClient(ambariIp);
            int pollingAttempt = 0;
View Full Code Here

    @Autowired
    private GccStackUtil gccStackUtil;

    public void allocateRoles(Long stackId, Set<CoreInstanceMetaData> coreInstanceMetaData) {
        try {
            Stack stack = stackRepository.findById(stackId);
            MDCBuilder.buildMdcContext(stack);
            if (!stack.isMetadataReady()) {
                if (coreInstanceMetaData.size() != stack.getNodeCount()) {
                    throw new WrongMetadataException(String.format(
                            "Size of the collected metadata set does not equal the node count of the stack. [stack: '%s']", stack.getId()));
                }
                Set<InstanceMetaData> instanceMetaData = prepareInstanceMetaData(stack, coreInstanceMetaData);
                stackUpdater.updateStackMetaData(stackId, instanceMetaData);
                stackUpdater.updateMetadataReady(stackId, true);
                LOGGER.info("Publishing {} event", ReactorConfig.AMBARI_ROLE_ALLOCATION_COMPLETE_EVENT);
View Full Code Here

            notifyStackCreateFailed(stackId, "Unhandled exception occured while creating stack.");
        }
    }

    public void updateInstanceMetadata(Long stackId, Set<CoreInstanceMetaData> coreInstanceMetaData) {
        Stack stack = stackRepository.findOneWithLists(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            Set<InstanceMetaData> originalMetadata = stack.getInstanceMetaData();
            Set<InstanceMetaData> instanceMetaData = prepareInstanceMetaData(stack, coreInstanceMetaData, stack.getInstanceMetaData().size() + 1);
            originalMetadata.addAll(instanceMetaData);
            stackUpdater.updateStackMetaData(stackId, originalMetadata);
            stackUpdater.updateMetadataReady(stackId, true);
            Set<String> instanceIds = new HashSet<>();
            for (InstanceMetaData metadataEntry : instanceMetaData) {
View Full Code Here

    @javax.annotation.Resource
    private Map<CloudPlatform, ResourceBuilderInit> resourceBuilderInits;

    public void buildStack(final CloudPlatform cloudPlatform, Long stackId, Map<String, Object> setupProperties, Map<String, String> userDataParams) {
        Stack stack = stackRepository.findById(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            if (stack.getStatus().equals(Status.REQUESTED)) {
                stack = stackUpdater.updateStackStatus(stack.getId(), Status.CREATE_IN_PROGRESS);
                websocketService.sendToTopicUser(stack.getOwner(), WebsocketEndPoint.STACK, new StatusMessage(stack.getId(), stack.getName(), stack
                        .getStatus().name()));
                stackUpdater.updateStackStatusReason(stack.getId(), stack.getStatus().name());
                if (!cloudPlatform.isWithTemplate()) {
                    stackUpdater.updateStackStatus(stack.getId(), Status.REQUESTED);
                    Set<Resource> resourceSet = new HashSet<>();
                    ResourceBuilderInit resourceBuilderInit = resourceBuilderInits.get(cloudPlatform);
                    final ProvisionContextObject pCO =
                            resourceBuilderInit.provisionInit(stack, userDataBuilder.build(cloudPlatform, stack.getHash(), userDataParams));
                    for (ResourceBuilder resourceBuilder : networkResourceBuilders.get(cloudPlatform)) {
                        List<Resource> resourceList = resourceBuilder.create(pCO, 0, new ArrayList<Resource>());
                        resourceSet.addAll(resourceList);
                        pCO.getNetworkResources().addAll(resourceList);
                    }
                    List<Future<List<Resource>>> futures = new ArrayList<>();
                    for (int i = 0; i < stack.getNodeCount(); i++) {
                        final int index = i;
                        Future<List<Resource>> submit = resourceBuilderExecutor.submit(new Callable<List<Resource>>() {
                            @Override
                            public List<Resource> call() throws Exception {
                                List<Resource> resources = new ArrayList<>();
                                for (final ResourceBuilder resourceBuilder : instanceResourceBuilders.get(cloudPlatform)) {
                                    List<Resource> resourceList = resourceBuilder.create(pCO, index, resources);
                                    resources.addAll(resourceList);
                                }
                                return resources;
                            }
                        });
                        futures.add(submit);
                    }
                    Exception exception = null;
                    for (Future<List<Resource>> future : futures) {
                        try {
                            resourceSet.addAll(future.get());
                        } catch (Exception e) {
                            exception = e;
                        }
                    }
                    if (exception != null) {
                        throw new BuildStackFailureException(exception.getMessage(), exception, resourceSet);
                    }

                    LOGGER.info("Publishing {} event [StackId: '{}']", ReactorConfig.PROVISION_COMPLETE_EVENT, stack.getId());
                    reactor.notify(ReactorConfig.PROVISION_COMPLETE_EVENT, Event.wrap(new ProvisionComplete(cloudPlatform, stack.getId(), resourceSet)));
                } else {
                    CloudPlatformConnector cloudPlatformConnector = cloudPlatformConnectors.get(cloudPlatform);
                    cloudPlatformConnector.buildStack(stack, userDataBuilder.build(cloudPlatform, stack.getHash(), userDataParams), setupProperties);
                }
            } else {
                LOGGER.info("CloudFormation stack creation was requested for a stack, that is not in REQUESTED status anymore. [stackId: '{}', status: '{}']",
                        stack.getId(), stack.getStatus());
            }
        } catch (BuildStackFailureException e) {
            stackUpdater.updateStackResources(stackId, e.getResourceSet());
            LOGGER.error("Unhandled exception occured while creating stack.", e);
            LOGGER.info("Publishing {} event.", ReactorConfig.STACK_CREATE_FAILED_EVENT);
View Full Code Here

    public void testConvertStackJsonToEntity() {
        // GIVEN
        given(credentialRepository.findOne(DUMMY_ID)).willReturn(awsCredential);
        given(templateRepository.findOne(DUMMY_ID)).willReturn(awsTemplate);
        // WHEN
        Stack result = underTest.convert(stackJson);
        // THEN
        assertEquals(result.getCredential().getId(), stackJson.getCredentialId());
        assertEquals(result.getTemplate().getId(), stackJson.getTemplateId());
        assertEquals(result.getStatus(), Status.REQUESTED);
        assertNull(result.getAccount());
        assertNull(result.getOwner());
        assertFalse(result.isPublicInAccount());
        verify(credentialRepository, times(1)).findOne(anyLong());
        verify(templateRepository, times(1)).findOne(anyLong());
    }
View Full Code Here

        // WHEN
        underTest.convert(stackJson);
    }

    private Stack createStack() {
        Stack stack = new Stack();
        stack.setAmbariIp(AMBARI_IP);
        stack.setStackCompleted(CF_STACK_COMPLETED);
        stack.setCluster(new Cluster());
        stack.setCredential(awsCredential);
        stack.setTemplate(awsTemplate);
        stack.setDescription(DESCRIPTION);
        stack.setHash(DUMMY_HASH);
        stack.setId(DUMMY_ID);
        stack.setInstanceMetaData(new HashSet<InstanceMetaData>());
        stack.setMetadataReady(METADATA_READY);
        stack.setName(DUMMY_NAME);
        stack.setNodeCount(NODE_COUNT);
        stack.setStatus(Status.AVAILABLE);
        stack.setStatusReason(DUMMY_STATUS_REASON);
        stack.setVersion(VERSION);
        stack.setPublicInAccount(true);
        stack.setAccount(DUMMY_NAME);
        stack.setOwner(DUMMY_NAME);
        return stack;
    }
View Full Code Here

        // WHEN
        underTest.updateHosts(stack.getId(), hostGroupAdjustments);
    }

    private Stack createStack(Cluster cluster) {
        Stack stack = new Stack();
        stack.setId(1L);
        stack.setCluster(cluster);
        return stack;
    }
View Full Code Here

        MockitoAnnotations.initMocks(this);
        clusterCreationSuccess = new ClusterCreationSuccess(1L, 20L, "1.1.1.1");
        event = new Event<>(clusterCreationSuccess);
        cluster = new Cluster();
        cluster.setEmailNeeded(false);
        stack = new Stack();
        Set<InstanceMetaData> instanceMetaData = new HashSet<>();
        stack.setInstanceMetaData(instanceMetaData);
        cluster.setOwner("John");
        cluster.setAccount("Acme");
    }
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.domain.Stack

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.