diff --git a/modules/dcache/src/main/java/org/dcache/pool/classic/PoolV4.java b/modules/dcache/src/main/java/org/dcache/pool/classic/PoolV4.java index 367afe10585..15617d982b0 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/classic/PoolV4.java +++ b/modules/dcache/src/main/java/org/dcache/pool/classic/PoolV4.java @@ -662,6 +662,7 @@ public PoolDataDetails getDataObject() { info.setPingHeartbeatInSecs(_pingThread.getHeartbeat()); info.setP2pFileMode(_p2pFileMode == P2P_PRECIOUS ? P2PMode.PRECIOUS : P2PMode.CACHED); + info.setHotFileReplicationEnabled(_hotFileReplicationEnabled); info.setPoolMode(_poolMode.toString()); if (_poolMode.isDisabled()) { info.setPoolStatusCode(_poolStatusCode); diff --git a/modules/dcache/src/main/java/org/dcache/pool/json/PoolDataDetails.java b/modules/dcache/src/main/java/org/dcache/pool/json/PoolDataDetails.java index 63aed1809ef..316a5c67736 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/json/PoolDataDetails.java +++ b/modules/dcache/src/main/java/org/dcache/pool/json/PoolDataDetails.java @@ -112,6 +112,7 @@ public enum P2PMode { private Lsf largeFileStore; private P2PMode p2pFileMode; + private boolean isHotFileReplicationEnabled; private Integer hybridInventory; private int errorCode; @@ -159,6 +160,10 @@ public P2PMode getP2pFileMode() { return p2pFileMode; } + public boolean isHotFileReplicationEnabled() { + return isHotFileReplicationEnabled; + } + public Integer getPingHeartbeatInSecs() { return pingHeartbeatInSecs; } @@ -196,22 +201,23 @@ private String asOnOff(boolean value) { } public void print(PrintWriter pw) { - pw.println("Base directory : " + baseDir); - pw.println("Version : " + poolVersion); - pw.println("Report remove : " + asOnOff(isRemovalReported)); - pw.println("Pool Mode : " + poolMode); + pw.println("Base directory : " + baseDir); + pw.println("Version : " + poolVersion); + pw.println("Report remove : " + asOnOff(isRemovalReported)); + pw.println("Pool Mode : " + poolMode); if (poolStatusCode != null) { - pw.println("Detail : [" + poolStatusCode + "] " + pw.println("Detail : [" + poolStatusCode + "] " + poolStatusMessage); } - pw.println("Hsm Load Suppr. : " + asOnOff(isHsmLoadSuppressed)); - pw.println("Ping Heartbeat : " + pingHeartbeatInSecs + " seconds"); - pw.println("Breakeven : " + breakEven); - pw.println("LargeFileStore : " + largeFileStore); - pw.println("P2P File Mode : " + p2pFileMode); + pw.println("Hsm Load Suppression : " + asOnOff(isHsmLoadSuppressed)); + pw.println("Ping Heartbeat : " + pingHeartbeatInSecs + " seconds"); + pw.println("Breakeven : " + breakEven); + pw.println("LargeFileStore : " + largeFileStore); + pw.println("P2P File Mode : " + p2pFileMode); + pw.println("Hot File Replication : " + asOnOff(isHotFileReplicationEnabled)); if (hybridInventory != null) { - pw.println("Inventory : " + hybridInventory); + pw.println("Inventory : " + hybridInventory); } if (costData != null) { @@ -269,6 +275,10 @@ public void setP2pFileMode( this.p2pFileMode = p2pFileMode; } + public void setHotFileReplicationEnabled(boolean isEnabled) { + this.isHotFileReplicationEnabled = isEnabled; + } + public void setPingHeartbeatInSecs(Integer pingHeartbeatInSecs) { this.pingHeartbeatInSecs = pingHeartbeatInSecs; } diff --git a/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java b/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java index 87fd4ba8f8e..ef99476459b 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java +++ b/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java @@ -1634,4 +1634,15 @@ public String call() { return "Current threshold: " + getThreshold(); } } + + @Command(name = "hotfile show", + description = "Show the values of the 'replicas' and 'threshold' parameters.", + hint = "Show hot-file replication status.") + public class HotfileShowCommand implements Callable { + + @Override + public String call() { + return "replicas=" + hotFileReplicaCount + " threshold=" + hotFileThreshold; + } + } } diff --git a/modules/dcache/src/test/java/org/dcache/pool/json/PoolDataDetailsTest.java b/modules/dcache/src/test/java/org/dcache/pool/json/PoolDataDetailsTest.java new file mode 100644 index 00000000000..7ab3d396c9d --- /dev/null +++ b/modules/dcache/src/test/java/org/dcache/pool/json/PoolDataDetailsTest.java @@ -0,0 +1,31 @@ +package org.dcache.pool.json; + +import org.junit.Test; +import java.io.PrintWriter; +import java.io.StringWriter; +import static org.junit.Assert.assertTrue; + +public class PoolDataDetailsTest { + + @Test + public void shouldPrintHotfileReplicationStatus() { + PoolDataDetails details = new PoolDataDetails(); + details.setHotFileReplicationEnabled(true); + + StringWriter sw = new StringWriter(); + try (PrintWriter pw = new PrintWriter(sw)) { + details.print(pw); + } + + String output = sw.toString(); + assertTrue("Output should contain Hot File Replication status", output.contains("Hot File Replication : ON")); + + details.setHotFileReplicationEnabled(false); + sw = new StringWriter(); + try (PrintWriter pw = new PrintWriter(sw)) { + details.print(pw); + } + output = sw.toString(); + assertTrue("Output should contain Hot File Replication status", output.contains("Hot File Replication : OFF")); + } +}