private HStore init(String methodName, Configuration conf, TableDescriptorBuilder builder, ColumnFamilyDescriptor hcd, MyStoreHook hook, boolean switchToPread) throws IOException { initHRegion(methodName, conf, builder, hcd, hook, switchToPread); if (hook == null) { store = new HStore(region, hcd, conf); } else { store = new MyStore(region, hcd, conf, hook, switchToPread); } return store; }
@Test public void testAge() throws IOException { long currentTime = System.currentTimeMillis(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); edge.setValue(currentTime); EnvironmentEdgeManager.injectEdge(edge); Configuration conf = TEST_UTIL.getConfiguration(); ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.of(family); initHRegion(name.getMethodName(), conf, TableDescriptorBuilder.newBuilder(TableName.valueOf(table)), hcd, null, false); HStore store = new HStore(region, hcd, conf) { @Override protected StoreEngine<?, ?, ?, ?> createStoreEngine(HStore store, Configuration conf, CellComparator kvComparator) throws IOException { List<HStoreFile> storefiles = Arrays.asList(mockStoreFile(currentTime - 10), mockStoreFile(currentTime - 100), mockStoreFile(currentTime - 1000), mockStoreFile(currentTime - 10000)); StoreFileManager sfm = mock(StoreFileManager.class); when(sfm.getStorefiles()).thenReturn(storefiles); StoreEngine<?, ?, ?, ?> storeEngine = mock(StoreEngine.class); when(storeEngine.getStoreFileManager()).thenReturn(sfm); return storeEngine; } }; assertEquals(10L, store.getMinStoreFileAge().getAsLong()); assertEquals(10000L, store.getMaxStoreFileAge().getAsLong()); assertEquals((10 + 100 + 1000 + 10000) / 4.0, store.getAvgStoreFileAge().getAsDouble(), 1E-4); }
private HStore init(String methodName, Configuration conf, TableDescriptorBuilder builder, ColumnFamilyDescriptor hcd, MyStoreHook hook, boolean switchToPread) throws IOException { initHRegion(methodName, conf, builder, hcd, hook, switchToPread); if (hook == null) { store = new HStore(region, hcd, conf); } else { store = new MyStore(region, hcd, conf, hook, switchToPread); } return store; }
@Test public void testAge() throws IOException { long currentTime = System.currentTimeMillis(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); edge.setValue(currentTime); EnvironmentEdgeManager.injectEdge(edge); Configuration conf = TEST_UTIL.getConfiguration(); ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.of(family); initHRegion(name.getMethodName(), conf, TableDescriptorBuilder.newBuilder(TableName.valueOf(table)), hcd, null, false); HStore store = new HStore(region, hcd, conf) { @Override protected StoreEngine<?, ?, ?, ?> createStoreEngine(HStore store, Configuration conf, CellComparator kvComparator) throws IOException { List<HStoreFile> storefiles = Arrays.asList(mockStoreFile(currentTime - 10), mockStoreFile(currentTime - 100), mockStoreFile(currentTime - 1000), mockStoreFile(currentTime - 10000)); StoreFileManager sfm = mock(StoreFileManager.class); when(sfm.getStorefiles()).thenReturn(storefiles); StoreEngine<?, ?, ?, ?> storeEngine = mock(StoreEngine.class); when(storeEngine.getStoreFileManager()).thenReturn(sfm); return storeEngine; } }; assertEquals(10L, store.getMinStoreFileAge().getAsLong()); assertEquals(10000L, store.getMaxStoreFileAge().getAsLong()); assertEquals((10 + 100 + 1000 + 10000) / 4.0, store.getAvgStoreFileAge().getAsDouble(), 1E-4); }