Search in sources :

Example 11 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class UpdateStackRequestValidator method isValid.

@Override
public boolean isValid(UpdateStackV4Request value, ConstraintValidatorContext context) {
    int updateResources = 0;
    if (value.getStatus() != null) {
        updateResources++;
    }
    InstanceGroupAdjustmentV4Request instanceGroupAdjustment = value.getInstanceGroupAdjustment();
    if (instanceGroupAdjustment != null) {
        updateResources++;
        if (value.getWithClusterEvent() && instanceGroupAdjustment.getScalingAdjustment() < 0) {
            ValidatorUtil.addConstraintViolation(context, "Invalid PUT request on this resource. Update event has to be upscale if you define withClusterEvent = 'true'.", "status");
            return false;
        }
    }
    if (updateResources != 1) {
        ValidatorUtil.addConstraintViolation(context, "Invalid PUT request on this resource. 1 update request is allowed at a time.", "status");
        return false;
    }
    return true;
}
Also used : InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request)

Example 12 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class SdxCcmUpgradeServiceTest method getStack.

private StackV4Response getStack(Tunnel tunnel, Status status) {
    StackV4Response response = new StackV4Response();
    response.setName("stackName");
    response.setTunnel(tunnel);
    response.setStatus(status);
    return response;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)

Example 13 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class UpgradePreconditionServiceTest method createStackResponse.

private StackViewV4Response createStackResponse(Status stackStatus, String stackName, String stackCrn) {
    StackViewV4Response dataHubStack = new StackViewV4Response();
    dataHubStack.setStatus(stackStatus);
    dataHubStack.setName(stackName);
    dataHubStack.setCrn(stackCrn);
    return dataHubStack;
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)

Example 14 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class StackOperationServiceTest method shouldNotTriggerStopWhenStackRunsOnSpotInstances.

@Test
public void shouldNotTriggerStopWhenStackRunsOnSpotInstances() {
    Stack stack = new Stack();
    stack.setId(9876L);
    stack.setStackStatus(new StackStatus(stack, AVAILABLE));
    when(stackStopRestrictionService.isInfrastructureStoppable(any())).thenReturn(StopRestrictionReason.NONE);
    when(spotInstanceUsageCondition.isStackRunsOnSpotInstances(stack)).thenReturn(true);
    when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
    assertThatThrownBy(() -> underTest.updateStatus(stack.getId(), StatusRequest.STOPPED, true)).isInstanceOf(BadRequestException.class).hasMessage(String.format("Cannot update the status of stack '%s' to STOPPED, because it runs on spot instances", stack.getName()));
    verify(stackUpdater, never()).updateStackStatus(any(), any(DetailedStackStatus.class));
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class DatahubPollerProviderTest method testStartDistroXPoller.

@ParameterizedTest
@MethodSource("distroxStartStatuses")
void testStartDistroXPoller(Status s1Status, Status c1Status, Status s2Status, Status c2Status, AttemptState attemptState, String message, List<String> remaining) throws Exception {
    List<String> pollingCrn = new ArrayList<>();
    pollingCrn.add("crn1");
    pollingCrn.add("crn2");
    StackV4Response stack1 = getStackV4Response(s1Status, c1Status, "crn1");
    StackV4Response stack2 = getStackV4Response(s2Status, c2Status, "crn2");
    Mockito.when(datahubService.getByCrn("crn1", Collections.emptySet())).thenReturn(stack1);
    Mockito.when(datahubService.getByCrn("crn2", Collections.emptySet())).thenReturn(stack2);
    AttemptResult<Void> result = underTest.startDatahubClustersPoller(pollingCrn, ENV_ID).process();
    assertEquals(attemptState, result.getState());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ArrayList(java.util.ArrayList) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)23 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)22 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)18 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)12 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)6 Collection (java.util.Collection)6 List (java.util.List)6 Set (java.util.Set)6 Inject (javax.inject.Inject)6 PollerStoppedException (com.dyngr.exception.PollerStoppedException)5 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)5