Search in sources :

Example 1 with PoolV2Mode

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);
        }
    });
}
Also used : PoolV2Mode(diskCacheV111.pools.PoolV2Mode) PoolQoSStatus(org.dcache.qos.data.PoolQoSStatus)

Example 2 with PoolV2Mode

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);
}
Also used : PoolManagerPoolInformation(diskCacheV111.vehicles.PoolManagerPoolInformation)

Example 3 with PoolV2Mode

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));
    });
}
Also used : PoolV2Mode(diskCacheV111.pools.PoolV2Mode) CostModule(diskCacheV111.poolManager.CostModule) PoolSelectionUnit(diskCacheV111.poolManager.PoolSelectionUnit) PoolManagerPoolInformation(diskCacheV111.vehicles.PoolManagerPoolInformation)

Example 4 with PoolV2Mode

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);
    });
}
Also used : PoolV2Mode(diskCacheV111.pools.PoolV2Mode) PoolStateUpdate(org.dcache.resilience.data.PoolStateUpdate)

Example 5 with PoolV2Mode

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);
}
Also used : PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) PoolCostInfo(diskCacheV111.pools.PoolCostInfo)

Aggregations

PoolV2Mode (diskCacheV111.pools.PoolV2Mode)48 PoolStateUpdate (org.dcache.resilience.data.PoolStateUpdate)10 Test (org.junit.Test)10 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)9 PoolManagerPoolUpMessage (diskCacheV111.vehicles.PoolManagerPoolUpMessage)9 CellAddressCore (dmg.cells.nucleus.CellAddressCore)8 CellMessage (dmg.cells.nucleus.CellMessage)6 CellPath (dmg.cells.nucleus.CellPath)5 PnfsId (diskCacheV111.util.PnfsId)4 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 FileAttribute (org.dcache.namespace.FileAttribute)4 MessageAction (org.dcache.tests.cells.MockCellEndpoint.MessageAction)4 FileAttributes (org.dcache.vehicles.FileAttributes)4 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)4 PoolFetchFileMessage (diskCacheV111.vehicles.PoolFetchFileMessage)3 Args (org.dcache.util.Args)3