Search in sources :

Example 26 with SRMException

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

the class CopyRequest method run.

@Override
public void run() throws SRMException, IllegalStateTransition {
    if (!getState().isFinal() && !isProcessingDone()) {
        try {
            proccessRequest();
            boolean hasOnlyFinalFileRequests = true;
            for (CopyFileRequest request : getFileRequests()) {
                State state = request.getState();
                if (!state.isFinal()) {
                    hasOnlyFinalFileRequests = false;
                }
            }
            setProcessingDone(true);
            if (hasOnlyFinalFileRequests) {
                setState(State.DONE, "All transfers completed.");
            } else {
                addHistoryEvent("Waiting for transfers to complete.");
            }
        } catch (IOException e) {
            throw new SRMException(e.getMessage(), e);
        } catch (InterruptedException e) {
            throw new SRMException("shutting down.", e);
        }
    }
}
Also used : SRMException(org.dcache.srm.SRMException) State(org.dcache.srm.scheduler.State) IOException(java.io.IOException)

Example 27 with SRMException

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

the class SrmCheckPermission method srmCheckPermission.

private SrmCheckPermissionResponse srmCheckPermission() throws SRMInternalErrorException, SRMInvalidRequestException {
    org.apache.axis.types.URI[] surls = request.getArrayOfSURLs().getUrlArray();
    if (surls == null || surls.length == 0) {
        throw new SRMInvalidRequestException("arrayOfSURLs is empty");
    }
    int length = surls.length;
    TSURLPermissionReturn[] permissions = new TSURLPermissionReturn[length];
    boolean hasSuccess = false;
    boolean hasFailure = false;
    for (int i = 0; i < length; i++) {
        TReturnStatus returnStatus;
        TPermissionMode pm = null;
        try {
            FileMetaData fmd = storage.getFileMetaData(user, URI.create(surls[i].toString()), false);
            int mode = fmd.permMode;
            if (fmd.isOwner(user)) {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 6) & 0x7));
            } else if (fmd.isGroupMember(user)) {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 3) & 0x7));
            } else {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode((mode & 0x7));
            }
            returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
            hasSuccess = true;
        } catch (SRMInternalErrorException e) {
            throw e;
        } catch (SRMInvalidPathException e) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
            hasFailure = true;
        } catch (SRMAuthorizationException e) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
            hasFailure = true;
        } catch (SRMException e) {
            LOGGER.warn(e.toString());
            returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
            hasFailure = true;
        }
        permissions[i] = new TSURLPermissionReturn(surls[i], returnStatus, pm);
    }
    return new SrmCheckPermissionResponse(ReturnStatuses.getSummaryReturnStatus(hasFailure, hasSuccess), new ArrayOfTSURLPermissionReturn(permissions));
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) ArrayOfTSURLPermissionReturn(org.dcache.srm.v2_2.ArrayOfTSURLPermissionReturn) TSURLPermissionReturn(org.dcache.srm.v2_2.TSURLPermissionReturn) ArrayOfTSURLPermissionReturn(org.dcache.srm.v2_2.ArrayOfTSURLPermissionReturn) TPermissionMode(org.dcache.srm.v2_2.TPermissionMode) URI(java.net.URI) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) SrmCheckPermissionResponse(org.dcache.srm.v2_2.SrmCheckPermissionResponse) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) FileMetaData(org.dcache.srm.FileMetaData)

Example 28 with SRMException

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

the class SrmExtendFileLifeTime method extendSurlLifeTime.

private TSURLLifetimeReturnStatus extendSurlLifeTime(org.apache.axis.types.URI surl, long newLifetimeInMillis) throws SRMInternalErrorException {
    TSURLLifetimeReturnStatus status = new TSURLLifetimeReturnStatus();
    status.setSurl(surl);
    TReturnStatus returnStatus;
    try {
        long lifetimeLeftInMillis = storage.srmExtendSurlLifetime(user, URI.create(surl.toString()), newLifetimeInMillis);
        status.setFileLifetime(toSeconds(lifetimeLeftInMillis));
        returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (SRMInternalErrorException e) {
        throw new SRMInternalErrorException("File lifetime extension failed for SURL " + surl + ": " + e.getMessage(), e);
    } catch (SRMException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.toString());
    }
    status.setStatus(returnStatus);
    return status;
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TSURLLifetimeReturnStatus(org.dcache.srm.v2_2.TSURLLifetimeReturnStatus) ArrayOfTSURLLifetimeReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLLifetimeReturnStatus)

Example 29 with SRMException

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

the class SrmExtendFileLifeTime method extendTurlOrPinLifeTime.

