Search in sources :

Example 1 with TMetaDataSpace

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

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

the class SrmShell method append.

private void append(PrintWriter writer, TMetaDataSpace space) {
    Integer lifetimeOfReservedSpace = space.getLifetimeAssigned();
    Integer lifetimeLeft = space.getLifetimeLeft();
    TRetentionPolicyInfo retentionPolicyInfo = space.getRetentionPolicyInfo();
    UnsignedLong sizeOfTotalReservedSpace = space.getTotalSize();
    UnsignedLong sizeOfGuaranteedReservedSpace = space.getGuaranteedSize();
    UnsignedLong unusedSize = space.getUnusedSize();
    writer.append("Space token       : ").println(space.getSpaceToken());
    if (space.getOwner() != null) {
        writer.append("Owner             : ").println(space.getOwner());
    }
    if (sizeOfTotalReservedSpace != null) {
        writer.append("Total size        : ").println(sizeOfTotalReservedSpace.longValue());
    }
    if (sizeOfGuaranteedReservedSpace != null) {
        writer.append("Guaranteed size   : ").println(sizeOfGuaranteedReservedSpace.longValue());
    }
    if (unusedSize != null) {
        writer.append("Unused size       : ").println(unusedSize.longValue());
    }
    if (lifetimeOfReservedSpace != null) {
        writer.append("Assigned lifetime : ").println(lifetimeOfReservedSpace);
    }
    if (lifetimeLeft != null) {
        writer.append("Remaining lifetime: ").println(lifetimeLeft);
    }
    if (retentionPolicyInfo != null) {
        TRetentionPolicy retentionPolicy = retentionPolicyInfo.getRetentionPolicy();
        TAccessLatency accessLatency = retentionPolicyInfo.getAccessLatency();
        writer.append("Retention         : ").append(retentionPolicy.toString());
        if (accessLatency != null) {
            writer.append("Access latency: ").append(accessLatency.toString());
        }
        writer.println();
    }
}
Also used : TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) UnsignedLong(org.apache.axis.types.UnsignedLong) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 3 with TMetaDataSpace

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

the class Storage method srmGetSpaceMetaData.

/**
 * @param spaceTokens
 * @return
 * @throws SRMException
 */
@Override
public TMetaDataSpace[] srmGetSpaceMetaData(SRMUser user, String[] spaceTokens) throws SRMException {
    guardSpaceManagerEnabled();
    GetSpaceMetaData getSpaces = new GetSpaceMetaData(spaceTokens);
    try {
        getSpaces = _spaceManagerStub.sendAndWait(getSpaces);
    } catch (TimeoutCacheException e) {
        throw new SRMInternalErrorException("Space manager timeout", e);
    } catch (NoRouteToCellException e) {
        throw new SRMNotSupportedException("Space manager is unavailable", e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (CacheException e) {
        _log.warn("GetSpaceMetaData failed with rc={} error={}", e.getRc(), e.getMessage());
        throw new SRMException("Space manager failure: " + e.getMessage(), e);
    }
    Space[] spaces = getSpaces.getSpaces();
    TMetaDataSpace[] spaceMetaDatas = new TMetaDataSpace[spaces.length];
    for (int i = 0; i < spaceMetaDatas.length; ++i) {
        Space space = spaces[i];
        TMetaDataSpace metaDataSpace = new TMetaDataSpace();
        TReturnStatus status;
        if (space != null) {
            Long expirationTime = space.getExpirationTime();
            if (expirationTime == null) {
                metaDataSpace.setLifetimeAssigned(-1);
                metaDataSpace.setLifetimeLeft(-1);
            } else {
                long lifetimeleft = Math.max(0, MILLISECONDS.toSeconds(expirationTime - System.currentTimeMillis()));
                metaDataSpace.setLifetimeAssigned((int) MILLISECONDS.toSeconds(expirationTime - space.getCreationTime()));
                metaDataSpace.setLifetimeLeft((int) lifetimeleft);
            }
            RetentionPolicy retentionPolicy = space.getRetentionPolicy();
            TRetentionPolicy policy = retentionPolicy.equals(RetentionPolicy.CUSTODIAL) ? TRetentionPolicy.CUSTODIAL : retentionPolicy.equals(RetentionPolicy.OUTPUT) ? TRetentionPolicy.OUTPUT : TRetentionPolicy.REPLICA;
            AccessLatency accessLatency = space.getAccessLatency();
            TAccessLatency latency = accessLatency.equals(AccessLatency.ONLINE) ? TAccessLatency.ONLINE : TAccessLatency.NEARLINE;
            UnsignedLong totalSize = new UnsignedLong(space.getSizeInBytes());
            UnsignedLong unusedSize = new UnsignedLong(space.getSizeInBytes() - space.getUsedSizeInBytes());
            metaDataSpace.setRetentionPolicyInfo(new TRetentionPolicyInfo(policy, latency));
            metaDataSpace.setTotalSize(totalSize);
            metaDataSpace.setGuaranteedSize(totalSize);
            metaDataSpace.setUnusedSize(unusedSize);
            SpaceState spaceState = space.getState();
            switch(spaceState) {
                case RESERVED:
                    status = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
                    break;
                case EXPIRED:
                    status = new TReturnStatus(TStatusCode.SRM_SPACE_LIFETIME_EXPIRED, "The lifetime on the space that is associated with the spaceToken has expired already");
                    break;
                default:
                    status = new TReturnStatus(TStatusCode.SRM_FAILURE, "Space has been released");
                    break;
            }
            metaDataSpace.setOwner("VoGroup=" + space.getVoGroup() + " VoRole=" + space.getVoRole());
        } else {
            status = new TReturnStatus(TStatusCode.SRM_INVALID_REQUEST, "No such space");
        }
        metaDataSpace.setStatus(status);
        metaDataSpace.setSpaceToken(spaceTokens[i]);
        spaceMetaDatas[i] = metaDataSpace;
    }
    return spaceMetaDatas;
}
Also used : GetSpaceMetaData(diskCacheV111.services.space.message.GetSpaceMetaData) Space(diskCacheV111.services.space.Space) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) AccessLatency(diskCacheV111.util.AccessLatency) UnsignedLong(org.apache.axis.types.UnsignedLong) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) RetentionPolicy(diskCacheV111.util.RetentionPolicy) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) SpaceState(diskCacheV111.services.space.SpaceState) UnsignedLong(org.apache.axis.types.UnsignedLong) AtomicLong(java.util.concurrent.atomic.AtomicLong) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 4 with TMetaDataSpace

use of org.dcache.srm.v2_2.TMetaDataSpace 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 5 with TMetaDataSpace

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

TMetaDataSpace (org.dcache.srm.v2_2.TMetaDataSpace)6 TRetentionPolicyInfo (org.dcache.srm.v2_2.TRetentionPolicyInfo)4 UnsignedLong (org.apache.axis.types.UnsignedLong)3 SrmGetSpaceMetaDataResponse (org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse)3 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)3 Nonnull (javax.annotation.Nonnull)2 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)2 SrmGetSpaceMetaDataRequest (org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest)2 TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)2 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)2 Space (diskCacheV111.services.space.Space)1 SpaceState (diskCacheV111.services.space.SpaceState)1 GetSpaceMetaData (diskCacheV111.services.space.message.GetSpaceMetaData)1 AccessLatency (diskCacheV111.util.AccessLatency)1 CacheException (diskCacheV111.util.CacheException)1 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1