Search in sources :

Example 56 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackService method getPublicStack.

public Stack getPublicStack(String name, IdentityUser identityUser) {
    Stack stack = stackRepository.findByNameInAccount(name, identityUser.getAccount());
    if (stack == null) {
        throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, name));
    }
    authorizationService.hasReadPermission(stack);
    return stack;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 57 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackService method getPublicStackJsonByName.

public StackResponse getPublicStackJsonByName(String name, IdentityUser identityUser, Collection<String> entries) {
    Stack stack = stackRepository.findByNameInAccountWithLists(name, identityUser.getAccount());
    if (stack == null) {
        throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, name));
    }
    authorizationService.hasReadPermission(stack);
    StackResponse stackResponse = conversionService.convert(stack, StackResponse.class);
    stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entries);
    return stackResponse;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 58 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackService method updateStatus.

@Transactional(TxType.NEVER)
public void updateStatus(Long stackId, StatusRequest status, boolean updateCluster) {
    Stack stack = getByIdWithLists(stackId);
    Cluster cluster = null;
    if (stack.getCluster() != null) {
        cluster = clusterRepository.findOneWithLists(stack.getCluster().getId());
    }
    switch(status) {
        case SYNC:
            sync(stack, false);
            break;
        case FULL_SYNC:
            sync(stack, true);
            break;
        case REPAIR_FAILED_NODES:
            repairFailedNodes(stack);
            break;
        case STOPPED:
            stop(stack, cluster, updateCluster);
            break;
        case STARTED:
            start(stack, cluster, updateCluster);
            break;
        default:
            throw new BadRequestException("Cannot update the status of stack because status request not valid.");
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.Stack) Transactional(javax.transaction.Transactional)

Example 59 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackService method delete.

public void delete(String name, IdentityUser user, Boolean forced, Boolean deleteDependencies) {
    Stack stack = stackRepository.findByNameInAccountOrOwner(name, user.getAccount(), user.getUserId());
    if (stack == null) {
        throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, name));
    }
    delete(stack, forced, deleteDependencies);
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 60 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackService method delete.

public void delete(Long id, IdentityUser user, Boolean forced, Boolean deleteDependencies) {
    Stack stack = stackRepository.findByIdInAccount(id, user.getAccount());
    if (stack == null) {
        throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, id));
    }
    delete(stack, forced, deleteDependencies);
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14