Skip to content

Commit

Permalink
Revert "poolmanager: delete property for switchingon/off caching for …
Browse files Browse the repository at this point in the history
…psu"

This reverts commit c0c11f4.

Motivation:
Reverting this patch has been shown to fix the issue in which poolmanager will in some instances not load parts of its configuration.

Target: master, 9.2
Requires-book: no
Requires-notes: no
Addresses: RT #10575
Acked-by: Tigran Mkrtchyan
  • Loading branch information
lemora committed Feb 22, 2024
1 parent 861b5a1 commit 2346902
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 17 deletions.
Expand Up @@ -102,6 +102,7 @@ public String getVersion() {
.build();
private boolean _useRegex;
private boolean _allPoolsActive;
public boolean _cachingEnabeled;

/**
* Ok, this is the critical part of PoolManager, but (!!!) the whole select path is READ-ONLY,
Expand All @@ -115,6 +116,12 @@ public String getVersion() {

private final NetHandler _netHandler = new NetHandler();
private transient PnfsHandler _pnfsHandler;

public void setCachingEnabeled(boolean cachingEnabeled) {
_cachingEnabeled = cachingEnabeled;
}


@Override
public Map<String, SelectionLink> getLinks() {
rlock();
Expand Down Expand Up @@ -655,28 +662,36 @@ public PoolPreferenceLevel[] match(DirectionType type, String netUnitName,
type, storeUnitName, dCacheUnitName, netUnitName, protocolUnitName,
variableMap, storageInfo.locations(), linkGroupName);



String cacheKey = null;
try {
Unit unit = _netHandler.match(netUnitName);
netUnitGroup = unit._uGroupList.values()
.stream()
.map(UGroup::getName).findFirst().get();
if (_cachingEnabeled) {

try {
Unit unit = _netHandler.match(netUnitName);
netUnitGroup = unit._uGroupList.values()
.stream()
.map(UGroup::getName).findFirst().get();

LOGGER.debug("this IP address belongs to {} in uGroup {} ", netUnitName, netUnitGroup);
LOGGER.debug("this IP address belongs to {} in uGroup {} ", netUnitName, netUnitGroup);


} catch (UnknownHostException e) {
LOGGER.error("Caching did not work, please check the configuration " + e);
}
} catch (UnknownHostException e) {
LOGGER.error("Caching did not work, please check the configuration " + e);
}

cacheKey = type.toString() + storeUnitName + dCacheUnitName +
netUnitGroup + protocolUnitName + linkGroupName;
cacheKey = type.toString() + storeUnitName + dCacheUnitName +
netUnitGroup + protocolUnitName + linkGroupName;

PoolPreferenceLevel[] cachedMatchValueTmp = cachedMatchValue.getIfPresent(cacheKey);
if (cachedMatchValueTmp != null) {
return cachedMatchValueTmp;
PoolPreferenceLevel[] cachedMatchValueTmp = cachedMatchValue.getIfPresent(cacheKey);
if (cachedMatchValueTmp != null) {
//counter = counter + 1;
//System.out.println("counter " + counter);
return cachedMatchValueTmp;

}
}

PoolPreferenceLevel[] result = null;
rlock();
try {
Expand All @@ -699,7 +714,9 @@ public PoolPreferenceLevel[] match(DirectionType type, String netUnitName,
if (LOGGER.isDebugEnabled()) {
logResult(result);
}
cachedMatchValue.put(cacheKey, result);
if (_cachingEnabeled){
cachedMatchValue.put(cacheKey, result);
}
return result;
}

Expand Down Expand Up @@ -1157,7 +1174,7 @@ public void setAllPoolsActive(String mode) {
break;
default:
throw new IllegalArgumentException(
"Syntax error, no such mode: " + mode);
"Syntax error," + " no such mode: " + mode);
}
} finally {
wunlock();
Expand Down Expand Up @@ -2629,8 +2646,11 @@ private String poolCountDescriptionFor(int count) {
}

protected void wlock() {

_psuWriteLock.lock();
cachedMatchValue.invalidateAll();
if (_cachingEnabeled) {
cachedMatchValue.invalidateAll();
}
}

protected void wunlock() {
Expand Down
Expand Up @@ -334,6 +334,8 @@ public void testTheSameCached() throws CommandException {
FileAttributes fileAttributes = new FileAttributes();
StorageInfos.injectInto(GenericStorageInfo.valueOf("*", "*"), fileAttributes);

_psu._cachingEnabeled = true;

PoolPreferenceLevel[] preferenceRes1 = _psu.match(
DirectionType.READ, // operation
"131.169.214.149", // net unit
Expand Down
8 changes: 8 additions & 0 deletions skel/share/defaults/poolmanager.properties
Expand Up @@ -114,3 +114,11 @@ poolmanager.request-notifier.timeout=1
(obsolete)poolmanager.cell.export = See poolmanager.cell.consume
(forbidden)poolmanager.plugins.selection-unit =
(forbidden)poolmanager.plugins.quota-manager =

#
# This property is used to optimise pool selection based on the idea that
# when a request is coming the probability that the next request for pool selection will
# have the same selection parameters is very high. depending on the set up you can switch on/ and off
# the caching of the selected pools.

(one-of?true|false)poolmanager.selection.unit.cachingenabeled = false

0 comments on commit 2346902

Please sign in to comment.