diff --git a/server/src/main/java/org/apache/druid/guice/SQLMetadataStorageDruidModule.java b/server/src/main/java/org/apache/druid/guice/SQLMetadataStorageDruidModule.java index 21d3a58a9769..7ece79ad40f9 100644 --- a/server/src/main/java/org/apache/druid/guice/SQLMetadataStorageDruidModule.java +++ b/server/src/main/java/org/apache/druid/guice/SQLMetadataStorageDruidModule.java @@ -22,6 +22,7 @@ import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Module; +import org.apache.druid.audit.AuditManager; import org.apache.druid.indexer.MetadataStorageUpdaterJobHandler; import org.apache.druid.indexer.SQLMetadataStorageUpdaterJobHandler; import org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator; @@ -44,6 +45,9 @@ import org.apache.druid.metadata.SegmentsMetadataManagerProvider; import org.apache.druid.metadata.SqlSegmentsMetadataManager; import org.apache.druid.metadata.SqlSegmentsMetadataManagerProvider; +import org.apache.druid.server.audit.AuditManagerConfig; +import org.apache.druid.server.audit.AuditSerdeHelper; +import org.apache.druid.server.audit.SQLAuditManager; public class SQLMetadataStorageDruidModule implements Module { @@ -78,6 +82,8 @@ public void createBindingChoices(Binder binder, String defaultValue) PolyBind.createChoiceWithDefault(binder, prop, Key.get(MetadataStorageActionHandlerFactory.class), defaultValue); PolyBind.createChoiceWithDefault(binder, prop, Key.get(MetadataStorageUpdaterJobHandler.class), defaultValue); PolyBind.createChoiceWithDefault(binder, prop, Key.get(MetadataSupervisorManager.class), defaultValue); + + configureAuditManager(binder); } @Override @@ -128,4 +134,22 @@ public void configure(Binder binder) .to(SQLMetadataSupervisorManager.class) .in(LazySingleton.class); } + + private void configureAuditManager(Binder binder) + { + JsonConfigProvider.bind(binder, "druid.audit.manager", AuditManagerConfig.class); + + PolyBind.createChoice( + binder, + "druid.audit.manager.type", + Key.get(AuditManager.class), + Key.get(SQLAuditManager.class) + ); + PolyBind.optionBinder(binder, Key.get(AuditManager.class)) + .addBinding("sql") + .to(SQLAuditManager.class) + .in(LazySingleton.class); + + binder.bind(AuditSerdeHelper.class).in(LazySingleton.class); + } } diff --git a/server/src/main/java/org/apache/druid/guice/ServerModule.java b/server/src/main/java/org/apache/druid/guice/ServerModule.java index b0ae86f4a14a..7ec37a0c4a3c 100644 --- a/server/src/main/java/org/apache/druid/guice/ServerModule.java +++ b/server/src/main/java/org/apache/druid/guice/ServerModule.java @@ -23,10 +23,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; -import com.google.inject.Key; import com.google.inject.Provides; -import com.google.inject.multibindings.MapBinder; -import org.apache.druid.audit.AuditManager; import org.apache.druid.guice.annotations.Self; import org.apache.druid.initialization.DruidModule; import org.apache.druid.jackson.DruidServiceSerializerModifier; @@ -36,10 +33,6 @@ import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.server.DruidNode; -import org.apache.druid.server.audit.AuditManagerConfig; -import org.apache.druid.server.audit.AuditSerdeHelper; -import org.apache.druid.server.audit.LoggingAuditManager; -import org.apache.druid.server.audit.SQLAuditManager; import org.apache.druid.server.initialization.ZkPathsConfig; import java.util.List; @@ -55,8 +48,6 @@ public void configure(Binder binder) { JsonConfigProvider.bind(binder, ZK_PATHS_PROPERTY_BASE, ZkPathsConfig.class); JsonConfigProvider.bind(binder, "druid", DruidNode.class, Self.class); - - configureAuditManager(binder); } @Provides @LazySingleton @@ -74,28 +65,4 @@ public List getJacksonModules() .setSerializerModifier(new DruidServiceSerializerModifier()) ); } - - private void configureAuditManager(Binder binder) - { - JsonConfigProvider.bind(binder, "druid.audit.manager", AuditManagerConfig.class); - - PolyBind.createChoice( - binder, - "druid.audit.manager.type", - Key.get(AuditManager.class), - Key.get(SQLAuditManager.class) - ); - final MapBinder auditManagerBinder - = PolyBind.optionBinder(binder, Key.get(AuditManager.class)); - auditManagerBinder - .addBinding("log") - .to(LoggingAuditManager.class) - .in(LazySingleton.class); - auditManagerBinder - .addBinding("sql") - .to(SQLAuditManager.class) - .in(LazySingleton.class); - - binder.bind(AuditSerdeHelper.class).in(LazySingleton.class); - } } diff --git a/server/src/main/java/org/apache/druid/guice/StartupLoggingModule.java b/server/src/main/java/org/apache/druid/guice/StartupLoggingModule.java index c75b0901a88f..db25a0906c38 100644 --- a/server/src/main/java/org/apache/druid/guice/StartupLoggingModule.java +++ b/server/src/main/java/org/apache/druid/guice/StartupLoggingModule.java @@ -20,7 +20,10 @@ package org.apache.druid.guice; import com.google.inject.Binder; +import com.google.inject.Key; import com.google.inject.Module; +import org.apache.druid.audit.AuditManager; +import org.apache.druid.server.audit.LoggingAuditManager; import org.apache.druid.server.log.StartupLoggingConfig; public class StartupLoggingModule implements Module @@ -29,5 +32,10 @@ public class StartupLoggingModule implements Module public void configure(Binder binder) { JsonConfigProvider.bind(binder, "druid.startup.logging", StartupLoggingConfig.class); + + PolyBind.optionBinder(binder, Key.get(AuditManager.class)) + .addBinding("log") + .to(LoggingAuditManager.class) + .in(LazySingleton.class); } }