Wikia / dropwizard-logstash-encoder

Eclipse Public License 1.0
18 stars 28 forks source link

IllegalArgumentException: bufferSize must be a power of 2 #2

Open osigida opened 9 years ago

osigida commented 9 years ago

Hi, I try to use you lib (1.0.2) for logging for DW 0.7.1 but constantly get error. I've configured only host and port, so no any custom configuration provided.

exception looks like:

WrapperSimpleApp: Encountered an error running main: java.lang.IllegalArgumentException: bufferSize must be a power of 2
java.lang.IllegalArgumentException: bufferSize must be a power of 2
    at net.logstash.logback.encoder.com.lmax.disruptor.AbstractSequencer.<init>(AbstractSequencer.java:51)
    at net.logstash.logback.encoder.com.lmax.disruptor.MultiProducerSequencer.<init>(MultiProducerSequencer.java:55)
    at net.logstash.logback.encoder.com.lmax.disruptor.RingBuffer.createMultiProducer(RingBuffer.java:132)
    at net.logstash.logback.encoder.com.lmax.disruptor.RingBuffer.create(RingBuffer.java:200)
    at net.logstash.logback.encoder.com.lmax.disruptor.dsl.Disruptor.<init>(Disruptor.java:87)
    at net.logstash.logback.appender.AsyncDisruptorAppender.start(AsyncDisruptorAppender.java:295)
    at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender.start(AbstractLogstashTcpSocketAppender.java:550)
    at com.wikia.dropwizard.logstash.appender.LogstashTcpAppenderFactory.build(LogstashTcpAppenderFactory.java:78)
    at io.dropwizard.logging.LoggingFactory.configure(LoggingFactory.java:110)
    at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72)
    at io.dropwizard.cli.Cli.run(Cli.java:70)
    at io.dropwizard.Application.run(Application.java:72)
    at com.lgi.kraken.TentacleService.defaultMain(TentacleService.java:66)
    at com.lgi.epg.schedule.ScheduleService.main(ScheduleService.java:39)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
    at java.lang.Thread.run(Thread.java:745)

Thanks a lot, Oleg

osigida commented 9 years ago

I've found out that something set queueSize to 10000, this value will be reused as ringBufferSize. so if I set queueSize: 8192 it works, but still not clear where 10000 comes from

osigida commented 9 years ago

here is the test for the case

@Test
public void testQueueSize() throws Exception {
    final LogstashTcpAppenderFactory logstashTcpAppenderFactory = new LogstashTcpAppenderFactory();
    Assert.assertEquals(AbstractLogstashTcpSocketAppender.DEFAULT_QUEUE_SIZE, logstashTcpAppenderFactory.getQueueSize());
}
osigida commented 9 years ago

this library is compiled with

   <dependency>
      <groupId>net.logstash.logback</groupId>
      <artifactId>logstash-logback-encoder</artifactId>
      <version>3.5</version>
    </dependency>

which has constant: public static final int DEFAULT_QUEUE_SIZE = 10000; see: https://github.com/logstash/logstash-logback-encoder/blob/logstash-logback-encoder-3.5/src/main/java/net/logstash/logback/appender/LogstashTcpSocketAppender.java

I've used logstash-logback-encoder version 4.2, which has this value changed to 8192

however, compiled version of dropwizard-logstash-encoder inlied the value of the constant, so in byte code it has follow values:

    @Min(1L)
    @Max(65535L)
    private int queueSize = 10000;

which make it incompatible with logstash-logback-encoder version 4.2

the fix: set queueSize: 8192 in configuration manually btw, libraries are outdated in the project, better to bump them up