Search in sources :

Example 86 with Operation

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);
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation)

Example 87 with 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);
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation)

Example 88 with 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;
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) EnvironmentUserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState) UserSyncState(com.sequenceiq.freeipa.api.v1.freeipa.user.model.UserSyncState)

Aggregations

Operation (com.sequenceiq.freeipa.entity.Operation)88 Test (org.junit.jupiter.api.Test)55 Stack (com.sequenceiq.freeipa.entity.Stack)23 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)18 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)15 OperationToSyncOperationStatus (com.sequenceiq.freeipa.converter.freeipa.user.OperationToSyncOperationStatus)12 AcceptResult (com.sequenceiq.freeipa.service.freeipa.user.AcceptResult)11 UserSyncRequestFilter (com.sequenceiq.freeipa.service.freeipa.user.UserSyncRequestFilter)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)7 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)7 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)6 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)5 FreeIpaUpgradeResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeResponse)4 SynchronizeAllUsersRequest (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest)4 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)3