public void testClearInterruptsFlush() throws Exception { FlushCounter handler = new FlushCounter(); SortedOplogSetImpl sos = prepSoplogSet("clearDuringFlush"); sos.testDelayDuringFlush = new CountDownLatch(1); sos.flush(null, handler); sos.clear(); flushAndWait(handler, sos); validateEmpty(sos); assertEquals(2, handler.flushes.get()); }
public void testCloseInterruptsFlush() throws Exception { FlushCounter handler = new FlushCounter(); SortedOplogSetImpl sos = prepSoplogSet("closeDuringFlush"); sos.testDelayDuringFlush = new CountDownLatch(1); sos.flush(null, handler); sos.close(); assertTrue(sos.isClosed()); assertEquals(1, handler.flushes.get()); }
public void testEmptyFlush() throws Exception { FlushCounter handler = new FlushCounter(); SortedOplogSet sos = prepSoplogSet("empty"); flushAndWait(handler, sos); flushAndWait(handler, sos); }
public void testClearRepeat() throws Exception { int i = 0; do { testClearInterruptsFlush(); LogService.logger().fine("Test " + i + " is complete"); tearDown(); setUp(); } while (i++ < 100); }
public void testMergedIterator() throws IOException { FlushCounter handler = new FlushCounter(); SortedOplogSet sos = createSoplogSet("merge"); sos.put(wrapInt(1), wrapInt(-1)); sos.put(wrapInt(2), wrapInt(-1)); sos.put(wrapInt(3), wrapInt(-1)); sos.put(wrapInt(4), wrapInt(-1)); sos.flush(null, handler); sos.put(wrapInt(2), wrapInt(2)); sos.put(wrapInt(4), wrapInt(-1)); sos.put(wrapInt(6), wrapInt(6)); sos.put(wrapInt(8), wrapInt(8)); sos.flush(null, handler); sos.put(wrapInt(1), wrapInt(-1)); sos.put(wrapInt(3), wrapInt(3)); sos.put(wrapInt(5), wrapInt(-1)); sos.put(wrapInt(7), wrapInt(7)); sos.put(wrapInt(9), wrapInt(9)); sos.flush(null, handler); sos.put(wrapInt(0), wrapInt(0)); sos.put(wrapInt(1), wrapInt(1)); sos.put(wrapInt(4), wrapInt(4)); sos.put(wrapInt(5), wrapInt(5)); ByteBuffer key = iter.next(); ByteBuffer val = iter.value();
public void testDestroy() throws IOException { set.destroy(); assertTrue(((SortedOplogSetImpl) set).isClosed()); try { set.scan(); fail(); } catch (IllegalStateException e) { } }
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(); }
public void testScanAfterClose() throws IOException { SortedIterator<ByteBuffer> iter = set.scan(); set.close(); assertFalse(iter.hasNext()); }
@Override protected SortedReader<ByteBuffer> createReader(NavigableMap<byte[], byte[]> data) throws IOException { set = createSoplogSet("test"); int i = 0; int flushes = 0; FlushCounter fc = new FlushCounter(); for (Entry<byte[], byte[]> entry : data.entrySet()) { set.put(entry.getKey(), entry.getValue()); if (i++ % 13 == 0) { flushes++; set.flush(null, fc); } } while (!fc.flushes.compareAndSet(flushes, 0)); return set; }
public void testErrorDuringFlush() throws Exception { FlushCounter handler = new FlushCounter(); handler.error.set(true); SortedOplogSetImpl sos = prepSoplogSet("err"); sos.testErrorDuringFlush = true; flushAndWait(handler, sos); }
public void testScanAfterClear() throws IOException { SortedIterator<ByteBuffer> iter = set.scan(); set.clear(); assertFalse(iter.hasNext()); }
public void testDestroyInterruptsFlush() throws Exception { FlushCounter handler = new FlushCounter(); SortedOplogSetImpl sos = prepSoplogSet("destroyDuringFlush"); sos.testDelayDuringFlush = new CountDownLatch(1); sos.flush(null, handler); sos.destroy(); assertTrue(sos.isClosed()); assertEquals(1, handler.flushes.get()); }