Search in sources :

Example 1 with URI

use of org.apache.axis.types.URI in project dcache by dCache.

the class SrmHandler method mapReleaseFilesResponse.

private SrmReleaseFilesResponse mapReleaseFilesResponse(SrmReleaseFilesRequest request, List<SrmResponse> responses) {
    Map<URI, TSURLReturnStatus> map = new HashMap<>();
    for (SrmResponse srmResponse : responses) {
        SrmReleaseFilesResponse response = (SrmReleaseFilesResponse) srmResponse.getResponse();
        for (TSURLReturnStatus status : response.getArrayOfFileStatuses().getStatusArray()) {
            if (status.getStatus().getStatusCode() == SRM_SUCCESS) {
                map.put(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_INVALID_PATH) {
            // no entry
            } else if (status.getStatus().getStatusCode() == SRM_AUTHORIZATION_FAILURE) {
                map.putIfAbsent(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_FILE_LIFETIME_EXPIRED) {
                map.putIfAbsent(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_FAILURE) {
                map.putIfAbsent(status.getSurl(), status);
            }
        }
    }
    TSURLReturnStatus[] statuses = Stream.of(request.getArrayOfSURLs().getUrlArray()).map(surl -> {
        TSURLReturnStatus status = map.get(surl);
        return (status != null) ? status : new TSURLReturnStatus(surl, new TReturnStatus(SRM_INVALID_PATH, "File not found"));
    }).toArray(TSURLReturnStatus[]::new);
    return new SrmReleaseFilesResponse(getSummaryReturnStatus(statuses), new ArrayOfTSURLReturnStatus(statuses));
}
Also used : SrmResponse(org.dcache.srm.SrmResponse) SrmExtendFileLifeTimeRequest(org.dcache.srm.v2_2.SrmExtendFileLifeTimeRequest) TCopyFileRequest(org.dcache.srm.v2_2.TCopyFileRequest) SRM_PARTIAL_SUCCESS(org.dcache.srm.v2_2.TStatusCode.SRM_PARTIAL_SUCCESS) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) Map(java.util.Map) SrmStatusOfReserveSpaceRequestRequest(org.dcache.srm.v2_2.SrmStatusOfReserveSpaceRequestRequest) SrmExtendFileLifeTimeResponse(org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse) SRMException(org.dcache.srm.SRMException) OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) CellInfo(dmg.cells.nucleus.CellInfo) TPutRequestFileStatus(org.dcache.srm.v2_2.TPutRequestFileStatus) SrmGetRequestSummaryRequest(org.dcache.srm.v2_2.SrmGetRequestSummaryRequest) TPutFileRequest(org.dcache.srm.v2_2.TPutFileRequest) SrmRmRequest(org.dcache.srm.v2_2.SrmRmRequest) Stream(java.util.stream.Stream) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) SRM_AUTHENTICATION_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_AUTHENTICATION_FAILURE) TStatusCode(org.dcache.srm.v2_2.TStatusCode) LoginAttribute(org.dcache.auth.attributes.LoginAttribute) SrmBringOnlineResponse(org.dcache.srm.v2_2.SrmBringOnlineResponse) ArrayOfTCopyRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTCopyRequestFileStatus) SrmPrepareToPutResponse(org.dcache.srm.v2_2.SrmPrepareToPutResponse) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) NetLoggerBuilder(org.dcache.util.NetLoggerBuilder) Constructor(java.lang.reflect.Constructor) SrmLsRequest(org.dcache.srm.v2_2.SrmLsRequest) Strings(com.google.common.base.Strings) CellStub(org.dcache.cells.CellStub) SrmReleaseSpaceResponse(org.dcache.srm.v2_2.SrmReleaseSpaceResponse) SrmResumeRequestRequest(org.dcache.srm.v2_2.SrmResumeRequestRequest) TRequestSummary(org.dcache.srm.v2_2.TRequestSummary) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) SRM_NON_EMPTY_DIRECTORY(org.dcache.srm.v2_2.TStatusCode.SRM_NON_EMPTY_DIRECTORY) Field(java.lang.reflect.Field) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) TBringOnlineRequestFileStatus(org.dcache.srm.v2_2.TBringOnlineRequestFileStatus) SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) SrmExtendFileLifeTimeInSpaceResponse(org.dcache.srm.v2_2.SrmExtendFileLifeTimeInSpaceResponse) SrmAbortRequestResponse(org.dcache.srm.v2_2.SrmAbortRequestResponse) SrmStatusOfBringOnlineRequestRequest(org.dcache.srm.v2_2.SrmStatusOfBringOnlineRequestRequest) SrmSetPermissionResponse(org.dcache.srm.v2_2.SrmSetPermissionResponse) SRM_EXCEED_ALLOCATION(org.dcache.srm.v2_2.TStatusCode.SRM_EXCEED_ALLOCATION) SRM_FILE_BUSY(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_BUSY) SrmRmResponse(org.dcache.srm.v2_2.SrmRmResponse) SrmStatusOfChangeSpaceForFilesRequestResponse(org.dcache.srm.v2_2.SrmStatusOfChangeSpaceForFilesRequestResponse) SrmAbortFilesResponse(org.dcache.srm.v2_2.SrmAbortFilesResponse) SrmCopyResponse(org.dcache.srm.v2_2.SrmCopyResponse) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) SettableFuture(com.google.common.util.concurrent.SettableFuture) ArrayOfTGetFileRequest(org.dcache.srm.v2_2.ArrayOfTGetFileRequest) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Collectors.toMap(java.util.stream.Collectors.toMap) SRM_FILE_LIFETIME_EXPIRED(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_LIFETIME_EXPIRED) SrmSetPermissionRequest(org.dcache.srm.v2_2.SrmSetPermissionRequest) RequestCounters(org.dcache.commons.stats.RequestCounters) Method(java.lang.reflect.Method) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) SrmGetPermissionResponse(org.dcache.srm.v2_2.SrmGetPermissionResponse) SrmMkdirResponse(org.dcache.srm.v2_2.SrmMkdirResponse) JwtJtiPrincipal(org.dcache.auth.JwtJtiPrincipal) SrmGetPermissionRequest(org.dcache.srm.v2_2.SrmGetPermissionRequest) RemoteException(java.rmi.RemoteException) CacheLoader(com.google.common.cache.CacheLoader) TMetaDataPathDetail(org.dcache.srm.v2_2.TMetaDataPathDetail) ArrayOfTPutRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTPutRequestFileStatus) SrmPrepareToGetRequest(org.dcache.srm.v2_2.SrmPrepareToGetRequest) CuratorFramework(org.apache.curator.framework.CuratorFramework) SrmMvRequest(org.dcache.srm.v2_2.SrmMvRequest) SrmReleaseSpaceRequest(org.dcache.srm.v2_2.SrmReleaseSpaceRequest) SRM_NO_FREE_SPACE(org.dcache.srm.v2_2.TStatusCode.SRM_NO_FREE_SPACE) SRM_INVALID_PATH(org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_PATH) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SrmExtendFileLifeTimeInSpaceRequest(org.dcache.srm.v2_2.SrmExtendFileLifeTimeInSpaceRequest) Function(java.util.function.Function) SrmGetRequestTokensResponse(org.dcache.srm.v2_2.SrmGetRequestTokensResponse) SrmPutDoneRequest(org.dcache.srm.v2_2.SrmPutDoneRequest) SRMAuthenticationException(org.dcache.srm.SRMAuthenticationException) SrmResponse(org.dcache.srm.SrmResponse) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) SrmStatusOfLsRequestResponse(org.dcache.srm.v2_2.SrmStatusOfLsRequestResponse) SrmRmdirRequest(org.dcache.srm.v2_2.SrmRmdirRequest) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) SrmStatusOfLsRequestRequest(org.dcache.srm.v2_2.SrmStatusOfLsRequestRequest) SRM_INTERNAL_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_INTERNAL_ERROR) SrmGetRequestSummaryResponse(org.dcache.srm.v2_2.SrmGetRequestSummaryResponse) Logger(org.slf4j.Logger) SrmResumeRequestResponse(org.dcache.srm.v2_2.SrmResumeRequestResponse) URI(org.apache.axis.types.URI) SrmStatusOfGetRequestResponse(org.dcache.srm.v2_2.SrmStatusOfGetRequestResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) Subject(javax.security.auth.Subject) TGetRequestFileStatus(org.dcache.srm.v2_2.TGetRequestFileStatus) SRM_TOO_MANY_RESULTS(org.dcache.srm.v2_2.TStatusCode.SRM_TOO_MANY_RESULTS) Collectors.toList(java.util.stream.Collectors.toList) Required(org.springframework.beans.factory.annotation.Required) SrmSuspendRequestRequest(org.dcache.srm.v2_2.SrmSuspendRequestRequest) LoadingCache(com.google.common.cache.LoadingCache) SrmReserveSpaceResponse(org.dcache.srm.v2_2.SrmReserveSpaceResponse) Subjects(org.dcache.auth.Subjects) SRM_SPACE_LIFETIME_EXPIRED(org.dcache.srm.v2_2.TStatusCode.SRM_SPACE_LIFETIME_EXPIRED) SRM_AUTHORIZATION_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_AUTHORIZATION_FAILURE) SrmPingRequest(org.dcache.srm.v2_2.SrmPingRequest) SrmAbortFilesRequest(org.dcache.srm.v2_2.SrmAbortFilesRequest) SRM_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_FAILURE) SrmCheckPermissionRequest(org.dcache.srm.v2_2.SrmCheckPermissionRequest) ArrayOfTRequestSummary(org.dcache.srm.v2_2.ArrayOfTRequestSummary) CertificateFactories(org.dcache.util.CertificateFactories) SrmPurgeFromSpaceRequest(org.dcache.srm.v2_2.SrmPurgeFromSpaceRequest) PrintWriter(java.io.PrintWriter) SrmPurgeFromSpaceResponse(org.dcache.srm.v2_2.SrmPurgeFromSpaceResponse) TRequestTokenReturn(org.dcache.srm.v2_2.TRequestTokenReturn) TTransferParameters(org.dcache.srm.v2_2.TTransferParameters) SrmLsResponse(org.dcache.srm.v2_2.SrmLsResponse) Set(java.util.Set) SrmReserveSpaceRequest(org.dcache.srm.v2_2.SrmReserveSpaceRequest) InvocationTargetException(java.lang.reflect.InvocationTargetException) ChildData(org.apache.curator.framework.recipes.cache.ChildData) TCopyRequestFileStatus(org.dcache.srm.v2_2.TCopyRequestFileStatus) SrmSuspendRequestResponse(org.dcache.srm.v2_2.SrmSuspendRequestResponse) SrmStatusOfPutRequestRequest(org.dcache.srm.v2_2.SrmStatusOfPutRequestRequest) AccessController(java.security.AccessController) SrmUpdateSpaceResponse(org.dcache.srm.v2_2.SrmUpdateSpaceResponse) SRM_DUPLICATION_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_DUPLICATION_ERROR) SrmPingResponse(org.dcache.srm.v2_2.SrmPingResponse) SrmStatusOfReserveSpaceRequestResponse(org.dcache.srm.v2_2.SrmStatusOfReserveSpaceRequestResponse) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) SRM_NOT_SUPPORTED(org.dcache.srm.v2_2.TStatusCode.SRM_NOT_SUPPORTED) SrmChangeSpaceForFilesResponse(org.dcache.srm.v2_2.SrmChangeSpaceForFilesResponse) ArrayList(java.util.ArrayList) SrmStatusOfCopyRequestRequest(org.dcache.srm.v2_2.SrmStatusOfCopyRequestRequest) SrmGetSpaceTokensResponse(org.dcache.srm.v2_2.SrmGetSpaceTokensResponse) BiConsumer(java.util.function.BiConsumer) SrmCopyRequest(org.dcache.srm.v2_2.SrmCopyRequest) ReturnStatuses.getSummaryReturnStatus(org.dcache.srm.handler.ReturnStatuses.getSummaryReturnStatus) ArrayOfTCopyFileRequest(org.dcache.srm.v2_2.ArrayOfTCopyFileRequest) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) SrmGetSpaceMetaDataRequest(org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest) SrmGetTransferProtocolsResponse(org.dcache.srm.v2_2.SrmGetTransferProtocolsResponse) SrmMkdirRequest(org.dcache.srm.v2_2.SrmMkdirRequest) Futures(com.google.common.util.concurrent.Futures) InetAddresses(com.google.common.net.InetAddresses) SrmBringOnlineRequest(org.dcache.srm.v2_2.SrmBringOnlineRequest) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) CertificateFactory(java.security.cert.CertificateFactory) SRM_FILE_UNAVAILABLE(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_UNAVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) SRM_CUSTOM_STATUS(org.dcache.srm.v2_2.TStatusCode.SRM_CUSTOM_STATUS) PreDestroy(javax.annotation.PreDestroy) AuthenticationHandler(org.dcache.http.AuthenticationHandler) SrmStatusOfUpdateSpaceRequestResponse(org.dcache.srm.v2_2.SrmStatusOfUpdateSpaceRequestResponse) Collectors.toSet(java.util.stream.Collectors.toSet) SRM_INVALID_REQUEST(org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_REQUEST) SRM_NO_USER_SPACE(org.dcache.srm.v2_2.TStatusCode.SRM_NO_USER_SPACE) SrmPrepareToGetResponse(org.dcache.srm.v2_2.SrmPrepareToGetResponse) ImmutableMap(com.google.common.collect.ImmutableMap) SRM_FATAL_INTERNAL_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_FATAL_INTERNAL_ERROR) SrmGetRequestTokensRequest(org.dcache.srm.v2_2.SrmGetRequestTokensRequest) SrmStatusOfBringOnlineRequestResponse(org.dcache.srm.v2_2.SrmStatusOfBringOnlineRequestResponse) Axis(org.dcache.srm.util.Axis) List(java.util.List) SrmStatusOfChangeSpaceForFilesRequestRequest(org.dcache.srm.v2_2.SrmStatusOfChangeSpaceForFilesRequestRequest) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) CellPath(dmg.cells.nucleus.CellPath) X509Credential(eu.emi.security.authn.x509.X509Credential) SrmAbortRequestRequest(org.dcache.srm.v2_2.SrmAbortRequestRequest) SrmPrepareToPutRequest(org.dcache.srm.v2_2.SrmPrepareToPutRequest) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) ArrayOfTGetRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTGetRequestFileStatus) SrmStatusOfPutRequestResponse(org.dcache.srm.v2_2.SrmStatusOfPutRequestResponse) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SrmStatusOfGetRequestRequest(org.dcache.srm.v2_2.SrmStatusOfGetRequestRequest) HashMap(java.util.HashMap) SrmStatusOfUpdateSpaceRequestRequest(org.dcache.srm.v2_2.SrmStatusOfUpdateSpaceRequestRequest) SrmCheckPermissionResponse(org.dcache.srm.v2_2.SrmCheckPermissionResponse) TGetFileRequest(org.dcache.srm.v2_2.TGetFileRequest) ArrayOfTBringOnlineRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTBringOnlineRequestFileStatus) SrmStatusOfCopyRequestResponse(org.dcache.srm.v2_2.SrmStatusOfCopyRequestResponse) CacheException(diskCacheV111.util.CacheException) SRM_FILE_LOST(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_LOST) SRM_REQUEST_TIMED_OUT(org.dcache.srm.v2_2.TStatusCode.SRM_REQUEST_TIMED_OUT) SrmPutDoneResponse(org.dcache.srm.v2_2.SrmPutDoneResponse) CuratorFrameworkAware(org.dcache.cells.CuratorFrameworkAware) JDC(org.dcache.srm.util.JDC) SrmChangeSpaceForFilesRequest(org.dcache.srm.v2_2.SrmChangeSpaceForFilesRequest) SrmReleaseFilesRequest(org.dcache.srm.v2_2.SrmReleaseFilesRequest) SrmUpdateSpaceRequest(org.dcache.srm.v2_2.SrmUpdateSpaceRequest) RequestExecutionTimeGauges(org.dcache.commons.stats.RequestExecutionTimeGauges) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRM_ABORTED(org.dcache.srm.v2_2.TStatusCode.SRM_ABORTED) SRM_SUCCESS(org.dcache.srm.v2_2.TStatusCode.SRM_SUCCESS) ArrayOfTMetaDataPathDetail(org.dcache.srm.v2_2.ArrayOfTMetaDataPathDetail) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SrmRmdirResponse(org.dcache.srm.v2_2.SrmRmdirResponse) SrmGetSpaceTokensRequest(org.dcache.srm.v2_2.SrmGetSpaceTokensRequest) SrmRequest(org.dcache.srm.SrmRequest) PathChildrenCache(org.apache.curator.framework.recipes.cache.PathChildrenCache) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn) SrmGetTransferProtocolsRequest(org.dcache.srm.v2_2.SrmGetTransferProtocolsRequest) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) HashMap(java.util.HashMap) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) URI(org.apache.axis.types.URI) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Example 2 with URI

