This is an automated email from the ASF dual-hosted git repository. udo pushed a commit to branch feature/GEODE-8294 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 6e927c7e0367537f77f30654f8db1452ab307264 Author: Patrick Johnson <pjohn...@pivotal.io> AuthorDate: Thu Jun 25 14:27:41 2020 -0700 GEODE-8294 - Integrate ModuleService into ListCollectingServiceLoader and InternalDistributedSystemMetricsService. --- .../src/test/resources/expected-pom.xml | 6 ++ .../ClusterDistributionManagerDUnitTest.java | 4 +- ...PersistentPartitionedRegionDistributedTest.java | 9 +-- .../cache/partitioned/ShutdownAllDUnitTest.java | 5 +- ...nalDistributedSystemBuilderIntegrationTest.java | 2 +- .../InternalDistributedSystemJUnitTest.java | 12 ++-- ...DistributedSystemLockMemoryIntegrationTest.java | 2 +- ...alDistributedSystemSecurityIntegrationTest.java | 2 +- .../internal/InternalLocatorIntegrationTest.java | 3 +- .../internal/EntityInfoIntegrationTest.java | 3 +- ...StartupConfigurationLoggingIntegrationTest.java | 3 +- .../geode/admin/AdminDistributedSystemFactory.java | 6 +- .../admin/internal/AdminDistributedSystemImpl.java | 6 +- .../org/apache/geode/admin/jmx/AgentFactory.java | 6 +- .../internal/AdminDistributedSystemJmxImpl.java | 3 +- .../apache/geode/admin/jmx/internal/AgentImpl.java | 8 ++- .../geode/admin/jmx/internal/AgentLauncher.java | 8 ++- .../internal/InternalDistributedSystem.java | 4 +- .../distributed/internal/InternalLocator.java | 3 +- .../org/apache/geode/internal/logging/Banner.java | 5 +- .../internal/util/ListCollectingServiceLoader.java | 55 ++++-------------- .../geode/logging/internal/Configuration.java | 26 +++++---- .../geode/logging/internal/ConfigurationInfo.java | 5 +- .../logging/internal/LoggingProviderLoader.java | 13 ++++- .../geode/logging/internal/LoggingSession.java | 5 +- .../InternalDistributedSystemMetricsService.java | 66 ++++++++++++---------- .../geode/metrics/internal/MetricsService.java | 3 +- .../apache/geode/internal/logging/BannerTest.java | 3 +- .../internal/util/ArgumentRedactorJUnitTest.java | 3 +- .../util/ListCollectingServiceLoaderTest.java | 49 +++++----------- .../internal/LoggingProviderLoaderTest.java | 5 +- .../geode/logging/internal/LoggingSessionTest.java | 5 +- ...DistributedSystemMetricsServiceBuilderTest.java | 43 +++++++------- geode-core/src/test/resources/expected-pom.xml | 10 ++-- geode-dunit/build.gradle | 1 + .../management/internal/cli/HeadlessGfsh.java | 15 +++-- .../geode/test/junit/rules/GfshCommandRule.java | 6 +- geode-dunit/src/test/resources/expected-pom.xml | 5 ++ geode-gfsh/build.gradle | 1 + .../internal/cli/HeadlessGfshIntegrationTest.java | 3 +- .../internal/cli/shell/GfshHistoryJUnitTest.java | 7 ++- .../cli/shell/GfshInitFileIntegrationTest.java | 17 +++--- .../geode/management/internal/cli/Launcher.java | 17 +++--- .../geode/management/internal/cli/shell/Gfsh.java | 13 +++-- .../cli/shell/GfshConsoleModeUnitTest.java | 5 +- .../cli/shell/GfshHeadlessModeUnitTest.java | 5 +- geode-gfsh/src/test/resources/expected-pom.xml | 5 ++ geode-log4j/build.gradle | 1 + .../impl/ConfigurationIntegrationTest.java | 12 ++-- ...gurationWithLogLevelChangesIntegrationTest.java | 4 +- .../internal/impl/FastLoggerIntegrationTest.java | 4 +- ...FastLoggerWithDefaultConfigIntegrationTest.java | 4 +- .../internal/impl/LoggingProviderLoaderTest.java | 3 +- geode-log4j/src/test/resources/expected-pom.xml | 5 ++ .../src/test/resources/expected-pom.xml | 5 ++ ...hutdownAllPersistentGatewaySenderDUnitTest.java | 3 +- 56 files changed, 288 insertions(+), 244 deletions(-) diff --git a/boms/geode-all-bom/src/test/resources/expected-pom.xml b/boms/geode-all-bom/src/test/resources/expected-pom.xml index 1078e67..ada6eb8 100644 --- a/boms/geode-all-bom/src/test/resources/expected-pom.xml +++ b/boms/geode-all-bom/src/test/resources/expected-pom.xml @@ -933,6 +933,12 @@ </dependency> <dependency> <groupId>org.apache.geode</groupId> + <artifactId>geode-dep-graph</artifactId> + <version>${version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.geode</groupId> <artifactId>geode-dunit</artifactId> <version>${version}</version> <scope>compile</scope> diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java index 9d3bbd9..de54356 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java @@ -73,6 +73,7 @@ import org.apache.geode.distributed.internal.membership.api.MembershipManagerHel import org.apache.geode.distributed.internal.membership.api.MembershipView; import org.apache.geode.distributed.internal.membership.gms.GMSMembership; import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.dunit.Invoke; import org.apache.geode.test.dunit.SerializableRunnable; import org.apache.geode.test.dunit.VM; @@ -434,7 +435,8 @@ public class ClusterDistributionManagerDUnitTest extends CacheTestCase { private void createAlertListener() throws Exception { DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(getSystemStatic(), null); - AdminDistributedSystem adminSystem = AdminDistributedSystemFactory.getDistributedSystem(config); + AdminDistributedSystem adminSystem = + AdminDistributedSystemFactory.getDistributedSystem(config, ModuleService.DEFAULT); adminSystem.setAlertLevel(AlertLevel.SEVERE); adminSystem.addAlertListener(alert -> { try { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java index 81777a1..61a39b4 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java @@ -97,6 +97,7 @@ import org.apache.geode.internal.cache.control.InternalResourceManager; import org.apache.geode.internal.cache.control.InternalResourceManager.ResourceObserver; import org.apache.geode.internal.cache.control.InternalResourceManager.ResourceObserverAdapter; import org.apache.geode.internal.cache.persistence.PersistentMemberID; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.AsyncInvocation; import org.apache.geode.test.dunit.IgnoredException; @@ -246,7 +247,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable vm2.invoke(() -> { DistributedSystemConfig config = defineDistributedSystem(getSystem(), ""); - AdminDistributedSystem adminDS = getDistributedSystem(config); + AdminDistributedSystem adminDS = getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); try { adminDS.waitToBeConnected(MINUTES.toMillis(2)); @@ -375,7 +376,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable vm2.invoke("revoke disk store should fail", () -> { assertThatThrownBy(() -> { DistributedSystemConfig config = defineDistributedSystem(getSystem(), ""); - AdminDistributedSystem adminDS = getDistributedSystem(config); + AdminDistributedSystem adminDS = getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); try { @@ -398,7 +399,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable vm2.invoke(() -> { DistributedSystemConfig config = defineDistributedSystem(getSystem(), ""); - AdminDistributedSystem adminDS = getDistributedSystem(config); + AdminDistributedSystem adminDS = getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); try { adminDS.waitToBeConnected(MINUTES.toMillis(2)); @@ -1651,7 +1652,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable private void revokeKnownMissingMembers(final int numExpectedMissing) throws AdminException, InterruptedException { DistributedSystemConfig config = defineDistributedSystem(getSystem(), ""); - AdminDistributedSystem adminDS = getDistributedSystem(config); + AdminDistributedSystem adminDS = getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); try { adminDS.waitToBeConnected(MINUTES.toMillis(2)); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/ShutdownAllDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/ShutdownAllDUnitTest.java index 24272da..491007a 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/ShutdownAllDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/ShutdownAllDUnitTest.java @@ -57,6 +57,7 @@ import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.cache.PartitionedRegion; import org.apache.geode.internal.cache.control.InternalResourceManager; import org.apache.geode.internal.cache.control.InternalResourceManager.ResourceObserver; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.AsyncInvocation; import org.apache.geode.test.dunit.Host; @@ -620,7 +621,7 @@ public class ShutdownAllDUnitTest extends JUnit4CacheTestCase { try { config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), ""); adminDS = (AdminDistributedSystemImpl) AdminDistributedSystemFactory - .getDistributedSystem(config); + .getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); Set members = adminDS.shutDownAllMembers(); int num = members == null ? 0 : members.size(); @@ -846,7 +847,7 @@ public class ShutdownAllDUnitTest extends JUnit4CacheTestCase { try { config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), ""); adminDS = (AdminDistributedSystemImpl) AdminDistributedSystemFactory - .getDistributedSystem(config); + .getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); Set members = adminDS.shutDownAllMembers(timeout); int num = members == null ? 0 : members.size(); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemBuilderIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemBuilderIntegrationTest.java index 0a90db7..13b0f0c 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemBuilderIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemBuilderIntegrationTest.java @@ -39,7 +39,7 @@ public class InternalDistributedSystemBuilderIntegrationTest { @Before public void setup() { metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(mock(MetricsService.class)); + when(metricsSessionBuilder.build(any(), any())).thenReturn(mock(MetricsService.class)); } @After diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java index fd0a26a..75ec5d1 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java @@ -105,7 +105,7 @@ public class InternalDistributedSystemJUnitTest { */ private InternalDistributedSystem createSystem(Properties props) { MetricsService.Builder metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(mock(MetricsService.class)); + when(metricsSessionBuilder.build(any(), any())).thenReturn(mock(MetricsService.class)); return createSystem(props, metricsSessionBuilder); } @@ -659,7 +659,7 @@ public class InternalDistributedSystemJUnitTest { props.setProperty(LOCATORS, ""); Config config1 = new DistributionConfigImpl(props, false); MetricsService.Builder metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(mock(MetricsService.class)); + when(metricsSessionBuilder.build(any(), any())).thenReturn(mock(MetricsService.class)); InternalDistributedSystem sys = new InternalDistributedSystem.Builder(config1.toProperties(), metricsSessionBuilder, ModuleService.DEFAULT) @@ -797,18 +797,18 @@ public class InternalDistributedSystemJUnitTest { public void usesSessionBuilderToCreateMetricsSession() { MetricsService metricsSession = mock(MetricsService.class); MetricsService.Builder metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(metricsSession); + when(metricsSessionBuilder.build(any(), any())).thenReturn(metricsSession); createSystem(getCommonProperties(), metricsSessionBuilder); - verify(metricsSessionBuilder).build(system); + verify(metricsSessionBuilder).build(system, any()); } @Test public void startsMetricsSession() { MetricsService metricsSession = mock(MetricsService.class); MetricsService.Builder metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(metricsSession); + when(metricsSessionBuilder.build(any(), any())).thenReturn(metricsSession); when(metricsSession.getMeterRegistry()).thenReturn(mock(MeterRegistry.class)); createSystem(getCommonProperties(), metricsSessionBuilder); @@ -824,7 +824,7 @@ public class InternalDistributedSystemJUnitTest { when(metricsSession.getMeterRegistry()).thenReturn(sessionMeterRegistry); MetricsService.Builder metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(metricsSession); + when(metricsSessionBuilder.build(any(), any())).thenReturn(metricsSession); when(metricsSession.getMeterRegistry()).thenReturn(sessionMeterRegistry); createSystem(getCommonProperties(), metricsSessionBuilder); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemLockMemoryIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemLockMemoryIntegrationTest.java index a2ca86e..5eff39d 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemLockMemoryIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemLockMemoryIntegrationTest.java @@ -47,7 +47,7 @@ public class InternalDistributedSystemLockMemoryIntegrationTest { @Before public void setUp() { builder = mock(MetricsService.Builder.class); - when(builder.build(any())).thenReturn(mock(MetricsService.class)); + when(builder.build(any(), any())).thenReturn(mock(MetricsService.class)); } @After diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemSecurityIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemSecurityIntegrationTest.java index be5e529..a67a120 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemSecurityIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemSecurityIntegrationTest.java @@ -41,7 +41,7 @@ public class InternalDistributedSystemSecurityIntegrationTest { @Before public void setup() { metricsSessionBuilder = mock(MetricsService.Builder.class); - when(metricsSessionBuilder.build(any())).thenReturn(mock(MetricsService.class)); + when(metricsSessionBuilder.build(any(), any())).thenReturn(mock(MetricsService.class)); } @After diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java index eecda74..8f1bc22 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java @@ -173,7 +173,8 @@ public class InternalLocatorIntegrationTest { properties.put("load-cluster-configuration-from-dir", "true"); assertThatThrownBy(() -> InternalLocator.startLocator(port, logFile, logWriter, securityLogWriter, bindAddress, true, - properties, hostnameForClients, workingDirectory, ModuleService.DEFAULT)).isInstanceOf(RuntimeException.class); + properties, hostnameForClients, workingDirectory, ModuleService.DEFAULT)) + .isInstanceOf(RuntimeException.class); assertThat(InternalLocator.hasLocator()).isFalse(); } diff --git a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/EntityInfoIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/EntityInfoIntegrationTest.java index 2adb253..ccf193c 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/EntityInfoIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/EntityInfoIntegrationTest.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -30,6 +31,6 @@ public class EntityInfoIntegrationTest { @Test public void getConfigurationInfoContainsLog4j2Xml() { - assertThat(getConfigurationInfo()).contains("log4j2.xml"); + assertThat(getConfigurationInfo(ModuleService.DEFAULT)).contains("log4j2.xml"); } } diff --git a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/StartupConfigurationLoggingIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/StartupConfigurationLoggingIntegrationTest.java index 6b9c09f..72ff854 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/StartupConfigurationLoggingIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/StartupConfigurationLoggingIntegrationTest.java @@ -43,6 +43,7 @@ import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.internal.logging.Banner; import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.assertj.LogFileAssert; import org.apache.geode.test.junit.categories.LoggingTest; @@ -78,7 +79,7 @@ public class StartupConfigurationLoggingIntegrationTest { system = (InternalDistributedSystem) DistributedSystem.connect(config); - banner = new Banner().getString(); + banner = new Banner(ModuleService.DEFAULT).getString(); DistributionConfig distributionConfig = system.getConfig(); startupConfiguration = StringUtils diff --git a/geode-core/src/main/java/org/apache/geode/admin/AdminDistributedSystemFactory.java b/geode-core/src/main/java/org/apache/geode/admin/AdminDistributedSystemFactory.java index 7cfe0c9..b2dc855 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/AdminDistributedSystemFactory.java +++ b/geode-core/src/main/java/org/apache/geode/admin/AdminDistributedSystemFactory.java @@ -24,6 +24,7 @@ import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.distributed.internal.DistributionConfigImpl; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.internal.logging.LocalLogWriter; +import org.apache.geode.services.module.ModuleService; /** * Factory for creating GemFire administration entities. @@ -128,8 +129,9 @@ public class AdminDistributedSystemFactory { * @param config configuration definition of the system to administer * @return administrative interface for a distributed system */ - public static AdminDistributedSystem getDistributedSystem(DistributedSystemConfig config) { - return new AdminDistributedSystemImpl((DistributedSystemConfigImpl) config); + public static AdminDistributedSystem getDistributedSystem(DistributedSystemConfig config, + ModuleService moduleService) { + return new AdminDistributedSystemImpl((DistributedSystemConfigImpl) config, moduleService); } /** diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java index 66ff10f..5a5e1ab 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java @@ -100,6 +100,7 @@ import org.apache.geode.internal.util.concurrent.FutureResult; import org.apache.geode.logging.internal.LoggingSession; import org.apache.geode.logging.internal.NullLoggingSession; import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.services.module.ModuleService; /** * Represents a GemFire distributed system for remote administration/management. @@ -204,7 +205,8 @@ public class AdminDistributedSystemImpl implements org.apache.geode.admin.AdminD * * @param config configuration defining this distributed system */ - public AdminDistributedSystemImpl(DistributedSystemConfigImpl config) { + public AdminDistributedSystemImpl(DistributedSystemConfigImpl config, + ModuleService moduleService) { loggingSession = createLoggingSession(); // init from config... @@ -235,7 +237,7 @@ public class AdminDistributedSystemImpl implements org.apache.geode.admin.AdminD this.logWriter = LogWriterFactory.createLogWriterLogger(this.config.createLogConfig(), false); if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) { // LOG: changed statement from config to info - this.logWriter.info(new Banner().getString()); + this.logWriter.info(new Banner(moduleService).getString()); } else { logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + " is set to true"); } diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/AgentFactory.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/AgentFactory.java index b4c8fc7..c3b018e 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/AgentFactory.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/AgentFactory.java @@ -17,6 +17,7 @@ package org.apache.geode.admin.jmx; import org.apache.geode.admin.AdminException; import org.apache.geode.admin.jmx.internal.AgentConfigImpl; import org.apache.geode.admin.jmx.internal.AgentImpl; +import org.apache.geode.services.module.ModuleService; /** * A factory class that creates JMX administration entities. @@ -40,8 +41,9 @@ public class AgentFactory { * * @see Agent#start */ - public static Agent getAgent(AgentConfig config) throws AdminException { - return new AgentImpl((AgentConfigImpl) config); + public static Agent getAgent(AgentConfig config, ModuleService moduleService) + throws AdminException { + return new AgentImpl((AgentConfigImpl) config, moduleService); } } diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java index 931ba18..6337e93 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java @@ -89,6 +89,7 @@ import org.apache.geode.internal.admin.StatAlertDefinition; import org.apache.geode.internal.admin.remote.UpdateAlertDefinitionMessage; import org.apache.geode.internal.logging.InternalLogWriter; import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.util.internal.GeodeGlossary; /** @@ -140,7 +141,7 @@ public class AdminDistributedSystemJmxImpl extends AdminDistributedSystemImpl */ public AdminDistributedSystemJmxImpl(AgentConfigImpl config) throws org.apache.geode.admin.AdminException { - super(config); + super(config, ModuleService.DEFAULT); this.mbeanName = "GemFire:type=AdminDistributedSystem,id=" + MBeanUtil.makeCompliantMBeanNameProperty(getId()); this.objectName = MBeanUtil.createMBean(this); diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java index 37b25e7..5e239ea 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java @@ -70,6 +70,7 @@ import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigListener; import org.apache.geode.logging.internal.spi.LogConfigSupplier; +import org.apache.geode.services.module.ModuleService; /** * The GemFire JMX Agent provides the ability to administrate one GemFire distributed system via @@ -185,8 +186,9 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent, * @throws org.apache.geode.admin.AdminException TODO-javadocs * @throws IllegalArgumentException if agentConfig is null */ - public AgentImpl(AgentConfigImpl agentConfig) throws AdminException, IllegalArgumentException { - loggingSession = LoggingSession.create(); + public AgentImpl(AgentConfigImpl agentConfig, ModuleService moduleService) + throws AdminException, IllegalArgumentException { + loggingSession = LoggingSession.create(moduleService); shutdownHook = new LoggingThread("Shutdown", false, () -> disconnectFromSystem()); addShutdownHook(); @@ -1045,7 +1047,7 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent, } try { - Agent agent = AgentFactory.getAgent(ac); + Agent agent = AgentFactory.getAgent(ac, ModuleService.DEFAULT); agent.start(); } catch (VirtualMachineError err) { diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java index b18deda..e61f396 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java @@ -52,6 +52,7 @@ import org.apache.geode.internal.util.JavaCommandBuilder; import org.apache.geode.logging.internal.OSProcess; import org.apache.geode.logging.internal.executors.LoggingThread; import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.services.module.ModuleService; /** * A command line utility that is responsible for administering a stand-alone GemFire JMX @@ -363,7 +364,7 @@ public class AgentLauncher { writeStatus(createStatus(this.basename, STARTING, OSProcess.getId())); - final Agent agent = createAgent((Properties) options.get(AGENT_PROPS)); + final Agent agent = createAgent((Properties) options.get(AGENT_PROPS), ModuleService.DEFAULT); final Thread thread = createAgentProcessThread(agent); thread.start(); @@ -372,7 +373,8 @@ public class AgentLauncher { pollAgentForPendingShutdown(agent); } - private Agent createAgent(final Properties props) throws IOException, AdminException { + private Agent createAgent(final Properties props, ModuleService moduleService) + throws IOException, AdminException { ClusterDistributionManager.setIsDedicatedAdminVM(true); SystemFailure.setExitOK(true); @@ -387,7 +389,7 @@ public class AgentLauncher { OSProcess.redirectOutput(new File(config.getLogFile())); // redirect output to the configured // log file - return AgentFactory.getAgent(config); + return AgentFactory.getAgent(config, moduleService); } private UncaughtExceptionHandler createUncaughtExceptionHandler() { diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java index b8b2507..eb9f483 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java @@ -580,7 +580,7 @@ public class InternalDistributedSystem extends DistributedSystem alertingService = new InternalAlertingServiceFactory().create(); LoggingUncaughtExceptionHandler .setFailureSetter(error -> SystemFailure.setFailure((VirtualMachineError) error)); - loggingSession = LoggingSession.create(); + loggingSession = LoggingSession.create(moduleService); originalConfig = config.distributionConfig(); isReconnectingDS = config.isReconnecting(); quorumChecker = config.quorumChecker(); @@ -835,7 +835,7 @@ public class InternalDistributedSystem extends DistributedSystem alertingSession.createSession(alertingService); alertingSession.startSession(); - metricsService = metricsServiceBuilder.build(this); + metricsService = metricsServiceBuilder.build(this, moduleService); metricsService.start(); // Log any instantiators that were registered before the log writer diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java index f4d8835..2233b08 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java @@ -489,7 +489,8 @@ public class InternalLocator extends Locator implements ConnectListener, LogConf // if startDistributedSystem is true then Locator uses a NullLoggingSession (does nothing) LoggingSession loggingSession = - startDistributedSystem ? NullLoggingSession.create() : LoggingSession.create(); + startDistributedSystem ? NullLoggingSession.create() + : LoggingSession.create(moduleService); newLocator = createLocator(port, loggingSession, logFile, logWriter, securityLogWriter, bindAddress, hostnameForClients, distributedSystemProperties, diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/Banner.java b/geode-core/src/main/java/org/apache/geode/internal/logging/Banner.java index 691798f..a756a4e 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/logging/Banner.java +++ b/geode-core/src/main/java/org/apache/geode/internal/logging/Banner.java @@ -46,6 +46,7 @@ import org.apache.geode.internal.serialization.Version; import org.apache.geode.internal.util.ArgumentRedactor; import org.apache.geode.logging.internal.ConfigurationInfo; import org.apache.geode.logging.internal.OSProcess; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.util.internal.GeodeGlossary; /** @@ -66,8 +67,8 @@ public class Banner { * Logging package or from Logging tests. */ @Deprecated - public Banner() { - this(ConfigurationInfo.getConfigurationInfo()); + public Banner(ModuleService moduleService) { + this(ConfigurationInfo.getConfigurationInfo(moduleService)); } public Banner(final String configurationInfo) { diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/ListCollectingServiceLoader.java b/geode-core/src/main/java/org/apache/geode/internal/util/ListCollectingServiceLoader.java index e06cc0d..fe98139 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/util/ListCollectingServiceLoader.java +++ b/geode-core/src/main/java/org/apache/geode/internal/util/ListCollectingServiceLoader.java @@ -14,17 +14,17 @@ */ package org.apache.geode.internal.util; -import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.Collections; import java.util.List; -import java.util.ServiceConfigurationError; -import java.util.ServiceLoader; +import java.util.Set; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.geode.annotations.VisibleForTesting; +import org.apache.geode.services.module.ModuleService; +import org.apache.geode.services.result.ModuleServiceResult; /** * Implements {@link CollectingServiceLoader} by returning a {@link List} of all currently loadable @@ -33,54 +33,21 @@ import org.apache.geode.annotations.VisibleForTesting; public class ListCollectingServiceLoader<S> implements CollectingServiceLoader<S> { private static final Logger logger = LogManager.getLogger(); - private final ServiceLoaderWrapper<S> serviceLoaderWrapper; - - public ListCollectingServiceLoader() { - this(new DefaultServiceLoader<>()); - } + private final ModuleService moduleService; @VisibleForTesting - ListCollectingServiceLoader(ServiceLoaderWrapper<S> serviceLoaderWrapper) { - this.serviceLoaderWrapper = serviceLoaderWrapper; + public ListCollectingServiceLoader(ModuleService moduleService) { + this.moduleService = moduleService; } @Override public Collection<S> loadServices(Class<S> service) { - serviceLoaderWrapper.load(service); + ModuleServiceResult<Set<S>> moduleServiceResult = moduleService.loadService(service); - Collection<S> services = new ArrayList<>(); - for (Iterator<S> iterator = serviceLoaderWrapper.iterator(); iterator.hasNext();) { - try { - S instance = iterator.next(); - services.add(instance); - } catch (ServiceConfigurationError serviceConfigurationError) { - logger.error("Error while loading implementations of {}", service.getName(), - serviceConfigurationError); - } + if (moduleServiceResult.isSuccessful()) { + return moduleServiceResult.getMessage(); } - return services; - } - - interface ServiceLoaderWrapper<S> { - - void load(Class<S> service); - - Iterator<S> iterator() throws ServiceConfigurationError; - } - - private static class DefaultServiceLoader<S> implements ServiceLoaderWrapper<S> { - - private ServiceLoader<S> actualServiceLoader; - - @Override - public void load(Class<S> service) { - actualServiceLoader = ServiceLoader.load(service); - } - - @Override - public Iterator<S> iterator() throws ServiceConfigurationError { - return actualServiceLoader.iterator(); - } + return Collections.EMPTY_LIST; } } diff --git a/geode-core/src/main/java/org/apache/geode/logging/internal/Configuration.java b/geode-core/src/main/java/org/apache/geode/logging/internal/Configuration.java index 2f6d2df..a299a56 100644 --- a/geode-core/src/main/java/org/apache/geode/logging/internal/Configuration.java +++ b/geode-core/src/main/java/org/apache/geode/logging/internal/Configuration.java @@ -26,6 +26,7 @@ import org.apache.geode.logging.internal.spi.LogLevelUpdateOccurs; import org.apache.geode.logging.internal.spi.LogLevelUpdateScope; import org.apache.geode.logging.internal.spi.LogWriterLevel; import org.apache.geode.logging.internal.spi.LoggingProvider; +import org.apache.geode.services.module.ModuleService; /** * Provides logging configuration by managing a {@link LoggingProvider} for the logging backend. @@ -70,9 +71,17 @@ public class Configuration implements LogConfigListener { */ private LogConfigSupplier logConfigSupplier; - public static Configuration create() { - return create(getLogLevelUpdateOccurs(), getLogLevelUpdateScope(), new LoggingProviderLoader() - .load()); + private Configuration(final LogLevelUpdateOccurs logLevelUpdateOccurs, + final LogLevelUpdateScope logLevelUpdateScope, final LoggingProvider loggingProvider) { + this.logLevelUpdateOccurs = logLevelUpdateOccurs; + this.logLevelUpdateScope = logLevelUpdateScope; + this.loggingProvider = loggingProvider; + } + + public static Configuration create(ModuleService moduleService) { + return create(getLogLevelUpdateOccurs(), getLogLevelUpdateScope(), + new LoggingProviderLoader(moduleService) + .load()); } @VisibleForTesting @@ -82,9 +91,9 @@ public class Configuration implements LogConfigListener { @VisibleForTesting public static Configuration create(final LogLevelUpdateOccurs logLevelUpdateOccurs, - final LogLevelUpdateScope logLevelUpdateScope) { + final LogLevelUpdateScope logLevelUpdateScope, ModuleService moduleService) { return create(logLevelUpdateOccurs, logLevelUpdateScope, - new LoggingProviderLoader().load()); + new LoggingProviderLoader(moduleService).load()); } @VisibleForTesting @@ -93,13 +102,6 @@ public class Configuration implements LogConfigListener { return new Configuration(logLevelUpdateOccurs, logLevelUpdateScope, loggingProvider); } - private Configuration(final LogLevelUpdateOccurs logLevelUpdateOccurs, - final LogLevelUpdateScope logLevelUpdateScope, final LoggingProvider loggingProvider) { - this.logLevelUpdateOccurs = logLevelUpdateOccurs; - this.logLevelUpdateScope = logLevelUpdateScope; - this.loggingProvider = loggingProvider; - } - static LogLevelUpdateOccurs getLogLevelUpdateOccurs() { try { return LogLevelUpdateOccurs.valueOf(System.getProperty(LOG_LEVEL_UPDATE_OCCURS_PROPERTY, diff --git a/geode-core/src/main/java/org/apache/geode/logging/internal/ConfigurationInfo.java b/geode-core/src/main/java/org/apache/geode/logging/internal/ConfigurationInfo.java index 182d36a..2ffe366 100644 --- a/geode-core/src/main/java/org/apache/geode/logging/internal/ConfigurationInfo.java +++ b/geode-core/src/main/java/org/apache/geode/logging/internal/ConfigurationInfo.java @@ -15,6 +15,7 @@ package org.apache.geode.logging.internal; import org.apache.geode.logging.internal.spi.LoggingProvider; +import org.apache.geode.services.module.ModuleService; /** * Fetches the configuration info from {@link LoggingProvider} for invocation from static context. @@ -22,7 +23,7 @@ import org.apache.geode.logging.internal.spi.LoggingProvider; */ public class ConfigurationInfo { - public static String getConfigurationInfo() { - return new LoggingProviderLoader().load().getConfigurationInfo(); + public static String getConfigurationInfo(ModuleService moduleService) { + return new LoggingProviderLoader(moduleService).load().getConfigurationInfo(); } } diff --git a/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingProviderLoader.java b/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingProviderLoader.java index ebf6228..2356033 100644 --- a/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingProviderLoader.java +++ b/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingProviderLoader.java @@ -28,6 +28,7 @@ import org.apache.geode.internal.ClassPathLoader; import org.apache.geode.internal.util.CollectingServiceLoader; import org.apache.geode.internal.util.ListCollectingServiceLoader; import org.apache.geode.logging.internal.spi.LoggingProvider; +import org.apache.geode.services.module.ModuleService; /** * Loads a {@link LoggingProvider} using this order of preference: @@ -41,6 +42,11 @@ import org.apache.geode.logging.internal.spi.LoggingProvider; public class LoggingProviderLoader { private static final Logger logger = LogManager.getLogger(); + private final ModuleService moduleService; + + public LoggingProviderLoader(ModuleService moduleService) { + this.moduleService = moduleService; + } /** * System property that may be used to override which {@code LoggingProvider} to use. @@ -61,7 +67,7 @@ public class LoggingProviderLoader { // 2: use ListCollectingServiceLoader and select highest priority SortedMap<Integer, LoggingProvider> loggingProviders = new TreeMap<>(); - loadServiceProviders() + loadServiceProviders(moduleService) .forEach(provider -> loggingProviders.put(provider.getPriority(), provider)); if (!loggingProviders.isEmpty()) { @@ -77,8 +83,9 @@ public class LoggingProviderLoader { return new SimpleLoggingProvider(); } - private Iterable<LoggingProvider> loadServiceProviders() { - CollectingServiceLoader<LoggingProvider> serviceLoader = new ListCollectingServiceLoader<>(); + private Iterable<LoggingProvider> loadServiceProviders(ModuleService moduleService) { + CollectingServiceLoader<LoggingProvider> serviceLoader = + new ListCollectingServiceLoader<>(moduleService); Collection<LoggingProvider> loggingProviders = serviceLoader.loadServices(LoggingProvider.class); return loggingProviders; diff --git a/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingSession.java b/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingSession.java index 1af2974..e1ee6f1 100644 --- a/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingSession.java +++ b/geode-core/src/main/java/org/apache/geode/logging/internal/LoggingSession.java @@ -29,6 +29,7 @@ import org.apache.geode.internal.logging.Banner; import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.logging.internal.spi.LogConfigSupplier; import org.apache.geode.logging.internal.spi.LogFile; +import org.apache.geode.services.module.ModuleService; /** * Configures the logging {@code Configuration} and provides lifecycle to Geode logging. @@ -49,8 +50,8 @@ public class LoggingSession implements InternalSessionContext { private State state = STOPPED; - public static LoggingSession create() { - return create(Configuration.create(), LoggingSessionRegistryProvider.get()); + public static LoggingSession create(ModuleService moduleService) { + return create(Configuration.create(moduleService), LoggingSessionRegistryProvider.get()); } @VisibleForTesting diff --git a/geode-core/src/main/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsService.java b/geode-core/src/main/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsService.java index 9ca4b40..8aa97d8 100644 --- a/geode-core/src/main/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsService.java +++ b/geode-core/src/main/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsService.java @@ -36,6 +36,7 @@ import org.apache.geode.internal.util.CollectingServiceLoader; import org.apache.geode.internal.util.ListCollectingServiceLoader; import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.metrics.MetricsPublishingService; +import org.apache.geode.services.module.ModuleService; /** * Manages metrics on behalf of an {@code InternalDistributedSystem}. @@ -61,17 +62,6 @@ public class InternalDistributedSystemMetricsService implements MetricsService { private final Set<MeterRegistry> persistentMeterRegistries = new HashSet<>(); private final MetricsService.Builder builder; - @FunctionalInterface - @VisibleForTesting - interface Factory { - MetricsService create(MetricsService.Builder builder, Logger logger, - CollectingServiceLoader<MetricsPublishingService> publishingServiceLoader, - CompositeMeterRegistry metricsServiceMeterRegistry, - Collection<MeterRegistry> persistentMeterRegistries, CloseableMeterBinder binder, - InternalDistributedSystem system, boolean isClient, boolean hasLocator, - boolean hasCacheServer); - } - @VisibleForTesting InternalDistributedSystemMetricsService(MetricsService.Builder builder, Logger logger, CollectingServiceLoader<MetricsPublishingService> publishingServiceLoader, @@ -88,6 +78,22 @@ public class InternalDistributedSystemMetricsService implements MetricsService { addCommonTags(system, isClient, hasLocator, hasCacheServer); } + private static String memberTypeFor(boolean hasLocator, boolean hasCacheServer) { + if (hasCacheServer && hasLocator) { + return "server-locator"; + } + + if (hasCacheServer) { + return "server"; + } + + if (hasLocator) { + return "locator"; + } + + return "embedded-cache"; + } + /** * Starts this metrics service. The service remains active until {@code stop()} is called. * <p> @@ -177,22 +183,6 @@ public class InternalDistributedSystemMetricsService implements MetricsService { meterRegistry.config().commonTags(tags); } - private static String memberTypeFor(boolean hasLocator, boolean hasCacheServer) { - if (hasCacheServer && hasLocator) { - return "server-locator"; - } - - if (hasCacheServer) { - return "server"; - } - - if (hasLocator) { - return "locator"; - } - - return "embedded-cache"; - } - private void startMetricsPublishingService(MetricsPublishingService service) { try { service.start(this); @@ -231,6 +221,17 @@ public class InternalDistributedSystemMetricsService implements MetricsService { } } + @FunctionalInterface + @VisibleForTesting + interface Factory { + MetricsService create(MetricsService.Builder builder, Logger logger, + CollectingServiceLoader<MetricsPublishingService> publishingServiceLoader, + CompositeMeterRegistry metricsServiceMeterRegistry, + Collection<MeterRegistry> persistentMeterRegistries, CloseableMeterBinder binder, + InternalDistributedSystem system, boolean isClient, boolean hasLocator, + boolean hasCacheServer); + } + public static class Builder implements MetricsService.Builder { private boolean isClient = false; private Supplier<Logger> loggerSupplier = LogService::getLogger; @@ -238,15 +239,18 @@ public class InternalDistributedSystemMetricsService implements MetricsService { private Factory metricsServiceFactory = InternalDistributedSystemMetricsService::new; private Supplier<CompositeMeterRegistry> compositeRegistrySupplier = CompositeMeterRegistry::new; - private Supplier<CollectingServiceLoader<MetricsPublishingService>> serviceLoaderSupplier = - ListCollectingServiceLoader::new; + private Supplier<CollectingServiceLoader<MetricsPublishingService>> serviceLoaderSupplier; private Set<MeterRegistry> persistentMeterRegistries = new HashSet<>(); private BooleanSupplier hasLocator = Locator::hasLocator; private BooleanSupplier hasCacheServer = () -> ServerLauncher.getInstance() != null; @Override - public MetricsService build(InternalDistributedSystem system) { - return metricsServiceFactory.create(this, loggerSupplier.get(), serviceLoaderSupplier.get(), + public MetricsService build(InternalDistributedSystem system, ModuleService moduleService) { + CollectingServiceLoader<MetricsPublishingService> loaderSupplier = + serviceLoaderSupplier != null ? serviceLoaderSupplier.get() + : new ListCollectingServiceLoader<>(moduleService); + + return metricsServiceFactory.create(this, loggerSupplier.get(), loaderSupplier, compositeRegistrySupplier.get(), persistentMeterRegistries, meterBinderSupplier.get(), system, isClient, hasLocator.getAsBoolean(), hasCacheServer.getAsBoolean()); } diff --git a/geode-core/src/main/java/org/apache/geode/metrics/internal/MetricsService.java b/geode-core/src/main/java/org/apache/geode/metrics/internal/MetricsService.java index 1cbf359..98030ae 100644 --- a/geode-core/src/main/java/org/apache/geode/metrics/internal/MetricsService.java +++ b/geode-core/src/main/java/org/apache/geode/metrics/internal/MetricsService.java @@ -20,6 +20,7 @@ import io.micrometer.core.instrument.MeterRegistry; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.metrics.MetricsSession; +import org.apache.geode.services.module.ModuleService; /** * A metrics session that can be started and stopped, and that manages a meter registry. @@ -84,6 +85,6 @@ public interface MetricsService extends MetricsSession { /** * Builds a metrics service associated with the given system. */ - MetricsService build(InternalDistributedSystem system); + MetricsService build(InternalDistributedSystem system, ModuleService moduleService); } } diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/BannerTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/BannerTest.java index c298c19..b8ed79d 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/logging/BannerTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/logging/BannerTest.java @@ -22,6 +22,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -35,7 +36,7 @@ public class BannerTest { @Before public void setUp() { - banner = new Banner().getString(); + banner = new Banner(ModuleService.DEFAULT).getString(); } @Test diff --git a/geode-core/src/test/java/org/apache/geode/internal/util/ArgumentRedactorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/util/ArgumentRedactorJUnitTest.java index 129627c..3ed634b 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/util/ArgumentRedactorJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/util/ArgumentRedactorJUnitTest.java @@ -32,6 +32,7 @@ import java.util.List; import org.junit.Test; import org.apache.geode.internal.logging.Banner; +import org.apache.geode.services.module.ModuleService; public class ArgumentRedactorJUnitTest { private static final String someProperty = "redactorTest.someProperty"; @@ -210,7 +211,7 @@ public class ArgumentRedactorJUnitTest { List<String> args = ArrayUtils.asList("--user=me", "--password=isRedacted", "--another-password-for-some-reason =isRedacted", "--yet-another-password = isRedacted"); - String banner = new Banner().getString(args.toArray(new String[0])); + String banner = new Banner(ModuleService.DEFAULT).getString(args.toArray(new String[0])); assertThat(banner).doesNotContain("isRedacted"); } finally { System.clearProperty(someProperty); diff --git a/geode-core/src/test/java/org/apache/geode/internal/util/ListCollectingServiceLoaderTest.java b/geode-core/src/test/java/org/apache/geode/internal/util/ListCollectingServiceLoaderTest.java index 0c55923..6fd5b4f 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/util/ListCollectingServiceLoaderTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/util/ListCollectingServiceLoaderTest.java @@ -17,59 +17,40 @@ package org.apache.geode.internal.util; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.inOrder; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ServiceConfigurationError; +import java.util.HashSet; +import java.util.Set; import org.junit.Rule; import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.mockito.quality.Strictness; -import org.apache.geode.internal.util.ListCollectingServiceLoader.ServiceLoaderWrapper; import org.apache.geode.metrics.MetricsPublishingService; +import org.apache.geode.services.module.ModuleService; +import org.apache.geode.services.result.impl.Success; public class ListCollectingServiceLoaderTest { @Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock - private ServiceLoaderWrapper<MetricsPublishingService> serviceLoaderWrapper; - - @Test - public void loadServices_delegatesLoading() { - when(serviceLoaderWrapper.iterator()).thenReturn(mock(Iterator.class)); - - ListCollectingServiceLoader<MetricsPublishingService> collectingServiceLoader = - new ListCollectingServiceLoader<>(serviceLoaderWrapper); - - collectingServiceLoader.loadServices(MetricsPublishingService.class); - - InOrder inOrder = inOrder(serviceLoaderWrapper); - inOrder.verify(serviceLoaderWrapper).load(same(MetricsPublishingService.class)); - inOrder.verify(serviceLoaderWrapper).iterator(); - } - @Test public void loadServices_returnsLoadedServices() { MetricsPublishingService service1 = mock(MetricsPublishingService.class); MetricsPublishingService service2 = mock(MetricsPublishingService.class); MetricsPublishingService service3 = mock(MetricsPublishingService.class); - List<MetricsPublishingService> expectedServices = asList(service1, service2, service3); + Set<Object> expectedServices = new HashSet<>(asList(service1, service2, service3)); + ModuleService moduleService = mock(ModuleService.class); - when(serviceLoaderWrapper.iterator()).thenReturn(expectedServices.iterator()); + when(moduleService.loadService(any())).thenReturn(Success.of(expectedServices)); ListCollectingServiceLoader<MetricsPublishingService> collectingServiceLoader = - new ListCollectingServiceLoader<>(serviceLoaderWrapper); + new ListCollectingServiceLoader<>(moduleService); Collection<MetricsPublishingService> actualServices = collectingServiceLoader.loadServices(MetricsPublishingService.class); @@ -82,15 +63,15 @@ public class ListCollectingServiceLoaderTest { public void loadServices_returnsLoadedServices_whenOneServiceThrows() { MetricsPublishingService service1 = mock(MetricsPublishingService.class); MetricsPublishingService service3 = mock(MetricsPublishingService.class); - Iterator<MetricsPublishingService> iterator = mock(Iterator.class); - ServiceConfigurationError error = new ServiceConfigurationError("Error message"); + ModuleService moduleService = mock(ModuleService.class); - when(iterator.hasNext()).thenReturn(true, true, true, false); - when(iterator.next()).thenReturn(service1).thenThrow(error).thenReturn(service3); - when(serviceLoaderWrapper.iterator()).thenReturn(iterator); + Set<Object> services = new HashSet<>(); + services.add(service1); + services.add(service3); + when(moduleService.loadService(any())).thenReturn(Success.of(services)); ListCollectingServiceLoader<MetricsPublishingService> collectingServiceLoader = - new ListCollectingServiceLoader<>(serviceLoaderWrapper); + new ListCollectingServiceLoader<>(moduleService); Collection<MetricsPublishingService> actualServices = collectingServiceLoader.loadServices(MetricsPublishingService.class); diff --git a/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingProviderLoaderTest.java b/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingProviderLoaderTest.java index b5f2792..ba41e77 100644 --- a/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingProviderLoaderTest.java +++ b/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingProviderLoaderTest.java @@ -27,6 +27,7 @@ import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogLevelUpdateOccurs; import org.apache.geode.logging.internal.spi.LogLevelUpdateScope; import org.apache.geode.logging.internal.spi.LoggingProvider; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -42,7 +43,7 @@ public class LoggingProviderLoaderTest { @Before public void setUp() { - loggingProviderLoader = new LoggingProviderLoader(); + loggingProviderLoader = new LoggingProviderLoader(ModuleService.DEFAULT); } @Test @@ -83,7 +84,7 @@ public class LoggingProviderLoaderTest { @Test public void getLoggingProviderReturnsSimpleLoggingProviderByDefault() { - LoggingProvider loggingProvider = new LoggingProviderLoader().load(); + LoggingProvider loggingProvider = new LoggingProviderLoader(ModuleService.DEFAULT).load(); assertThat(loggingProvider).isInstanceOf(SimpleLoggingProvider.class); } diff --git a/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingSessionTest.java b/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingSessionTest.java index 81f7087..d574509 100644 --- a/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingSessionTest.java +++ b/geode-core/src/test/java/org/apache/geode/logging/internal/LoggingSessionTest.java @@ -34,6 +34,7 @@ import org.mockito.Mockito; import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigSupplier; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -52,7 +53,7 @@ public class LoggingSessionTest { public void setUp() { loggingSessionNotifier = spy(new LoggingSessionRegistryProvider()); logConfigSupplier = spy(LogConfigSupplier.class); - configuration = spy(Configuration.create()); + configuration = spy(Configuration.create(ModuleService.DEFAULT)); LogConfig config = mock(LogConfig.class); when(logConfigSupplier.getLogConfig()).thenReturn(config); @@ -65,7 +66,7 @@ public class LoggingSessionTest { @Test public void createUsesLoggingSessionListenersGetByDefault() { - loggingSession = LoggingSession.create(); + loggingSession = LoggingSession.create(ModuleService.DEFAULT); assertThat(loggingSession.getLoggingSessionNotifier()) .isEqualTo(LoggingSessionRegistryProvider.get()); diff --git a/geode-core/src/test/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsServiceBuilderTest.java b/geode-core/src/test/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsServiceBuilderTest.java index 52caf9c..10f9b63 100644 --- a/geode-core/src/test/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsServiceBuilderTest.java +++ b/geode-core/src/test/java/org/apache/geode/metrics/internal/InternalDistributedSystemMetricsServiceBuilderTest.java @@ -43,6 +43,7 @@ import org.mockito.junit.MockitoRule; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.internal.util.CollectingServiceLoader; import org.apache.geode.metrics.MetricsPublishingService; +import org.apache.geode.services.module.ModuleService; public class InternalDistributedSystemMetricsServiceBuilderTest { @@ -64,7 +65,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { when(system.getName()).thenReturn("some-system-name"); when(system.getDistributedMember().getHost()).thenReturn("some-host-name"); - MetricsService metricsService = serviceBuilder.build(system); + MetricsService metricsService = serviceBuilder.build(system, ModuleService.DEFAULT); try { assertThat(metricsService).isInstanceOf(InternalDistributedSystemMetricsService.class); @@ -83,7 +84,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { MetricsService metricsService = serviceBuilder .setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); assertThat(metricsService) .isSameAs(metricsServiceCreatedByFactory); @@ -92,7 +93,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void passesItselfToFactory() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(same(serviceBuilder), any(), any(), any(), any(), any(), any(), anyBoolean(), @@ -106,7 +107,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setServiceLoader(theServiceLoader) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), same(theServiceLoader), any(), any(), any(), any(), anyBoolean(), @@ -117,7 +118,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { public void constructsServiceLoader_ifServiceLoaderNotSet() { serviceBuilder .setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(CollectingServiceLoader.class), any(), any(), any(), any(), @@ -130,7 +131,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setCompositeMeterRegistry(theMetricsServiceMeterRegistry) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), same(theMetricsServiceMeterRegistry), any(), any(), any(), @@ -140,7 +141,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void constructsCompositeMeterRegistry_ifMetricsServiceMeterRegistryNotSet() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(CompositeMeterRegistry.class), any(), any(), any(), @@ -153,7 +154,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory); individuallyAddedClientMeterRegistries.forEach(serviceBuilder::addPersistentMeterRegistry); - serviceBuilder.build(system); + serviceBuilder.build(system, ModuleService.DEFAULT); @SuppressWarnings("unchecked") ArgumentCaptor<Collection<MeterRegistry>> clientMeterRegistriesPassedToFactory = @@ -173,7 +174,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .addPersistentMeterRegistries(bulkAddedClientMeterRegistries) - .build(system); + .build(system, ModuleService.DEFAULT); @SuppressWarnings("unchecked") ArgumentCaptor<Collection<MeterRegistry>> clientMeterRegistriesPassedToFactory = @@ -190,7 +191,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void passesEmptyClientMeterRegistriesCollectionToFactory_ifNoClientMeterRegistriesAdded() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); @SuppressWarnings("unchecked") ArgumentCaptor<Collection<MeterRegistry>> clientMeterRegistriesPassedToFactory = @@ -210,7 +211,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setBinder(theBinder) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), same(theBinder), any(), anyBoolean(), @@ -220,7 +221,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void passesStandardMeterBinderToFactory_ifMeterBinderNotSet() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(StandardMeterBinder.class), any(), @@ -233,7 +234,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setLogger(theLogger) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), same(theLogger), any(), any(), any(), any(), any(), anyBoolean(), @@ -244,14 +245,14 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { public void usesGivenLocatorDetectorToDetectLocator() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setLocatorDetector(() -> true) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), anyBoolean(), eq(true), anyBoolean()); serviceBuilder.setLocatorDetector(() -> false) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), anyBoolean(), eq(false), @@ -262,7 +263,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { public void usesGivenCacheServerDetectorToDetectCacheServer() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setCacheServerDetector(() -> true) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean(), @@ -270,7 +271,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { serviceBuilder .setCacheServerDetector(() -> false) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean(), @@ -280,7 +281,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void constructsLogger_ifLoggerNotSet() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(Logger.class), any(), any(), any(), any(), any(), anyBoolean(), @@ -291,7 +292,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { public void passesIsClientToFactory() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) .setIsClient(true) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), eq(true), anyBoolean(), @@ -301,7 +302,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { @Test public void passesIsNotClientToFactory_ifIsClientNotGiven() { serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(system); + .build(system, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), any(), eq(false), anyBoolean(), @@ -313,7 +314,7 @@ public class InternalDistributedSystemMetricsServiceBuilderTest { InternalDistributedSystem theSystem = mock(InternalDistributedSystem.class); serviceBuilder.setMetricsServiceFactory(metricsServiceFactory) - .build(theSystem); + .build(theSystem, ModuleService.DEFAULT); verify(metricsServiceFactory) .create(any(), any(), any(), any(), any(), any(), same(theSystem), anyBoolean(), diff --git a/geode-core/src/test/resources/expected-pom.xml b/geode-core/src/test/resources/expected-pom.xml index c483f75..47ae85a 100644 --- a/geode-core/src/test/resources/expected-pom.xml +++ b/geode-core/src/test/resources/expected-pom.xml @@ -47,11 +47,6 @@ </dependencyManagement> <dependencies> <dependency> - <groupId>org.apache.geode</groupId> - <artifactId>geode-logging</artifactId> - <scope>compile</scope> - </dependency> - <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <scope>compile</scope> @@ -219,6 +214,11 @@ </dependency> <dependency> <groupId>org.apache.geode</groupId> + <artifactId>geode-logging</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.geode</groupId> <artifactId>geode-membership</artifactId> <scope>runtime</scope> </dependency> diff --git a/geode-dunit/build.gradle b/geode-dunit/build.gradle index 1508cc2..6f2ddb1 100755 --- a/geode-dunit/build.gradle +++ b/geode-dunit/build.gradle @@ -28,6 +28,7 @@ dependencies { implementation(project(':geode-tcp-server')) implementation(project(':geode-core')) implementation(project(':geode-gfsh')) + implementation(project(':geode-common-services')) implementation(project(':geode-log4j')) { exclude module: 'geode-core' } diff --git a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java index be9ac31..fb956f5 100644 --- a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java +++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java @@ -38,6 +38,7 @@ import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.shell.Gfsh; import org.apache.geode.management.internal.cli.shell.GfshConfig; import org.apache.geode.management.internal.cli.shell.jline.GfshUnsupportedTerminal; +import org.apache.geode.services.module.ModuleService; /** @@ -56,16 +57,17 @@ public class HeadlessGfsh implements ResultHandler { private long timeout; public String outputString = null; - public HeadlessGfsh(String name, int timeout, String parentDir) + public HeadlessGfsh(String name, int timeout, String parentDir, ModuleService moduleService) throws IOException { - this(name, timeout, null, parentDir); + this(name, timeout, null, parentDir, moduleService); } - public HeadlessGfsh(String name, int timeout, Properties envProps, String parentDir) + public HeadlessGfsh(String name, int timeout, Properties envProps, String parentDir, + ModuleService moduleService) throws IOException { this.timeout = timeout; System.setProperty("jline.terminal", GfshUnsupportedTerminal.class.getName()); - this.shell = new HeadlessGfshShell(name, this, parentDir); + this.shell = new HeadlessGfshShell(name, this, parentDir, moduleService); this.shell.setEnvProperty(Gfsh.ENV_APP_RESULT_VIEWER, "non-basic"); if (envProps != null) { @@ -198,9 +200,10 @@ public class HeadlessGfsh implements ResultHandler { private boolean hasError = false; boolean stopCalledThroughAPI = false; - protected HeadlessGfshShell(String testName, ResultHandler handler, String parentDir) + protected HeadlessGfshShell(String testName, ResultHandler handler, String parentDir, + ModuleService moduleService) throws IOException { - super(false, new String[] {}, new HeadlessGfshConfig(testName, parentDir)); + super(false, new String[] {}, new HeadlessGfshConfig(testName, parentDir), moduleService); this.handler = handler; } diff --git a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/GfshCommandRule.java b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/GfshCommandRule.java index c0286c2..98552c2 100644 --- a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/GfshCommandRule.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/GfshCommandRule.java @@ -35,6 +35,7 @@ import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.shell.Gfsh; import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.management.internal.i18n.CliStrings; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.junit.assertions.CommandResultAssert; @@ -102,7 +103,8 @@ public class GfshCommandRule extends DescribedExternalResource { } catch (IOException e) { workingDir = temporaryFolder.getRoot(); } - this.gfsh = new HeadlessGfsh(getClass().getName(), gfshTimeout, workingDir.getAbsolutePath()); + this.gfsh = new HeadlessGfsh(getClass().getName(), gfshTimeout, workingDir.getAbsolutePath(), + ModuleService.DEFAULT); ignoredException = addIgnoredException("java.rmi.NoSuchObjectException: no such object in table"); @@ -198,7 +200,7 @@ public class GfshCommandRule extends DescribedExternalResource { absolutePath = temporaryFolder.getRoot().getAbsolutePath(); } - this.gfsh = new HeadlessGfsh(getClass().getName(), 30, absolutePath); + this.gfsh = new HeadlessGfsh(getClass().getName(), 30, absolutePath, ModuleService.DEFAULT); } final CommandStringBuilder connectCommand = new CommandStringBuilder(CliStrings.CONNECT); String endpoint; diff --git a/geode-dunit/src/test/resources/expected-pom.xml b/geode-dunit/src/test/resources/expected-pom.xml index c0d7b6e..8af9bf0 100644 --- a/geode-dunit/src/test/resources/expected-pom.xml +++ b/geode-dunit/src/test/resources/expected-pom.xml @@ -89,6 +89,11 @@ </dependency> <dependency> <groupId>org.apache.geode</groupId> + <artifactId>geode-common-services</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.geode</groupId> <artifactId>geode-log4j</artifactId> <scope>runtime</scope> <exclusions> diff --git a/geode-gfsh/build.gradle b/geode-gfsh/build.gradle index e779f41..25a63e3 100644 --- a/geode-gfsh/build.gradle +++ b/geode-gfsh/build.gradle @@ -30,6 +30,7 @@ dependencies { implementation(project(':geode-membership')) implementation(project(':geode-serialization')) implementation(project(':geode-unsafe')) + implementation(project(':geode-common-services')) implementation('org.springframework:spring-web') implementation('org.apache.commons:commons-lang3') implementation('com.healthmarketscience.rmiio:rmiio') diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java index f0e6019..f27a784 100644 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java @@ -43,6 +43,7 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.management.cli.Result; import org.apache.geode.management.internal.cli.result.CommandResult; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.GfshTest; /** @@ -76,7 +77,7 @@ public class HeadlessGfshIntegrationTest { legacyConnect(properties); gfsh = new HeadlessGfsh("Test", 25, - this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath()); + this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath(), ModuleService.DEFAULT); } @SuppressWarnings("deprecation") diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java index 70d9f17..e6fbcf3 100644 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java @@ -27,6 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.apache.geode.services.module.ModuleService; + public class GfshHistoryJUnitTest { @@ -36,6 +38,7 @@ public class GfshHistoryJUnitTest { @Rule public TemporaryFolder tempDirectory = new TemporaryFolder(); + private Gfsh gfsh; @Before public void setUp() throws Exception { @@ -49,6 +52,7 @@ public class GfshHistoryJUnitTest { null, // logCount null // initFileName ); + gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig, ModuleService.DEFAULT); } @After @@ -61,7 +65,6 @@ public class GfshHistoryJUnitTest { @Test public void testHistoryFileIsCreated() throws Exception { - Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); gfsh.executeScriptLine("connect"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); @@ -71,7 +74,6 @@ public class GfshHistoryJUnitTest { @Test public void testHistoryFileDoesNotContainPasswords() throws Exception { - Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); gfsh.executeScriptLine("connect --password=foo"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); @@ -80,7 +82,6 @@ public class GfshHistoryJUnitTest { @Test public void testClearHistory() throws Exception { - Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); gfsh.executeScriptLine("connect"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); assertEquals(2, lines.size()); diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshInitFileIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshInitFileIntegrationTest.java index 1c0cb1d..3643127 100755 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshInitFileIntegrationTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/shell/GfshInitFileIntegrationTest.java @@ -48,6 +48,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.apache.geode.management.internal.cli.LogWrapper; +import org.apache.geode.services.module.ModuleService; /** * Unit tests for supplying an init file to Gfsh. @@ -127,7 +128,7 @@ public class GfshInitFileIntegrationTest { public void initFile_isNull() { GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, null); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (success is zero)") @@ -146,7 +147,7 @@ public class GfshInitFileIntegrationTest { public void initFile_doesNotExist() { GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (failure is non-zero)") @@ -166,7 +167,7 @@ public class GfshInitFileIntegrationTest { createFile(initFilePath); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (success is zero)") @@ -187,7 +188,7 @@ public class GfshInitFileIntegrationTest { defaultCharset()); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (success is zero)") @@ -210,7 +211,7 @@ public class GfshInitFileIntegrationTest { defaultCharset(), true); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (success is zero)") @@ -230,7 +231,7 @@ public class GfshInitFileIntegrationTest { writeStringToFile(initFilePath.toFile(), "fail" + lineSeparator(), defaultCharset()); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (failure is non-zero)") @@ -248,7 +249,7 @@ public class GfshInitFileIntegrationTest { writeStringToFile(initFilePath.toFile(), "fail" + lineSeparator(), defaultCharset(), true); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (failure is non-zero)") @@ -267,7 +268,7 @@ public class GfshInitFileIntegrationTest { defaultCharset(), true); GfshConfig gfshConfig = new GfshConfig(gfshHistoryFilePath.toString(), "", 0, gfshLogDirPath.toString(), null, null, null, initFilePath.toString()); - Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig); + Gfsh gfsh = Gfsh.getInstance(false, null, gfshConfig, ModuleService.DEFAULT); assertThat(gfsh.getLastExecutionStatus()) .as("gfsh last execution status (failure is non-zero)") diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/Launcher.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/Launcher.java index edfdc24..c5b4ca3 100755 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/Launcher.java +++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/Launcher.java @@ -31,6 +31,7 @@ import org.apache.geode.internal.util.ArgumentRedactor; import org.apache.geode.management.internal.cli.shell.Gfsh; import org.apache.geode.management.internal.cli.shell.GfshConfig; import org.apache.geode.management.internal.i18n.CliStrings; +import org.apache.geode.services.module.ModuleService; /** * Launcher class for : @@ -127,14 +128,14 @@ public class Launcher { } Launcher launcher = new Launcher(); - int exitValue = launcher.parseCommandLine(args); + int exitValue = launcher.parseCommandLine(ModuleService.DEFAULT, args); ExitCode.fromValue(exitValue).doSystemExit(); } - private int parseCommandLineCommand(final String... args) { + private int parseCommandLineCommand(ModuleService moduleService, final String... args) { Gfsh gfsh = null; try { - gfsh = Gfsh.getInstance(false, args, new GfshConfig()); + gfsh = Gfsh.getInstance(false, args, new GfshConfig(), moduleService); this.startupTimeLogHelper.logStartupTime(); } catch (IllegalStateException isex) { System.err.println("ERROR : " + isex.getMessage()); @@ -180,7 +181,7 @@ public class Launcher { return exitRequest.getExitCode(); } - private int parseOptions(final String... args) { + private int parseOptions(ModuleService moduleService, final String... args) { OptionSet parsedOptions; try { parsedOptions = this.commandLineParser.parse(args); @@ -197,7 +198,7 @@ public class Launcher { Gfsh gfsh = null; try { - gfsh = Gfsh.getInstance(launchShell, args, new GfshConfig()); + gfsh = Gfsh.getInstance(launchShell, args, new GfshConfig(), moduleService); this.startupTimeLogHelper.logStartupTime(); } catch (IllegalStateException isex) { System.err.println("ERROR : " + isex.getMessage()); @@ -237,12 +238,12 @@ public class Launcher { return exitRequest.getExitCode(); } - private int parseCommandLine(final String... args) { + private int parseCommandLine(ModuleService moduleService, final String... args) { if (args.length > 0 && !args[0].startsWith(GfshParser.SHORT_OPTION_SPECIFIER)) { - return parseCommandLineCommand(args); + return parseCommandLineCommand(moduleService, args); } - return parseOptions(args); + return parseOptions(moduleService, args); } private void log(Throwable t, Gfsh gfsh) { diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java index ea35931..53d1d54 100755 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java +++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.java @@ -69,6 +69,7 @@ import org.apache.geode.management.internal.cli.shell.jline.GfshUnsupportedTermi import org.apache.geode.management.internal.cli.shell.unsafe.GfshSignalHandler; import org.apache.geode.management.internal.cli.util.CommentSkipHelper; import org.apache.geode.management.internal.i18n.CliStrings; +import org.apache.geode.services.module.ModuleService; /** * Extends an interactive shell provided by @@ -172,7 +173,7 @@ public class Gfsh extends JLineShell { * @param args arguments to be used to create a GemFire shell instance */ protected Gfsh(String[] args) { - this(true, args, new GfshConfig()); + this(true, args, new GfshConfig(), ModuleService.DEFAULT); } /** @@ -182,7 +183,8 @@ public class Gfsh extends JLineShell { * @param launchShell whether to make Console available * @param args arguments to be used to create a GemFire shell instance or execute command */ - protected Gfsh(boolean launchShell, String[] args, GfshConfig gfshConfig) { + protected Gfsh(boolean launchShell, String[] args, GfshConfig gfshConfig, + ModuleService moduleService) { // 1. Disable suppressing of duplicate messages JLineLogHandler.setSuppressDuplicateMessages(false); @@ -195,7 +197,7 @@ public class Gfsh extends JLineShell { // 3. log system properties & gfsh environment TODO: change GFSH to use Geode logging @SuppressWarnings("deprecation") - final Banner banner = new Banner(); + final Banner banner = new Banner(moduleService); this.gfshFileLogger.info(banner.getString()); // 4. Customized History implementation @@ -248,13 +250,14 @@ public class Gfsh extends JLineShell { redirectInternalJavaLoggers(); } - public static Gfsh getInstance(boolean launchShell, String[] args, GfshConfig gfshConfig) { + public static Gfsh getInstance(boolean launchShell, String[] args, GfshConfig gfshConfig, + ModuleService moduleService) { Gfsh localGfshInstance = instance; if (localGfshInstance == null) { synchronized (INSTANCE_LOCK) { localGfshInstance = instance; if (localGfshInstance == null) { - localGfshInstance = new Gfsh(launchShell, args, gfshConfig); + localGfshInstance = new Gfsh(launchShell, args, gfshConfig, moduleService); localGfshInstance.executeInitFileIfPresent(); instance = localGfshInstance; } diff --git a/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshConsoleModeUnitTest.java b/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshConsoleModeUnitTest.java index 34d12cf..81e0ac5 100644 --- a/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshConsoleModeUnitTest.java +++ b/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshConsoleModeUnitTest.java @@ -24,6 +24,8 @@ import java.util.logging.Logger; import org.junit.Before; import org.junit.Test; +import org.apache.geode.services.module.ModuleService; + public class GfshConsoleModeUnitTest extends GfshAbstractUnitTest { @@ -31,12 +33,11 @@ public class GfshConsoleModeUnitTest extends GfshAbstractUnitTest { @Before public void before() { super.before(); - gfsh = new Gfsh(true, null, new GfshConfig()); + gfsh = new Gfsh(true, null, new GfshConfig(), ModuleService.DEFAULT); } @Test public void consoleModeShouldRedirectOnlyJDKLoggers() { - gfsh = new Gfsh(true, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); // when initialized in console mode, all log messages will show up in console diff --git a/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHeadlessModeUnitTest.java b/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHeadlessModeUnitTest.java index e255df9..4732e82 100644 --- a/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHeadlessModeUnitTest.java +++ b/geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHeadlessModeUnitTest.java @@ -24,6 +24,8 @@ import java.util.logging.Logger; import org.junit.Before; import org.junit.Test; +import org.apache.geode.services.module.ModuleService; + public class GfshHeadlessModeUnitTest extends GfshAbstractUnitTest { @@ -31,12 +33,11 @@ public class GfshHeadlessModeUnitTest extends GfshAbstractUnitTest { @Before public void before() { super.before(); - gfsh = new Gfsh(false, null, new GfshConfig()); + gfsh = new Gfsh(false, null, new GfshConfig(), ModuleService.DEFAULT); } @Test public void headlessModeShouldRedirectBothJDKAndGFSHLoggers() { - gfsh = new Gfsh(false, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); while (loggerNames.hasMoreElements()) { diff --git a/geode-gfsh/src/test/resources/expected-pom.xml b/geode-gfsh/src/test/resources/expected-pom.xml index 5bdb326..c57effa 100644 --- a/geode-gfsh/src/test/resources/expected-pom.xml +++ b/geode-gfsh/src/test/resources/expected-pom.xml @@ -112,6 +112,11 @@ <scope>runtime</scope> </dependency> <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-common-services</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <scope>runtime</scope> diff --git a/geode-log4j/build.gradle b/geode-log4j/build.gradle index c02f91a..629867f 100644 --- a/geode-log4j/build.gradle +++ b/geode-log4j/build.gradle @@ -27,6 +27,7 @@ dependencies { implementation(project(':geode-core')) implementation(project(':geode-logging')) + implementation(project(':geode-common-services')) implementation('org.apache.commons:commons-lang3') implementation('org.apache.logging.log4j:log4j-api') diff --git a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationIntegrationTest.java b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationIntegrationTest.java index 483ccb1..da20a89 100644 --- a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationIntegrationTest.java +++ b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationIntegrationTest.java @@ -42,6 +42,7 @@ import org.junit.experimental.categories.Category; import org.apache.geode.logging.internal.Configuration; import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigSupplier; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -89,7 +90,8 @@ public class ConfigurationIntegrationTest { public void updatesLogLevelForScopeGeodeLoggers() { when(logConfig.getLogLevel()).thenReturn(WARNING.intLevel()); - Configuration configuration = Configuration.create(ALWAYS, GEODE_LOGGERS); + Configuration configuration = + Configuration.create(ALWAYS, GEODE_LOGGERS, ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); assertThat(geodeLogger.getLevel()).isEqualTo(Level.WARN); @@ -101,7 +103,8 @@ public class ConfigurationIntegrationTest { public void updatesLogLevelForScopeGeodeAndSecurityLoggers() { when(logConfig.getLogLevel()).thenReturn(WARNING.intLevel()); - Configuration configuration = Configuration.create(ALWAYS, GEODE_AND_SECURITY_LOGGERS); + Configuration configuration = + Configuration.create(ALWAYS, GEODE_AND_SECURITY_LOGGERS, ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); assertThat(geodeLogger.getLevel()).isEqualTo(Level.WARN); @@ -113,7 +116,7 @@ public class ConfigurationIntegrationTest { public void updatesLogLevelForScopeAllLoggers() { when(logConfig.getLogLevel()).thenReturn(WARNING.intLevel()); - Configuration configuration = Configuration.create(ALWAYS, ALL_LOGGERS); + Configuration configuration = Configuration.create(ALWAYS, ALL_LOGGERS, ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); assertThat(geodeLogger.getLevel()).isEqualTo(Level.WARN); @@ -125,7 +128,8 @@ public class ConfigurationIntegrationTest { public void updatesLogLevelForScopeGeodeAndApplicationLoggers() { when(logConfig.getLogLevel()).thenReturn(WARNING.intLevel()); - Configuration configuration = Configuration.create(ALWAYS, GEODE_AND_APPLICATION_LOGGERS); + Configuration configuration = + Configuration.create(ALWAYS, GEODE_AND_APPLICATION_LOGGERS, ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); assertThat(geodeLogger.getLevel()).isEqualTo(Level.WARN); diff --git a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationWithLogLevelChangesIntegrationTest.java b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationWithLogLevelChangesIntegrationTest.java index 1d47731..fe7581e 100644 --- a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationWithLogLevelChangesIntegrationTest.java +++ b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationWithLogLevelChangesIntegrationTest.java @@ -46,6 +46,7 @@ import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigSupplier; import org.apache.geode.logging.internal.spi.LogLevelUpdateOccurs; import org.apache.geode.logging.internal.spi.LogLevelUpdateScope; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -94,7 +95,8 @@ public class ConfigurationWithLogLevelChangesIntegrationTest { LogConfigSupplier logConfigSupplier = mock(LogConfigSupplier.class); when(logConfigSupplier.getLogConfig()).thenReturn(config); - configuration = create(LogLevelUpdateOccurs.ALWAYS, LogLevelUpdateScope.GEODE_LOGGERS); + configuration = create(LogLevelUpdateOccurs.ALWAYS, LogLevelUpdateScope.GEODE_LOGGERS, + ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); geodeLogger = LogService.getLogger(); diff --git a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerIntegrationTest.java b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerIntegrationTest.java index e624d4d..529576e 100644 --- a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerIntegrationTest.java +++ b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerIntegrationTest.java @@ -47,6 +47,7 @@ import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigSupplier; import org.apache.geode.logging.internal.spi.LogLevelUpdateOccurs; import org.apache.geode.logging.internal.spi.LogLevelUpdateScope; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -105,7 +106,8 @@ public class FastLoggerIntegrationTest { LogConfigSupplier logConfigSupplier = mock(LogConfigSupplier.class); when(logConfigSupplier.getLogConfig()).thenReturn(logConfig); - configuration = create(LogLevelUpdateOccurs.NEVER, LogLevelUpdateScope.GEODE_LOGGERS); + configuration = create(LogLevelUpdateOccurs.NEVER, LogLevelUpdateScope.GEODE_LOGGERS, + ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); } diff --git a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerWithDefaultConfigIntegrationTest.java b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerWithDefaultConfigIntegrationTest.java index 32ebef1..31c5a17 100755 --- a/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerWithDefaultConfigIntegrationTest.java +++ b/geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerWithDefaultConfigIntegrationTest.java @@ -31,6 +31,7 @@ import org.apache.geode.logging.internal.spi.LogConfig; import org.apache.geode.logging.internal.spi.LogConfigSupplier; import org.apache.geode.logging.internal.spi.LogLevelUpdateOccurs; import org.apache.geode.logging.internal.spi.LogLevelUpdateScope; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -51,7 +52,8 @@ public class FastLoggerWithDefaultConfigIntegrationTest { when(logConfigSupplier.getLogConfig()).thenReturn(logConfig); Configuration configuration = - Configuration.create(LogLevelUpdateOccurs.ALWAYS, LogLevelUpdateScope.GEODE_LOGGERS); + Configuration.create(LogLevelUpdateOccurs.ALWAYS, LogLevelUpdateScope.GEODE_LOGGERS, + ModuleService.DEFAULT); configuration.initialize(logConfigSupplier); } diff --git a/geode-log4j/src/test/java/org/apache/geode/logging/log4j/internal/impl/LoggingProviderLoaderTest.java b/geode-log4j/src/test/java/org/apache/geode/logging/log4j/internal/impl/LoggingProviderLoaderTest.java index 22f5ed8..0deace0 100644 --- a/geode-log4j/src/test/java/org/apache/geode/logging/log4j/internal/impl/LoggingProviderLoaderTest.java +++ b/geode-log4j/src/test/java/org/apache/geode/logging/log4j/internal/impl/LoggingProviderLoaderTest.java @@ -24,6 +24,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.experimental.categories.Category; import org.apache.geode.logging.internal.LoggingProviderLoader; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.junit.categories.LoggingTest; /** @@ -39,7 +40,7 @@ public class LoggingProviderLoaderTest { @Before public void setUp() { - loggingProviderLoader = new LoggingProviderLoader(); + loggingProviderLoader = new LoggingProviderLoader(ModuleService.DEFAULT); } @Test diff --git a/geode-log4j/src/test/resources/expected-pom.xml b/geode-log4j/src/test/resources/expected-pom.xml index 874caa6..9d81761 100644 --- a/geode-log4j/src/test/resources/expected-pom.xml +++ b/geode-log4j/src/test/resources/expected-pom.xml @@ -57,6 +57,11 @@ <scope>runtime</scope> </dependency> <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-common-services</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <scope>runtime</scope> diff --git a/geode-membership/src/test/resources/expected-pom.xml b/geode-membership/src/test/resources/expected-pom.xml index 95d05f1..b244705 100644 --- a/geode-membership/src/test/resources/expected-pom.xml +++ b/geode-membership/src/test/resources/expected-pom.xml @@ -53,6 +53,11 @@ </dependency> <dependency> <groupId>org.apache.geode</groupId> + <artifactId>geode-common-services</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.geode</groupId> <artifactId>geode-logging</artifactId> <scope>runtime</scope> </dependency> diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/misc/ShutdownAllPersistentGatewaySenderDUnitTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/misc/ShutdownAllPersistentGatewaySenderDUnitTest.java index e7b4629..a149361 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/misc/ShutdownAllPersistentGatewaySenderDUnitTest.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/misc/ShutdownAllPersistentGatewaySenderDUnitTest.java @@ -30,6 +30,7 @@ import org.apache.geode.internal.cache.CacheObserverAdapter; import org.apache.geode.internal.cache.CacheObserverHolder; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.internal.cache.wan.WANTestBase; +import org.apache.geode.services.module.ModuleService; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.AsyncInvocation; import org.apache.geode.test.dunit.IgnoredException; @@ -188,7 +189,7 @@ public class ShutdownAllPersistentGatewaySenderDUnitTest extends WANTestBase { config = AdminDistributedSystemFactory .defineDistributedSystem(cache.getDistributedSystem(), ""); adminDS = (AdminDistributedSystemImpl) AdminDistributedSystemFactory - .getDistributedSystem(config); + .getDistributedSystem(config, ModuleService.DEFAULT); adminDS.connect(); Set members = adminDS.shutDownAllMembers(timeout); int num = members == null ? 0 : members.size();