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;
}
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();
}
}
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;
}
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));
}
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;
}
}
Aggregations