Skip to content

Commit f31e94b

Browse files
committed
poolmanager: Clarify use of preallocated space in pool selection
Pool manager can make use of the fie size or preallocated space during write pool selection. The field is unused for all other pool selections, yet the field is present in the base class. This makes the purpose of the field less clear than it should be. This patch moves the field to the write pool selection message and the field is changed to precallocated to reflect its use. It differs from the file size in storage info/file attributes by being a preallocation, not an exact size of the final file. It is only ever used when locating a pool with enough free space. Some DCAP specific code is moved from pool manager to the DCAP door. The patch also makes file size and checksum attributes required for read pool selection. These should be available to a pool when staging a file or copying it between pools. Target: trunk Require-book: no Require-notes: no Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> Patch: http://rb.dcache.org/r/5322
1 parent d180e90 commit f31e94b

25 files changed

+136
-163
lines changed

modules/dcache-dcap/src/main/java/diskCacheV111/doors/DCapDoorInterpreterV3.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,16 @@ public void fileAttributesAvailable()
21412141
//
21422142
// try to get some space to store the file.
21432143
//
2144-
getPoolMessage = new PoolMgrSelectWritePoolMsg(_fileAttributes,_protocolInfo,0) ;
2144+
long preallocated = 0L;
2145+
String value = _fileAttributes.getStorageInfo().getKey("alloc-size");
2146+
if (value != null) {
2147+
try {
2148+
preallocated = Long.parseLong(value);
2149+
} catch (NumberFormatException e) {
2150+
// bad values are ignored
2151+
}
2152+
}
2153+
getPoolMessage = new PoolMgrSelectWritePoolMsg(_fileAttributes, _protocolInfo, preallocated);
21452154
getPoolMessage.setIoQueueName(_ioQueueName );
21462155
if( _path != null ) {
21472156
getPoolMessage.setPnfsPath(_path);
@@ -2181,7 +2190,6 @@ public void fileAttributesAvailable()
21812190
getPoolMessage =
21822191
new PoolMgrSelectReadPoolMsg(_fileAttributes,
21832192
_protocolInfo,
2184-
0,
21852193
_readPoolSelectionContext,
21862194
allowedStates);
21872195
getPoolMessage.setIoQueueName(_ioQueueName );

modules/dcache/src/main/java/diskCacheV111/admin/UserAdminShell.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,7 @@ private PnfsFlagReply setPnfsFlag(
10051005

10061006

10071007
PoolMgrReplicateFileMsg select =
1008-
new PoolMgrReplicateFileMsg(fileAttributesMsg.getFileAttributes(),
1009-
pinfo, 0L);
1008+
new PoolMgrReplicateFileMsg(fileAttributesMsg.getFileAttributes(), pinfo);
10101009

10111010
msg = new CellMessage( new CellPath("PoolManager"),select ) ;
10121011

modules/dcache/src/main/java/diskCacheV111/poolManager/CostModuleV1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public synchronized void messageToForward(PoolMgrSelectPoolMsg msg)
397397

398398
int diff = 1;
399399
long pinned =
400-
(msg instanceof PoolMgrSelectWritePoolMsg) ? msg.getFileSize() : 0;
400+
(msg instanceof PoolMgrSelectWritePoolMsg) ? ((PoolMgrSelectWritePoolMsg) msg).getPreallocated() : 0;
401401
queue.modifyQueue(diff);
402402
spaceInfo.modifyPinnedSpace(pinned);
403403
considerInvalidatingCache(currentPerformanceCost, costInfo);

modules/dcache/src/main/java/diskCacheV111/poolManager/PoolManagerV5.java

100755100644
Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,9 @@ public String apply(PoolSelectionUnit.SelectionPool pool) {
483483
throw new CacheException(57, "No appropriate pools found for link: " + linkName);
484484
}
485485

486-
FileAttributes fileAttributes = new FileAttributes();
487-
fileAttributes.setSize(filesize);
488486
Partition partition =
489487
_poolMonitor.getPartitionManager().getPartition(link.getTag());
490-
msg.setPoolName(partition.selectWritePool(_costModule, pools, fileAttributes).getName());
488+
msg.setPoolName(partition.selectWritePool(_costModule, pools, new FileAttributes(), filesize).getName());
491489
msg.setSucceeded();
492490
return msg;
493491
}
@@ -673,8 +671,8 @@ public void setFileSize( long fileSize ){}
673671
}
674672
*/
675673

