Skip to content

Commit

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

commit 1bda804eecff6d7af73b46c8057ef9158abe48b8 ( https://rb.dcache.org/r/13835/) has introduced caching psu prefferences based on

poolmanager.selection.unit.cachingenabeled property.

This property is useless and the caching should be always on.

Rusult

Code optimasation and less confusion for admins

Target: master
Patch: https://rb.dcache.org/r/
Acked-by: Albert Rossi
Requires-notes: no
  • Loading branch information
mksahakyan committed May 6, 2023
1 parent 9a2291c commit c0c11f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 46 deletions.
Expand Up @@ -102,7 +102,6 @@ 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 @@ -116,12 +115,6 @@ 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 @@ -662,36 +655,29 @@ public PoolPreferenceLevel[] match(DirectionType type, String netUnitName,
type, storeUnitName, dCacheUnitName, netUnitName, protocolUnitName,
variableMap, storageInfo.locations(), linkGroupName);



String cacheKey = null;
if (_cachingEnabeled) {

try {
Unit unit = _netHandler.match(netUnitName);
netUnitGroup = unit._uGroupList.values()
.stream()
.map(UGroup::getName).findFirst().get();
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) {
//counter = counter + 1;
//System.out.println("counter " + counter);
return cachedMatchValueTmp;
PoolPreferenceLevel[] cachedMatchValueTmp = cachedMatchValue.getIfPresent(cacheKey);
if (cachedMatchValueTmp != null) {
return cachedMatchValueTmp;

}
}

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

Expand Down Expand Up @@ -2646,11 +2630,8 @@ private String poolCountDescriptionFor(int count) {
}

protected void wlock() {

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

protected void wunlock() {
Expand Down
Expand Up @@ -334,8 +334,6 @@ 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: 0 additions & 8 deletions skel/share/defaults/poolmanager.properties
Expand Up @@ -114,11 +114,3 @@ 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 c0c11f4

Please sign in to comment.