Skip to content

Commit

Permalink
Add preallocation field to PoolAcceptFileMessage
Browse files Browse the repository at this point in the history
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 <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6386/
  • Loading branch information
gbehrmann committed Jan 9, 2014
1 parent 4c41bd1 commit 98012be
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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() ) ;
Expand Down
Expand Up @@ -423,7 +423,8 @@ public void startMoverOnThePool()
? new PoolAcceptFileMessage(
pool,
protocol_info,
fileAttributes)
fileAttributes,
(size == null) ? 0L : size)
: new PoolDeliverFileMessage(
pool,
protocol_info,
Expand Down
@@ -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;
Expand All @@ -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;
}
}
6 changes: 5 additions & 1 deletion modules/dcache/src/main/java/org/dcache/util/Transfer.java
Expand Up @@ -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);
Expand Down

0 comments on commit 98012be

Please sign in to comment.