Skip to content

Commit

Permalink
Fix audit manager bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
kfaraz committed Dec 19, 2023
1 parent 33d8a22 commit 1cff032
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
33 changes: 0 additions & 33 deletions server/src/main/java/org/apache/druid/guice/ServerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -74,28 +65,4 @@ public List<? extends Module> 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<String, AuditManager> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

0 comments on commit 1cff032

Please sign in to comment.