use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class OperationService method completeOperation.
public Operation completeOperation(String accountId, String operationId, Collection<SuccessDetails> success, Collection<FailureDetails> failure) {
Operation operation = getOperationForAccountIdAndOperationId(accountId, operationId);
operation.setStatus(OperationState.COMPLETED);
operation.setSuccessList(List.copyOf(success));
operation.setFailureList(List.copyOf(failure));
operation.setEndTime(System.currentTimeMillis());
LOGGER.info("Operation completed: {}. 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 requestOperation.
private Operation requestOperation(String accountId, OperationType operationType, Collection<String> environmentCrns, Collection<String> userCrns) {
Operation operation = new Operation();
operation.setOperationId(UUID.randomUUID().toString());
operation.setStatus(OperationState.REQUESTED);
operation.setAccountId(accountId);
operation.setOperationType(operationType);
operation.setEnvironmentList(List.copyOf(environmentCrns));
operation.setUserList(List.copyOf(userCrns));
LOGGER.info("Operation requested: {}", operation);
return operationRepository.save(operation);
}
use of com.sequenceiq.freeipa.entity.Operation in project cloudbreak by hortonworks.
the class EnvironmentUserSyncStateCalculator method calculateUserSyncState.
private UserSyncState calculateUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) {
Operation lastSync = userSyncStatus.getLastStartedFullSync();
UserSyncState state;
switch(lastSync.getStatus()) {
case RUNNING:
state = UserSyncState.SYNC_IN_PROGRESS;
break;
case COMPLETED:
state = calculateStateForCompletedOperation(accountId, envCrnString, userSyncStatus);
break;
case REQUESTED:
case REJECTED:
// REQUESTED or REJECTED operations will never be saved as part of the UserSyncStatus
throw createExceptionForUnexpectedOperationStatus(envCrnString, userSyncStatus);
case TIMEDOUT:
LOGGER.warn("UserSyncStatus.lastStartedFullSync '{}' is timed out for environment '{}'", lastSync.getOperationId(), envCrnString);
state = UserSyncState.SYNC_FAILED;
break;
case FAILED:
state = UserSyncState.SYNC_FAILED;
break;
default:
state = UserSyncState.STALE;
break;
}
return state;
}
Aggregations