Search in sources :

Example 1 with SrmGetSpaceMetaDataRequest

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest 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 SrmGetSpaceMetaDataRequest

use of org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest 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)

Aggregations

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