From 449651ff22c88582ad13c32fe400c36ebedb7a10 Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Thu, 21 Sep 2023 21:52:22 +0200 Subject: [PATCH] poolmanager: fix wrandom partition incompatibilities --- .../org/dcache/poolmanager/WRandomPartition.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/dcache/src/main/java/org/dcache/poolmanager/WRandomPartition.java b/modules/dcache/src/main/java/org/dcache/poolmanager/WRandomPartition.java index 71ee6d6fdcc..841293733f6 100644 --- a/modules/dcache/src/main/java/org/dcache/poolmanager/WRandomPartition.java +++ b/modules/dcache/src/main/java/org/dcache/poolmanager/WRandomPartition.java @@ -10,6 +10,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Random; import diskCacheV111.poolManager.CostModule; @@ -63,8 +64,8 @@ public P2pPair selectPool2Pool(CostModule cm, List src, List filter(dst, new DifferentHost(srcPoolInfo.getHostName()))); if (!tryList.isEmpty()) { - PoolInfo destPoolInfo = selectWritePool(cm, tryList, attributes, attributes.getSize()); - return new P2pPair(srcPoolInfo, destPoolInfo); + SelectedPool destPoolInfo = selectWritePool(cm, tryList, attributes, attributes.getSize()); + return new P2pPair(new SelectedPool(srcPoolInfo), destPoolInfo); } } @@ -72,20 +73,20 @@ public P2pPair selectPool2Pool(CostModule cm, List src, List } @Override - public PoolInfo selectReadPool(CostModule cm, List pools, FileAttributes attributes) throws CacheException { - return pools.get(_random.nextInt(pools.size())); + public SelectedPool selectReadPool(CostModule cm, List pools, FileAttributes attributes) throws CacheException { + return new SelectedPool(pools.get(_random.nextInt(pools.size()))); } @Override - public PoolInfo selectStagePool(CostModule cm, List pools, String previousPool, String previousHost, FileAttributes attributes) throws CacheException { + public SelectedPool selectStagePool(CostModule cm, List pools, Optional previousPool, FileAttributes attributes) throws CacheException { return selectWritePool(cm, pools, attributes, attributes.getSize()); } @Override - public PoolInfo selectWritePool(CostModule cm, List pools, FileAttributes attributes, long preallocated) throws CacheException { + public SelectedPool selectWritePool(CostModule cm, List pools, FileAttributes attributes, long preallocated) throws CacheException { WeightedPool weightedPools[] = toWeightedWritePoolsArray(pools); int index = selectWrandomIndex(weightedPools); - return weightedPools[index].getCostInfo(); + return new SelectedPool(weightedPools[index].getCostInfo()); } private WeightedPool[] toWeightedWritePoolsArray(Collection costInfos) {