From d905594c235ea2d01db6a6ba0a47cf5948029e74 Mon Sep 17 00:00:00 2001 From: Paul Millar Date: Mon, 20 Nov 2017 17:42:10 +0100 Subject: [PATCH] pnfsmanager: update slow logging admin command help Motivation: The help text associated with the slow logging admin commands is rather outdated; for example, it mentions PNFS as the namespace. Modification: Update text to better describe what this method does. Use the correct exception to indicate the value is out of range (avoiding potential stack-trace). Result: The help text for the "log slow threshold" has been updated. Target: master Request: 3.2 Request: 3.1 Request: 3.0 Request: 2.16 Require-notes: yes Require-book: no Ticket: http://rt.dcache.org/Ticket/Display.html?id=9295 Patch: https://rb.dcache.org/r/10644/ Acked-by: Tigran Mkrtchyan --- .../namespace/PnfsManagerV3.java | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/modules/dcache/src/main/java/diskCacheV111/namespace/PnfsManagerV3.java b/modules/dcache/src/main/java/diskCacheV111/namespace/PnfsManagerV3.java index 2c9fd7a49f5..b214f014733 100644 --- a/modules/dcache/src/main/java/diskCacheV111/namespace/PnfsManagerV3.java +++ b/modules/dcache/src/main/java/diskCacheV111/namespace/PnfsManagerV3.java @@ -73,6 +73,7 @@ import dmg.cells.nucleus.CellPath; import dmg.cells.nucleus.NoRouteToCellException; import dmg.cells.nucleus.UOID; +import dmg.util.CommandException; import dmg.util.command.Argument; import dmg.util.command.Command; import dmg.util.command.CommandLine; @@ -936,54 +937,51 @@ public String call() throws CacheException, NoSuchAlgorithmException } @Command(name = "set log slow threshold", - hint = "set the threshold for reporting slow PNFS interactions", - description = "Enable reporting of slow PNFS interactions." + - " If the interaction is greater than the timeout specified by this command," + - " a warning message is logged.") + hint = "configure logging of slow namespace interactions", + description = "Enable and configure how slow namespace " + + "interactions are logged. If an interaction takes " + + "longer to complete than the configured threshold " + + "duration then a warning is logged.") public class SetLogLowThresholdCommand implements Callable { - @Argument(usage = "Time in milliseconds, must be greater than zero.") - String timeout; + @Argument(usage = "The minimum duration of a namespace interaction, " + + "in milliseconds, before a warning is logged. The value " + + "must be greater than zero.") + int timeout; @Override - public String call() throws NumberFormatException + public String call() throws CommandException { - int newTimeout; - try { - newTimeout = Integer.parseInt( timeout); - } catch ( NumberFormatException e) { - throw new NumberFormatException("Badly formatted number " + timeout); - } - - if( newTimeout <= 0) { - return "Timeout must be greater than zero."; + if (timeout <= 0) { + throw new CommandException("Timeout must be greater than zero."); } - _logSlowThreshold = newTimeout; + _logSlowThreshold = timeout; return ""; } } @Command(name = "get log slow threshold", - hint = "return the current threshold for reporting slow PNFS interactions", - description = "If the threshold disabled returns" + " \"disabled\" " +"otherwise returns " + - "the set time in ms.") + hint = "the current threshold for reporting slow namespace interactions", + description = "If this feature is currently disabled, returns " + + "\"disabled\" otherwise returns the duration in " + + "milliseconds.") public class GetLogSlowThresholdCommand implements Callable { @Override public String call() { - if( _logSlowThreshold == THRESHOLD_DISABLED) { - return "disabled"; - } - return String.valueOf(_logSlowThreshold) + " ms"; + return _logSlowThreshold == THRESHOLD_DISABLED + ? "disabled" + : (_logSlowThreshold + " ms"); } } @Command(name = "set log slow threshold disabled", - hint = "disable reporting of slow PNFS interactions", - description = "No warning messages are logged.") + hint = "disable reporting of slow namespace interactions", + description = "Do not log a warning if namespace interactions " + + "are slow.") public class SetLogSlowThresfoldDisabledCommand implements Callable { @Override