public Configuration(String instanceName, String zookeepers, String user, String password, String table) { super.setProperty("instanceName", instanceName); super.setProperty("zookeepers", zookeepers); super.setProperty("user", user); super.setProperty("password", password); super.setProperty("table", table); } }
void save(SimpleConfiguration appConfig) { appConfig.setProperty(PREFIX + mapId + ".combiner", combinerType + ""); if (updateObserverType != null) { appConfig.setProperty(PREFIX + mapId + ".updateObserver", updateObserverType + ""); } } }
@Override protected void setAppConfig(SimpleConfiguration config) { config.setProperty("myapp.sizeLimit", 50000); }
/** * Sets all Fluo properties to their default in the given configuration. NOTE - some properties do * not have defaults and will not be set. */ public static void setDefaultConfiguration(SimpleConfiguration config) { config.setProperty(CONNECTION_ZOOKEEPERS_PROP, CONNECTION_ZOOKEEPERS_DEFAULT); config.setProperty(CONNECTION_ZOOKEEPER_TIMEOUT_PROP, CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT); config.setProperty(DFS_ROOT_PROP, DFS_ROOT_DEFAULT); config.setProperty(ACCUMULO_ZOOKEEPERS_PROP, ACCUMULO_ZOOKEEPERS_DEFAULT); config.setProperty(WORKER_NUM_THREADS_PROP, WORKER_NUM_THREADS_DEFAULT); config.setProperty(TRANSACTION_ROLLBACK_TIME_PROP, TRANSACTION_ROLLBACK_TIME_DEFAULT); config.setProperty(LOADER_NUM_THREADS_PROP, LOADER_NUM_THREADS_DEFAULT); config.setProperty(LOADER_QUEUE_SIZE_PROP, LOADER_QUEUE_SIZE_DEFAULT); config.setProperty(MINI_START_ACCUMULO_PROP, MINI_START_ACCUMULO_DEFAULT); config.setProperty(MINI_DATA_DIR_PROP, MINI_DATA_DIR_DEFAULT); }
/** * Sets all Fluo properties to their default in the given configuration. NOTE - some properties do * not have defaults and will not be set. */ public static void setDefaultConfiguration(SimpleConfiguration config) { config.setProperty(CONNECTION_ZOOKEEPERS_PROP, CONNECTION_ZOOKEEPERS_DEFAULT); config.setProperty(CONNECTION_ZOOKEEPER_TIMEOUT_PROP, CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT); config.setProperty(DFS_ROOT_PROP, DFS_ROOT_DEFAULT); config.setProperty(ACCUMULO_ZOOKEEPERS_PROP, ACCUMULO_ZOOKEEPERS_DEFAULT); config.setProperty(WORKER_NUM_THREADS_PROP, WORKER_NUM_THREADS_DEFAULT); config.setProperty(TRANSACTION_ROLLBACK_TIME_PROP, TRANSACTION_ROLLBACK_TIME_DEFAULT); config.setProperty(LOADER_NUM_THREADS_PROP, LOADER_NUM_THREADS_DEFAULT); config.setProperty(LOADER_QUEUE_SIZE_PROP, LOADER_QUEUE_SIZE_DEFAULT); config.setProperty(MINI_START_ACCUMULO_PROP, MINI_START_ACCUMULO_DEFAULT); config.setProperty(MINI_DATA_DIR_PROP, MINI_DATA_DIR_DEFAULT); }
@Override public void save(FluoConfiguration fluoConf) { SimpleConfiguration appConfig = fluoConf.getAppConfiguration(); // TODO Auto-generated method stub appConfig.setProperty(PREFIX + id + ".instance", instance); appConfig.setProperty(PREFIX + id + ".zookeepers", zookeepers); appConfig.setProperty(PREFIX + id + ".user", user); appConfig.setProperty(PREFIX + id + ".password", password); appConfig.setProperty(PREFIX + id + ".table", table); }
/** * This method provides a standard way to register a table optimization for the Fluo table before * initialization. After Fluo is initialized, the optimizations can be retrieved by calling * {@link #getConfiguredOptimizations(FluoConfiguration)}. * * @param appConfig config, likely obtained from calling * {@link FluoConfiguration#getAppConfiguration()} * @param key A unique identifier for the optimization * @param clazz The optimization factory type. */ public static void registerOptimization(SimpleConfiguration appConfig, String key, Class<? extends TableOptimizationsFactory> clazz) { appConfig.setProperty(PREFIX + key, clazz.getName()); }
static void setSerializer(FluoConfiguration fluoConfig, String serializerType) { fluoConfig.getAppConfiguration().setProperty("recipes.serializer", serializerType); }
/** * Call this to configure a KryoFactory type before initializing Fluo. */ public static void setKryoFactory(FluoConfiguration config, String factoryType) { config.getAppConfiguration().setProperty(KRYO_FACTORY_PROP, factoryType); }
/** * Call this to configure a KryoFactory type before initializing Fluo. */ public static void setKryoFactory(FluoConfiguration config, Class<? extends KryoFactory> factoryType) { config.getAppConfiguration().setProperty(KRYO_FACTORY_PROP, factoryType.getName()); } }
void save(SimpleConfiguration appConfig) { appConfig.setProperty(PREFIX + queueId + ".buckets", buckets + ""); appConfig.setProperty(PREFIX + queueId + ".key", keyType); appConfig.setProperty(PREFIX + queueId + ".val", valueType); if (exporterType != null) { appConfig.setProperty(PREFIX + queueId + ".exporter", exporterType); } if (bufferSize != null) { appConfig.setProperty(PREFIX + queueId + ".bufferSize", bufferSize); } if (bucketsPerTablet != null) { appConfig.setProperty(PREFIX + queueId + ".bucketsPerTablet", bucketsPerTablet); } Bytes exportRangeStart = Bytes.of(queueId + ExportQueue.RANGE_BEGIN); Bytes exportRangeStop = Bytes.of(queueId + ExportQueue.RANGE_END); new TransientRegistry(appConfig).addTransientRange("exportQueue." + queueId, new RowRange(exportRangeStart, exportRangeStop)); TableOptimizations.registerOptimization(appConfig, queueId, Optimizer.class); }
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)); } } } }
/** * Returns a SimpleConfiguration clientConfig with properties set from this configuration * * @return SimpleConfiguration */ public SimpleConfiguration getClientConfiguration() { SimpleConfiguration clientConfig = new SimpleConfiguration(); Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); if (key.startsWith(CONNECTION_PREFIX) || key.startsWith(ACCUMULO_PREFIX) || key.startsWith(CLIENT_PREFIX)) { clientConfig.setProperty(key, getRawString(key)); } } return clientConfig; }
/** * @param fallback SimpleConfiguration to join together * @return a new simple configuration that contains all of the current properties from this plus * the properties from fallback that are not present in this. * * @since 1.2.0 */ public SimpleConfiguration orElse(SimpleConfiguration fallback) { SimpleConfiguration copy = new SimpleConfiguration(this); for (Map.Entry<String, String> entry : fallback.toMap().entrySet()) { if (!copy.containsKey(entry.getKey())) { copy.setProperty(entry.getKey(), entry.getValue()); } } return copy; }
/** * Returns a SimpleConfiguration clientConfig with properties set from this configuration * * @return SimpleConfiguration */ public SimpleConfiguration getClientConfiguration() { SimpleConfiguration clientConfig = new SimpleConfiguration(); Iterator<String> iter = getKeys(); while (iter.hasNext()) { String key = iter.next(); if (key.startsWith(CONNECTION_PREFIX) || key.startsWith(ACCUMULO_PREFIX) || key.startsWith(CLIENT_PREFIX)) { clientConfig.setProperty(key, getRawString(key)); } } return clientConfig; }
@Override public void save(FluoConfiguration fluoConfig) { SimpleConfiguration appConfig = fluoConfig.getAppConfiguration(); appConfig.setProperty(PREFIX + cqId + ".buckets", numBuckets + ""); appConfig.setProperty(PREFIX + cqId + ".key", keyType); appConfig.setProperty(PREFIX + cqId + ".val", valueType); if (bufferSize != null) { appConfig.setProperty(PREFIX + cqId + ".bufferSize", bufferSize); } if (bucketsPerTablet != null) { appConfig.setProperty(PREFIX + cqId + ".bucketsPerTablet", bucketsPerTablet); } Bytes dataRangeEnd = Bytes.of(cqId + DATA_RANGE_END); Bytes updateRangeEnd = Bytes.of(cqId + UPDATE_RANGE_END); new TransientRegistry(fluoConfig.getAppConfiguration()).addTransientRange("cfm." + cqId, new RowRange(dataRangeEnd, updateRangeEnd)); TableOptimizations.registerOptimization(appConfig, cqId, CombineQueue.Optimizer.class); }
public static SimpleConfiguration getZookeeperConfig(FluoConfiguration config) { if (!isInitialized(config)) { throw new IllegalStateException( "Fluo Application '" + config.getApplicationName() + "' has not been initialized"); } SimpleConfiguration zooConfig = new SimpleConfiguration(); try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) { curator.start(); try (ByteArrayInputStream bais = new ByteArrayInputStream(curator.getData().forPath(ZookeeperPath.CONFIG_SHARED))) { Properties sharedProps = new Properties(); sharedProps.load(bais); for (String prop : sharedProps.stringPropertyNames()) { zooConfig.setProperty(prop, sharedProps.getProperty(prop)); } } } catch (Exception e) { throw new IllegalStateException(e); } return zooConfig; }
/** * @param fallback SimpleConfiguration to join together * @return a new simple configuration that contains all of the current properties from this plus * the properties from fallback that are not present in this. * * @since 1.2.0 */ public SimpleConfiguration orElse(SimpleConfiguration fallback) { SimpleConfiguration copy = new SimpleConfiguration(this); for (Map.Entry<String, String> entry : fallback.toMap().entrySet()) { if (!copy.containsKey(entry.getKey())) { copy.setProperty(entry.getKey(), entry.getValue()); } } return copy; }
/** * This method is expected to be called before Fluo is initialized to register transient ranges. * */ public void addTransientRange(String id, RowRange range) { String start = DatatypeConverter.printHexBinary(range.getStart().toArray()); String end = DatatypeConverter.printHexBinary(range.getEnd().toArray()); appConfig.setProperty(PREFIX + id, start + ":" + end); }
/** * This method can be called to register table optimizations before initializing Fluo. This will * register {@link Optimizer} with * {@link TableOptimizations#registerOptimization(SimpleConfiguration, String, Class)}. See the * project level documentation for an example. * * @param fluoConfig The config that will be used to initialize Fluo * @param prefix The prefix used for your Row Hasher. If you have a single instance, could call * {@link RowHasher#getPrefix()}. * @param numTablets Initial number of tablet to create. */ public static void configure(FluoConfiguration fluoConfig, String prefix, int numTablets) { fluoConfig.getAppConfiguration().setProperty(PREFIX + prefix + ".numTablets", numTablets); TableOptimizations.registerOptimization(fluoConfig.getAppConfiguration(), prefix, Optimizer.class); }