Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog2.bootstrap;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.log4j.InstrumentedAppender;
import com.github.joschi.jadconfig.JadConfig;
import com.github.joschi.jadconfig.ParameterException;
import com.github.joschi.jadconfig.Repository;
import com.github.joschi.jadconfig.RepositoryException;
import com.github.joschi.jadconfig.ValidationException;
import com.github.joschi.jadconfig.guava.GuavaConverterFactory;
import com.github.joschi.jadconfig.guice.NamedConfigParametersModule;
import com.github.joschi.jadconfig.jodatime.JodaTimeConverterFactory;
import com.github.joschi.jadconfig.repositories.EnvironmentRepository;
import com.github.joschi.jadconfig.repositories.PropertiesRepository;
import com.github.joschi.jadconfig.repositories.SystemPropertiesRepository;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Binder;
import com.google.inject.CreationException;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.name.Names;
import com.google.inject.spi.Message;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.log4j.Level;
import org.graylog2.plugin.BaseConfiguration;
import org.graylog2.plugin.Plugin;
import org.graylog2.plugin.PluginConfigBean;
import org.graylog2.plugin.PluginLoaderConfig;
import org.graylog2.plugin.PluginMetaData;
import org.graylog2.plugin.PluginModule;
import org.graylog2.plugin.ServerStatus;
import org.graylog2.plugin.Tools;
import org.graylog2.plugin.Version;
import org.graylog2.plugin.system.NodeIdPersistenceException;
import org.graylog2.shared.UI;
import org.graylog2.shared.bindings.GuiceInjectorHolder;
import org.graylog2.shared.bindings.PluginBindings;
import org.graylog2.shared.plugins.PluginLoader;
import org.graylog2.shared.utilities.ExceptionUtils;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.logging.Slf4JLoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.nio.file.AccessDeniedException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Strings.nullToEmpty;
public abstract class CmdLineTool implements CliCommand {
private static final Logger LOG = LoggerFactory.getLogger(CmdLineTool.class);
protected static final String ENVIRONMENT_PREFIX = "GRAYLOG2_";
protected static final String PROPERTIES_PREFIX = "graylog2.";
protected static final Version version = Version.CURRENT_CLASSPATH;
protected static final String FILE_SEPARATOR = System.getProperty("file.separator");
protected static final String TMPDIR = System.getProperty("java.io.tmpdir", "/tmp");
protected final JadConfig jadConfig;
protected final BaseConfiguration configuration;
@Option(name = "--dump-config", description = "Show the effective Graylog configuration and exit")
protected boolean dumpConfig = false;
@Option(name = "--dump-default-config", description = "Show the default configuration and exit")
protected boolean dumpDefaultConfig = false;
@Option(name = {"-d", "--debug"}, description = "Run Graylog in debug mode")
private boolean debug = false;
@Option(name = {"-f", "--configfile"}, description = "Configuration file for Graylog")
private String configFile = "/etc/graylog/server/server.conf";
protected String commandName = "command";
protected Injector injector;
protected CmdLineTool(BaseConfiguration configuration) {
this(null, configuration);
}
protected CmdLineTool(String commandName, BaseConfiguration configuration) {
jadConfig = new JadConfig();
jadConfig.addConverterFactory(new GuavaConverterFactory());
jadConfig.addConverterFactory(new JodaTimeConverterFactory());
if (commandName == null) {
if (this.getClass().isAnnotationPresent(Command.class)) {
this.commandName = this.getClass().getAnnotation(Command.class).name();
} else {
this.commandName = "tool";
}
} else {
this.commandName = commandName;
}
this.configuration = configuration;
}
protected abstract boolean validateConfiguration();
public boolean isDumpConfig() {
return dumpConfig;
}
public boolean isDumpDefaultConfig() {
return dumpDefaultConfig;
}
public boolean isDebug() {
return debug;
}
protected abstract List getCommandBindings();
protected abstract List