@Override public void flushAndClose(EnumMap<Metadata, byte[]> metadata) throws IOException { final AtomicReference<Throwable> err = new AtomicReference<Throwable>(null); flush(metadata, new FlushHandler() { @Override public void complete() { } @Override public void error(Throwable t) { err.set(t); } }); // waits for flush completion close(); Throwable t = err.get(); if (t != null) { throw new IOException(t); } }
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 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()); }
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()); }