From 7858751ab545e403588478ff28742a5e69cf5e88 Mon Sep 17 00:00:00 2001 From: sahusanket Date: Mon, 28 Oct 2024 17:28:18 +0530 Subject: [PATCH] Changing from lamda to a NO OP guice module --- .../ProgramTwillRunnableModuleTest.java | 14 ++------ .../DistributedProgramContainerModule.java | 4 +-- .../runtimejob/DefaultRuntimeJob.java | 3 +- .../InternalServiceRoutingHandlerTest.java | 3 +- .../monitor/RuntimeClientServerTest.java | 3 +- .../monitor/RuntimeClientServiceTest.java | 7 ++-- .../monitor/RuntimeServiceRoutingTest.java | 5 +-- .../app/services/http/AppFabricTestBase.java | 3 +- .../internal/guice/AppFabricTestModule.java | 3 +- .../provisioner/TetheringProvisionerTest.java | 3 +- .../TetheringRuntimeJobManagerTest.java | 3 +- .../cdap/common/guice/NoOpAuditLogModule.java | 32 +++++++++++++++++++ .../DatasetOpExecutorServerTwillRunnable.java | 3 +- .../runtime/main/LogSaverTwillRunnable.java | 3 +- .../main/MetricsProcessorTwillRunnable.java | 3 +- .../runtime/main/MetricsTwillRunnable.java | 3 +- .../AuthorizationTestModule.java | 3 +- .../io/cdap/cdap/SupportBundleTestModule.java | 3 +- .../LeaderElectionMessagingServiceTest.java | 5 +-- .../server/MessagingHttpServiceTest.java | 3 +- .../main/java/io/cdap/cdap/test/TestBase.java | 3 +- .../logging/appender/tms/TestTMSLogging.java | 3 +- ...MessagingMetricsCollectionServiceTest.java | 8 ++--- .../MetricsAdminSubscriberServiceTest.java | 7 ++-- 24 files changed, 83 insertions(+), 47 deletions(-) create mode 100644 cdap-common/src/main/java/io/cdap/cdap/common/guice/NoOpAuditLogModule.java diff --git a/cdap-app-fabric-tests/src/test/java/io/cdap/cdap/internal/app/runtime/distributed/ProgramTwillRunnableModuleTest.java b/cdap-app-fabric-tests/src/test/java/io/cdap/cdap/internal/app/runtime/distributed/ProgramTwillRunnableModuleTest.java index 47e70c0f73d4..cbed3f7d581f 100644 --- a/cdap-app-fabric-tests/src/test/java/io/cdap/cdap/internal/app/runtime/distributed/ProgramTwillRunnableModuleTest.java +++ b/cdap-app-fabric-tests/src/test/java/io/cdap/cdap/internal/app/runtime/distributed/ProgramTwillRunnableModuleTest.java @@ -29,6 +29,7 @@ import io.cdap.cdap.app.runtime.spark.distributed.SparkTwillRunnable; import io.cdap.cdap.common.app.RunIds; import io.cdap.cdap.common.conf.CConfiguration; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.test.MockTwillContext; import io.cdap.cdap.internal.app.runtime.BasicArguments; import io.cdap.cdap.internal.app.runtime.ProgramOptionConstants; @@ -102,7 +103,7 @@ protected ServiceAnnouncer getServiceAnnouncer() { } }.createModule(CConfiguration.create(), new Configuration(), createProgramOptions(programRunId), programRunId); - Injector injector = Guice.createInjector(module, getAuditLogNoOpModule()); + Injector injector = Guice.createInjector(module, new NoOpAuditLogModule()); injector.getInstance(ServiceProgramRunner.class); injector.getInstance(ProgramStateWriter.class); } @@ -156,7 +157,7 @@ protected ServiceAnnouncer getServiceAnnouncer() { - Injector injector = Guice.createInjector(module,getAuditLogNoOpModule()); + Injector injector = Guice.createInjector(module,new NoOpAuditLogModule()); injector.getInstance(SparkProgramRunner.class); injector.getInstance(ProgramStateWriter.class); @@ -182,13 +183,4 @@ private ProgramOptions createProgramOptions(ProgramRunId programRunId) { return new SimpleProgramOptions(programRunId.getParent(), new BasicArguments(systemArgs), new BasicArguments()); } - - private Module getAuditLogNoOpModule(){ - return new AbstractModule() { - @Override - protected void configure() { - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); - } - }; - } } diff --git a/cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/DistributedProgramContainerModule.java b/cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/DistributedProgramContainerModule.java index e302005b100a..b40a81bf1179 100644 --- a/cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/DistributedProgramContainerModule.java +++ b/cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/DistributedProgramContainerModule.java @@ -33,6 +33,7 @@ import io.cdap.cdap.common.guice.DFSLocationModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.KafkaClientModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.SupplierProviderBridge; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; @@ -134,7 +135,7 @@ public DistributedProgramContainerModule(CConfiguration cConf, Configuration hCo @Override protected void configure() { List modules = getCoreModules(); - + modules.add(new NoOpAuditLogModule()); RuntimeMonitorType runtimeMonitorType = SystemArguments.getRuntimeMonitorType(cConf, programOpts); modules.add(RuntimeMonitors.getRemoteAuthenticatorModule(runtimeMonitorType, programOpts)); @@ -148,7 +149,6 @@ protected void configure() { bind(UsageWriter.class).to(MessagingUsageWriter.class); // Overrides the metadata store to be no-op (programs never access it directly) bind(MetadataStorage.class).to(NoopMetadataStorage.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } })); diff --git a/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/distributed/runtimejob/DefaultRuntimeJob.java b/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/distributed/runtimejob/DefaultRuntimeJob.java index 13354453eacf..917d5f479c99 100644 --- a/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/distributed/runtimejob/DefaultRuntimeJob.java +++ b/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/distributed/runtimejob/DefaultRuntimeJob.java @@ -58,6 +58,7 @@ import io.cdap.cdap.common.conf.CConfiguration; import io.cdap.cdap.common.conf.Constants; import io.cdap.cdap.common.discovery.ResolvingDiscoverable; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.io.Locations; import io.cdap.cdap.common.lang.jar.BundleJarUtil; import io.cdap.cdap.common.lang.jar.ClassLoaderFolder; @@ -483,8 +484,6 @@ protected void configure() { bind(ArtifactRepositoryReader.class).to(RemoteArtifactRepositoryReader.class) .in(Scopes.SINGLETON); bind(ArtifactRepository.class).to(RemoteArtifactRepository.class); - - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } }); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/InternalServiceRoutingHandlerTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/InternalServiceRoutingHandlerTest.java index b706160516fa..ce3cf6bd924c 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/InternalServiceRoutingHandlerTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/InternalServiceRoutingHandlerTest.java @@ -31,6 +31,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.http.DefaultHttpRequestConfig; import io.cdap.cdap.common.internal.remote.InternalAuthenticator; import io.cdap.cdap.common.internal.remote.NoOpInternalAuthenticator; @@ -86,6 +87,7 @@ public void beforeTest() throws Exception { new ConfigModule(cConf), new LocalLocationModule(), new InMemoryDiscoveryModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { @@ -94,7 +96,6 @@ protected void configure() { bind(InternalAuthenticator.class).to( NoOpInternalAuthenticator.class); bind(RemoteAuthenticator.class).to(NoOpRemoteAuthenticator.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServerTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServerTest.java index 77c779b12d81..71ae0e23a7a3 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServerTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServerTest.java @@ -34,6 +34,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; import io.cdap.cdap.messaging.DefaultTopicMetadata; @@ -113,6 +114,7 @@ public void beforeTest() throws Exception { Injector injector = Guice.createInjector( new ConfigModule(cConf), RemoteAuthenticatorModules.getNoOpModule(), + new NoOpAuditLogModule(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), @@ -137,7 +139,6 @@ protected void bindLogProcessor() { @Override protected void configure() { bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServiceTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServiceTest.java index 79c94b9f8bbf..8aac8f55fe79 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServiceTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeClientServiceTest.java @@ -45,6 +45,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.io.DatumReader; import io.cdap.cdap.common.io.DatumWriter; @@ -189,9 +190,9 @@ protected void configure() { NoOpMetricsCollectionService.class); bind(DiscoveryService.class).toInstance(discoveryService); bind(DiscoveryServiceClient.class).toInstance(discoveryService); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } - } + }, + new NoOpAuditLogModule() ); messagingService = injector.getInstance(MessagingService.class); @@ -224,6 +225,7 @@ protected void configure() { new AuthorizationEnforcementModule().getNoOpModules(), new AuthenticationContextModules().getNoOpModule(), new IOModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { @@ -234,7 +236,6 @@ protected void configure() { bind(DiscoveryService.class).toInstance(discoveryService); bind(DiscoveryServiceClient.class).toInstance(discoveryService); bind(ProgramRunId.class).toInstance(PROGRAM_RUN_ID); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeServiceRoutingTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeServiceRoutingTest.java index 8a4931f542be..2f8b0bc1545e 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeServiceRoutingTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/runtime/monitor/RuntimeServiceRoutingTest.java @@ -34,6 +34,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.http.DefaultHttpRequestConfig; import io.cdap.cdap.common.internal.remote.NoOpRemoteAuthenticator; import io.cdap.cdap.common.internal.remote.RemoteClient; @@ -134,9 +135,9 @@ protected void bindLogProcessor() { @Override protected void configure() { bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } - } + }, + new NoOpAuditLogModule() ); messagingService = injector.getInstance(MessagingService.class); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/services/http/AppFabricTestBase.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/services/http/AppFabricTestBase.java index 26916e4e040a..ed6d9feeb195 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/services/http/AppFabricTestBase.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/app/services/http/AppFabricTestBase.java @@ -59,6 +59,7 @@ import io.cdap.cdap.common.discovery.EndpointStrategy; import io.cdap.cdap.common.discovery.RandomEndpointStrategy; import io.cdap.cdap.common.discovery.URIScheme; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.id.Id; import io.cdap.cdap.common.internal.remote.DefaultInternalAuthenticator; import io.cdap.cdap.common.internal.remote.RemoteClientFactory; @@ -246,7 +247,7 @@ protected void configure() { // needed because we set Kerberos to true in DefaultNamespaceAdminTest bind(UGIProvider.class).to(CurrentUGIProvider.class); bind(MetadataSubscriberService.class).in(Scopes.SINGLETON); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); + install(new NoOpAuditLogModule()); } }); } diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/guice/AppFabricTestModule.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/guice/AppFabricTestModule.java index 278ab4d3c187..522654c371f3 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/guice/AppFabricTestModule.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/guice/AppFabricTestModule.java @@ -28,6 +28,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.twill.NoopTwillRunnerService; @@ -109,8 +110,8 @@ protected void configure() { install(new MetadataReaderWriterModules().getInMemoryModules()); install(new MessagingServerRuntimeModule().getInMemoryModules()); install(new MockProvisionerModule()); + install(new NoOpAuditLogModule()); // Needed by MonitorHandlerModuler bind(TwillRunner.class).to(NoopTwillRunnerService.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/provisioner/TetheringProvisionerTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/provisioner/TetheringProvisionerTest.java index e98caf4f2045..f9e21e20406c 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/provisioner/TetheringProvisionerTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/provisioner/TetheringProvisionerTest.java @@ -29,6 +29,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; import io.cdap.cdap.data.runtime.StorageModule; import io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule; @@ -67,13 +68,13 @@ public void testGuiceInjector() throws Exception { new ProvisionerModule(), new AuthorizationEnforcementModule().getNoOpModules(), new MessagingServerRuntimeModule().getInMemoryModules(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class); bind(SecureStore.class).toInstance(FakeSecureStore.builder().build()); bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/runtimejob/TetheringRuntimeJobManagerTest.java b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/runtimejob/TetheringRuntimeJobManagerTest.java index 15f23cd00caf..3245d2216391 100644 --- a/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/runtimejob/TetheringRuntimeJobManagerTest.java +++ b/cdap-app-fabric/src/test/java/io/cdap/cdap/internal/tethering/runtime/spi/runtimejob/TetheringRuntimeJobManagerTest.java @@ -39,6 +39,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; import io.cdap.cdap.data.runtime.StorageModule; import io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule; @@ -124,11 +125,11 @@ public static void setUp() throws IOException, TopicAlreadyExistsException, Peer new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new StorageModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } }); // Define all StructuredTable before starting any services that need StructuredTable diff --git a/cdap-common/src/main/java/io/cdap/cdap/common/guice/NoOpAuditLogModule.java b/cdap-common/src/main/java/io/cdap/cdap/common/guice/NoOpAuditLogModule.java new file mode 100644 index 000000000000..aac56ce39d7f --- /dev/null +++ b/cdap-common/src/main/java/io/cdap/cdap/common/guice/NoOpAuditLogModule.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2024 Cask Data, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package io.cdap.cdap.common.guice; + +import com.google.inject.AbstractModule; +import io.cdap.cdap.api.auditlogging.AuditLogWriter; + +/** + * A NO OPERATION guice module for {@link AuditLogWriter}. + * This is to be used in modules where AUDIT LOGGING is not expected, but it is a part of common netty layer binding, + * So it needs to be included. + */ +public class NoOpAuditLogModule extends AbstractModule { + @Override + protected void configure() { + bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); + } +} diff --git a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/DatasetOpExecutorServerTwillRunnable.java b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/DatasetOpExecutorServerTwillRunnable.java index c3353bfe9f7e..62d5e1f5bb5a 100644 --- a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/DatasetOpExecutorServerTwillRunnable.java +++ b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/DatasetOpExecutorServerTwillRunnable.java @@ -31,6 +31,7 @@ import io.cdap.cdap.common.guice.DFSLocationModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.KafkaClientModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; @@ -125,6 +126,7 @@ static Injector createInjector(CConfiguration cConf, Configuration hConf, String new SecureStoreClientModule(), new AuthorizationEnforcementModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { @@ -135,7 +137,6 @@ protected void configure() { // TODO (CDAP-14677): find a better way to inject metadata publisher bind(MetadataPublisher.class).to(MessagingMetadataPublisher.class); bind(MetadataServiceClient.class).to(DefaultMetadataServiceClient.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } }); } diff --git a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/LogSaverTwillRunnable.java b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/LogSaverTwillRunnable.java index 76cf123903f0..202de923e637 100644 --- a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/LogSaverTwillRunnable.java +++ b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/LogSaverTwillRunnable.java @@ -29,6 +29,7 @@ import io.cdap.cdap.common.guice.DFSLocationModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.KafkaClientModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; @@ -119,12 +120,12 @@ static Injector createGuiceInjector(CConfiguration cConf, Configuration hConf, new AuthorizationEnforcementModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), new MessagingClientModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class); bind(UGIProvider.class).to(RemoteUGIProvider.class).in(Scopes.SINGLETON); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsProcessorTwillRunnable.java b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsProcessorTwillRunnable.java index c8bc8bb376b3..cb25e378f7d2 100644 --- a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsProcessorTwillRunnable.java +++ b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsProcessorTwillRunnable.java @@ -32,6 +32,7 @@ import io.cdap.cdap.common.guice.DFSLocationModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.KafkaClientModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; @@ -136,11 +137,11 @@ static Injector createGuiceInjector(CConfiguration cConf, Configuration hConf, S new AuthorizationEnforcementModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), new MetricsWriterModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsTwillRunnable.java b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsTwillRunnable.java index 962799f308fe..356285d1adff 100644 --- a/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsTwillRunnable.java +++ b/cdap-master/src/main/java/io/cdap/cdap/data/runtime/main/MetricsTwillRunnable.java @@ -29,6 +29,7 @@ import io.cdap.cdap.common.guice.DFSLocationModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.KafkaClientModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; @@ -127,12 +128,12 @@ static Injector createGuiceInjector(CConfiguration cConf, Configuration hConf, new AuditModule(), new AuthorizationEnforcementModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class); bind(UGIProvider.class).to(RemoteUGIProvider.class).in(Scopes.SINGLETON); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-security/src/test/java/io/cdap/cdap/security/authorization/AuthorizationTestModule.java b/cdap-security/src/test/java/io/cdap/cdap/security/authorization/AuthorizationTestModule.java index 4b533155af63..8fcb72305a56 100644 --- a/cdap-security/src/test/java/io/cdap/cdap/security/authorization/AuthorizationTestModule.java +++ b/cdap-security/src/test/java/io/cdap/cdap/security/authorization/AuthorizationTestModule.java @@ -23,6 +23,7 @@ import io.cdap.cdap.api.auditlogging.AuditLogWriter; import io.cdap.cdap.api.data.DatasetContext; import io.cdap.cdap.common.conf.Constants; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.security.spi.authorization.AuthorizationContext; import io.cdap.cdap.security.spi.authorization.PermissionManager; @@ -43,7 +44,7 @@ protected void configure() { expose(PermissionManager.class); bind(RoleController.class).to(DelegatingRoleController.class).in(Scopes.SINGLETON);; expose(RoleController.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); + install(new NoOpAuditLogModule()); expose(AuditLogWriter.class); } } diff --git a/cdap-support-bundle/src/test/java/io/cdap/cdap/SupportBundleTestModule.java b/cdap-support-bundle/src/test/java/io/cdap/cdap/SupportBundleTestModule.java index 30a52f5e313f..0c7d34be08cc 100644 --- a/cdap-support-bundle/src/test/java/io/cdap/cdap/SupportBundleTestModule.java +++ b/cdap-support-bundle/src/test/java/io/cdap/cdap/SupportBundleTestModule.java @@ -28,6 +28,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.twill.NoopTwillRunnerService; @@ -103,8 +104,8 @@ protected void configure() { install(new MetadataReaderWriterModules().getInMemoryModules()); install(new MessagingServerRuntimeModule().getInMemoryModules()); install(new MockProvisionerModule()); + install(new NoOpAuditLogModule()); // Needed by MonitorHandlerModuler bind(TwillRunner.class).to(NoopTwillRunnerService.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } diff --git a/cdap-tms/src/test/java/io/cdap/cdap/messaging/distributed/LeaderElectionMessagingServiceTest.java b/cdap-tms/src/test/java/io/cdap/cdap/messaging/distributed/LeaderElectionMessagingServiceTest.java index 7ec95990a9c1..51f7343e474b 100644 --- a/cdap-tms/src/test/java/io/cdap/cdap/messaging/distributed/LeaderElectionMessagingServiceTest.java +++ b/cdap-tms/src/test/java/io/cdap/cdap/messaging/distributed/LeaderElectionMessagingServiceTest.java @@ -31,6 +31,7 @@ import io.cdap.cdap.common.conf.Constants; import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.DFSLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.ZkClientModule; import io.cdap.cdap.common.guice.ZkDiscoveryModule; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; @@ -297,9 +298,9 @@ protected void configure() { bind(MessagingService.class).to(LeaderElectionMessagingService.class) .in(Scopes.SINGLETON); expose(MessagingService.class); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } - } + }, + new NoOpAuditLogModule() ); } } diff --git a/cdap-tms/src/test/java/io/cdap/cdap/messaging/server/MessagingHttpServiceTest.java b/cdap-tms/src/test/java/io/cdap/cdap/messaging/server/MessagingHttpServiceTest.java index b9607fd6537f..04119a7d0abc 100644 --- a/cdap-tms/src/test/java/io/cdap/cdap/messaging/server/MessagingHttpServiceTest.java +++ b/cdap-tms/src/test/java/io/cdap/cdap/messaging/server/MessagingHttpServiceTest.java @@ -32,6 +32,7 @@ import io.cdap.cdap.common.conf.Constants; import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.internal.remote.RemoteClientFactory; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; @@ -118,11 +119,11 @@ public void beforeTest() throws IOException { new AuthenticationContextModules().getNoOpModule(), new AuthorizationEnforcementModule().getNoOpModules(), new MessagingServerRuntimeModule().getInMemoryModules(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService()); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-unit-test/src/main/java/io/cdap/cdap/test/TestBase.java b/cdap-unit-test/src/main/java/io/cdap/cdap/test/TestBase.java index 2f9d635ba780..70a4eff90a52 100644 --- a/cdap-unit-test/src/main/java/io/cdap/cdap/test/TestBase.java +++ b/cdap-unit-test/src/main/java/io/cdap/cdap/test/TestBase.java @@ -70,6 +70,7 @@ import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; import io.cdap.cdap.common.guice.LocalLocationModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.guice.RemoteAuthenticatorModules; import io.cdap.cdap.common.http.DefaultHttpRequestConfig; import io.cdap.cdap.common.namespace.NamespaceAdmin; @@ -322,6 +323,7 @@ protected void configure() { new PreviewManagerModule(false), new PreviewRunnerManagerModule().getInMemoryModules(), new MockProvisionerModule(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { @@ -337,7 +339,6 @@ protected void configure() { // Needed by MonitorHandlerModuler bind(TwillRunner.class).to(NoopTwillRunnerService.class); bind(MetadataSubscriberService.class).in(Scopes.SINGLETON); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-watchdog/src/test/java/io/cdap/cdap/logging/appender/tms/TestTMSLogging.java b/cdap-watchdog/src/test/java/io/cdap/cdap/logging/appender/tms/TestTMSLogging.java index a8468e18e34f..84d50d2d8b8f 100644 --- a/cdap-watchdog/src/test/java/io/cdap/cdap/logging/appender/tms/TestTMSLogging.java +++ b/cdap-watchdog/src/test/java/io/cdap/cdap/logging/appender/tms/TestTMSLogging.java @@ -29,6 +29,7 @@ import io.cdap.cdap.common.conf.Constants; import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.logging.LoggingContext; import io.cdap.cdap.common.metrics.NoOpMetricsCollectionService; import io.cdap.cdap.logging.appender.LogAppenderInitializer; @@ -95,11 +96,11 @@ public static void init() throws IOException, TopicAlreadyExistsException, Unaut new InMemoryDiscoveryModule(), new AuthorizationEnforcementModule().getNoOpModules(), new MessagingServerRuntimeModule().getInMemoryModules(), + new NoOpAuditLogModule(), new AbstractModule() { @Override protected void configure() { bind(MetricsCollectionService.class).toInstance(new NoOpMetricsCollectionService()); - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); } } ); diff --git a/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/collect/MessagingMetricsCollectionServiceTest.java b/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/collect/MessagingMetricsCollectionServiceTest.java index f7226874526a..5097b2a1afa7 100644 --- a/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/collect/MessagingMetricsCollectionServiceTest.java +++ b/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/collect/MessagingMetricsCollectionServiceTest.java @@ -30,6 +30,7 @@ import io.cdap.cdap.api.metrics.MetricsCollectionService; import io.cdap.cdap.common.conf.CConfiguration; import io.cdap.cdap.common.conf.Constants; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.io.BinaryDecoder; import io.cdap.cdap.internal.io.ReflectionDatumReader; import io.cdap.cdap.messaging.DefaultMessageFetchRequest; @@ -140,12 +141,7 @@ private void checkReceivedMetrics(Table expected, Map getAdditionalModules() { List modules = new ArrayList<>(); modules.add(new AuthorizationEnforcementModule().getNoOpModules()); - modules.add(new AbstractModule() { - @Override - protected void configure() { - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); - } - }); + modules.add(new NoOpAuditLogModule()); return modules; } diff --git a/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/process/MetricsAdminSubscriberServiceTest.java b/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/process/MetricsAdminSubscriberServiceTest.java index 98d5ba4a0bde..fa27be8d186e 100644 --- a/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/process/MetricsAdminSubscriberServiceTest.java +++ b/cdap-watchdog/src/test/java/io/cdap/cdap/metrics/process/MetricsAdminSubscriberServiceTest.java @@ -32,6 +32,7 @@ import io.cdap.cdap.common.guice.ConfigModule; import io.cdap.cdap.common.guice.IOModule; import io.cdap.cdap.common.guice.InMemoryDiscoveryModule; +import io.cdap.cdap.common.guice.NoOpAuditLogModule; import io.cdap.cdap.common.utils.Tasks; import io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule; import io.cdap.cdap.messaging.spi.MessagingService; @@ -104,11 +105,9 @@ protected void configure() { // Bind the admin subscriber bind(MetricsAdminSubscriberService.class).in(Scopes.SINGLETON); expose(MetricsAdminSubscriberService.class); - - bind(AuditLogWriter.class).toInstance(auditLogContexts -> {}); - expose(AuditLogWriter.class); } - } + }, + new NoOpAuditLogModule() ); messagingService = injector.getInstance(MessagingService.class);