From af14c845774759004231de42040359974dd5004b Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 18 Oct 2023 11:30:02 +1000 Subject: [PATCH 1/8] log at info Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/services/BesuPluginContextImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 0a0f5019a52..461c6c8f9da 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -138,10 +138,10 @@ public void registerPlugins(final Path pluginsDir) { plugins.add(plugin); } - LOG.debug("Plugin registration complete."); + LOG.info("Plugin registration complete."); lines.add(""); lines.add("TOTAL = " + plugins.size()); - LOG.debug(FramedLogMessage.generate(lines)); + LOG.info(FramedLogMessage.generate(lines)); state = Lifecycle.REGISTERED; } From cbe19cb2e0b0540b7a697774b6dd5a2463e5b489 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 18 Oct 2023 11:51:12 +1000 Subject: [PATCH 2/8] typo Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/services/RpcEndpointServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/besu/src/main/java/org/hyperledger/besu/services/RpcEndpointServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/RpcEndpointServiceImpl.java index 4513bf0bf39..94bb5560839 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/RpcEndpointServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/RpcEndpointServiceImpl.java @@ -28,7 +28,7 @@ import java.util.function.Function; import java.util.stream.Collectors; -/** The Rpc endpoint service implementation. */ +/** The RPC endpoint service implementation. */ public class RpcEndpointServiceImpl implements RpcEndpointService { private final Map> rpcMethods = new HashMap<>(); From db5c65f8055c72d85df74cd59697f7e4c808c84b Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 18 Oct 2023 11:51:31 +1000 Subject: [PATCH 3/8] log command line option that is affected Signed-off-by: Sally MacFarlane --- .../java/org/hyperledger/besu/cli/util/CommandLineUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java index 0115420005e..a44e616bd3d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java @@ -110,7 +110,7 @@ public static void checkMultiOptionDependencies( } /** - * Fail if option doesnt meet requirement. + * Fail if option doesn't meet requirement. * * @param commandLine the command line * @param errorMessage the error message @@ -126,7 +126,8 @@ public static void failIfOptionDoesntMeetRequirement( final String affectedOptions = getAffectedOptions(commandLine, dependentOptionsNames); if (!affectedOptions.isEmpty()) { - throw new CommandLine.ParameterException(commandLine, errorMessage); + throw new CommandLine.ParameterException( + commandLine, errorMessage + " [" + affectedOptions + "]"); } } } From 77cbec7b93fd2c496cadfc534d0b0670606b9a48 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 19 Oct 2023 12:49:26 +1000 Subject: [PATCH 4/8] made plugins summary log part of config overview Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/cli/BesuCommand.java | 2 ++ .../cli/ConfigurationOverviewBuilder.java | 13 ++++++++++++ .../besu/services/BesuPluginContextImpl.java | 21 ++++++++++++------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 47463d2c997..d7ce4dfa539 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -3555,6 +3555,8 @@ private String generateConfigurationOverview() { builder.setTxPoolImplementation(buildTransactionPoolConfiguration().getTxPoolImplementation()); + builder.setPluginContext(besuComponent.getBesuPluginContext()); + return builder.build(); } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index e017caa9ddf..373eaa2ed27 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -16,6 +16,7 @@ import org.hyperledger.besu.BesuInfo; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.services.BesuPluginContextImpl; import org.hyperledger.besu.util.log.FramedLogMessage; import org.hyperledger.besu.util.platform.PlatformDetector; @@ -50,6 +51,7 @@ public class ConfigurationOverviewBuilder { private boolean isHighSpec = false; private TransactionPoolConfiguration.Implementation txPoolImplementation; private Map environment; + private BesuPluginContextImpl besuPluginContext; /** * @param logger the logger @@ -277,6 +279,9 @@ public String build() { lines.add("Total memory: " + normalizeSize(hardwareInfo.getMemory().getTotal())); lines.add("CPU cores: " + hardwareInfo.getProcessor().getLogicalProcessorCount()); + lines.add(""); + lines.addAll(getBesuPluginContext().getPluginsSummaryLog()); + return FramedLogMessage.generate(lines); } @@ -308,4 +313,12 @@ private void detectJemalloc(final List lines) { private String normalizeSize(final long size) { return String.format("%.02f", (double) (size) / 1024 / 1024 / 1024) + " GB"; } + + public BesuPluginContextImpl getBesuPluginContext() { + return besuPluginContext; + } + + public void setPluginContext(final BesuPluginContextImpl besuPluginContext) { + this.besuPluginContext = besuPluginContext; + } } diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 461c6c8f9da..13e47bf4176 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -21,7 +21,6 @@ import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.services.BesuService; import org.hyperledger.besu.plugin.services.PluginVersionsProvider; -import org.hyperledger.besu.util.log.FramedLogMessage; import java.io.IOException; import java.net.MalformedURLException; @@ -76,6 +75,7 @@ private enum Lifecycle { private final Map, ? super BesuService> serviceRegistry = new HashMap<>(); private final List plugins = new ArrayList<>(); private final List pluginVersions = new ArrayList<>(); + final List lines = new ArrayList<>(); /** * Add service. @@ -105,9 +105,7 @@ public Optional getService(final Class serviceType * @param pluginsDir the plugins dir */ public void registerPlugins(final Path pluginsDir) { - final List lines = new ArrayList<>(); - lines.add("plugins dir " + pluginsDir.toAbsolutePath()); - lines.add(""); + lines.add("Plugins:"); checkState( state == Lifecycle.UNINITIALIZED, "Besu plugins have already been registered. Cannot register additional plugins."); @@ -120,11 +118,13 @@ public void registerPlugins(final Path pluginsDir) { final ServiceLoader serviceLoader = ServiceLoader.load(BesuPlugin.class, pluginLoader); + int pluginsCount = 0; for (final BesuPlugin plugin : serviceLoader) { + pluginsCount++; try { plugin.register(this); LOG.info("Registered plugin of type {}.", plugin.getClass().getName()); - lines.add(String.format("SUCCESS %s", plugin.getClass().getSimpleName())); + lines.add(String.format(plugin.getClass().getSimpleName())); addPluginVersion(plugin); } catch (final Exception e) { LOG.error( @@ -139,13 +139,18 @@ public void registerPlugins(final Path pluginsDir) { } LOG.info("Plugin registration complete."); - lines.add(""); - lines.add("TOTAL = " + plugins.size()); - LOG.info(FramedLogMessage.generate(lines)); + lines.add( + String.format( + "TOTAL = %d of %d plugins successfully loaded", plugins.size(), pluginsCount)); + lines.add(String.format("from %s", pluginsDir.toAbsolutePath())); state = Lifecycle.REGISTERED; } + public List getPluginsSummaryLog() { + return lines; + } + private void addPluginVersion(final BesuPlugin plugin) { final Package pluginPackage = plugin.getClass().getPackage(); final String implTitle = From 4c43d5364ecbae6d76d25f6ef63caf042bc6c51c Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 19 Oct 2023 13:00:55 +1000 Subject: [PATCH 5/8] debug lvl for one remaining msg Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/services/BesuPluginContextImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 13e47bf4176..276c577623e 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -138,7 +138,7 @@ public void registerPlugins(final Path pluginsDir) { plugins.add(plugin); } - LOG.info("Plugin registration complete."); + LOG.debug("Plugin registration complete."); lines.add( String.format( "TOTAL = %d of %d plugins successfully loaded", plugins.size(), pluginsCount)); From cddf542370ad6469f1ccec19b617a53d1c0cf5c6 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 19 Oct 2023 13:17:58 +1000 Subject: [PATCH 6/8] javadoc Signed-off-by: Sally MacFarlane --- .../hyperledger/besu/cli/ConfigurationOverviewBuilder.java | 6 +++++- .../hyperledger/besu/services/BesuPluginContextImpl.java | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 373eaa2ed27..3e37a1a2063 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -314,10 +314,14 @@ private String normalizeSize(final long size) { return String.format("%.02f", (double) (size) / 1024 / 1024 / 1024) + " GB"; } - public BesuPluginContextImpl getBesuPluginContext() { + private BesuPluginContextImpl getBesuPluginContext() { return besuPluginContext; } + /** + * set the plugin context + * @param besuPluginContext the plugin context + */ public void setPluginContext(final BesuPluginContextImpl besuPluginContext) { this.besuPluginContext = besuPluginContext; } diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 276c577623e..28cbfd16d98 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -147,6 +147,10 @@ public void registerPlugins(final Path pluginsDir) { state = Lifecycle.REGISTERED; } + /** + * get the summary log, as a list of string lines + * @return the summary + */ public List getPluginsSummaryLog() { return lines; } From ccef082a970a097e6416a393d07b794e20d7178a Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 19 Oct 2023 13:18:08 +1000 Subject: [PATCH 7/8] formatting Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java | 1 + .../org/hyperledger/besu/services/BesuPluginContextImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 3e37a1a2063..1648b7aa049 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -320,6 +320,7 @@ private BesuPluginContextImpl getBesuPluginContext() { /** * set the plugin context + * * @param besuPluginContext the plugin context */ public void setPluginContext(final BesuPluginContextImpl besuPluginContext) { diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 28cbfd16d98..184c85f45de 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -149,6 +149,7 @@ public void registerPlugins(final Path pluginsDir) { /** * get the summary log, as a list of string lines + * * @return the summary */ public List getPluginsSummaryLog() { From d2943bac9a51f0c795174167208cfe9982571597 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 19 Oct 2023 15:07:55 +1000 Subject: [PATCH 8/8] check for null plugin context Signed-off-by: Sally MacFarlane --- .../besu/cli/ConfigurationOverviewBuilder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 1648b7aa049..508b195a8eb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -280,7 +280,10 @@ public String build() { lines.add("CPU cores: " + hardwareInfo.getProcessor().getLogicalProcessorCount()); lines.add(""); - lines.addAll(getBesuPluginContext().getPluginsSummaryLog()); + + if (besuPluginContext != null) { + lines.addAll(besuPluginContext.getPluginsSummaryLog()); + } return FramedLogMessage.generate(lines); } @@ -314,10 +317,6 @@ private String normalizeSize(final long size) { return String.format("%.02f", (double) (size) / 1024 / 1024 / 1024) + " GB"; } - private BesuPluginContextImpl getBesuPluginContext() { - return besuPluginContext; - } - /** * set the plugin context *