676-
private boolean quotasExceeded( StorageInfo info ){
677-
674+
private boolean quotasExceeded(FileAttributes fileAttributes) {
675+
StorageInfo info = fileAttributes.getStorageInfo();
678676
String storageClass = info.getStorageClass()+"@"+info.getHsm() ;
679677

680678
QuotaMgrCheckQuotaMessage quotas = new QuotaMgrCheckQuotaMessage( storageClass ) ;
@@ -702,28 +700,6 @@ private boolean quotasExceeded( StorageInfo info ){
702700

703701
}
704702

705-
private long determineExpectedFileSize(long expectedLength, StorageInfo storageInfo)
706-
{
707-
if (expectedLength > 0) {
708-
return expectedLength;
709-
}
710-
711-
if (storageInfo.getFileSize() > 0) {
712-
return storageInfo.getFileSize();
713-
}
714-
715-
String s = storageInfo.getKey("alloc-size");
716-
if (s != null) {
717-
try {
718-
return Long.parseLong(s);
719-
} catch (NumberFormatException e) {
720-
// bad values are ignored
721-
}
722-
}
723-
724-
return 0;
725-
}
726-
727703
public DelayedReply messageArrived(PoolManagerSelectLinkGroupForWriteMessage message)
728704
{
729705
if (message.getStorageInfo() == null) {
@@ -852,43 +828,23 @@ public WriteRequestHandler(CellMessage envelope,
852828

853829
@Override
854830
public void run(){
831+
FileAttributes fileAttributes = _request.getFileAttributes();
832+
StorageInfo storageInfo = fileAttributes.getStorageInfo();
833+
ProtocolInfo protocolInfo = _request.getProtocolInfo();
855834

856-
StorageInfo storageInfo = _request.getStorageInfo() ;
857-
ProtocolInfo protocolInfo = _request.getProtocolInfo() ;
858-
859-
_log.info( _pnfsId.toString()+" write handler started" );
835+
_log.info("{} write handler started", _pnfsId);
860836
long started = System.currentTimeMillis();
861837

862-
if( storageInfo == null ){
863-
requestFailed( 21 , "Storage info not available for write request : "+_pnfsId ) ;
864-
return ;
865-
}else if( protocolInfo == null ){
866-
requestFailed( 22 , "Protocol info not available for write request : "+_pnfsId ) ;
867-
return ;
868-
}
869-
if( _quotasEnabled && quotasExceeded( storageInfo ) ){
838+
if( _quotasEnabled && quotasExceeded(fileAttributes) ){
870839
requestFailed( 55 , "Quotas Exceeded for StorageClass : "+storageInfo.getStorageClass() ) ;
871840
return ;
872841
}
873842

874-
long expectedLength =
875-
determineExpectedFileSize(_request.getFileSize(), storageInfo);
876-
877-
/* The cost module relies on the expected file size.
878-
*/
879-
_request.setFileSize(expectedLength);
880-
881-
try{
882-
883-
FileAttributes fileAttributes = new FileAttributes();
884-
fileAttributes.setPnfsId(_pnfsId);
885-
fileAttributes.setStorageInfo(storageInfo);
886-
fileAttributes.setSize(expectedLength);
843+
try {
887844
PoolInfo pool =
888845
_poolMonitor
889-
.getPoolSelector(fileAttributes, protocolInfo, _request
890-
.getLinkGroup())
891-
.selectWritePool();
846+
.getPoolSelector(fileAttributes, protocolInfo, _request.getLinkGroup())
847+
.selectWritePool(_request.getPreallocated());
892848

893849
_log.info("{} write handler selected {} after {} ms", _pnfsId, pool.getName(),
894850
System.currentTimeMillis() - started);

modules/dcache/src/main/java/diskCacheV111/poolManager/PoolMonitorV5.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public List<List<PoolInfo>> getReadPools()
172172
}
173173

174174
@Override
175-
public PoolInfo selectWritePool()
175+
public PoolInfo selectWritePool(long preallocated)
176176
throws CacheException
177177
{
178178
PoolPreferenceLevel[] levels = match(DirectionType.WRITE);
@@ -191,7 +191,7 @@ public PoolInfo selectWritePool()
191191
if (!pools.isEmpty()) {
192192
Partition partition =
193193
_partitionManager.getPartition(level.getTag());
194-
return partition.selectWritePool(_costModule, pools, _fileAttributes);
194+
return partition.selectWritePool(_costModule, pools, _fileAttributes, preallocated);
195195
}
196196
}
197197

modules/dcache/src/main/java/diskCacheV111/poolManager/RequestContainerV5.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,7 @@ public void messageArrived(CellMessage envelope,
673673
new PoolMgrReplicateFileMsg(fileAttributes,
674674
new DCapProtocolInfo("DCap", 3, 0,
675675
new InetSocketAddress(args.argv(1),
676-
2222)),
677-
fileAttributes.getStorageInfo().getFileSize());
676+
2222)));
678677

679678
sendMessage( new CellMessage(new CellPath("PoolManager"), req) );
680679

modules/dcache/src/main/java/diskCacheV111/services/TransferManagerHandler.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ public void createEntryResponseArrived(PnfsCreateEntryMessage create)
333333
manager.persist(this);
334334

335335
fileAttributes = create.getFileAttributes();
336+
if (size != null) {
337+
fileAttributes.setSize(size);
338+
}
336339
pnfsId = create.getPnfsId();
337340
pnfsIdString = pnfsId.toString();
338341
info.setPnfsId(pnfsId);
@@ -349,7 +352,7 @@ public void storageInfoArrived(PnfsGetStorageInfoMessage storage_info_msg)
349352
return;
350353
}
351354
if(!store && tlog != null) {
352-
tlog.middle(storage_info_msg.getStorageInfo().getFileSize());
355+
tlog.middle(storage_info_msg.getFileAttributes().getSize());
353356
}
354357
//
355358
// Added by litvinse@fnal.gov
@@ -385,18 +388,9 @@ public void storageInfoArrived(PnfsGetStorageInfoMessage storage_info_msg)
385388
public void selectPool()
386389
{
387390
protocol_info = manager.getProtocolInfo(transferRequest);
388-
long sizeToSend =transferRequest.getSize() == null ? 0L: transferRequest
389-
.getSize();
390-
PoolMgrSelectPoolMsg request =
391-
store ?
392-
new PoolMgrSelectWritePoolMsg(fileAttributes,
393-
protocol_info,
394-
sizeToSend)
395-
:
396-
new PoolMgrSelectReadPoolMsg(fileAttributes,
397-
protocol_info,
398-
sizeToSend,
399-
_readPoolSelectionContext);
391+
PoolMgrSelectPoolMsg request = store
392+
? new PoolMgrSelectWritePoolMsg(fileAttributes, protocol_info, (size == null) ? 0L: size)
393+
: new PoolMgrSelectReadPoolMsg(fileAttributes, protocol_info, _readPoolSelectionContext);
400394
request.setPnfsPath(pnfsPath);
401395
request.setSubject(transferRequest.getSubject());
402396
log.debug("PoolMgrSelectPoolMsg: " + request );

modules/dcache/src/main/java/diskCacheV111/services/space/Manager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4820,6 +4820,7 @@ public void selectPool(CellMessage cellMessage,
48204820
}
48214821
return;
48224822
}
4823+
PoolMgrSelectWritePoolMsg selectWritePool = (PoolMgrSelectWritePoolMsg) selectPool;
48234824
File file = null;
48244825
try {
48254826
logger.debug("selectPool: getFiles({})", pnfsPath);
@@ -4835,15 +4836,15 @@ public void selectPool(CellMessage cellMessage,
48354836
logger.info("failed to find pool: {}", e.getMessage());
48364837
}
48374838
if(file==null) {
4838-
StorageInfo storageInfo = selectPool.getStorageInfo();
4839+
StorageInfo storageInfo = selectWritePool.getStorageInfo();
48394840
AccessLatency al;
48404841
RetentionPolicy rp;
48414842
String defaultSpaceToken;
48424843
al = storageInfo.getAccessLatency();
48434844
rp = storageInfo.getRetentionPolicy();
48444845
defaultSpaceToken=storageInfo.getMap().get("writeToken");
4845-
ProtocolInfo protocolInfo = selectPool.getProtocolInfo();
4846-
Subject subject = selectPool.getSubject();
4846+
ProtocolInfo protocolInfo = selectWritePool.getProtocolInfo();
4847+
Subject subject = selectWritePool.getSubject();
48474848
AuthorizationRecord authRecord;
48484849
if (Subjects.getFqans(subject).isEmpty()&&
48494850
Subjects.getUserName(subject)==null) {
@@ -4860,8 +4861,8 @@ public void selectPool(CellMessage cellMessage,
48604861
"calling reserveAndUseSpace()");
48614862

48624863
file = reserveAndUseSpace(pnfsPath,
4863-
null, // selectPool.getPnfsId(),
4864-
selectPool.getFileSize(),
4864+
null, // selectWritePool.getPnfsId(),
4865+
selectWritePool.getPreallocated(),
48654866
al,
48664867
rp,
48674868
authRecord,
@@ -4900,21 +4901,21 @@ public void selectPool(CellMessage cellMessage,
49004901
long fileId = useSpace(spaceToken,
49014902
voGroup,
49024903
voRole,
4903-
selectPool.getFileSize(),
4904+
selectWritePool.getPreallocated(),
49044905
lifetime,
49054906
pnfsPath,
4906-
selectPool.getPnfsId());
4907+
selectWritePool.getPnfsId());
49074908
file = getFile(fileId);
49084909
}
49094910
}
49104911
else {
4911-
if (isReply&&selectPool.getReturnCode()==0) {
4912+
if (isReply&&selectWritePool.getReturnCode()==0) {
49124913
logger.debug("selectPool: file is not null, " +
49134914
"calling updateSpaceFile()");
49144915
updateSpaceFile(file.getId(),null,null,pnfsId,null,null,null);
49154916
}
49164917
}
4917-
if (isReply&&selectPool.getReturnCode()!=0) {
4918+
if (isReply&&selectWritePool.getReturnCode()!=0) {
49184919
Connection connection = null;
49194920
try {
49204921
connection = connection_pool.getConnection();
@@ -4948,8 +4949,8 @@ public void selectPool(CellMessage cellMessage,
49484949
long linkGroupid = space.getLinkGroupId();
49494950
LinkGroup linkGroup = getLinkGroup(linkGroupid);
49504951
String linkGroupName = linkGroup.getName();
4951-
selectPool.setLinkGroup(linkGroupName);
4952-
StorageInfo storageInfo = selectPool.getStorageInfo();
4952+
selectWritePool.setLinkGroup(linkGroupName);
4953+
StorageInfo storageInfo = selectWritePool.getStorageInfo();
49534954
storageInfo.setKey("SpaceToken",Long.toString(spaceId));
49544955
if (storageInfo.getFileSize() == 0 &&
49554956
file.getSizeInBytes() > 1) {

modules/dcache/src/main/java/diskCacheV111/srm/dcache/PinCompanion.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ public BringOnlineState() {
216216
PoolMgrSelectReadPoolMsg msg =
217217
new PoolMgrSelectReadPoolMsg(_attributes,
218218
getProtocolInfo(),
219-
_attributes.getSize(),
220219
_selectPoolContext);
221220
msg.setSkipCostUpdate(true);
222221
msg.setSubject(_subject);

modules/dcache/src/main/java/diskCacheV111/vehicles/PoolMgrReplicateFileMsg.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class PoolMgrReplicateFileMsg extends PoolMgrSelectReadPoolMsg {
2020
private int _destinationFileStatus = Pool2PoolTransferMsg.UNDETERMINED ;
2121

2222
/** Creates a new instance of PoolMgrReplicateFile */
23-
public PoolMgrReplicateFileMsg(FileAttributes fileAttributes, ProtocolInfo protocolInfo, long fileSize)
23+
public PoolMgrReplicateFileMsg(FileAttributes fileAttributes, ProtocolInfo protocolInfo)
2424
{
25-
super(fileAttributes, protocolInfo, fileSize, null);
25+
super(fileAttributes, protocolInfo, null);
2626
}
2727
public void setAllowRestore( boolean allowRestore ){
2828
_allowRestore = allowRestore ;

0 commit comments

Comments
 (0)