@Test public void testGetByPrefix() { TestConfiguration tc = new TestConfiguration(); tc.set(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a1", "325"); tc.set(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a2", "asg34"); tc.set(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i1", "class34"); tc.set(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i1.opt", "o99"); Map<String,String> pm1 = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); Map<String,String> pm2 = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); assertSame(pm1, pm2); Map<String,String> expected1 = new HashMap<>(); expected1.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a1", "325"); expected1.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a2", "asg34"); assertEquals(expected1, pm1); Map<String,String> pm3 = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); Map<String,String> pm4 = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); assertSame(pm3, pm4); Map<String,String> expected2 = new HashMap<>(); expected2.put(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i1", "class34"); expected2.put(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i1.opt", "o99"); assertEquals(expected2, pm3); Map<String,String> pm5 = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); Map<String,String> pm6 = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); assertSame(pm5, pm6); assertEquals(0, pm5.size()); Map<String,String> pm7 = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); assertSame(pm1, pm7); Map<String,String> pm8 = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); assertSame(pm3, pm8); Map<String,String> pm9 = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); assertSame(pm5, pm9); tc.set(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i2", "class42"); tc.set(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i2.opt", "o78234"); expected2.put(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i2", "class42"); expected2.put(Property.TABLE_ITERATOR_SCAN_PREFIX.getKey() + "i2.opt", "o78234"); Map<String,String> pmA = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); Map<String,String> pmB = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); assertNotSame(pm3, pmA); assertSame(pmA, pmB); assertEquals(expected2, pmA); Map<String,String> pmC = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); Map<String,String> pmD = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); assertNotSame(pm1, pmC); assertSame(pmC, pmD); assertEquals(expected1, pmC); tc.set(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "ctx123", "hdfs: Map<String,String> pmE = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); Map<String,String> pmF = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); assertSame(pmE, pmF); assertNotSame(pm5, pmE); assertEquals( Map.of(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "ctx123", "hdfs: Map<String,String> pmG = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); Map<String,String> pmH = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); assertNotSame(pmA, pmG); assertSame(pmG, pmH); assertEquals(expected2, pmG); Map<String,String> pmI = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); Map<String,String> pmJ = tc.getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); assertNotSame(pmC, pmI); assertSame(pmI, pmJ); assertEquals(expected1, pmI); Map<String,String> pmK = tc.getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY); assertSame(pmE, pmK); Map<String,String> pmL = tc.getAllPropertiesWithPrefix(Property.TABLE_ITERATOR_SCAN_PREFIX); assertSame(pmG, pmL); }
public Map<String,String> getAllPropertiesWithPrefix(Property property) { checkType(property, PropertyType.PREFIX); PrefixProps prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != getUpdateCount()) { prefixCacheUpdateLock.lock(); try { long updateCount = getUpdateCount(); prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != updateCount) { Map<String,String> propMap = new HashMap<>(); getProperties(propMap, key -> key.startsWith(property.getKey())); propMap = Map.copyOf(propMap); EnumMap<Property,PrefixProps> localPrefixes = new EnumMap<>(Property.class); localPrefixes.putAll(cachedPrefixProps); prefixProps = new PrefixProps(propMap, updateCount); localPrefixes.put(property, prefixProps); cachedPrefixProps = localPrefixes; } } finally { prefixCacheUpdateLock.unlock(); } } return prefixProps.props; }
AccumuloConfiguration implements Iterable<Entry<String,String>> { public Map<String,String> getAllPropertiesWithPrefix(Property property) { checkType(property, PropertyType.PREFIX); PrefixProps prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != getUpdateCount()) { prefixCacheUpdateLock.lock(); try { long updateCount = getUpdateCount(); prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != updateCount) { Map<String,String> propMap = new HashMap<>(); getProperties(propMap, key -> key.startsWith(property.getKey())); propMap = Map.copyOf(propMap); EnumMap<Property,PrefixProps> localPrefixes = new EnumMap<>(Property.class); localPrefixes.putAll(cachedPrefixProps); prefixProps = new PrefixProps(propMap, updateCount); localPrefixes.put(property, prefixProps); cachedPrefixProps = localPrefixes; } } finally { prefixCacheUpdateLock.unlock(); } } return prefixProps.props; } }
AccumuloConfiguration implements Iterable<Entry<String,String>> { public Map<String,String> getAllPropertiesWithPrefix(Property property) { checkType(property, PropertyType.PREFIX); PrefixProps prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != getUpdateCount()) { prefixCacheUpdateLock.lock(); try { long updateCount = getUpdateCount(); prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != updateCount) { Map<String,String> propMap = new HashMap<>(); getProperties(propMap, key -> key.startsWith(property.getKey())); propMap = Map.copyOf(propMap); EnumMap<Property,PrefixProps> localPrefixes = new EnumMap<>(Property.class); localPrefixes.putAll(cachedPrefixProps); prefixProps = new PrefixProps(propMap, updateCount); localPrefixes.put(property, prefixProps); cachedPrefixProps = localPrefixes; } } finally { prefixCacheUpdateLock.unlock(); } } return prefixProps.props; }  }
AccumuloConfiguration implements Iterable<Entry<String,String>> { public Map<String,String> getAllPropertiesWithPrefix(Property property) { checkType(property, PropertyType.PREFIX); PrefixProps prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != getUpdateCount()) { prefixCacheUpdateLock.lock(); try { long updateCount = getUpdateCount(); prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != updateCount) { Map<String,String> propMap = new HashMap<>(); getProperties(propMap, key -> key.startsWith(property.getKey())); propMap = Map.copyOf(propMap); EnumMap<Property,PrefixProps> localPrefixes = new EnumMap<>(Property.class); localPrefixes.putAll(cachedPrefixProps); prefixProps = new PrefixProps(propMap, updateCount); localPrefixes.put(property, prefixProps); cachedPrefixProps = localPrefixes; } } finally { prefixCacheUpdateLock.unlock(); } } return prefixProps.props; }  String get(String property); abstract String get(Property property); Property resolve(Property property, Property deprecatedProperty); abstract void getProperties(Map<String,String> props, Predicate<String> filter); @Override Iterator<Entry<String,String>> iterator(); long getUpdateCount(); Map<String,String> getAllPropertiesWithPrefix(Property property); Map<String,String> getAllPropertiesWithPrefixStripped(Property prefix); long getAsBytes(Property property); long getTimeInMillis(Property property); boolean getBoolean(Property property); double getFraction(Property property); int[] getPort(Property property); int getCount(Property property); String getPath(Property property); int getMaxFilesPerTablet(); boolean isPropertySet(Property prop, boolean cacheAndWatch); Deriver<T> newDeriver(Function<AccumuloConfiguration,T> converter); Collection<ScanExecutorConfig> getScanExecutors(); void invalidateCache(); }
AccumuloConfiguration implements Iterable<Entry<String,String>> { public Map<String,String> getAllPropertiesWithPrefix(Property property) { checkType(property, PropertyType.PREFIX); PrefixProps prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != getUpdateCount()) { prefixCacheUpdateLock.lock(); try { long updateCount = getUpdateCount(); prefixProps = cachedPrefixProps.get(property); if (prefixProps == null || prefixProps.updateCount != updateCount) { Map<String,String> propMap = new HashMap<>(); getProperties(propMap, key -> key.startsWith(property.getKey())); propMap = Map.copyOf(propMap); EnumMap<Property,PrefixProps> localPrefixes = new EnumMap<>(Property.class); localPrefixes.putAll(cachedPrefixProps); prefixProps = new PrefixProps(propMap, updateCount); localPrefixes.put(property, prefixProps); cachedPrefixProps = localPrefixes; } } finally { prefixCacheUpdateLock.unlock(); } } return prefixProps.props; }  String get(String property); abstract String get(Property property); Property resolve(Property property, Property deprecatedProperty); abstract void getProperties(Map<String,String> props, Predicate<String> filter); @Override Iterator<Entry<String,String>> iterator(); long getUpdateCount(); Map<String,String> getAllPropertiesWithPrefix(Property property); Map<String,String> getAllPropertiesWithPrefixStripped(Property prefix); long getAsBytes(Property property); long getTimeInMillis(Property property); boolean getBoolean(Property property); double getFraction(Property property); int[] getPort(Property property); int getCount(Property property); String getPath(Property property); int getMaxFilesPerTablet(); boolean isPropertySet(Property prop, boolean cacheAndWatch); Deriver<T> newDeriver(Function<AccumuloConfiguration,T> converter); Collection<ScanExecutorConfig> getScanExecutors(); void invalidateCache();  }