Search in sources :

Example 1 with SrmGetSpaceMetaDataResponse

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse in project dcache by dCache.

the class AxisSrmFileSystem method getSpaceMetaData.

@Nonnull
@Override
public TMetaDataSpace[] getSpaceMetaData(String... spaceTokens) throws RemoteException, SRMException {
    checkArgument(spaceTokens.length > 0);
    SrmGetSpaceMetaDataResponse response = srm.srmGetSpaceMetaData(new SrmGetSpaceMetaDataRequest(null, new ArrayOfString(spaceTokens)));
    TMetaDataSpace[] spaceDataArray = response.getArrayOfSpaceDetails().getSpaceDataArray();
    if (spaceDataArray == null || spaceDataArray.length == 0) {
        checkSuccess(response.getReturnStatus(), TStatusCode.SRM_SUCCESS, TStatusCode.SRM_PARTIAL_SUCCESS);
        throw new SrmProtocolException("Server reply lacks space meta data.");
    } else {
        checkSuccess(response.getReturnStatus(), TStatusCode.SRM_SUCCESS, TStatusCode.SRM_PARTIAL_SUCCESS, TStatusCode.SRM_FAILURE);
    }
    return spaceDataArray;
}
Also used : ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) SrmGetSpaceMetaDataRequest(org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse) Nonnull(javax.annotation.Nonnull)

Example 2 with SrmGetSpaceMetaDataResponse

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse in project dcache by dCache.

the class SrmGetSpaceMetaData method srmGetSpaceMetaData.

private SrmGetSpaceMetaDataResponse srmGetSpaceMetaData() throws SRMException {
    String[] spaceTokens = request.getArrayOfSpaceTokens().getStringArray();
    if (spaceTokens == null || spaceTokens.length == 0) {
        throw new SRMInvalidRequestException("arrayOfSpaceToken is empty");
    }
    TMetaDataSpace[] array = storage.srmGetSpaceMetaData(user, spaceTokens);
    return new SrmGetSpaceMetaDataResponse(getSummaryReturnStatus(array), new ArrayOfTMetaDataSpace(array));
}
Also used : ArrayOfTMetaDataSpace(org.dcache.srm.v2_2.ArrayOfTMetaDataSpace) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) ArrayOfTMetaDataSpace(org.dcache.srm.v2_2.ArrayOfTMetaDataSpace) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse)

Example 3 with SrmGetSpaceMetaDataResponse

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse in project dcache by dCache.

the class SRMGetSpaceMetaDataClientV2 method start.

@Override
public void start() throws Exception {
    checkCredentialValid();
    try {
        String[] tokens = configuration.getSpaceTokensList();
        SrmGetSpaceMetaDataRequest request = new SrmGetSpaceMetaDataRequest();
        request.setArrayOfSpaceTokens(new ArrayOfString(tokens));
        SrmGetSpaceMetaDataResponse response = srm.srmGetSpaceMetaData(request);
        if (response == null) {
            throw new IOException(" null SrmGetSpaceMetaDataResponse");
        }
        TReturnStatus rs = response.getReturnStatus();
        if (rs == null) {
            throw new IOException(" null TReturnStatus ");
        }
        if (RequestStatusTool.isFailedRequestStatus(rs)) {
            throw new IOException("SrmGetSpaceMetaData failed, unexpected or failed return status : " + rs.getStatusCode() + " explanation=" + rs.getExplanation());
        }
        TMetaDataSpace[] spaceMetaDatas = response.getArrayOfSpaceDetails().getSpaceDataArray();
        for (TMetaDataSpace spaceMetaData : spaceMetaDatas) {
            System.out.println("Space Reservation with token=" + spaceMetaData.getSpaceToken());
            if (spaceMetaData.getStatus().getStatusCode() != TStatusCode.SRM_SUCCESS) {
                System.out.println("\t StatusCode=" + spaceMetaData.getStatus().getStatusCode() + " explanation=" + spaceMetaData.getStatus().getExplanation());
                continue;
            }
            System.out.println("\t           owner:" + spaceMetaData.getOwner());
            System.out.println("\t       totalSize:" + spaceMetaData.getTotalSize());
            System.out.println("\t  guaranteedSize:" + spaceMetaData.getGuaranteedSize());
            System.out.println("\t      unusedSize:" + spaceMetaData.getUnusedSize());
            System.out.println("\tlifetimeAssigned:" + spaceMetaData.getLifetimeAssigned());
            System.out.println("\t    lifetimeLeft:" + spaceMetaData.getLifetimeLeft());
            TRetentionPolicyInfo policyInfo = spaceMetaData.getRetentionPolicyInfo();
            if (policyInfo != null) {
                System.out.println("\t   accessLatency:" + policyInfo.getAccessLatency());
                System.out.println("\t retentionPolicy:" + policyInfo.getRetentionPolicy());
            }
        }
    } catch (Exception e) {
        throw e;
    }
}
Also used : TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) SrmGetSpaceMetaDataRequest(org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) IOException(java.io.IOException) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse) IOException(java.io.IOException)

Example 4 with SrmGetSpaceMetaDataResponse

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse in project dcache by dCache.

the class SrmGetSpaceMetaData method getFailedResponse.

public static final SrmGetSpaceMetaDataResponse getFailedResponse(String text, TStatusCode statusCode) {
    SrmGetSpaceMetaDataResponse response = new SrmGetSpaceMetaDataResponse();
    response.setReturnStatus(new TReturnStatus(statusCode, text));
    return response;
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse)

Aggregations

SrmGetSpaceMetaDataResponse (org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse)4 TMetaDataSpace (org.dcache.srm.v2_2.TMetaDataSpace)3 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)2 SrmGetSpaceMetaDataRequest (org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest)2 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)2 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)1 ArrayOfTMetaDataSpace (org.dcache.srm.v2_2.ArrayOfTMetaDataSpace)1 TRetentionPolicyInfo (org.dcache.srm.v2_2.TRetentionPolicyInfo)1