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