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;
}
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;
}
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;
}
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));
}
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());
}
Aggregations