Search in sources :

Example 1 with PoolSelectionUnit

use of diskCacheV111.poolManager.PoolSelectionUnit in project dcache by dCache.

the class PoolOpChangeHandler method reloadAndScan.

public synchronized PoolOpDiff reloadAndScan(PoolMonitor newPoolMonitor) {
    LOGGER.trace("Comparing current pool info to new psu.");
    PoolOpDiff diff = compare(poolMonitor(), newPoolMonitor);
    if (diff.isEmpty()) {
        LOGGER.trace("reloadAndScan, nothing to do.");
        lastRefresh = System.currentTimeMillis();
        return diff;
    }
    LOGGER.trace("Cancelling pool operations for removed pools {}.", diff.getOldPools());
    diff.getOldPools().forEach(this::cancelAndRemoveCurrentPoolOperation);
    LOGGER.trace("Cancelling pool operations for pools removed from groups {}.", diff.getPoolsRemovedFromPoolGroup());
    diff.getPoolsRemovedFromPoolGroup().keySet().forEach(this::cancelCurrentPoolOperation);
    LOGGER.trace("Removing uninitialized from other sets.");
    diff.getUninitializedPools().forEach((p) -> {
        diff.getPoolsAddedToPoolGroup().removeAll(p);
        diff.getPoolsRemovedFromPoolGroup().removeAll(p);
        diff.getModeChanged().remove(p);
        diff.getTagsChanged().remove(p);
    });
    PoolSelectionUnit currentPsu = newPoolMonitor.getPoolSelectionUnit();
    LOGGER.trace("Adding new pools to the pool operation map.");
    diff.getNewPools().forEach(poolOperationMap::add);
    LOGGER.trace("Scanning pools added to pool groups.");
    diff.getPoolsAddedToPoolGroup().entries().forEach(g -> scanPoolAddedToPoolGroup(g, currentPsu));
    LOGGER.trace("Scanning pools removed from pool groups.");
    diff.getPoolsRemovedFromPoolGroup().entries().forEach(e -> scanPoolRemovedFromPoolGroup(e, currentPsu));
    LOGGER.trace("Scanning pool groups pointing to new units {}.", diff.getNewUnits());
    diff.getNewUnits().forEach(u -> scanPoolsWithStorageUnitModified(u.getName(), currentPsu));
    LOGGER.trace("Scanning pool groups with units whose " + "constraints have changed; new constraints {}.", diff.getConstraintsChanged());
    diff.getConstraintsChanged().forEach(u -> scanPoolsWithStorageUnitModified(u, currentPsu));
    LOGGER.trace("Alerting change of pool status.");
    diff.getModeChanged().entrySet().forEach(e -> poolOperationMap.handlePoolStatusChange(e.getKey(), PoolQoSStatus.valueOf(e.getValue())));
    LOGGER.trace("Rescanning the pool groups whose marker changed.");
    diff.getMarkerChanged().forEach(g -> scanPoolsOfModifiedPoolGroup(g, currentPsu));
    LOGGER.trace("Rescanning the pools with changed tags.");
    diff.getTagsChanged().keySet().stream().map(currentPsu::getPool).forEach(p -> poolOperationMap.scan(p.getName(), null, null, null, p.getPoolMode(), true));
    LOGGER.trace("Checking to see if previously uninitialized pools are now ready.");
    poolOperationMap.saveExcluded();
    lastRefresh = System.currentTimeMillis();
    LOGGER.trace("DIFF:\n{}", diff);
    LOGGER.trace("Swapping pool monitors");
    initializer.updatePoolMonitor(newPoolMonitor);
    poolOperationMap.setCurrentPsu(newPoolMonitor.getPoolSelectionUnit());
    return diff;
}
Also used : PoolSelectionUnit(diskCacheV111.poolManager.PoolSelectionUnit)

Example 2 with PoolSelectionUnit

use of diskCacheV111.poolManager.PoolSelectionUnit in project dcache by dCache.

the class PoolOpChangeHandler method comparePoolGroupMarkers.

private void comparePoolGroupMarkers(PoolOpDiff diff, Set<String> common, PoolSelectionUnit currentPsu, PoolSelectionUnit nextPsu) {
    for (String group : common) {
        SelectionPoolGroup nextPoolGroup = nextPsu.getPoolGroups().get(group);
        SelectionPoolGroup currPoolGroup = currentPsu.getPoolGroups().get(group);
        if (nextPoolGroup.isPrimary() != currPoolGroup.isPrimary()) {
            diff.getOldGroups().add(group);
            diff.getNewGroups().add(nextPoolGroup.getName());
            /*
                 * Only rescan groups whose marker changed.
                 */
            diff.getMarkerChanged().add(group);
        }
    }
}
Also used : SelectionPoolGroup(diskCacheV111.poolManager.PoolSelectionUnit.SelectionPoolGroup)

