@Override public long bufferSize() { return sos.bufferSize(); }
private void throttle() { int n = 0; while (sos.bufferSize() + sos.unflushedSize() > maxBufferMemory) { try { Thread.sleep(1 << n++); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } }
@Override public void put(byte[] key, byte[] value) throws IOException { throttle(); if (sos.bufferSize() > bufferSize) { roll(false); } writer.get().append(key, value); sos.put(key, value); }
protected void validateEmpty(SortedOplogSet sos) throws IOException { assertEquals(0, sos.bufferSize()); assertEquals(0, sos.unflushedSize()); SortedIterator<ByteBuffer> iter = sos.scan(); assertFalse(iter.hasNext()); iter.close(); sos.close(); }