use of org.apache.axis.types.URI in project dcache by dCache.

the class SRMMvClientV2 method start.

@Override
public void start() throws Exception {
    checkCredentialValid();
    SrmMvRequest req = new SrmMvRequest();
    req.setFromSURL(new URI(surl_strings[0]));
    req.setToSURL(new URI(surl_strings[1]));
    configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
    SrmMvResponse resp = srm.srmMv(req);
    TReturnStatus rs = resp.getReturnStatus();
    if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
        TStatusCode rc = rs.getStatusCode();
        StringBuilder sb = new StringBuilder();
        sb.append("Return code: ").append(rc.toString()).append("\n");
        sb.append("Explanation: ").append(rs.getExplanation()).append("\n");
        System.out.println(sb.toString());
        System.exit(1);
    }
}
Also used : SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) SrmMvRequest(org.dcache.srm.v2_2.SrmMvRequest) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) URI(org.apache.axis.types.URI) TStatusCode(org.dcache.srm.v2_2.TStatusCode)

Example 3 with URI

use of org.apache.axis.types.URI in project dcache by dCache.

the class SRMPutClientV2 method start.

@Override
public void start() throws Exception {
    try {
        copier = new Copier(configuration);
        new Thread(copier).start();
        int len = from.length;
        TPutFileRequest[] fileRequests = new TPutFileRequest[len];
        String[] SURLS = new String[len];
        for (int i = 0; i < len; ++i) {
            java.net.URI filesource = from[i];
            int filetype = SRMDispatcher.getUrlType(filesource);
            if ((filetype & SRMDispatcher.FILE_URL) == 0) {
                throw new IOException(" source is not file " + filesource);
            }
            if ((filetype & SRMDispatcher.DIRECTORY_URL) == SRMDispatcher.DIRECTORY_URL) {
                throw new IOException(" source is directory " + filesource);
            }
            if ((filetype & SRMDispatcher.CAN_READ_FILE_URL) == 0) {
                throw new IOException(" source is not readable " + filesource);
            }
            File f = new File(filesource.getPath());
            long filesize = f.length();
            SURLS[i] = to[i].toASCIIString();
            URI uri = new URI(SURLS[i]);
            fileRequests[i] = new TPutFileRequest();
            fileRequests[i].setExpectedFileSize(new UnsignedLong(filesize));
            fileRequests[i].setTargetSURL(uri);
            pendingSurlsToIndex.put(SURLS[i], i);
        }
        hook = new Thread(this);
        Runtime.getRuntime().addShutdownHook(hook);
        SrmPrepareToPutRequest srmPrepareToPutRequest = new SrmPrepareToPutRequest();
        srmPrepareToPutRequest.setUserRequestDescription(configuration.getUserRequestDescription());
        String storagetype = configuration.getStorageType();
        if (storagetype != null) {
            srmPrepareToPutRequest.setDesiredFileStorageType(FileStorageType.fromString(storagetype.toUpperCase()).toTFileStorageType());
        }
        srmPrepareToPutRequest.setDesiredTotalRequestTime((int) configuration.getRequestLifetime());
        srmPrepareToPutRequest.setArrayOfFileRequests(new ArrayOfTPutFileRequest(fileRequests));
        TAccessPattern ap = null;
        if (configuration.getAccessPattern() != null) {
            ap = TAccessPattern.fromString(configuration.getAccessPattern());
        }
        TConnectionType ct = null;
        if (configuration.getConnectionType() != null) {
            ct = TConnectionType.fromString(configuration.getConnectionType());
        }
        ArrayOfString protocolArray = null;
        if (configuration.getProtocols() != null) {
            protocolArray = new ArrayOfString(configuration.getProtocols());
        }
        ArrayOfString arrayOfClientNetworks = null;
        if (configuration.getArrayOfClientNetworks() != null) {
            arrayOfClientNetworks = new ArrayOfString(configuration.getArrayOfClientNetworks());
        }
        if (ap != null || ct != null || arrayOfClientNetworks != null || protocolArray != null) {
            srmPrepareToPutRequest.setTransferParameters(new TTransferParameters(ap, ct, arrayOfClientNetworks, protocolArray));
        }
        TRetentionPolicy rp = configuration.getRetentionPolicy() != null ? RetentionPolicy.fromString(configuration.getRetentionPolicy()).toTRetentionPolicy() : null;
        TAccessLatency al = configuration.getAccessLatency() != null ? AccessLatency.fromString(configuration.getAccessLatency()).toTAccessLatency() : null;
        if ((al != null) && (rp == null)) {
            throw new IllegalArgumentException("if access latency is specified, " + "then retention policy have to be specified as well");
        } else if (rp != null) {
            srmPrepareToPutRequest.setTargetFileRetentionPolicyInfo(new TRetentionPolicyInfo(rp, al));
        }
        if (configuration.getOverwriteMode() != null) {
            srmPrepareToPutRequest.setOverwriteOption(TOverwriteMode.fromString(configuration.getOverwriteMode()));
        }
        if (configuration.getSpaceToken() != null) {
            srmPrepareToPutRequest.setTargetSpaceToken(configuration.getSpaceToken());
        }
        configuration.getStorageSystemInfo().ifPresent(srmPrepareToPutRequest::setStorageSystemInfo);
        response = srm.srmPrepareToPut(srmPrepareToPutRequest);
        if (response == null) {
            throw new IOException(" null response");
        }
        TReturnStatus status = response.getReturnStatus();
        if (status == null) {
            throw new IOException(" null return status");
        }
        TStatusCode statusCode = status.getStatusCode();
        if (statusCode == null) {
            throw new IOException(" null status code");
        }
        if (RequestStatusTool.isFailedRequestStatus(status) && (statusCode != TStatusCode.SRM_FAILURE || response.getArrayOfFileStatuses() == null)) {
            String explanation = status.getExplanation();
            if (explanation != null) {
                throw new IOException("srmPrepareToPut submission failed, unexpected or failed status : " + statusCode + " explanation= " + explanation);
            } else {
                throw new IOException("srmPrepareToPut submission failed, unexpected or failed status : " + statusCode);
            }
        }
        requestToken = response.getRequestToken();
        dsay(" srm returned requestToken = " + requestToken);
        if (response.getArrayOfFileStatuses() == null) {
            throw new IOException("returned PutRequestFileStatuses is an empty array");
        }
        TPutRequestFileStatus[] putRequestFileStatuses = response.getArrayOfFileStatuses().getStatusArray();
        if (putRequestFileStatuses.length != len) {
            throw new IOException("incorrect number of GetRequestFileStatuses" + "in RequestStatus expected " + len + " received " + putRequestFileStatuses.length);
        }
        while (!pendingSurlsToIndex.isEmpty()) {
            long estimatedWaitInSeconds = 5;
            for (TPutRequestFileStatus putRequestFileStatus : putRequestFileStatuses) {
                URI surl = putRequestFileStatus.getSURL();
                if (surl == null) {
                    esay("invalid putRequestFileStatus, surl is null");
                    continue;
                }
                String surl_string = surl.toString();
                if (!pendingSurlsToIndex.containsKey(surl_string)) {
                    esay("invalid putRequestFileStatus, surl = " + surl_string + " not found");
                    continue;
                }
                TReturnStatus fileStatus = putRequestFileStatus.getStatus();
                if (fileStatus == null) {
                    throw new IOException(" null file return status");
                }
                TStatusCode fileStatusCode = fileStatus.getStatusCode();
                if (fileStatusCode == null) {
                    throw new IOException(" null file status code");
                }
                if (RequestStatusTool.isFailedFileRequestStatus(fileStatus)) {
                    String explanation = fileStatus.getExplanation();
                    String error = isNullOrEmpty(explanation) ? fileStatusCode.toString() : fileStatusCode + ": " + explanation;
                    say(error);
                    int indx = pendingSurlsToIndex.remove(surl_string);
                    setReportFailed(from[indx], to[indx], error);
                    continue;
                }
                if (putRequestFileStatus.getTransferURL() != null) {
                    java.net.URI globusTURL = new java.net.URI(putRequestFileStatus.getTransferURL().toString());
                    int indx = pendingSurlsToIndex.remove(surl_string);
                    setReportFailed(from[indx], to[indx], "received TURL, but did not complete transfer");
                    CopyJob job = new SRMV2CopyJob(from[indx], globusTURL, srm, requestToken, logger, to[indx], false, this);
                    copier.addCopyJob(job);
                    continue;
                }
                if (putRequestFileStatus.getEstimatedWaitTime() != null && putRequestFileStatus.getEstimatedWaitTime() < estimatedWaitInSeconds && putRequestFileStatus.getEstimatedWaitTime() >= 1) {
                    estimatedWaitInSeconds = putRequestFileStatus.getEstimatedWaitTime();
                }
            }
            if (pendingSurlsToIndex.isEmpty()) {
                dsay("no more pending transfers, breaking the loop");
                Runtime.getRuntime().removeShutdownHook(hook);
                break;
            }
            // do not wait longer then 60 seconds
            if (estimatedWaitInSeconds > 60) {
                estimatedWaitInSeconds = 60;
            }
            try {
                say("sleeping " + estimatedWaitInSeconds + " seconds ...");
                Thread.sleep(estimatedWaitInSeconds * 1000);
            } catch (InterruptedException ie) {
                logger.elog(ie.toString());
            }
            SrmStatusOfPutRequestRequest srmStatusOfPutRequestRequest = new SrmStatusOfPutRequestRequest();
            srmStatusOfPutRequestRequest.setRequestToken(requestToken);
            // if we do not have completed file requests
            // we want to get status for all files
            // we do not need to specify any surls
            int expectedResponseLength;
            // we do not know what to expect from the server when
            // no surls are specified int the status update request
            // so we always are sending the list of all pending srm urls
            String[] pendingSurlStrings = pendingSurlsToIndex.keySet().toArray(new String[pendingSurlsToIndex.size()]);
            expectedResponseLength = pendingSurlStrings.length;
            URI[] surlArray = new URI[expectedResponseLength];
            for (int i = 0; i < expectedResponseLength; ++i) {
                surlArray[i] = new URI(pendingSurlStrings[i]);
            }
            srmStatusOfPutRequestRequest.setArrayOfTargetSURLs(new ArrayOfAnyURI(surlArray));
            SrmStatusOfPutRequestResponse srmStatusOfPutRequestResponse = srm.srmStatusOfPutRequest(srmStatusOfPutRequestRequest);
            if (srmStatusOfPutRequestResponse == null) {
                throw new IOException(" null srmStatusOfPutRequestResponse");
            }
            if (srmStatusOfPutRequestResponse.getArrayOfFileStatuses() == null) {
                esay("putRequestFileStatuses == null");
                throw new IOException("putRequestFileStatuses == null");
            }
            putRequestFileStatuses = srmStatusOfPutRequestResponse.getArrayOfFileStatuses().getStatusArray();
            if (putRequestFileStatuses.length != expectedResponseLength) {
                esay("incorrect number of RequestFileStatuses");
                throw new IOException("incorrect number of RequestFileStatuses");
            }
            status = srmStatusOfPutRequestResponse.getReturnStatus();
            if (status == null) {
                throw new IOException(" null return status");
            }
            statusCode = status.getStatusCode();
            if (statusCode == null) {
                throw new IOException(" null status code");
            }
            if (RequestStatusTool.isFailedRequestStatus(status)) {
                String error = "srmPrepareToPut update failed, status : " + statusCode + " explanation=" + status.getExplanation();
                esay(error);
                for (int i = 0; i < expectedResponseLength; ++i) {
                    TReturnStatus frstatus = putRequestFileStatuses[i].getStatus();
                    if (frstatus != null) {
                        esay("PutFileRequest[" + putRequestFileStatuses[i].getSURL() + "] status=" + frstatus.getStatusCode() + " explanation=" + frstatus.getExplanation());
                        if (!RequestStatusTool.isTransientStateStatus(frstatus)) {
                            pendingSurlsToIndex.remove(putRequestFileStatuses[i].getSURL().toString());
                        }
                    }
                }
                throw new IOException(error);
            }
        }
    } catch (Exception e) {
        try {
            if (copier != null) {
                dsay("stopping copier" + e);
                copier.stop();
                abortAllPendingFiles();
            }
        } catch (Exception e1) {
            edsay(e1.toString());
        }
        throw e;
    } finally {
        if (copier != null) {
            copier.doneAddingJobs();
            try {
                copier.waitCompletion();
            } catch (Exception e1) {
                edsay(e1.toString());
            }
        }
        report.dumpReport();
        if (!report.everythingAllRight()) {
            report.reportErrors(System.err);
        }
    }
}
Also used : TAccessPattern(org.dcache.srm.v2_2.TAccessPattern) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) TPutFileRequest(org.dcache.srm.v2_2.TPutFileRequest) TTransferParameters(org.dcache.srm.v2_2.TTransferParameters) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(org.apache.axis.types.URI) SrmStatusOfPutRequestRequest(org.dcache.srm.v2_2.SrmStatusOfPutRequestRequest) TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) TPutRequestFileStatus(org.dcache.srm.v2_2.TPutRequestFileStatus) SrmPrepareToPutRequest(org.dcache.srm.v2_2.SrmPrepareToPutRequest) TConnectionType(org.dcache.srm.v2_2.TConnectionType) UnsignedLong(org.apache.axis.types.UnsignedLong) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) SrmStatusOfPutRequestResponse(org.dcache.srm.v2_2.SrmStatusOfPutRequestResponse) IOException(java.io.IOException) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) TStatusCode(org.dcache.srm.v2_2.TStatusCode) IOException(java.io.IOException) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) File(java.io.File) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Example 4 with URI

