Skip to content

Commit 449651f

Browse files
committed
poolmanager: fix wrandom partition incompatibilities
1 parent fb04d1c commit 449651f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

modules/dcache/src/main/java/org/dcache/poolmanager/WRandomPartition.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Comparator;
1111
import java.util.List;
1212
import java.util.Map;
13+
import java.util.Optional;
1314
import java.util.Random;
1415

1516
import diskCacheV111.poolManager.CostModule;
@@ -63,29 +64,29 @@ public P2pPair selectPool2Pool(CostModule cm, List<PoolInfo> src, List<PoolInfo>
6364
filter(dst, new DifferentHost(srcPoolInfo.getHostName())));
6465

6566
if (!tryList.isEmpty()) {
66-
PoolInfo destPoolInfo = selectWritePool(cm, tryList, attributes, attributes.getSize());
67-
return new P2pPair(srcPoolInfo, destPoolInfo);
67+
SelectedPool destPoolInfo = selectWritePool(cm, tryList, attributes, attributes.getSize());
68+
return new P2pPair(new SelectedPool(srcPoolInfo), destPoolInfo);
6869
}
6970
}
7071

7172
return null;
7273
}
7374

7475
@Override
75-
public PoolInfo selectReadPool(CostModule cm, List<PoolInfo> pools, FileAttributes attributes) throws CacheException {
76-
return pools.get(_random.nextInt(pools.size()));
76+
public SelectedPool selectReadPool(CostModule cm, List<PoolInfo> pools, FileAttributes attributes) throws CacheException {
77+
return new SelectedPool(pools.get(_random.nextInt(pools.size())));
7778
}
7879

7980
@Override
80-
public PoolInfo selectStagePool(CostModule cm, List<PoolInfo> pools, String previousPool, String previousHost, FileAttributes attributes) throws CacheException {
81+
public SelectedPool selectStagePool(CostModule cm, List<PoolInfo> pools, Optional<PoolInfo> previousPool, FileAttributes attributes) throws CacheException {
8182
return selectWritePool(cm, pools, attributes, attributes.getSize());
8283
}
8384

8485
@Override
85-
public PoolInfo selectWritePool(CostModule cm, List<PoolInfo> pools, FileAttributes attributes, long preallocated) throws CacheException {
86+
public SelectedPool selectWritePool(CostModule cm, List<PoolInfo> pools, FileAttributes attributes, long preallocated) throws CacheException {
8687
WeightedPool weightedPools[] = toWeightedWritePoolsArray(pools);
8788
int index = selectWrandomIndex(weightedPools);
88-
return weightedPools[index].getCostInfo();
89+
return new SelectedPool(weightedPools[index].getCostInfo());
8990
}
9091

9192
private WeightedPool[] toWeightedWritePoolsArray(Collection<PoolInfo> costInfos) {

0 commit comments

Comments
 (0)