Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
todvora committed Feb 10, 2025
1 parent 81e2553 commit c25849b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@
import org.graylog2.cluster.certificates.CertificateExchange;
import org.graylog2.cluster.certificates.CertificateExchangeImpl;
import org.graylog2.database.MongoConnection;
import org.graylog2.featureflag.FeatureFlags;
import org.graylog2.shared.plugins.ChainingClassLoader;
import org.graylog2.shared.plugins.GraylogClassLoader;

public class PreflightChecksBindings extends AbstractModule {


private final ChainingClassLoader chainingClassLoader;
private final FeatureFlags featureFlags;

public PreflightChecksBindings(ChainingClassLoader chainingClassLoader, FeatureFlags featureFlags) {
public PreflightChecksBindings(ChainingClassLoader chainingClassLoader) {
this.chainingClassLoader = chainingClassLoader;
this.featureFlags = featureFlags;
}

@Override
Expand All @@ -61,20 +58,12 @@ protected void configure() {
addPreflightCheck(OpenSearchPreconditionsCheck.class);
addPreflightCheck(OpensearchDataDirCompatibilityCheck.class);
addPreflightCheck(PasswordSecretPreflightCheck.class);

bindLimittedObjectMapper();

// Mongodb is needed for legacy datanode storage, where we want to extract the certificate chain from
// mongodb and store it in local keystore
bind(MongoConnection.class).toProvider(MongoConnectionProvider.class);
addPreflightCheck(DatanodeKeystoreCheck.class);
}

private void bindLimittedObjectMapper() {
bind(ClassLoader.class).annotatedWith(GraylogClassLoader.class).toInstance(chainingClassLoader);
bind(ObjectMapper.class).toProvider(PreflightObjectMapperProvider.class).asEagerSingleton();
}

protected void addPreflightCheck(Class<? extends PreflightCheck> preflightCheck) {
preflightChecksBinder().addBinding(preflightCheck.getCanonicalName()).to(preflightCheck);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private Injector getPreflightInjector(List<Module> preflightCheckModules) {
new PreflightClusterConfigurationModule(chainingClassLoader),
new NamedConfigParametersOverrideModule(jadConfig.getConfigurationBeans()),
new ConfigurationModule(configuration),
new PreflightChecksBindings(chainingClassLoader, featureFlags),
new PreflightChecksBindings(chainingClassLoader),
new DatanodeConfigurationBindings(),
new Module() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
*/
package org.graylog.datanode.bootstrap.preflight;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.AbstractModule;
import org.graylog.datanode.bindings.PreflightObjectMapperProvider;
import org.graylog2.cluster.ClusterConfigServiceImpl;
import org.graylog2.plugin.cluster.ClusterConfigService;
import org.graylog2.shared.plugins.ChainingClassLoader;
import org.graylog2.shared.plugins.GraylogClassLoader;

public class PreflightClusterConfigurationModule extends AbstractModule {
private final ChainingClassLoader chainingClassLoader;
Expand All @@ -32,5 +35,12 @@ public PreflightClusterConfigurationModule(ChainingClassLoader chainingClassLoad
protected void configure() {
bind(ChainingClassLoader.class).toInstance(chainingClassLoader);
bind(ClusterConfigService.class).to(ClusterConfigServiceImpl.class).asEagerSingleton();

bindLimitedObjectMapper();
}

private void bindLimitedObjectMapper() {
bind(ClassLoader.class).annotatedWith(GraylogClassLoader.class).toInstance(chainingClassLoader);
bind(ObjectMapper.class).toProvider(PreflightObjectMapperProvider.class).asEagerSingleton();
}
}

0 comments on commit c25849b

Please sign in to comment.