Skip to content

Commit

Permalink
Revert "dcache-qos: remove trigger to rescan pools on tag change"
Browse files Browse the repository at this point in the history
This reverts commit 310889c.
  • Loading branch information
alrossi committed Jul 3, 2023
1 parent 310889c commit 70b9a43
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
10 changes: 0 additions & 10 deletions docs/TheBook/src/main/markdown/config-qos-engine.md
Expand Up @@ -1280,16 +1280,6 @@ be scheduled for scans.
>
> **Use the QoS transition to change existing disk+tape files to tape.**
### Changing pool tags

If a pool's tags are used to determine replica distribution (based on the storage
unit definition of `onlyOneCopyPer`) and these are changed, QoS will not automatically
force the pool to be scanned immediately upon restart (it will just be
scheduled for a restart scan based on the defined grace period).

> If it is desirable to rescan a pool's replicas immediately after its
> tags have been changed, this must be done manually (see above).
### Troubleshooting operations

Intervention to rectify qos handling should hopefully be needed infrequently;
Expand Down
Expand Up @@ -61,6 +61,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import diskCacheV111.poolManager.CostModule;
import diskCacheV111.poolManager.PoolSelectionUnit;
import diskCacheV111.poolManager.PoolSelectionUnit.SelectionPool;
import diskCacheV111.poolManager.PoolSelectionUnit.SelectionPoolGroup;
Expand All @@ -69,9 +70,11 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import diskCacheV111.poolManager.StorageUnitInfoExtractor;
import diskCacheV111.pools.PoolV2Mode;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import org.dcache.poolmanager.PoolInfo;
import org.dcache.poolmanager.PoolMonitor;
import org.dcache.qos.data.PoolQoSStatus;
import org.dcache.qos.services.scanner.data.PoolFilter;
Expand Down Expand Up @@ -114,6 +117,7 @@ public synchronized PoolOpDiff reloadAndScan(PoolMonitor newPoolMonitor) {
diff.getPoolsAddedToPoolGroup().removeAll(p);
diff.getPoolsRemovedFromPoolGroup().removeAll(p);
diff.getModeChanged().remove(p);
diff.getTagsChanged().remove(p);
});

PoolSelectionUnit currentPsu = newPoolMonitor.getPoolSelectionUnit();
Expand Down Expand Up @@ -153,6 +157,16 @@ public synchronized PoolOpDiff reloadAndScan(PoolMonitor newPoolMonitor) {
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();
Expand Down Expand Up @@ -221,6 +235,9 @@ private PoolOpDiff compare(PoolMonitor currentPoolMonitor, PoolMonitor nextPoolM
LOGGER.trace("comparing pool mode");
comparePoolMode(diff, commonPools, nextPsu);

LOGGER.trace("comparing pool tags");
comparePoolTags(diff, commonPools, currentPoolMonitor, nextPoolMonitor);

return diff;
}

Expand Down Expand Up @@ -307,6 +324,24 @@ private void comparePoolsInPoolGroups(PoolOpDiff diff,
}
}

private void comparePoolTags(PoolOpDiff diff, Set<String> common, PoolMonitor current,
PoolMonitor next) {
CostModule currentCostModule = current.getCostModule();
CostModule nextCostModule = next.getCostModule();

diff.getNewPools()
.forEach(p -> diff.getTagsChanged().put(p, getPoolTags(p, nextCostModule)));

common.forEach(p -> {
Map<String, String> newTags = getPoolTags(p, nextCostModule);
Map<String, String> oldTags = getPoolTags(p, currentCostModule);
if (oldTags == null || (newTags != null
&& !oldTags.equals(newTags))) {
diff.getTagsChanged().put(p, newTags);
}
});
}

private Set<String> compareStorageUnits(PoolOpDiff diff,
PoolSelectionUnit currentPsu,
PoolSelectionUnit nextPsu) {
Expand Down Expand Up @@ -393,6 +428,14 @@ private Set<String> comparePoolGroups(PoolOpDiff diff,
return Sets.intersection(next, curr);
}

private Map<String, String> getPoolTags(String pool, CostModule costModule) {
PoolInfo poolInfo = costModule.getPoolInfo(pool);
if (poolInfo == null) {
return null;
}
return poolInfo.getTags();
}

/**
* Scans the "new" pool, also making sure all files have the sticky bit.
*/
Expand Down
Expand Up @@ -110,6 +110,12 @@ public final class PoolOpDiff {
*/
private final Map<String, PoolV2Mode> modeChanged = new HashMap<>();

/*
* (pool, tags)
*/
private final Map<String, Map<String, String>> tagsChanged
= new HashMap<>();

public Collection<String> getConstraintsChanged() {
return constraintsChanged;
}
Expand Down Expand Up @@ -154,6 +160,10 @@ public Multimap<String, String> getPoolsRemovedFromPoolGroup() {
return poolsRmved;
}

public Map<String, Map<String, String>> getTagsChanged() {
return tagsChanged;
}

public Collection<String> getUninitializedPools() {
return uninitPools;
}
Expand All @@ -172,7 +182,7 @@ public boolean isEmpty() {
&& newUnits.isEmpty() && oldUnits.isEmpty()
&& poolsAdded.isEmpty() && poolsRmved.isEmpty()
&& unitsAdded.isEmpty() && unitsRmved.isEmpty()
&& constraintsChanged.isEmpty()
&& constraintsChanged.isEmpty() && tagsChanged.isEmpty()
&& modeChanged.isEmpty();
}

Expand All @@ -189,12 +199,14 @@ public String toString() {
"Units Added: %s\n" +
"Units Removed: %s\n" +
"Constraints changed: %s\n" +
"Mode changed: %s\n",
"Mode changed: %s\n" +
"Tags changed: %s\n",
newPools, oldPools, uninitPools,
newGroups, oldGroups,
newUnits, oldUnits,
poolsAdded, poolsRmved,
unitsAdded, unitsRmved,
constraintsChanged, modeChanged);
constraintsChanged, modeChanged,
tagsChanged);
}
}

0 comments on commit 70b9a43

Please sign in to comment.