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());
}
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations