DefaultCommandStore extends AbstractStore implements CommandStore { @Override public CommandReader beginRead(long startOffset) throws IOException { makeSureOpen(); File targetFile = findFileForOffset(startOffset); if (targetFile == null) { throw new IOException("File for offset " + startOffset + " in dir " + baseDir + " does not exist"); } long fileStartOffset = extractStartOffset(targetFile); long channelPosition = startOffset - fileStartOffset; DefaultCommandReader reader = new DefaultCommandReader(targetFile, channelPosition, commandReaderFlyingThreshold); readers.put(reader, Boolean.TRUE); return reader; } DefaultCommandStore(File file, int maxFileSize, KeeperMonitor keeperMonitor);  DefaultCommandStore(File file, int maxFileSize, int minTimeMilliToGcAfterModified, IntSupplier fileNumToKeep, long commandReaderFlyingThreshold, KeeperMonitor keeperMonitor); @Override int appendCommands(ByteBuf byteBuf); @Override long totalLength(); @Override CommandReader beginRead(long startOffset); @Override boolean awaitCommandsOffset(long offset, int timeMilli); @Override long lowestReadingOffset(); @Override void addCommandsListener(long offset, final CommandsListener listener); @Override void close(); @Override void destroy(); @Override String toString(); String simpleDesc(); @Override long lowestAvailableOffset(); @Override void gc(); static final long DEFAULT_COMMAND_READER_FLYING_THRESHOLD; }
@Test public void testBeginRead() throws IOException{ int testCount = 10; long total = commandStore.totalLength(); Assert.assertEquals(0, total); for(int i=0;i < testCount;i++){ commandStore.appendCommands(Unpooled.wrappedBuffer(randomString(maxFileSize).getBytes())); total += maxFileSize; commandStore.beginRead(total); } }