/** * @return An immutable copy of this configurations as a map. Changes to this after toMap() is * called will not be reflected in the map. */ public Map<String, String> toMap() { Builder<String, String> builder = ImmutableMap.builder(); Iterator<String> ki = getKeys(); while (ki.hasNext()) { String k = ki.next(); builder.put(k, getRawString(k)); } return builder.build(); }
/** * @return An immutable copy of this configurations as a map. Changes to this after toMap() is * called will not be reflected in the map. */ public Map<String, String> toMap() { Builder<String, String> builder = ImmutableMap.builder(); Iterator<String> ki = getKeys(); while (ki.hasNext()) { String k = ki.next(); builder.put(k, getRawString(k)); } return builder.build(); }
void save(SimpleConfiguration appConfig) { fluentCfg.save(appConfig); if (exporterConfig != null) { Iterator<String> keys = exporterConfig.getKeys(); while (keys.hasNext()) { String key = keys.next(); appConfig.setProperty(PREFIX + fluentCfg.queueId + ".exporterCfg." + key, exporterConfig.getRawString(key)); } } } }
/** * This method is expected to be called after Fluo is initialized to get the ranges that were * registered before initialization. */ public List<RowRange> getTransientRanges() { List<RowRange> ranges = new ArrayList<>(); Iterator<String> keys = appConfig.getKeys(PREFIX.substring(0, PREFIX.length() - 1)); while (keys.hasNext()) { String key = keys.next(); String val = appConfig.getString(key); String[] sa = val.split(":"); RowRange rowRange = new RowRange(Bytes.of(DatatypeConverter.parseHexBinary(sa[0])), Bytes.of(DatatypeConverter.parseHexBinary(sa[1]))); ranges.add(rowRange); } return ranges; } }
/** * A utility method to get all registered table optimizations. Many recipes will automatically * register table optimizations when configured. */ public static TableOptimizations getConfiguredOptimizations(FluoConfiguration fluoConfig) { try (FluoClient client = FluoFactory.newClient(fluoConfig)) { SimpleConfiguration appConfig = client.getAppConfiguration(); TableOptimizations tableOptim = new TableOptimizations(); SimpleConfiguration subset = appConfig.subset(PREFIX.substring(0, PREFIX.length() - 1)); Iterator<String> keys = subset.getKeys(); while (keys.hasNext()) { String key = keys.next(); String clazz = subset.getString(key); try { TableOptimizationsFactory factory = Class.forName(clazz).asSubclass(TableOptimizationsFactory.class).newInstance(); tableOptim.merge(factory.getTableOptimizations(key, appConfig)); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new RuntimeException(e); } } return tableOptim; } } }