use of diskCacheV111.pools.PoolV2Mode in project dcache by dCache.
the class PoolOpChangeHandler method comparePoolMode.
private void comparePoolMode(PoolOpDiff diff, Set<String> commonPools, PoolSelectionUnit psu) {
/*
* First add the info for all new pools to the diff.
*/
diff.getNewPools().stream().forEach((p) -> {
diff.getModeChanged().put(p, psu.getPool(p).getPoolMode());
});
/*
* Now check for differences with current pools that are still valid.
*/
commonPools.stream().forEach((p) -> {
PoolV2Mode newMode = psu.getPool(p).getPoolMode();
PoolQoSStatus oldStatus = poolOperationMap.getCurrentStatus(p);
PoolQoSStatus newStatus = PoolQoSStatus.valueOf(newMode);
if (newStatus != oldStatus) {
diff.getModeChanged().put(p, newMode);
}
});
}
use of diskCacheV111.pools.PoolV2Mode in project dcache by dCache.
the class PoolInfoMap method setPoolInfo.
/**
* Called under write lock
*/
private void setPoolInfo(String pool, PoolV2Mode mode, ImmutableMap<String, String> tags, PoolCostInfo cost) {
Integer pindex = safeIndexOf(pool, pools);
PoolInformation entry = new PoolInformation(pool, pindex);
entry.update(mode, tags, cost);
poolInfo.put(pindex, entry);
}
use of diskCacheV111.pools.PoolV2Mode in project dcache by dCache.
the class PoolInfoMap method comparePoolInfo.
/**
* Called under read lock
*/
private void comparePoolInfo(PoolInfoDiff diff, Set<String> commonPools, PoolMonitor poolMonitor) {
PoolSelectionUnit psu = poolMonitor.getPoolSelectionUnit();
CostModule costModule = poolMonitor.getCostModule();
/*
* First add the info for all new pools to the diff.
*/
diff.getNewPools().stream().forEach((p) -> {
diff.getModeChanged().put(p, getPoolMode(psu.getPool(p)));
diff.getTagsChanged().put(p, getPoolTags(p, costModule));
diff.getPoolCost().put(p, getPoolCostInfo(p, costModule));
});
/*
* Now check for differences with current pools that are still valid.
*/
commonPools.stream().forEach((p) -> {
PoolInformation info = poolInfo.get(getPoolIndex(p));
PoolV2Mode newMode = getPoolMode(psu.getPool(p));
PoolV2Mode oldMode = info.getMode();
if (oldMode == null || (newMode != null && !oldMode.equals(newMode))) {
diff.getModeChanged().put(p, newMode);
}
ImmutableMap<String, String> newTags = getPoolTags(p, costModule);
ImmutableMap<String, String> oldTags = info.getTags();
if (oldTags == null || (newTags != null && !oldTags.equals(newTags))) {
diff.getTagsChanged().put(p, newTags);
}
/*
* Since we are not altering the actual collections inside
* the PoolInfoMap, but are simply modifying the PoolInformation
* object, and since its own update method is synchronized,
* we can take care of the update here while holding a read lock.
*/
info.update(newMode, newTags, getPoolCostInfo(p, costModule));
});
}
use of diskCacheV111.pools.PoolV2Mode in project dcache by dCache.
the class TestBase method initializePoolInfoMap.
protected void initializePoolInfoMap() {
poolInfoMap.apply(poolInfoMap.compare(testPoolMonitor));
testSelectionUnit.getAllDefinedPools(false).stream().forEach((p) -> {
PoolStateUpdate update = new PoolStateUpdate(p.getName(), new PoolV2Mode(PoolV2Mode.ENABLED));
poolInfoMap.updatePoolStatus(update);
});
}
use of diskCacheV111.pools.PoolV2Mode in project dcache by dCache.
the class CostModuleTest method buildPoolUpMessageWithCost.
/**
* Create a pool-up message for a pool with the given space parameters
*
* @param poolName name of the pool
* @param totalSpace total capacity of the pool in Gigabytes
* @param freeSpace space not yet used in Gigabytes
* @param preciousSpace space used by files marked precious in Gigabytes
* @param removableSpace space used by files that are removable in Gigabytes
* @return
*/
private static PoolManagerPoolUpMessage buildPoolUpMessageWithCost(String poolName, long totalSpace, long freeSpace, long preciousSpace, long removableSpace) {
PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
PoolCostInfo poolCost = new PoolCostInfo(poolName, IoQueueManager.DEFAULT_QUEUE);
poolCost.setSpaceUsage(GiB.toBytes(totalSpace), GiB.toBytes(freeSpace), GiB.toBytes(preciousSpace), GiB.toBytes(removableSpace));
long serialId = System.currentTimeMillis();
return new PoolManagerPoolUpMessage(poolName, serialId, poolMode, poolCost);
}
Aggregations