use of org.dcache.srm.v2_2.SrmPutDoneRequest in project dcache by dCache.
the class SRMV2CopyJob method done.
@Override
public void done(boolean success, String error) {
synchronized (this) {
if (isDone) {
return;
}
isDone = true;
}
try {
URI[] surlArray = new URI[] { new URI(surl.toASCIIString()) };
if (!success) {
SrmAbortFilesRequest srmAbortFilesRequest = new SrmAbortFilesRequest();
srmAbortFilesRequest.setRequestToken(requestToken);
srmAbortFilesRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
SrmAbortFilesResponse srmAbortFilesResponse = srm.srmAbortFiles(srmAbortFilesRequest);
if (srmAbortFilesResponse == null) {
logger.elog("srmAbortFilesResponse is null");
} else {
TReturnStatus returnStatus = srmAbortFilesResponse.getReturnStatus();
if (returnStatus == null) {
logger.elog("srmAbortFiles return status is null");
} else {
logger.log("srmAbortFiles status code=" + returnStatus.getStatusCode());
}
}
} else if (isSrmPrepareToGet) {
SrmReleaseFilesRequest srmReleaseFilesRequest = new SrmReleaseFilesRequest();
srmReleaseFilesRequest.setRequestToken(requestToken);
srmReleaseFilesRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
SrmReleaseFilesResponse srmReleaseFilesResponse = srm.srmReleaseFiles(srmReleaseFilesRequest);
TReturnStatus returnStatus = srmReleaseFilesResponse.getReturnStatus();
if (returnStatus == null) {
success = false;
error = "srmReleaseFilesResponse return status is null";
} else {
logger.log("srmReleaseFilesResponse status code=" + returnStatus.getStatusCode());
}
} else {
SrmPutDoneRequest srmPutDoneRequest = new SrmPutDoneRequest();
srmPutDoneRequest.setRequestToken(requestToken);
srmPutDoneRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
SrmPutDoneResponse srmPutDoneResponse = srm.srmPutDone(srmPutDoneRequest);
TReturnStatus returnStatus = srmPutDoneResponse.getReturnStatus();
if (returnStatus == null) {
success = false;
error = "srmPutDone return status is null";
} else if (returnStatus.getStatusCode() != TStatusCode.SRM_SUCCESS) {
success = false;
ArrayOfTSURLReturnStatus arrayOfFileStatuses = srmPutDoneResponse.getArrayOfFileStatuses();
if (arrayOfFileStatuses != null && arrayOfFileStatuses.getStatusArray() != null && arrayOfFileStatuses.getStatusArray().length > 0 && arrayOfFileStatuses.getStatusArray()[0].getStatus().getStatusCode() != TStatusCode.SRM_SUCCESS && !Strings.isNullOrEmpty(arrayOfFileStatuses.getStatusArray()[0].getStatus().getExplanation())) {
error = arrayOfFileStatuses.getStatusArray()[0].getStatus().getExplanation();
} else {
error = returnStatus.getExplanation();
}
}
}
} catch (URI.MalformedURIException | RemoteException e) {
if (success) {
success = false;
error = e.toString();
} else {
logger.elog(e.toString());
}
} finally {
if (success) {
if (isSrmPrepareToGet) {
client.setReportSucceeded(surl, null);
} else {
client.setReportSucceeded(null, surl);
}
} else {
error = "received TURL but failed to copy: " + error;
if (isSrmPrepareToGet) {
client.setReportFailed(surl, null, error);
} else {
client.setReportFailed(null, surl, error);
}
}
}
}
use of org.dcache.srm.v2_2.SrmPutDoneRequest in project dcache by dCache.
the class RemoteTurlPutterV2 method staticPutDone.
public static void staticPutDone(RequestCredential credential, String surl, String requestToken, long retry_timeout, int retry_num, String caCertificatePath, Transport transport) throws Exception {
SRMClientV2 srmv2 = new SRMClientV2(URIs.createWithDefaultPort(surl), Optional.of(credential.getDelegatedCredential()), Optional.empty(), retry_timeout, retry_num, false, false, caCertificatePath, transport);
URI[] surlArray = new URI[1];
surlArray[0] = new URI(surl);
SrmPutDoneRequest srmPutDoneRequest = new SrmPutDoneRequest();
srmPutDoneRequest.setRequestToken(requestToken);
srmPutDoneRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
SrmPutDoneResponse srmPutDoneResponse = srmv2.srmPutDone(srmPutDoneRequest);
TReturnStatus returnStatus = srmPutDoneResponse.getReturnStatus();
if (returnStatus == null) {
LOGGER.error("srmPutDone return status is null");
return;
}
LOGGER.debug("srmPutDone status code={}", returnStatus.getStatusCode());
}
use of org.dcache.srm.v2_2.SrmPutDoneRequest in project dcache by dCache.
the class RemoteTurlPutterV2 method putDone.
protected void putDone(String surl) throws RemoteException, URI.MalformedURIException {
URI[] surlArray = new URI[1];
SrmPutDoneRequest srmPutDoneRequest = new SrmPutDoneRequest();
srmPutDoneRequest.setRequestToken(requestToken);
srmPutDoneRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
SrmPutDoneResponse srmPutDoneResponse = srmv2.srmPutDone(srmPutDoneRequest);
TReturnStatus returnStatus = srmPutDoneResponse.getReturnStatus();
if (returnStatus == null) {
LOGGER.error("srmPutDone return status is null");
return;
}
LOGGER.debug("srmPutDone status code={}", returnStatus.getStatusCode());
}
Aggregations