use of org.dcache.srm.request.ContainerRequest in project dcache by dCache.
the class SrmReleaseFiles method srmReleaseFiles.
private SrmReleaseFilesResponse srmReleaseFiles() throws DataAccessException, SRMInvalidRequestException, SRMInternalErrorException {
ArrayOfAnyURI arrayOfSURLs = srmReleaseFilesRequest.getArrayOfSURLs();
org.apache.axis.types.URI[] surls;
if (arrayOfSURLs != null) {
surls = arrayOfSURLs.getUrlArray();
} else {
surls = null;
}
if (surls != null && surls.length == 0) {
throw new SRMInvalidRequestException("Request contains no SURL");
}
String requestToken = srmReleaseFilesRequest.getRequestToken();
if (requestToken == null) {
if (surls == null) {
throw new SRMInvalidRequestException("Request contains no SURL");
}
return releaseBySURLs(surls);
}
ContainerRequest<?> requestToRelease;
try {
requestToRelease = Request.getRequest(requestToken, ContainerRequest.class);
} catch (SRMInvalidRequestException e) {
return unpinBySURLAndRequestToken(requestToken, surls);
}
try (JDC ignored = requestToRelease.applyJdc()) {
TSURLReturnStatus[] surlReturnStatuses;
if (requestToRelease instanceof GetRequest) {
GetRequest getRequest = (GetRequest) requestToRelease;
if (surls == null) {
surlReturnStatuses = getRequest.release();
} else {
surlReturnStatuses = getRequest.releaseFiles(surls);
}
getRequest.updateStatus();
} else if (requestToRelease instanceof BringOnlineRequest) {
BringOnlineRequest bringOnlineRequest = (BringOnlineRequest) requestToRelease;
if (surls == null) {
surlReturnStatuses = bringOnlineRequest.release();
} else {
surlReturnStatuses = bringOnlineRequest.releaseFiles(surls);
}
bringOnlineRequest.updateStatus();
} else {
throw new SRMInvalidRequestException("No such get or bring online request: " + requestToken);
}
return new SrmReleaseFilesResponse(getSummaryReturnStatus(surlReturnStatuses), new ArrayOfTSURLReturnStatus(surlReturnStatuses));
}
}
use of org.dcache.srm.request.ContainerRequest in project dcache by dCache.
the class SRM method cancelRequest.
public void cancelRequest(StringBuilder sb, long requestId) throws SRMInvalidRequestException {
Job job = Job.getJob(requestId, Job.class);
if (job == null || !(job instanceof ContainerRequest)) {
sb.append("request with id ").append(requestId).append(" is not found\n");
return;
}
ContainerRequest<?> r = (ContainerRequest<?>) job;
try {
r.setState(State.CANCELED, "Canceled by admin through cancel command.");
sb.append("state changed, no guarantee that the process will end immediately\n");
sb.append(r.toString(false)).append('\n');
} catch (IllegalStateTransition ist) {
sb.append("Illegal State Transition : ").append(ist.getMessage());
LOGGER.error("Illegal State Transition : {}", ist.getMessage());
}
}
Aggregations