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;
}
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);
}
}
}
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);
}
});
}
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));
}
}
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;
}
Aggregations