Search in sources :

Example 26 with SRMInternalErrorException

use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.

the class GetFileRequest method processStateChange.

@Override
protected void processStateChange(State newState, String description) {
    State oldState = getState();
    LOGGER.debug("State changed from {} to {}", oldState, newState);
    switch(newState) {
        case READY:
            try {
                getContainerRequest().resetRetryDeltaTime();
            } catch (SRMInvalidRequestException ire) {
                LOGGER.error(ire.toString());
            }
            break;
        case DONE:
        case FAILED:
        case CANCELED:
            AbstractStorageElement storage = getStorage();
            try {
                SRMUser user = getUser();
                String fileId = getFileId();
                String pinId = getPinId();
                if (fileId != null && pinId != null) {
                    LOGGER.info("State changed to final state, unpinning fileId = {} pinId = {}.", fileId, pinId);
                    CheckedFuture<String, ? extends SRMException> future = storage.unPinFile(null, fileId, pinId);
                    future.addListener(() -> {
                        try {
                            LOGGER.debug("Unpinned (pinId={}).", future.checkedGet());
                        } catch (SRMException e) {
                            LOGGER.error("Unpinning failed: {}", e.getMessage());
                        }
                    }, MoreExecutors.directExecutor());
                } else {
                    BringOnlineFileRequest.unpinBySURLandRequestToken(storage, user, String.valueOf(getRequestId()), getSurl());
                }
            } catch (SRMInternalErrorException | SRMInvalidRequestException e) {
                LOGGER.error(e.toString());
            }
    }
    super.processStateChange(newState, description);
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMUser(org.dcache.srm.SRMUser) SRMException(org.dcache.srm.SRMException) AbstractStorageElement(org.dcache.srm.AbstractStorageElement) State(org.dcache.srm.scheduler.State) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 27 with SRMInternalErrorException

use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.

the class BringOnlineFileRequest method release.

public TReturnStatus release(SRMUser user) throws SRMInternalErrorException {
    String fileId;
    String pinId;
    wlock();
    try {
        State state = getState();
        switch(state) {
            case DONE:
                fileId = getFileId();
                pinId = getPinId();
                if (fileId == null || pinId == null) {
                    return new TReturnStatus(TStatusCode.SRM_FAILURE, "SURL is not pinned");
                }
                // Unpinning is done below, outside the lock
                break;
            case CANCELED:
                return new TReturnStatus(TStatusCode.SRM_ABORTED, "SURL has been aborted and cannot be released");
            case FAILED:
                return new TReturnStatus(TStatusCode.SRM_FAILURE, "Pinning failed");
            default:
                setState(State.CANCELED, "Aborted by srmReleaseFile request.");
                return new TReturnStatus(TStatusCode.SRM_ABORTED, "SURL is not yet pinned, pinning aborted");
        }
    } catch (IllegalStateTransition e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
    } finally {
        wunlock();
    }
    LOGGER.debug("srmReleaseFile, unpinning fileId={} pinId={}", fileId, pinId);
    CheckedFuture<String, ? extends SRMException> future = getStorage().unPinFile(user, fileId, pinId);
    try {
        future.checkedGet(60, TimeUnit.SECONDS);
        setPinId(null);
        saveJob(true);
        return new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (TimeoutException e) {
        throw new SRMInternalErrorException("Operation timed out.");
    } catch (SRMException e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, "Failed to unpin SURL: " + e.getMessage());
    }
}
Also used : IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) State(org.dcache.srm.scheduler.State) TimeoutException(java.util.concurrent.TimeoutException)

Example 28 with SRMInternalErrorException

use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.

the class BringOnlineFileRequest method unpinBySURLandRequestToken.

public static TReturnStatus unpinBySURLandRequestToken(AbstractStorageElement storage, SRMUser user, String requestToken, URI surl) throws SRMInternalErrorException {
    String fileId;
    try {
        fileId = storage.getFileMetaData(user, surl, true).fileId;
    } catch (SRMInternalErrorException e) {
        throw e;
    } catch (SRMAuthorizationException e) {
        return new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
    } catch (SRMInvalidPathException e) {
        return new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
    } catch (SRMException e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
    }
    CheckedFuture<String, ? extends SRMException> future = storage.unPinFileBySrmRequestId(user, fileId, requestToken);
    try {
        future.checkedGet(60, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
        throw new SRMInternalErrorException("Operation timed out");
    } catch (SRMException e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, "Failed to unpin: " + e.getMessage());
    }
    return new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) TimeoutException(java.util.concurrent.TimeoutException)

Example 29 with SRMInternalErrorException

use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.

the class BringOnlineFileRequest method unpinBySURL.

