diff --git a/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorage.java b/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorage.java index 521c29afd..46b6e52e4 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorage.java +++ b/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorage.java @@ -15,18 +15,23 @@ public class TimeBaseStorage implements Storage { private static final boolean isDebug = logger.isDebugEnabled(); private static final int RESERVE_BUFFER_SIZE = 2; + private static final int DEFAULT_BUFFER_SIZE = 20; private boolean discard = true; private boolean limit; private long limitTime = 1000; - private int bufferSize = 20; + private final int bufferSize; - private List storage = new ArrayList(bufferSize + RESERVE_BUFFER_SIZE); + private List storage ; private final DataSender dataSender; private final SpanChunkFactory spanChunkFactory; public TimeBaseStorage(DataSender dataSender, SpanChunkFactory spanChunkFactory) { + this(dataSender, spanChunkFactory, DEFAULT_BUFFER_SIZE); + } + + public TimeBaseStorage(DataSender dataSender, SpanChunkFactory spanChunkFactory, int bufferSize) { if (dataSender == null) { throw new NullPointerException("dataSender must not be null"); } @@ -35,16 +40,14 @@ public class TimeBaseStorage implements Storage { } this.dataSender = dataSender; this.spanChunkFactory = spanChunkFactory; + this.bufferSize = bufferSize; + this.storage = new ArrayList(bufferSize + RESERVE_BUFFER_SIZE); } public void setDiscard(boolean discard) { this.discard = discard; } - public void setBufferSize(int bufferSize) { - this.bufferSize = bufferSize; - } - public void setLimitTime(long limitTime) { this.limitTime = limitTime; } diff --git a/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorageFactory.java b/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorageFactory.java index 6bad0f70f..87e6f52d8 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorageFactory.java +++ b/src/main/java/com/nhn/pinpoint/profiler/context/TimeBaseStorageFactory.java @@ -34,8 +34,7 @@ public class TimeBaseStorageFactory implements StorageFactory { @Override public Storage createStorage() { - TimeBaseStorage timeBaseStorage = new TimeBaseStorage(this.dataSender, spanChunkFactory); - timeBaseStorage.setBufferSize(this.bufferSize); + TimeBaseStorage timeBaseStorage = new TimeBaseStorage(this.dataSender, spanChunkFactory, this.bufferSize); timeBaseStorage.setLimitTime(this.discardTimeLimit); timeBaseStorage.setDiscard(this.discardEnable); return timeBaseStorage;