From 98012be5b20dd921b3aca5754f893a21efed0cb8 Mon Sep 17 00:00:00 2001 From: Gerd Behrmann Date: Wed, 8 Jan 2014 12:13:08 +0100 Subject: [PATCH] Add preallocation field to PoolAcceptFileMessage Adds a field for preallocation to the pool accept message - I imagine the pool could make use of this information to preallocate space during mover startup or reject a mover if not enough garbage collectible space is available up front. In the short term this will be used by space manager for implicit space reservation. Target: trunk Require-notes: no Require-book: no Acked-by: Tigran Mkrtchyan Patch: http://rb.dcache.org/r/6386/ --- .../doors/DCapDoorInterpreterV3.java | 29 ++++++++++++------- .../services/TransferManagerHandler.java | 3 +- .../vehicles/PoolAcceptFileMessage.java | 23 ++++++++++----- .../main/java/org/dcache/util/Transfer.java | 6 +++- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/modules/dcache-dcap/src/main/java/diskCacheV111/doors/DCapDoorInterpreterV3.java b/modules/dcache-dcap/src/main/java/diskCacheV111/doors/DCapDoorInterpreterV3.java index b59d43b81b1..0f83c602185 100644 --- a/modules/dcache-dcap/src/main/java/diskCacheV111/doors/DCapDoorInterpreterV3.java +++ b/modules/dcache-dcap/src/main/java/diskCacheV111/doors/DCapDoorInterpreterV3.java @@ -2126,16 +2126,7 @@ public void fileAttributesAvailable() // // try to get some space to store the file. // - long preallocated = 0L; - String value = _fileAttributes.getStorageInfo().getKey("alloc-size"); - if (value != null) { - try { - preallocated = Long.parseLong(value); - } catch (NumberFormatException e) { - // bad values are ignored - } - } - getPoolMessage = new PoolMgrSelectWritePoolMsg(_fileAttributes, _protocolInfo, preallocated); + getPoolMessage = new PoolMgrSelectWritePoolMsg(_fileAttributes, _protocolInfo, getPreallocated()); getPoolMessage.setIoQueueName(_ioQueueName ); if( _path != null ) { getPoolMessage.setPnfsPath(_path); @@ -2201,6 +2192,21 @@ public void fileAttributesAvailable() setTimer(_poolRetry) ; } + + private long getPreallocated() + { + long preallocated = 0L; + String value = _fileAttributes.getStorageInfo().getKey("alloc-size"); + if (value != null) { + try { + preallocated = Long.parseLong(value); + } catch (NumberFormatException e) { + // bad values are ignored + } + } + return preallocated; + } + private void storeChecksumInPnfs( PnfsId pnfsId , String checksumString){ try{ PnfsFlagMessage flag = @@ -2265,7 +2271,8 @@ private void storeChecksumInPnfs( PnfsId pnfsId , String checksumString){ new PoolAcceptFileMessage( pool, _protocolInfo , - _fileAttributes); + _fileAttributes, + getPreallocated()); }else{ sendReply( "poolMgrGetPoolArrived" , 7 , "Illegal Message arrived : "+reply.getClass().getName() ) ; diff --git a/modules/dcache/src/main/java/diskCacheV111/services/TransferManagerHandler.java b/modules/dcache/src/main/java/diskCacheV111/services/TransferManagerHandler.java index 6bf596c3520..75399156e02 100644 --- a/modules/dcache/src/main/java/diskCacheV111/services/TransferManagerHandler.java +++ b/modules/dcache/src/main/java/diskCacheV111/services/TransferManagerHandler.java @@ -423,7 +423,8 @@ public void startMoverOnThePool() ? new PoolAcceptFileMessage( pool, protocol_info, - fileAttributes) + fileAttributes, + (size == null) ? 0L : size) : new PoolDeliverFileMessage( pool, protocol_info, diff --git a/modules/dcache/src/main/java/diskCacheV111/vehicles/PoolAcceptFileMessage.java b/modules/dcache/src/main/java/diskCacheV111/vehicles/PoolAcceptFileMessage.java index c8abc76340c..0263af938cd 100644 --- a/modules/dcache/src/main/java/diskCacheV111/vehicles/PoolAcceptFileMessage.java +++ b/modules/dcache/src/main/java/diskCacheV111/vehicles/PoolAcceptFileMessage.java @@ -1,5 +1,3 @@ -// $Id: PoolAcceptFileMessage.java,v 1.4 2004-11-05 12:07:19 tigran Exp $ - package diskCacheV111.vehicles; import java.util.EnumSet; @@ -10,16 +8,25 @@ import static org.dcache.namespace.FileAttribute.ACCESS_LATENCY; import static org.dcache.namespace.FileAttribute.RETENTION_POLICY; -public class PoolAcceptFileMessage extends PoolIoFileMessage { - +public class PoolAcceptFileMessage extends PoolIoFileMessage +{ private static final long serialVersionUID = 7898737438685700742L; - public PoolAcceptFileMessage( String pool , - ProtocolInfo protocolInfo , - FileAttributes fileAttributes){ - super( pool , protocolInfo , fileAttributes ) ; + private final long _preallocated; + + public PoolAcceptFileMessage(String pool, + ProtocolInfo protocolInfo, + FileAttributes fileAttributes, + long preallocated) + { + super(pool, protocolInfo, fileAttributes); checkArgument(fileAttributes.isDefined( EnumSet.of(ACCESS_LATENCY, RETENTION_POLICY))); + _preallocated = preallocated; + } + public long getPreallocated() + { + return _preallocated; } } diff --git a/modules/dcache/src/main/java/org/dcache/util/Transfer.java b/modules/dcache/src/main/java/org/dcache/util/Transfer.java index fd5ee7c7aab..fd0cf658d82 100644 --- a/modules/dcache/src/main/java/org/dcache/util/Transfer.java +++ b/modules/dcache/src/main/java/org/dcache/util/Transfer.java @@ -834,8 +834,12 @@ public void startMover(String queue, long timeout) ProtocolInfo protocolInfo = getProtocolInfoForPool(); PoolIoFileMessage message; if (isWrite()) { + long allocated = _allocated; + if (allocated == 0 && fileAttributes.isDefined(SIZE)) { + allocated = fileAttributes.getSize(); + } message = - new PoolAcceptFileMessage(pool, protocolInfo, fileAttributes); + new PoolAcceptFileMessage(pool, protocolInfo, fileAttributes, allocated); } else { message = new PoolDeliverFileMessage(pool, protocolInfo, fileAttributes);