public static TReturnStatus unpinBySURL(AbstractStorageElement storage, SRMUser user, URI surl) throws SRMInternalErrorException {
    String fileId;
    try {
        fileId = storage.getFileMetaData(user, surl, true).fileId;
    } catch (SRMInternalErrorException e) {
        throw e;
    } catch (SRMAuthorizationException e) {
        return new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
    } catch (SRMInvalidPathException e) {
        return new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
    } catch (SRMException e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
    }
    CheckedFuture<String, ? extends SRMException> future = storage.unPinFile(user, fileId);
    try {
        future.checkedGet(60, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
        throw new SRMInternalErrorException("Operation timed out");
    } catch (SRMException e) {
        return new TReturnStatus(TStatusCode.SRM_FAILURE, "Failed to unpin: " + e.getMessage());
    }
    return new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) TimeoutException(java.util.concurrent.TimeoutException)

Example 30 with SRMInternalErrorException

use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.

the class TStatusCodes method checkSuccess.

public static void checkSuccess(TReturnStatus returnStatus, TStatusCode... success) throws SRMException {
    TStatusCode statusCode = returnStatus.getStatusCode();
    String explanation = returnStatus.getExplanation();
    if (asList(success).contains(statusCode)) {
        return;
    }
    if (explanation == null) {
        explanation = "Operation failed with " + returnStatus.getStatusCode();
    }
    if (statusCode == TStatusCode.SRM_FAILURE) {
        throw new SRMException(explanation);
    } else if (statusCode == TStatusCode.SRM_PARTIAL_SUCCESS) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_AUTHENTICATION_FAILURE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_AUTHORIZATION_FAILURE) {
        throw new SRMAuthorizationException(explanation);
    } else if (statusCode == TStatusCode.SRM_INVALID_REQUEST) {
        throw new SRMInvalidRequestException(explanation);
    } else if (statusCode == TStatusCode.SRM_INVALID_PATH) {
        throw new SRMInvalidPathException(explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_LIFETIME_EXPIRED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_SPACE_LIFETIME_EXPIRED) {
        throw new SRMSpaceLifetimeExpiredException(explanation);
    } else if (statusCode == TStatusCode.SRM_EXCEED_ALLOCATION) {
        throw new SRMExceedAllocationException(explanation);
    } else if (statusCode == TStatusCode.SRM_NO_USER_SPACE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_NO_FREE_SPACE) {
        throw new SRMNoFreeSpaceException(explanation);
    } else if (statusCode == TStatusCode.SRM_DUPLICATION_ERROR) {
        throw new SRMDuplicationException(explanation);
    } else if (statusCode == TStatusCode.SRM_NON_EMPTY_DIRECTORY) {
        throw new SRMNonEmptyDirectoryException(explanation);
    } else if (statusCode == TStatusCode.SRM_TOO_MANY_RESULTS) {
        throw new SRMTooManyResultsException(explanation);
    } else if (statusCode == TStatusCode.SRM_INTERNAL_ERROR) {
        throw new SRMInternalErrorException(explanation);
    } else if (statusCode == TStatusCode.SRM_FATAL_INTERNAL_ERROR) {
        throw new SRMInternalErrorException(explanation);
    } else if (statusCode == TStatusCode.SRM_NOT_SUPPORTED) {
        throw new SRMNotSupportedException(explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_QUEUED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_INPROGRESS) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_ABORTED) {
        throw new SRMAbortedException(explanation);
    } else if (statusCode == TStatusCode.SRM_RELEASED) {
        throw new SRMReleasedException(explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_PINNED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_IN_CACHE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_SPACE_AVAILABLE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_LOWER_SPACE_GRANTED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_TIMED_OUT) {
        throw new SRMRequestTimedOutException(explanation);
    } else if (statusCode == TStatusCode.SRM_LAST_COPY) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_BUSY) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_LOST) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_UNAVAILABLE) {
        throw new SRMFileUnvailableException(explanation);
    } else if (statusCode == TStatusCode.SRM_CUSTOM_STATUS) {
        throw new SRMOtherException(statusCode, explanation);
    } else {
        throw new SRMOtherException(statusCode, explanation);
    }
}
Also used : SRMExceedAllocationException(org.dcache.srm.SRMExceedAllocationException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) SRMNonEmptyDirectoryException(org.dcache.srm.SRMNonEmptyDirectoryException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) SRMAbortedException(org.dcache.srm.SRMAbortedException) TStatusCode(org.dcache.srm.v2_2.TStatusCode) SRMTooManyResultsException(org.dcache.srm.SRMTooManyResultsException) SRMRequestTimedOutException(org.dcache.srm.SRMRequestTimedOutException) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) SRMFileUnvailableException(org.dcache.srm.SRMFileUnvailableException) SRMReleasedException(org.dcache.srm.SRMReleasedException) SRMOtherException(org.dcache.srm.SRMOtherException) SRMSpaceLifetimeExpiredException(org.dcache.srm.SRMSpaceLifetimeExpiredException) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) SRMNoFreeSpaceException(org.dcache.srm.SRMNoFreeSpaceException) SRMDuplicationException(org.dcache.srm.SRMDuplicationException)

Aggregations

SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)46 SRMException (org.dcache.srm.SRMException)34 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)26 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)21 CacheException (diskCacheV111.util.CacheException)20 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)19 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)18 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)17 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)17 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)17 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)17 NotDirCacheException (diskCacheV111.util.NotDirCacheException)17 FsPath (diskCacheV111.util.FsPath)13 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)13 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)10 Subject (javax.security.auth.Subject)10 URI (java.net.URI)9 PnfsHandler (diskCacheV111.util.PnfsHandler)8 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)7 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)6