/** * Tests flush operation */ public void testFlush() throws Exception { int count = 10; int bucketId = (int) System.nanoTime(); HdfsSortedOplogOrganizer organizer = new HdfsSortedOplogOrganizer(regionManager, bucketId); // flush and create hoplog ArrayList<TestEvent> items = new ArrayList<TestEvent>(); for (int i = 0; i < count; i++) { items.add(new TestEvent(("key-" + i), ("value-" + System.nanoTime()))); } organizer.flush(items.iterator(), count); // check file existence in bucket directory FileStatus[] hoplogs = getBucketHoplogs(getName() + "/" + bucketId, HdfsSortedOplogOrganizer.FLUSH_HOPLOG_EXTENSION); // only one hoplog should exists assertEquals(1, hoplogs.length); assertEquals(count, organizer.sizeEstimate()); assertEquals(0, stats.getActiveReaderCount()); }
public void testSingleHoplogCardinality() throws Exception { int count = 10; int bucketId = (int) System.nanoTime(); HoplogOrganizer organizer = new HdfsSortedOplogOrganizer(regionManager, bucketId); // flush and create hoplog ArrayList<TestEvent> items = new ArrayList<TestEvent>(); for (int i = 0; i < count; i++) { items.add(new TestEvent(("key-" + i), ("value-" + System.nanoTime()))); } // assert that size is 0 before flush begins assertEquals(0, organizer.sizeEstimate()); organizer.flush(items.iterator(), count); assertEquals(count, organizer.sizeEstimate()); assertEquals(0, stats.getActiveReaderCount()); organizer.close(); organizer = new HdfsSortedOplogOrganizer(regionManager, bucketId); assertEquals(count, organizer.sizeEstimate()); assertEquals(1, stats.getActiveReaderCount()); }
assertEquals(stats.getActiveReaderCount(), stats.getActiveReaderCount()); assertEquals(0, stats.getInactiveFileCount());
assertEquals(0, stats.getActiveReaderCount()); assertEquals(10, stats.getActiveFileCount()); assertEquals(0, stats.getInactiveFileCount()); assertEquals(5, stats.getActiveReaderCount()); assertEquals(0, stats.getActiveReaderCount()); assertEquals(0, stats.getInactiveFileCount());