use of org.komamitsu.fluency.fluentd.FluencyBuilderForFluentd in project fluency by komamitsu.
the class WithRealFluentd method testWithRealFluentd.
@Test
void testWithRealFluentd() throws Exception {
WithRealFluentd.Config config = getConfig();
assumeTrue(config != null);
FluencyBuilderForFluentd builder = new FluencyBuilderForFluentd();
builder.setSslEnabled(config.sslEnabled);
try (Fluency fluency = builder.build(config.host, config.port)) {
Map<String, Object> data = new HashMap<>();
data.put("name", "komamitsu");
data.put("age", 42);
data.put("comment", "hello, world");
ExecutorService executorService = Executors.newCachedThreadPool();
List<Future<Void>> futures = new ArrayList<>();
for (int i = 0; i < config.concurrency; i++) {
futures.add(executorService.submit(new EmitTask(fluency, config.tag, data, config.requests)));
}
for (Future<Void> future : futures) {
future.get(config.waitSeconds, TimeUnit.SECONDS);
}
}
}
use of org.komamitsu.fluency.fluentd.FluencyBuilderForFluentd in project fluency by komamitsu.
the class WithRealFluentd method testWithRealMultipleFluentd.
@Test
void testWithRealMultipleFluentd() throws IOException, InterruptedException, TimeoutException, ExecutionException {
WithRealFluentd.Config config = getConfig();
assumeTrue(config != null);
assumeTrue(config.anotherPort != null);
FluencyBuilderForFluentd builder = new FluencyBuilderForFluentd();
builder.setSslEnabled(config.sslEnabled);
builder.setAckResponseMode(true);
try (Fluency fluency = builder.build(Arrays.asList(new InetSocketAddress(config.host, config.port), new InetSocketAddress(config.host, config.anotherPort)))) {
Map<String, Object> data = new HashMap<>();
data.put("name", "komamitsu");
data.put("age", 42);
data.put("comment", "hello, world");
ExecutorService executorService = Executors.newCachedThreadPool();
List<Future<Void>> futures = new ArrayList<>();
for (int i = 0; i < config.concurrency; i++) {
futures.add(executorService.submit(new EmitTask(fluency, config.tag, data, config.requests)));
}
for (Future<Void> future : futures) {
future.get(config.waitSeconds, TimeUnit.SECONDS);
}
}
}
use of org.komamitsu.fluency.fluentd.FluencyBuilderForFluentd in project fluency by komamitsu.
the class Main method main.
public static void main(String[] args) throws IOException {
String host = args[0];
int port = Integer.parseInt(args[1]);
String tag = args[2];
FluencyBuilderForFluentd builder = new FluencyBuilderForFluentd();
builder.setSslEnabled(true);
builder.setWaitUntilBufferFlushed(5000);
builder.setWaitUntilFlusherTerminated(5000);
builder.setSenderMaxRetryCount(4);
Fluency fluency = builder.build(host, port);
Map<String, Object> event = new HashMap<>();
event.put("name", "komamitsu");
event.put("comment", "zzz");
fluency.emit(tag, event);
fluency.close();
}
use of org.komamitsu.fluency.fluentd.FluencyBuilderForFluentd in project fluency by komamitsu.
the class WithRealFluentd method testWithRealFluentdWithFileBackup.
@Test
void testWithRealFluentdWithFileBackup() throws ExecutionException, TimeoutException, IOException, InterruptedException {
WithRealFluentd.Config config = getConfig();
assumeTrue(config != null);
FluencyBuilderForFluentd builder = new FluencyBuilderForFluentd();
builder.setSslEnabled(config.sslEnabled);
// Fluency might use a lot of buffer for loaded backup files.
// So it'd better increase max buffer size
builder.setMaxBufferSize(512 * 1024 * 1024L);
builder.setFileBackupDir(System.getProperty("java.io.tmpdir"));
try (Fluency fluency = new FluencyBuilderForFluentd().build(config.host, config.port)) {
Map<String, Object> data = new HashMap<>();
data.put("name", "komamitsu");
data.put("age", 42);
data.put("comment", "hello, world");
ExecutorService executorService = Executors.newCachedThreadPool();
List<Future<Void>> futures = new ArrayList<>();
for (int i = 0; i < config.concurrency; i++) {
futures.add(executorService.submit(new EmitTask(fluency, config.tag, data, config.requests)));
}
for (Future<Void> future : futures) {
future.get(config.waitSeconds, TimeUnit.SECONDS);
}
}
}
Aggregations