Search in sources :

Example 21 with SRMInvalidRequestException

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

the class LsFileRequest method run.

@Override
public synchronized void run() throws IllegalStateTransition {
    LOGGER.trace("run");
    if (!getState().isFinal()) {
        try {
            LsRequest parent = getContainerRequest();
            long t0 = 0;
            if (LOGGER.isDebugEnabled()) {
                t0 = System.currentTimeMillis();
            }
            String fileId = SRM.getSRM().getUploadFileId(surl);
            TMetaDataPathDetail detail;
            if (fileId != null) {
                // srmPrepareToPut (no srmPutDone is yet called) request for.
                try {
                    FileMetaData fmd = getStorage().getFileMetaData(getUser(), surl, fileId);
                    detail = convertFileMetaDataToTMetaDataPathDetail(surl, fmd, parent.getLongFormat());
                } catch (SRMInvalidPathException e) {
                    detail = new TMetaDataPathDetail();
                    detail.setType(TFileType.FILE);
                }
                detail.setPath(getPath(surl));
                detail.setStatus(new TReturnStatus(TStatusCode.SRM_FILE_BUSY, "The requested SURL is locked by an upload."));
            } else {
                detail = getMetaDataPathDetail(surl, 0, parent.getOffset(), parent.getCount(), parent.getNumOfLevels(), parent.getLongFormat());
            }
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("LsFileRequest.run(), TOOK {}", (System.currentTimeMillis() - t0));
            }
            try {
                getContainerRequest().resetRetryDeltaTime();
            } catch (SRMInvalidRequestException ire) {
                LOGGER.error(ire.toString());
            }
            wlock();
            try {
                metaDataPathDetail = detail;
                if (!getState().isFinal()) {
                    setState(State.DONE, State.DONE.toString());
                }
            } finally {
                wunlock();
            }
        } catch (SRMException e) {
            fail(e.getStatusCode(), e.getMessage());
        } catch (URISyntaxException e) {
            fail(TStatusCode.SRM_FAILURE, e.getMessage());
        } catch (DataAccessException | IllegalStateTransition e) {
            LOGGER.error(e.toString(), e);
            fail(TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
        }
    }
}
Also used : IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayOfTMetaDataPathDetail(org.dcache.srm.v2_2.ArrayOfTMetaDataPathDetail) TMetaDataPathDetail(org.dcache.srm.v2_2.TMetaDataPathDetail) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) URISyntaxException(java.net.URISyntaxException) SRMException(org.dcache.srm.SRMException) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) FileMetaData(org.dcache.srm.FileMetaData) DataAccessException(org.springframework.dao.DataAccessException)

Example 22 with SRMInvalidRequestException

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

the class PutFileRequest method getTPutRequestFileStatus.

protected TPutRequestFileStatus getTPutRequestFileStatus() throws SRMInvalidRequestException {
    TPutRequestFileStatus fileStatus = new TPutRequestFileStatus();
    fileStatus.setFileSize(((getSize() == null) ? null : new UnsignedLong(getSize())));
    org.apache.axis.types.URI anSurl;
    try {
        anSurl = new org.apache.axis.types.URI(getSurlString());
    } catch (org.apache.axis.types.URI.MalformedURIException e) {
        LOGGER.error(e.toString());
        throw new SRMInvalidRequestException("wrong surl format");
    }
    fileStatus.setSURL(anSurl);
    // fileStatus.set
    TReturnStatus returnStatus = getReturnStatus();
    String turlstring = getTurlString();
    if (turlstring != null && TStatusCode.SRM_SPACE_AVAILABLE.equals(returnStatus.getStatusCode())) {
        org.apache.axis.types.URI transferURL;
        try {
            transferURL = new org.apache.axis.types.URI(turlstring);
        } catch (org.apache.axis.types.URI.MalformedURIException e) {
            LOGGER.error("Generated broken TURL \"{}\": {}", turlstring, e);
            throw new SRMInvalidRequestException("wrong turl format");
        }
        fileStatus.setTransferURL(transferURL);
    }
    fileStatus.setEstimatedWaitTime(getContainerRequest().getRetryDeltaTime());
    fileStatus.setRemainingPinLifetime((int) getRemainingLifetime() / 1000);
    if (TStatusCode.SRM_SPACE_LIFETIME_EXPIRED.equals(returnStatus.getStatusCode())) {
        // SRM_SPACE_LIFETIME_EXPIRED is illeal on the file level,
        // but we use it to correctly calculate the request level status
        // so we do the translation here
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, null);
    }
    fileStatus.setStatus(returnStatus);
    return fileStatus;
}
Also used : TPutRequestFileStatus(org.dcache.srm.v2_2.TPutRequestFileStatus) UnsignedLong(org.apache.axis.types.UnsignedLong) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) URI(java.net.URI) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 23 with SRMInvalidRequestException

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

