Skip to content

Commit

Permalink
dcache-chimera: use RemotePoolMonitor to discover file locality
Browse files Browse the repository at this point in the history
Motivation:
The DCacheAwareJdbcFs exposes file locality and uses in instance of
RemotePoolMonitor for that. Unfortunately, a new instance is requested
for each requests, which is more expensive, than directly querying the
PoolManager.

Modification:
Update DCacheAwareJdbcFs to a single instance of RemotePoolMonitor.
Update nfs door to subscribe to pool-monitor topic.

Result:
A single instance of RemotePoolMonitor is shared among multiple
getlocality requests over nfs.

Acked-by: Paul Millar
Acked-by: Lea Morschel
Acked-by: Albert Rossi
Target: master, 7.1, 7.0, 6.2
Require-book: no
Require-notes: yes
  • Loading branch information
kofemann committed May 6, 2021
1 parent a31b429 commit 9f69e5c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import com.google.common.base.Throwables;
import org.apache.curator.shaded.com.google.common.collect.ImmutableMap;
import org.dcache.poolmanager.RemotePoolMonitor;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.PlatformTransactionManager;

Expand Down Expand Up @@ -88,7 +89,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import diskCacheV111.util.PnfsId;
import diskCacheV111.vehicles.DCapProtocolInfo;
import diskCacheV111.vehicles.DoorRequestInfoMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolMonitor;
import diskCacheV111.vehicles.ProtocolInfo;

import dmg.cells.nucleus.CellAddressCore;
Expand All @@ -103,7 +103,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import org.dcache.pinmanager.PinManagerListPinsMessage.Info;
import org.dcache.pinmanager.PinManagerPinMessage;
import org.dcache.pinmanager.PinManagerUnpinMessage;
import org.dcache.poolmanager.PoolMonitor;
import org.dcache.vehicles.FileAttributes;


Expand Down Expand Up @@ -179,13 +178,17 @@ public boolean isUnpinnable()
PinManagerListPinsMessage.State.READY_TO_UNPIN, PinState.READY_TO_UNPIN,
PinManagerListPinsMessage.State.FAILED_TO_UNPIN, PinState.FAILED_TO_UNPIN);

private CellStub poolManagerStub;
private CellStub pinManagerStub;
private CellStub billingStub;
private PnfsHandler pnfsHandler;
private CellAddressCore myAddress;
private boolean queryPnfsManagerOnRename;

/**
* Pool manager's runtime configuration.
*/
private RemotePoolMonitor poolMonitor;

@Required
public void setQueryPnfsManagerOnRename(boolean yes)
{
Expand All @@ -206,10 +209,6 @@ public void setPnfsHandler(PnfsHandler pnfsHandler) {
this.pnfsHandler = pnfsHandler;
}

public void setPoolManagerStub(CellStub poolManagerStub) {
this.poolManagerStub = poolManagerStub;
}

public void setPinManagerStub(CellStub pinManagerStub) {
this.pinManagerStub = pinManagerStub;
}
Expand All @@ -218,6 +217,11 @@ public void setBillingStub(CellStub billingStub) {
this.billingStub = billingStub;
}

public void setPoolMonitor(RemotePoolMonitor poolMonitor)
{
this.poolMonitor = poolMonitor;
}

@Override
public void setCellAddress(CellAddressCore address) {
myAddress = address;
Expand Down Expand Up @@ -328,13 +332,9 @@ public void remove(FsInode directory, String name, FsInode inode) throws Chimera
* instead of simply its status as recorded in the Chimera database.
*/
private String getFileLocality(String filePath) throws ChimeraFsException {
PoolMonitor _poolMonitor;
FileLocality locality = FileLocality.UNAVAILABLE;

try {
_poolMonitor = poolManagerStub.sendAndWait(
new PoolManagerGetPoolMonitor()).getPoolMonitor();

Set<FileAttribute> requestedAttributes
= EnumSet.of(FileAttribute.TYPE,
FileAttribute.SIZE,
Expand All @@ -349,8 +349,8 @@ private String getFileLocality(String filePath) throws ChimeraFsException {
* client so that link net masks do not interfere; note that SRM uses
* "localhost", so it is not a deviation from existing behavior.
*/
locality = _poolMonitor.getFileLocality(attributes, "localhost");
} catch (CacheException | NoRouteToCellException | InterruptedException t) {
locality = poolMonitor.getFileLocality(attributes, "localhost");
} catch (CacheException t) {
throw new ChimeraFsException("getFileLocality", t);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@
<property name="shouldUpdate" value="${nfs.db.schema.auto}"/>
</bean>


<bean id="pool-monitor" class="org.dcache.poolmanager.RemotePoolMonitor">
<description>Maintains runtime information about all pools</description>
<property name="poolManagerStub" ref="poolManagerStub"/>
</bean>

<bean id="fileSystem" class="org.dcache.chimera.DCacheAwareJdbcFs"
depends-on="liquibase">
<description>Chimera Filesystem</description>
<constructor-arg ref="dataSource" />
<constructor-arg ref="tx-manager" />
<property name="pnfsHandler" ref="pnfs"/>
<property name="poolManagerStub" ref="poolManagerStub"/>
<property name="poolMonitor" ref="pool-monitor"/>
<property name="pinManagerStub" ref="pinManagerStub"/>
<property name="billingStub" ref="billing-stub"/>
<property name="queryPnfsManagerOnRename" value="${nfs.enable.pnfsmanager-query-on-move}"/>
Expand Down
7 changes: 6 additions & 1 deletion skel/share/defaults/nfs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nfs.cell.name=NFS-${host.name}
# consume from.
#
nfs.cell.consume = ${nfs.cell.name}
nfs.cell.subscribe=${nfs.loginbroker.request-topic},PoolStatusTopic
nfs.cell.subscribe=${nfs.loginbroker.request-topic},PoolStatusTopic,${nfs.pool-monitor-topic}


#
Expand Down Expand Up @@ -110,6 +110,11 @@ nfs.loginbroker.update-threshold=${dcache.loginbroker.update-threshold}
nfs.loginbroker.family = file
nfs.loginbroker.version = nfs4.1

# ---- Channel on which pool monitor updates are pushed out.
#
nfs.pool-monitor-topic=${dcache.pool-monitor.topic}


## This property is a space-separated list of hostnames or IP
## addresses to publish for this door. Hostnames are resolved to an
## IP address on start-up, but not subsequently. Non-wildcard IP
Expand Down
1 change: 1 addition & 0 deletions skel/share/services/nfs.batch
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ check nfs.db.password.file
check nfs.domain
check nfs.mover.queue
check -strong nfs.enable.access-log
check -strong nfs.pool-monitor-topic

create org.dcache.cells.UniversalSpringCell ${nfs.cell.name} \
"classpath:org/dcache/chimera/nfsv41/door/nfsv41-common.xml \
Expand Down

0 comments on commit 9f69e5c

Please sign in to comment.