use of org.apache.axis.types.URI in project dcache by dCache.

the class SRMPutClientV2 method abortAllPendingFiles.

private void abortAllPendingFiles() throws Exception {
    if (pendingSurlsToIndex.isEmpty()) {
        return;
    }
    if (response != null) {
        requestToken = response.getRequestToken();
        if (requestToken != null) {
            String[] surl_strings = pendingSurlsToIndex.keySet().toArray(new String[pendingSurlsToIndex.size()]);
            int len = surl_strings.length;
            say("Releasing all remaining file requests");
            URI[] surlArray = new URI[len];
            for (int i = 0; i < len; ++i) {
                surlArray[i] = new URI(surl_strings[i]);
            }
            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) {
                    esay("srmAbortFiles return status is null");
                    return;
                }
                say("srmAbortFiles status code=" + returnStatus.getStatusCode());
            }
        } else {
            if (response.getArrayOfFileStatuses() != null) {
                if (response.getArrayOfFileStatuses().getStatusArray() != null) {
                    for (int i = 0; i < response.getArrayOfFileStatuses().getStatusArray().length; i++) {
                        URI surl = response.getArrayOfFileStatuses().getStatusArray(i).getSURL();
                        TReturnStatus fst = response.getArrayOfFileStatuses().getStatusArray(i).getStatus();
                        esay("SURL[" + i + "]=" + surl.toString() + " status=" + fst.getStatusCode() + " explanation=" + fst.getExplanation());
                    }
                }
            }
        }
    }
}
Also used : SrmAbortFilesRequest(org.dcache.srm.v2_2.SrmAbortFilesRequest) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SrmAbortFilesResponse(org.dcache.srm.v2_2.SrmAbortFilesResponse) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(org.apache.axis.types.URI) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Example 5 with URI

