use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class MessageInputFactory method create.
public MessageInput create(InputCreateRequest lr, String user, String nodeId) throws NoSuchInputTypeException {
final MessageInput input = create(lr.type(), new Configuration(lr.configuration()));
input.setTitle(lr.title());
input.setGlobal(lr.global());
input.setCreatorUserId(user);
input.setCreatedAt(Tools.nowUTC());
if (!lr.global())
input.setNodeId(nodeId);
return input;
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class BlockingBatchedESOutputTest method setUp.
@Before
public void setUp() throws Exception {
this.metricRegistry = new MetricRegistry();
this.journal = new NoopJournal();
this.config = new Configuration() {
@Override
public int getOutputBatchSize() {
return 3;
}
};
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class UdpTransportTest method launchTransportForBootStrapTest.
private UdpTransport launchTransportForBootStrapTest(final ChannelHandler channelHandler) throws MisfireException {
final UdpTransport transport = new UdpTransport(CONFIGURATION, throughputCounter, new LocalMetricRegistry()) {
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
handlers.put("counter", Callables.returning(channelHandler));
handlers.putAll(super.getFinalChannelHandlers(input));
return handlers;
}
};
final MessageInput messageInput = mock(MessageInput.class);
when(messageInput.getId()).thenReturn("TEST");
when(messageInput.getName()).thenReturn("TEST");
transport.launch(messageInput);
return transport;
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class CmdLineTool method run.
@Override
public void run() {
final Level logLevel = setupLogger();
final PluginBindings pluginBindings = installPluginConfigAndBindings(getPluginPath(configFile), chainingClassLoader);
if (isDumpDefaultConfig()) {
dumpDefaultConfigAndExit();
}
final NamedConfigParametersModule configModule = readConfiguration(configFile);
if (isDumpConfig()) {
dumpCurrentConfigAndExit();
}
if (!validateConfiguration()) {
LOG.error("Validating configuration file failed - exiting.");
System.exit(1);
}
beforeStart();
final List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
LOG.info("Running with JVM arguments: {}", Joiner.on(' ').join(arguments));
injector = setupInjector(configModule, pluginBindings, binder -> binder.bind(ChainingClassLoader.class).toInstance(chainingClassLoader));
if (injector == null) {
LOG.error("Injector could not be created, exiting! (Please include the previous error messages in bug reports.)");
System.exit(1);
}
// This is holding all our metrics.
final MetricRegistry metrics = injector.getInstance(MetricRegistry.class);
addInstrumentedAppender(metrics, logLevel);
// Report metrics via JMX.
final JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
reporter.start();
startCommand();
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class Server method startNodeRegistration.
@Override
protected void startNodeRegistration(Injector injector) {
// Register this node.
final NodeService nodeService = injector.getInstance(NodeService.class);
final ServerStatus serverStatus = injector.getInstance(ServerStatus.class);
final ActivityWriter activityWriter = injector.getInstance(ActivityWriter.class);
nodeService.registerServer(serverStatus.getNodeId().toString(), configuration.isMaster(), configuration.getRestTransportUri(), Tools.getLocalCanonicalHostname());
serverStatus.setLocalMode(isLocal());
if (configuration.isMaster() && !nodeService.isOnlyMaster(serverStatus.getNodeId())) {
LOG.warn("Detected another master in the cluster. Retrying in {} seconds to make sure it is not " + "an old stale instance.", TimeUnit.MILLISECONDS.toSeconds(configuration.getStaleMasterTimeout()));
try {
Thread.sleep(configuration.getStaleMasterTimeout());
} catch (InterruptedException e) {
/* nope */
}
if (!nodeService.isOnlyMaster(serverStatus.getNodeId())) {
// All devils here.
String what = "Detected other master node in the cluster! Starting as non-master! " + "This is a mis-configuration you should fix.";
LOG.warn(what);
activityWriter.write(new Activity(what, Server.class));
// Write a notification.
final NotificationService notificationService = injector.getInstance(NotificationService.class);
Notification notification = notificationService.buildNow().addType(Notification.Type.MULTI_MASTER).addSeverity(Notification.Severity.URGENT);
notificationService.publishIfFirst(notification);
configuration.setIsMaster(false);
} else {
LOG.warn("Stale master has gone. Starting as master.");
}
}
}
Aggregations