mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
DataNode: removing the dependency to the data_dir (#18483)
* removing the dependency to the data_dir * removing the dependency to the data_dir * adding native lib dir
This commit is contained in:
@@ -55,7 +55,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Helper class to hold configuration of Graylog
|
||||
* Helper class to hold configuration of DataNode
|
||||
*/
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class Configuration extends BaseConfiguration {
|
||||
@@ -100,6 +100,9 @@ public class Configuration extends BaseConfiguration {
|
||||
@Parameter(value = "config_location", validators = DirectoryReadableValidator.class)
|
||||
private Path configLocation = null;
|
||||
|
||||
@Parameter(value = "native_lib_dir", required = true)
|
||||
private Path nativeLibDir = Path.of("native_libs");
|
||||
|
||||
@Parameter(value = "process_logs_buffer_size")
|
||||
private Integer opensearchProcessLogsBufferSize = 500;
|
||||
|
||||
@@ -245,7 +248,7 @@ public class Configuration extends BaseConfiguration {
|
||||
|
||||
@Parameter(value = "node_search_cache_size")
|
||||
private String searchCacheSize = "10gb";
|
||||
|
||||
|
||||
/**
|
||||
* https://opensearch.org/docs/latest/tuning-your-cluster/availability-and-recovery/snapshots/snapshot-restore/#shared-file-system
|
||||
*/
|
||||
@@ -437,6 +440,10 @@ public class Configuration extends BaseConfiguration {
|
||||
return metricsPolicy;
|
||||
}
|
||||
|
||||
public Path getNativeLibDir() {
|
||||
return nativeLibDir;
|
||||
}
|
||||
|
||||
public static class NodeIdFileValidator implements Validator<String> {
|
||||
@Override
|
||||
public void validate(String name, String path) throws ValidationException {
|
||||
@@ -663,7 +670,7 @@ public class Configuration extends BaseConfiguration {
|
||||
public String getNodeSearchCacheSize() {
|
||||
return searchCacheSize;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPathRepo() {
|
||||
return pathRepo;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.LoggerContext;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.graylog.datanode.Configuration;
|
||||
import org.graylog.datanode.bootstrap.commands.MigrateCmd;
|
||||
import org.graylog2.bindings.NamedConfigParametersOverrideModule;
|
||||
import org.graylog2.bootstrap.CliCommand;
|
||||
@@ -185,7 +186,7 @@ public abstract class CmdLineTool implements CliCommand {
|
||||
* Things that have to run before the {@link #startCommand()} method is being called.
|
||||
* Please note that this happens *before* the configuration file has been parsed.
|
||||
*/
|
||||
protected void beforeStart(TLSProtocolsConfiguration configuration, PathConfiguration pathConfiguration) {
|
||||
protected void beforeStart(TLSProtocolsConfiguration tlsProtocolsConfiguration, Configuration configuration) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +263,7 @@ public abstract class CmdLineTool implements CliCommand {
|
||||
installCommandConfig();
|
||||
|
||||
beforeStart();
|
||||
beforeStart(parseAndGetTLSConfiguration(), parseAndGetPathConfiguration(configFile));
|
||||
beforeStart(parseAndGetTLSConfiguration(), parseAndGetConfiguration(configFile));
|
||||
|
||||
processConfiguration(jadConfig);
|
||||
|
||||
@@ -306,6 +307,12 @@ public abstract class CmdLineTool implements CliCommand {
|
||||
startCommand();
|
||||
}
|
||||
|
||||
private Configuration parseAndGetConfiguration(String configFile) {
|
||||
final Configuration configuration = new Configuration();
|
||||
processConfiguration(new JadConfig(getConfigRepositories(configFile), configuration));
|
||||
return configuration;
|
||||
}
|
||||
|
||||
// Parse only the TLSConfiguration bean
|
||||
// to avoid triggering anything that might initialize the default SSLContext
|
||||
private TLSProtocolsConfiguration parseAndGetTLSConfiguration() {
|
||||
|
||||
@@ -97,8 +97,8 @@ public abstract class ServerBootstrap extends CmdLineTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeStart(TLSProtocolsConfiguration tlsProtocolsConfiguration, PathConfiguration pathConfiguration) {
|
||||
super.beforeStart(tlsProtocolsConfiguration, pathConfiguration);
|
||||
protected void beforeStart(TLSProtocolsConfiguration tlsProtocolsConfiguration, Configuration configuration) {
|
||||
super.beforeStart(tlsProtocolsConfiguration, configuration);
|
||||
|
||||
// Do not use a PID file if the user requested not to
|
||||
if (!isNoPidFile()) {
|
||||
@@ -109,8 +109,7 @@ public abstract class ServerBootstrap extends CmdLineTool {
|
||||
applySecuritySettings(tlsProtocolsConfiguration);
|
||||
|
||||
// Set these early in the startup because netty's NativeLibraryUtil uses a static initializer
|
||||
setNettyNativeDefaults(pathConfiguration);
|
||||
|
||||
setNettyNativeDefaults(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,10 +174,10 @@ public abstract class ServerBootstrap extends CmdLineTool {
|
||||
});
|
||||
}
|
||||
|
||||
private void setNettyNativeDefaults(PathConfiguration pathConfiguration) {
|
||||
private void setNettyNativeDefaults(Configuration configuration) {
|
||||
// Give netty a better spot than /tmp to unpack its tcnative libraries
|
||||
if (System.getProperty("io.netty.native.workdir") == null) {
|
||||
System.setProperty("io.netty.native.workdir", pathConfiguration.getNativeLibDir().toAbsolutePath().toString());
|
||||
System.setProperty("io.netty.native.workdir", configuration.getNativeLibDir().toAbsolutePath().toString());
|
||||
}
|
||||
// Don't delete the native lib after unpacking, as this confuses needrestart(1) on some distributions
|
||||
if (System.getProperty("io.netty.native.deleteLibAfterLoading") == null) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.graylog.datanode.configuration;
|
||||
import com.github.joschi.jadconfig.Parameter;
|
||||
import org.graylog2.configuration.PathConfiguration;
|
||||
|
||||
public class BaseConfiguration extends PathConfiguration {
|
||||
public class BaseConfiguration {
|
||||
@Parameter(value = "async_eventbus_processors")
|
||||
private int asyncEventbusProcessors = 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user