use of org.apache.axis.types.URI in project dcache by dCache.

the class SRMRmClientV2 method start.

@Override
public void start() throws Exception {
    checkCredentialValid();
    SrmRmRequest req = new SrmRmRequest();
    URI[] uris = new URI[surls.length];
    for (int i = 0; i < surls.length; ++i) {
        uris[i] = new URI(surl_strings[i]);
    }
    req.setArrayOfSURLs(new ArrayOfAnyURI(uris));
    configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
    SrmRmResponse resp = srm.srmRm(req);
    TReturnStatus rs = resp.getReturnStatus();
    if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
        TStatusCode rc = rs.getStatusCode();
        StringBuilder sb = new StringBuilder();
        sb.append("Return code: ").append(rc.toString()).append("\n");
        sb.append("Explanation: ").append(rs.getExplanation()).append("\n");
        if (resp.getArrayOfFileStatuses() != null) {
            TSURLReturnStatus[] arrayOfStatuses = resp.getArrayOfFileStatuses().getStatusArray();
            if (arrayOfStatuses != null) {
                for (int i = 0; i < arrayOfStatuses.length; i++) {
                    if (arrayOfStatuses[i] != null) {
                        sb.append("file#").append(i).append(" : ");
                        if (arrayOfStatuses[i].getSurl() != null) {
                            sb.append(arrayOfStatuses[i].getSurl());
                        }
                        if (arrayOfStatuses[i].getStatus() != null) {
                            sb.append(", ");
                            sb.append(arrayOfStatuses[i].getStatus().getStatusCode());
                            sb.append(", \"");
                            sb.append(arrayOfStatuses[i].getStatus().getExplanation());
                            sb.append("\"");
                        }
                        sb.append('\n');
                    }
                }
            }
        }
        System.out.println(sb.toString());
        System.exit(1);
    }
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) SrmRmResponse(org.dcache.srm.v2_2.SrmRmResponse) URI(org.apache.axis.types.URI) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) SrmRmRequest(org.dcache.srm.v2_2.SrmRmRequest) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) TStatusCode(org.dcache.srm.v2_2.TStatusCode)

