当前位置: 首页>>代码示例>>Java>>正文


Java SimpleConfiguration类代码示例

本文整理汇总了Java中org.apache.fluo.api.config.SimpleConfiguration的典型用法代码示例。如果您正苦于以下问题:Java SimpleConfiguration类的具体用法?Java SimpleConfiguration怎么用?Java SimpleConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleConfiguration类属于org.apache.fluo.api.config包,在下文中一共展示了SimpleConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compactTransient

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
/**
 * Compact all transient regions that were registered using {@link TransientRegistry}
 */
public static void compactTransient(FluoConfiguration fluoConfig) throws Exception {
  Connector conn = getConnector(fluoConfig);

  try (FluoClient client = FluoFactory.newClient(fluoConfig)) {
    SimpleConfiguration appConfig = client.getAppConfiguration();

    TransientRegistry transientRegistry = new TransientRegistry(appConfig);
    List<RowRange> ranges = transientRegistry.getTransientRanges();

    for (RowRange r : ranges) {
      long t1 = System.currentTimeMillis();
      conn.tableOperations().compact(fluoConfig.getAccumuloTable(),
          new Text(r.getStart().toArray()), new Text(r.getEnd().toArray()), true, true);
      long t2 = System.currentTimeMillis();
      logger.info("Compacted {} in {}ms", r, (t2 - t1));
    }
  }
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:22,代码来源:TableOperations.java

示例2: getTableOptimizations

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public TableOptimizations getTableOptimizations(String key, SimpleConfiguration appConfig) {
  int numTablets = appConfig.getInt(PREFIX + key + ".numTablets");

  String prefix = key + ":";

  List<Bytes> splits = new ArrayList<>(numTablets - 1);

  int numSplits = numTablets - 1;
  int distance = (((int) Math.pow(Character.MAX_RADIX, HASH_LEN) - 1) / numTablets) + 1;
  int split = distance;
  for (int i = 0; i < numSplits; i++) {
    splits.add(Bytes.of(prefix
        + Strings.padStart(Integer.toString(split, Character.MAX_RADIX), HASH_LEN, '0')));
    split += distance;
  }

  splits.add(Bytes.of(prefix + "~"));


  TableOptimizations tableOptim = new TableOptimizations();
  tableOptim.setSplits(splits);
  tableOptim.setTabletGroupingRegex(Pattern.quote(prefix.toString()));

  return tableOptim;
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:27,代码来源:RowHasher.java

示例3: getConfiguredOptimizations

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
/**
 * 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;
  }
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:27,代码来源:TableOptimizations.java

示例4: save

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:22,代码来源:CqConfigurator.java

示例5: save

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:26,代码来源:FluentConfigurator.java

示例6: testExportQueueOptions

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Test
public void testExportQueueOptions() {
  FluoConfiguration conf = new FluoConfiguration();

  CombineQueue.configure("Q1").keyType("KT").valueType("VT").buckets(100).save(conf);
  CombineQueue.configure("Q2").keyType("KT2").valueType("VT2").buckets(200).bucketsPerTablet(20)
      .bufferSize(1000000).save(conf);

  SimpleConfiguration appConfig = conf.getAppConfiguration();

  Assert.assertEquals(CqConfigurator.getKeyType("Q1", appConfig), "KT");
  Assert.assertEquals(CqConfigurator.getValueType("Q1", appConfig), "VT");
  Assert.assertEquals(CqConfigurator.getNumBucket("Q1", appConfig), 100);
  Assert.assertEquals(CqConfigurator.getBucketsPerTablet("Q1", appConfig),
      CqConfigurator.DEFAULT_BUCKETS_PER_TABLET);
  Assert.assertEquals(CqConfigurator.getBufferSize("Q1", appConfig),
      CqConfigurator.DEFAULT_BUFFER_SIZE);

  Assert.assertEquals(CqConfigurator.getKeyType("Q2", appConfig), "KT2");
  Assert.assertEquals(CqConfigurator.getValueType("Q2", appConfig), "VT2");
  Assert.assertEquals(CqConfigurator.getNumBucket("Q2", appConfig), 200);
  Assert.assertEquals(CqConfigurator.getBucketsPerTablet("Q2", appConfig), 20);
  Assert.assertEquals(CqConfigurator.getBufferSize("Q2", appConfig), 1000000);
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:25,代码来源:OptionsTest.java

示例7: configure

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
/**
 * Configure properties needed to connect to a Fluo application
 *
 * @param conf Job configuration
 * @param config use {@link org.apache.fluo.api.config.FluoConfiguration} to configure
 *        programmatically
 */
@SuppressWarnings("deprecation")
public static void configure(Job conf, SimpleConfiguration config) {
  try {
    FluoConfiguration fconfig = new FluoConfiguration(config);
    try (Environment env = new Environment(fconfig)) {
      long ts =
          env.getSharedResources().getTimestampTracker().allocateTimestamp().getTxTimestamp();
      conf.getConfiguration().setLong(TIMESTAMP_CONF_KEY, ts);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      config.save(baos);
      conf.getConfiguration().set(PROPS_CONF_KEY,
          new String(baos.toByteArray(), StandardCharsets.UTF_8));

      AccumuloInputFormat.setZooKeeperInstance(conf, fconfig.getAccumuloInstance(),
          fconfig.getAccumuloZookeepers());
      AccumuloInputFormat.setConnectorInfo(conf, fconfig.getAccumuloUser(),
          new PasswordToken(fconfig.getAccumuloPassword()));
      AccumuloInputFormat.setInputTableName(conf, env.getTable());
      AccumuloInputFormat.setScanAuthorizations(conf, env.getAuthorizations());
    }
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:fluo,代码行数:33,代码来源:FluoRowInputFormat.java

示例8: configure

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
/**
 * Configure properties needed to connect to a Fluo application
 *
 * @param conf Job configuration
 * @param config use {@link FluoConfiguration} to configure programmatically
 */
@SuppressWarnings("deprecation")
public static void configure(Job conf, SimpleConfiguration config) {
  try {
    FluoConfiguration fconfig = new FluoConfiguration(config);
    try (Environment env = new Environment(fconfig)) {
      long ts =
          env.getSharedResources().getTimestampTracker().allocateTimestamp().getTxTimestamp();
      conf.getConfiguration().setLong(TIMESTAMP_CONF_KEY, ts);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      config.save(baos);
      conf.getConfiguration().set(PROPS_CONF_KEY,
          new String(baos.toByteArray(), StandardCharsets.UTF_8));

      AccumuloInputFormat.setZooKeeperInstance(conf, fconfig.getAccumuloInstance(),
          fconfig.getAccumuloZookeepers());
      AccumuloInputFormat.setConnectorInfo(conf, fconfig.getAccumuloUser(),
          new PasswordToken(fconfig.getAccumuloPassword()));
      AccumuloInputFormat.setInputTableName(conf, env.getTable());
      AccumuloInputFormat.setScanAuthorizations(conf, env.getAuthorizations());
    }
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:fluo,代码行数:32,代码来源:FluoEntryInputFormat.java

示例9: start

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("graphite");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  String host = config.getString("host");
  String prefix = config.getString("prefix", "");
  int port = config.getInt("port", 8080);
  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  Graphite graphite = new Graphite(host, port);
  GraphiteReporter reporter =
      GraphiteReporter.forRegistry(params.getMetricRegistry()).convertDurationsTo(durationUnit)
          .convertRatesTo(rateUnit).prefixedWith(prefix).build(graphite);
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics to graphite server {}:{}", host, port);

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:27,代码来源:GraphiteReporterStarter.java

示例10: start

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("console");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());
  PrintStream out = System.out;
  if (config.getString("target", "stdout").equals("stderr")) {
    out = System.err;
  }

  ConsoleReporter reporter = ConsoleReporter.forRegistry(params.getMetricRegistry())
      .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).outputTo(out).build();
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics to console");

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:26,代码来源:ConsoleReporterStarter.java

示例11: start

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("slf4j");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());
  Logger logger = LoggerFactory.getLogger(config.getString("logger", "metrics"));

  Slf4jReporter reporter = Slf4jReporter.forRegistry(params.getMetricRegistry())
      .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).outputTo(logger).build();
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics using slf4j");

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:23,代码来源:Slf4jReporterStarter.java

示例12: start

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("csv");

  String dir = config.getString("dir", "");
  if (!config.getBoolean("enable", false) || dir.isEmpty()) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  CsvReporter reporter = CsvReporter.forRegistry(params.getMetricRegistry())
      .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).build(new File(dir));
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics as csv to directory {}", dir);

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:23,代码来源:CsvReporterStarter.java

示例13: start

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("jmx");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  JmxReporter reporter =
      JmxReporter.forRegistry(params.getMetricRegistry()).convertDurationsTo(durationUnit)
          .convertRatesTo(rateUnit).inDomain(params.getDomain()).build();
  reporter.start();

  log.info("Reporting metrics to JMX");

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:23,代码来源:JmxReporterStarter.java

示例14: getZookeeperConfig

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
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();

    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;
}
 
开发者ID:apache,项目名称:fluo,代码行数:25,代码来源:FluoAdminImpl.java

示例15: save

import org.apache.fluo.api.config.SimpleConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:11,代码来源:AeFluentConfigurator.java


注:本文中的org.apache.fluo.api.config.SimpleConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。