the class PutFileRequest method processStateChange.

@Override
protected void processStateChange(State newState, String description) {
    State oldState = getState();
    LOGGER.debug("State changed from {} to {}", oldState, newState);
    if (newState == State.READY) {
        try {
            getContainerRequest().resetRetryDeltaTime();
        } catch (SRMInvalidRequestException ire) {
            LOGGER.error(ire.toString());
        }
    }
    try {
        if (newState == State.FAILED && getFileId() != null) {
            getStorage().abortPut(getUser(), getFileId(), getSurl(), description);
        }
    } catch (SRMException e) {
        LOGGER.error("Failed to abort put after failure: {}", e.getMessage());
    }
    super.processStateChange(newState, description);
}
Also used : SRMException(org.dcache.srm.SRMException) State(org.dcache.srm.scheduler.State) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 24 with SRMInvalidRequestException

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

the class BringOnlineFileRequest method getTGetRequestFileStatus.

protected TBringOnlineRequestFileStatus getTGetRequestFileStatus() throws SRMInvalidRequestException {
    TBringOnlineRequestFileStatus fileStatus = new TBringOnlineRequestFileStatus();
    if (fileMetaData != null) {
        fileStatus.setFileSize(new UnsignedLong(fileMetaData.size));
    }
    try {
        fileStatus.setSourceSURL(new org.apache.axis.types.URI(getSurlString()));
    } catch (org.apache.axis.types.URI.MalformedURIException e) {
        LOGGER.error(e.toString());
        throw new SRMInvalidRequestException("wrong surl format");
    }
    if (this.isPinned()) {
        fileStatus.setRemainingPinTime((int) (getRemainingLifetime() / 1000));
    }
    fileStatus.setEstimatedWaitTime(getContainerRequest().getRetryDeltaTime());
    fileStatus.setStatus(getReturnStatus());
    return fileStatus;
}
Also used : UnsignedLong(org.apache.axis.types.UnsignedLong) TBringOnlineRequestFileStatus(org.dcache.srm.v2_2.TBringOnlineRequestFileStatus) URI(java.net.URI) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 25 with SRMInvalidRequestException

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

the class GetFileRequest method getTGetRequestFileStatus.

protected TGetRequestFileStatus getTGetRequestFileStatus() throws SRMInvalidRequestException {
    TGetRequestFileStatus fileStatus = new TGetRequestFileStatus();
    if (getFileMetaData() != null) {
        fileStatus.setFileSize(new UnsignedLong(getFileMetaData().size));
    }
    try {
        fileStatus.setSourceSURL(new org.apache.axis.types.URI(getSurlString()));
    } catch (org.apache.axis.types.URI.MalformedURIException e) {
        LOGGER.error(e.toString());
        throw new SRMInvalidRequestException("wrong surl format");
    }
    TReturnStatus returnStatus = getReturnStatus();
    String turlstring = getTurlString();
    if (turlstring != null && TStatusCode.SRM_FILE_PINNED.equals(returnStatus.getStatusCode())) {
        try {
            fileStatus.setTransferURL(new org.apache.axis.types.URI(turlstring));
        } catch (org.apache.axis.types.URI.MalformedURIException e) {
            LOGGER.error("Generated broken TURL \"{}\": {}", turlstring, e);
            throw new SRMInvalidRequestException("wrong turl format");
        }
    }
    if (this.isPinned()) {
        fileStatus.setRemainingPinTime((int) (getRemainingLifetime() / 1000));
    }
    fileStatus.setEstimatedWaitTime(getContainerRequest().getRetryDeltaTime());
    fileStatus.setStatus(returnStatus);
    return fileStatus;
}
Also used : UnsignedLong(org.apache.axis.types.UnsignedLong) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TGetRequestFileStatus(org.dcache.srm.v2_2.TGetRequestFileStatus) URI(java.net.URI) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Aggregations

SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)32 URI (java.net.URI)13 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)13 SRMException (org.dcache.srm.SRMException)11 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)9 JDC (org.dcache.srm.util.JDC)7 UnsignedLong (org.apache.axis.types.UnsignedLong)6 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)5 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)5 AbstractStorageElement (org.dcache.srm.AbstractStorageElement)4 SRMNotSupportedException (org.dcache.srm.SRMNotSupportedException)4 FileMetaData (org.dcache.srm.FileMetaData)3 SRMUser (org.dcache.srm.SRMUser)3 IllegalStateTransition (org.dcache.srm.scheduler.IllegalStateTransition)3 State (org.dcache.srm.scheduler.State)3 TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)3 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)3 URI (org.apache.axis.types.URI)2 SRMAbortedException (org.dcache.srm.SRMAbortedException)2 SRMRequestTimedOutException (org.dcache.srm.SRMRequestTimedOutException)2