Aggregations

URI (org.apache.axis.types.URI)36 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)28 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)27 TStatusCode (org.dcache.srm.v2_2.TStatusCode)15 IOException (java.io.IOException)13 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)11 SrmAbortFilesRequest (org.dcache.srm.v2_2.SrmAbortFilesRequest)7 SrmAbortFilesResponse (org.dcache.srm.v2_2.SrmAbortFilesResponse)7 TTransferParameters (org.dcache.srm.v2_2.TTransferParameters)6 JDC (org.dcache.srm.util.JDC)5 SrmPutDoneResponse (org.dcache.srm.v2_2.SrmPutDoneResponse)5 SrmReleaseFilesRequest (org.dcache.srm.v2_2.SrmReleaseFilesRequest)5 SrmReleaseFilesResponse (org.dcache.srm.v2_2.SrmReleaseFilesResponse)5 TRetentionPolicyInfo (org.dcache.srm.v2_2.TRetentionPolicyInfo)5 SRMException (org.dcache.srm.SRMException)4 ArrayOfTGetFileRequest (org.dcache.srm.v2_2.ArrayOfTGetFileRequest)4 SrmPutDoneRequest (org.dcache.srm.v2_2.SrmPutDoneRequest)4 RemoteException (java.rmi.RemoteException)3 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)3 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)3