use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class UserSyncAcceptorTest method testUserSyncAcceptedWithDifferentEnvironment.
@Test
void testUserSyncAcceptedWithDifferentEnvironment() {
Operation syncOperation = mock(Operation.class);
when(syncOperation.getUserList()).thenReturn(List.of("userA", "userB"));
when(syncOperation.getEnvironmentList()).thenReturn(List.of("envA"));
Operation runningSyncOperation = mock(Operation.class);
when(runningSyncOperation.getUserList()).thenReturn(List.of("userA"));
when(runningSyncOperation.getEnvironmentList()).thenReturn(List.of("envB"));
assertFalse(userSyncAcceptor.doOperationsConflict(syncOperation, runningSyncOperation));
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class FreeIpaScalingService method triggerDownscale.
private DownscaleResponse triggerDownscale(DownscaleRequest request, Stack stack, AvailabilityType originalAvailabilityType) {
Operation operation = startScalingOperation(stack.getAccountId(), request.getEnvironmentCrn(), OperationType.DOWNSCALE);
ArrayList<String> instanceIdList = getDownscaleCandidates(stack, originalAvailabilityType, request.getTargetAvailabilityType());
DownscaleEvent downscaleEvent = new DownscaleEvent(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), stack.getId(), instanceIdList, request.getTargetAvailabilityType().getInstanceCount(), false, false, false, operation.getOperationId());
try {
LOGGER.info("Trigger downscale flow with event: {}", downscaleEvent);
FlowIdentifier flowIdentifier = flowManager.notify(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), downscaleEvent);
DownscaleResponse response = new DownscaleResponse();
response.setOperationId(operation.getOperationId());
response.setOriginalAvailabilityType(originalAvailabilityType);
response.setTargetAvailabilityType(request.getTargetAvailabilityType());
response.setFlowIdentifier(flowIdentifier);
return response;
} catch (Exception e) {
String exception = handleFlowException(operation, e, stack);
throw new BadRequestException(exception);
}
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class FreeIpaScalingService method triggerUpscale.
private UpscaleResponse triggerUpscale(UpscaleRequest request, Stack stack, AvailabilityType originalAvailabilityType) {
Operation operation = startScalingOperation(stack.getAccountId(), request.getEnvironmentCrn(), OperationType.UPSCALE);
UpscaleEvent upscaleEvent = new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), stack.getId(), request.getTargetAvailabilityType().getInstanceCount(), false, false, false, operation.getOperationId());
try {
LOGGER.info("Trigger upscale flow with event: {}", upscaleEvent);
FlowIdentifier flowIdentifier = flowManager.notify(UpscaleFlowEvent.UPSCALE_EVENT.event(), upscaleEvent);
UpscaleResponse response = new UpscaleResponse();
response.setOperationId(operation.getOperationId());
response.setOriginalAvailabilityType(originalAvailabilityType);
response.setTargetAvailabilityType(request.getTargetAvailabilityType());
response.setFlowIdentifier(flowIdentifier);
return response;
} catch (Exception e) {
String exception = handleFlowException(operation, e, stack);
throw new BadRequestException(exception);
}
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class OperationService method failOperation.
public Operation failOperation(String accountId, String operationId, String failureMessage, Collection<SuccessDetails> success, Collection<FailureDetails> failure) {
Operation operation = getOperationForAccountIdAndOperationId(accountId, operationId);
operation.setStatus(OperationState.FAILED);
operation.setError(failureMessage);
operation.setEndTime(System.currentTimeMillis());
operation.setSuccessList(List.copyOf(success));
operation.setFailureList(List.copyOf(failure));
LOGGER.warn("Operation failed: {}. Operation duration was {} ms.", operation, operation.getEndTime() - operation.getStartTime());
return operationRepository.save(operation);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class OperationService method timeout.
public Operation timeout(String operationId, String accountId) {
Operation operation = getOperationForAccountIdAndOperationId(accountId, operationId);
operation.setStatus(OperationState.TIMEDOUT);
operation.setEndTime(System.currentTimeMillis());
LOGGER.info("Operation timed out: {}", operation);
return operationRepository.save(operation);
}
Aggregations