Example 3 with PoolSelectionUnit

use of diskCacheV111.poolManager.PoolSelectionUnit 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 4 with PoolSelectionUnit

use of diskCacheV111.poolManager.PoolSelectionUnit in project dcache by dCache.

the class PoolOpChangeHandler method addPoolGroupsForNewUnits.

private void addPoolGroupsForNewUnits(PoolOpDiff diff, PoolSelectionUnit nextPsu) {
    Collection<StorageUnit> newUnits = diff.getNewUnits();
    for (StorageUnit unit : newUnits) {
        String name = unit.getName();
        StorageUnitInfoExtractor.getPrimaryGroupsFor(name, nextPsu).forEach((g) -> diff.unitsAdded.put(g, name));
    }
}
Also used : StorageUnit(diskCacheV111.poolManager.StorageUnit)

Example 5 with PoolSelectionUnit

use of diskCacheV111.poolManager.PoolSelectionUnit in project dcache by dCache.

the class ALRPStorageUnitQoSProvider method fetchRequirements.

@Override
public FileQoSRequirements fetchRequirements(FileQoSUpdate update) throws QoSException {
    FileQoSRequirements descriptor = initialize(update);
    if (descriptor == null) {
        /*
             *  Should only happen when a CLEAR CACHE LOCATION finds no locations.
             */
        return null;
    }
    FileAttributes attributes = descriptor.getAttributes();
    AccessLatency accessLatency = attributes.getAccessLatency();
    RetentionPolicy retentionPolicy = attributes.getRetentionPolicy();
    String unitKey = attributes.getStorageClass() + "@" + attributes.getHsm();
    SelectionUnit unit = poolSelectionUnit().getStorageUnit(unitKey);
    if (!(unit instanceof StorageUnit)) {
        throw new QoSException(unitKey + " does not correspond to a storage unit; " + "cannot retrieve requirements for " + descriptor.getPnfsId());
    }
    StorageUnit storageUnit = (StorageUnit) unit;
    Integer required = storageUnit.getRequiredCopies();
    List<String> onlyOneCopyPer = storageUnit.getOnlyOneCopyPer();
    if (retentionPolicy == CUSTODIAL) {
        /*
             *  REVISIT -- currently we support only one tape location.
             */
        descriptor.setRequiredTape(1);
    } else {
        descriptor.setRequiredTape(0);
    }
    if (accessLatency == ONLINE) {
        /*
             *  REVISIT -- current override of file AL based on storage unit
             *  REVISIT -- eventually we will want to override the storage unit default for a given file
             */
        descriptor.setRequiredDisk(required == null ? 1 : required);
        if (onlyOneCopyPer != null) {
            descriptor.setPartitionKeys(new HashSet<>(onlyOneCopyPer));
        }
    } else {
        descriptor.setRequiredDisk(0);
    }
    LOGGER.debug("fetchRequirements for {}, returning {}.", update, descriptor);
    return descriptor;
}
Also used : AccessLatency(diskCacheV111.util.AccessLatency) SelectionUnit(diskCacheV111.poolManager.PoolSelectionUnit.SelectionUnit) PoolSelectionUnit(diskCacheV111.poolManager.PoolSelectionUnit) StorageUnit(diskCacheV111.poolManager.StorageUnit) QoSException(org.dcache.qos.QoSException) FileQoSRequirements(org.dcache.qos.data.FileQoSRequirements) FileAttributes(org.dcache.vehicles.FileAttributes) RetentionPolicy(diskCacheV111.util.RetentionPolicy)

Aggregations

PoolSelectionUnit (diskCacheV111.poolManager.PoolSelectionUnit)11 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)8 StorageUnit (diskCacheV111.poolManager.StorageUnit)5 SelectionPoolGroup (diskCacheV111.poolManager.PoolSelectionUnit.SelectionPoolGroup)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 SelectionPool (diskCacheV111.poolManager.PoolSelectionUnit.SelectionPool)3 SelectionUnit (diskCacheV111.poolManager.PoolSelectionUnit.SelectionUnit)3 StorageUnitInfoExtractor (diskCacheV111.poolManager.StorageUnitInfoExtractor)3 Collection (java.util.Collection)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 PoolMonitor (org.dcache.poolmanager.PoolMonitor)3 FileAttributes (org.dcache.vehicles.FileAttributes)3 Sets (com.google.common.collect.Sets)2 CostModule (diskCacheV111.poolManager.CostModule)2 PoolManagerPoolInformation (diskCacheV111.vehicles.PoolManagerPoolInformation)2 CommandInterpreter (dmg.util.CommandInterpreter)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1