use of org.dcache.srm.v2_2.SrmGetRequestSummaryRequest in project dcache by dCache.
the class SrmHandler method dispatch.
private Object dispatch(Subject subject, String requestName, Object request) throws CacheException, InterruptedException, SRMException, NoRouteToCellException {
X509Credential credential = Axis.getDelegatedCredential().orElse(null);
String remoteIP = Axis.getRemoteAddress();
String remoteHost = isClientDNSLookup ? InetAddresses.forUriString(remoteIP).getCanonicalHostName() : remoteIP;
Set<LoginAttribute> loginAttributes = AuthenticationHandler.getLoginAttributes(Axis.getHttpServletRequest());
Function<Object, SrmRequest> toMessage = req -> new SrmRequest(subject, loginAttributes, credential, remoteHost, requestName, req);
try {
switch(requestName) {
case "srmGetRequestTokens":
return dispatch((SrmGetRequestTokensRequest) request, toMessage);
case "srmGetRequestSummary":
return dispatch((SrmGetRequestSummaryRequest) request, toMessage);
case "srmReleaseFiles":
return dispatch((SrmReleaseFilesRequest) request, toMessage);
case "srmExtendFileLifeTime":
// special processing.
return dispatch(request, toMessage);
default:
return dispatch(request, toMessage);
}
} catch (ExecutionException e) {
Throwables.propagateIfInstanceOf(e.getCause(), SRMException.class);
Throwables.propagateIfInstanceOf(e.getCause(), CacheException.class);
Throwables.propagateIfInstanceOf(e.getCause(), NoRouteToCellException.class);
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of org.dcache.srm.v2_2.SrmGetRequestSummaryRequest in project dcache by dCache.
the class SRMGetRequestSummaryClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
try {
String[] tokens = configuration.getArrayOfRequestTokens();
SrmGetRequestSummaryRequest request = new SrmGetRequestSummaryRequest();
request.setArrayOfRequestTokens(new ArrayOfString(tokens));
SrmGetRequestSummaryResponse response = srm.srmGetRequestSummary(request);
if (response == null) {
throw new IOException(" null SrmGetRequestSummaryResponse ");
}
TReturnStatus rs = response.getReturnStatus();
if (rs == null) {
throw new IOException(" null TReturnStatus ");
}
if (response.getArrayOfRequestSummaries() != null) {
ArrayOfTRequestSummary summaries = response.getArrayOfRequestSummaries();
if (summaries.getSummaryArray() != null) {
for (int i = 0; i < summaries.getSummaryArray().length; i++) {
TRequestSummary summary = summaries.getSummaryArray(i);
if (summary != null) {
TReturnStatus st = summary.getStatus();
TRequestType type = summary.getRequestType();
System.out.println("\tRequest number : " + summary.getRequestToken());
System.out.println("\t Request type : " + (type != null ? type.getValue() : "UNKNOWN"));
System.out.println("\t Return status");
System.out.println("\t\t Status code : " + (st != null ? st.getStatusCode() : "null"));
System.out.println("\t\t Explanation : " + (st != null ? st.getExplanation() : "null"));
System.out.println("\tTotal # of files: " + summary.getTotalNumFilesInRequest());
System.out.println("\t completed files: " + summary.getNumOfCompletedFiles());
System.out.println("\t waiting files: " + summary.getNumOfWaitingFiles());
System.out.println("\t failed files: " + summary.getNumOfFailedFiles());
}
}
}
}
if (RequestStatusTool.isFailedRequestStatus(rs)) {
throw new IOException("srmGetRequestSummary failed, unexpected or failed return status : " + rs.getStatusCode() + " explanation=" + rs.getExplanation());
}
} catch (Exception e) {
throw e;
}
}
Aggregations