use of org.dcache.srm.v2_2.SrmReserveSpaceRequest in project dcache by dCache.
the class AxisSrmFileSystem method reserveSpace.
@Nonnull
@Override
public TMetaDataSpace reserveSpace(long size, @Nullable String description, @Nullable TAccessLatency al, TRetentionPolicy rp, @Nullable Integer lifetime) throws SRMException, RemoteException, InterruptedException {
SrmReserveSpaceResponse response = srm.srmReserveSpace(new SrmReserveSpaceRequest(null, description, new TRetentionPolicyInfo(rp, al), new UnsignedLong(size), new UnsignedLong(size), lifetime, null, null, null));
while (response.getReturnStatus().getStatusCode() == TStatusCode.SRM_REQUEST_QUEUED || response.getReturnStatus().getStatusCode() == TStatusCode.SRM_REQUEST_INPROGRESS) {
if (response.getEstimatedProcessingTime() != null) {
TimeUnit.SECONDS.sleep(response.getEstimatedProcessingTime());
} else {
TimeUnit.SECONDS.sleep(2);
}
SrmStatusOfReserveSpaceRequestResponse status = srm.srmStatusOfReserveSpaceRequest(new SrmStatusOfReserveSpaceRequestRequest(null, response.getRequestToken()));
response.setReturnStatus(status.getReturnStatus());
response.setLifetimeOfReservedSpace(status.getLifetimeOfReservedSpace());
response.setRetentionPolicyInfo(status.getRetentionPolicyInfo());
response.setSizeOfGuaranteedReservedSpace(status.getSizeOfGuaranteedReservedSpace());
response.setSizeOfTotalReservedSpace(status.getSizeOfTotalReservedSpace());
response.setSpaceToken(status.getSpaceToken());
response.setEstimatedProcessingTime(status.getEstimatedProcessingTime());
}
checkSuccess(response.getReturnStatus(), TStatusCode.SRM_SUCCESS, TStatusCode.SRM_LOWER_SPACE_GRANTED);
TMetaDataSpace space = new TMetaDataSpace();
space.setLifetimeAssigned(response.getLifetimeOfReservedSpace());
space.setRetentionPolicyInfo(response.getRetentionPolicyInfo());
space.setGuaranteedSize(response.getSizeOfGuaranteedReservedSpace());
space.setTotalSize(response.getSizeOfTotalReservedSpace());
space.setSpaceToken(response.getSpaceToken());
space.setStatus(response.getReturnStatus());
return space;
}
Aggregations