private TSURLLifetimeReturnStatus extendTurlOrPinLifeTime(ContainerRequest<?> request, org.apache.axis.types.URI surl, long newLifetimeInMillis) throws SRMInternalErrorException {
    TSURLLifetimeReturnStatus status = new TSURLLifetimeReturnStatus();
    status.setSurl(surl);
    TReturnStatus returnStatus;
    try {
        FileRequest<?> fileRequest = request.getFileRequestBySurl(URI.create(surl.toString()));
        long lifetimeLeftMillis = fileRequest.extendLifetime(newLifetimeInMillis);
        status.setPinLifetime(toSeconds(lifetimeLeftMillis));
        returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (SRMFileRequestNotFoundException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, "SURL does match any existing file request associated with the request token");
    } catch (SRMInvalidRequestException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_REQUEST, "TURL is no longer valid and cannot be extended");
    } catch (SRMReleasedException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_RELEASED, "TURL has been released and cannot be extended");
    } catch (SRMAbortedException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_ABORTED, "TURL has been aborted and cannot be extended");
    } catch (SRMInternalErrorException e) {
        throw new SRMInternalErrorException("File lifetime extension failed for request " + request.getClientRequestId() + " with SURL " + surl + ": " + e.getMessage(), e);
    } catch (SRMException e) {
        LOGGER.warn("File lifetime extension failed for request {} with SURL {}: {}", request.getClientRequestId(), surl, e.getMessage());
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, "TURL for request " + request.getClientRequestId() + " with SURL " + surl + " cannot be extended: " + e.getMessage());
    }
    status.setStatus(returnStatus);
    return status;
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) SRMReleasedException(org.dcache.srm.SRMReleasedException) SRMAbortedException(org.dcache.srm.SRMAbortedException) TSURLLifetimeReturnStatus(org.dcache.srm.v2_2.TSURLLifetimeReturnStatus) ArrayOfTSURLLifetimeReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLLifetimeReturnStatus) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 30 with SRMException

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

the class RemoteTurlPutterV2 method getInitialRequest.

@Override
public void getInitialRequest() throws SRMException {
    if (number_of_file_reqs == 0) {
        LOGGER.debug("number_of_file_reqs is 0, nothing to do");
        return;
    }
    try {
        java.net.URI srmUrl = URIs.createWithDefaultPort(SURLs[0]);
        srmv2 = new SRMClientV2(srmUrl, Optional.of(credential.getDelegatedCredential()), Optional.empty(), retry_timout, retry_num, false, false, caCertificatePath, transport);
        int len = SURLs.length;
        TPutFileRequest[] fileRequests = new TPutFileRequest[len];
        for (int i = 0; i < len; ++i) {
            URI uri = new URI(SURLs[i]);
            fileRequests[i] = new TPutFileRequest();
            fileRequests[i].setTargetSURL(uri);
            pendingSurlsToIndex.put(SURLs[i], i);
        }
        SrmPrepareToPutRequest srmPrepareToPutRequest = new SrmPrepareToPutRequest();
        if (retentionPolicy != null || accessLatency != null) {
            TRetentionPolicyInfo retentionPolicyInfo = new TRetentionPolicyInfo();
            retentionPolicyInfo.setRetentionPolicy(retentionPolicy);
            retentionPolicyInfo.setAccessLatency(accessLatency);
            srmPrepareToPutRequest.setTargetFileRetentionPolicyInfo(retentionPolicyInfo);
        }
        TTransferParameters transferParameters = new TTransferParameters();
        transferParameters.setAccessPattern(TAccessPattern.TRANSFER_MODE);
        transferParameters.setConnectionType(TConnectionType.WAN);
        transferParameters.setArrayOfTransferProtocols(new ArrayOfString(protocols));
        srmPrepareToPutRequest.setTransferParameters(transferParameters);
        srmPrepareToPutRequest.setArrayOfFileRequests(new ArrayOfTPutFileRequest(fileRequests));
        srmPrepareToPutRequest.setDesiredFileStorageType(storageType);
        srmPrepareToPutRequest.setDesiredTotalRequestTime((int) requestLifetime);
        srmPrepareToPutRequest.setOverwriteOption(overwriteMode);
        srmPrepareToPutRequest.setTargetSpaceToken(targetSpaceToken);
        srmPrepareToPutResponse = srmv2.srmPrepareToPut(srmPrepareToPutRequest);
    } catch (URISyntaxException | IOException | InterruptedException | ServiceException e) {
        LOGGER.error("failed to connect to {} {}", SURLs[0], e.getMessage());
        throw new SRMException("failed to connect to " + SURLs[0], e);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) TPutFileRequest(org.dcache.srm.v2_2.TPutFileRequest) TTransferParameters(org.dcache.srm.v2_2.TTransferParameters) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(org.apache.axis.types.URI) TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) SRMException(org.dcache.srm.SRMException) ServiceException(javax.xml.rpc.ServiceException) SrmPrepareToPutRequest(org.dcache.srm.v2_2.SrmPrepareToPutRequest) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString)

Aggregations

SRMException (org.dcache.srm.SRMException)52 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)34 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)26 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)25 CacheException (diskCacheV111.util.CacheException)20 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)19 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)17 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)17 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)16 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)16 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)16 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)16 NotDirCacheException (diskCacheV111.util.NotDirCacheException)16 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)14 FsPath (diskCacheV111.util.FsPath)11 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)10 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)8 PnfsHandler (diskCacheV111.util.PnfsHandler)7 Subject (javax.security.auth.Subject)7 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)7