Java Code Examples for com.typesafe.config.Config#getLong()

The following examples show how to use com.typesafe.config.Config#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DagManager.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve the {@link JobStatus} from the {@link JobExecutionPlan}.
 */
private JobStatus pollJobStatus(DagNode<JobExecutionPlan> dagNode) {
  Config jobConfig = dagNode.getValue().getJobSpec().getConfig();
  String flowGroup = jobConfig.getString(ConfigurationKeys.FLOW_GROUP_KEY);
  String flowName = jobConfig.getString(ConfigurationKeys.FLOW_NAME_KEY);
  long flowExecutionId = jobConfig.getLong(ConfigurationKeys.FLOW_EXECUTION_ID_KEY);
  String jobGroup = jobConfig.getString(ConfigurationKeys.JOB_GROUP_KEY);
  String jobName = jobConfig.getString(ConfigurationKeys.JOB_NAME_KEY);

  long pollStartTime = System.nanoTime();
  Iterator<JobStatus> jobStatusIterator =
      this.jobStatusRetriever.getJobStatusesForFlowExecution(flowName, flowGroup, flowExecutionId, jobName, jobGroup);
  Instrumented.updateTimer(this.jobStatusPolledTimer, System.nanoTime() - pollStartTime, TimeUnit.NANOSECONDS);

  if (jobStatusIterator.hasNext()) {
    return jobStatusIterator.next();
  } else {
    return null;
  }
}
 
Example 2
Source File: LmdbBinderStore.java    From mewbase with MIT License 6 votes vote down vote up
@Deprecated
public LmdbBinderStore(Config cfg) {

    this.docsDir = cfg.getString("mewbase.binders.lmdb.store.basedir");
    this.maxDBs = cfg.getInt("mewbase.binders.lmdb.store.max.binders");
    this.maxDBSize = cfg.getLong("mewbase.binders.lmdb.store.max.binder.size");

    logger.info("Starting LMDB binder store with docs dir: " + docsDir);
    File fDocsDir = new File(docsDir);
    createIfDoesntExists(fDocsDir);
    this.env = Env.<ByteBuffer>create()
            .setMapSize(maxDBSize)
            .setMaxDbs(maxDBs)
            .setMaxReaders(1024)
            .open(fDocsDir, Integer.MAX_VALUE, MDB_NOTLS);

    // get the names all the current binders and open them
    List<byte[]> names = env.getDbiNames();
    names.stream().map( name -> open(new String(name)));
}
 
Example 3
Source File: PubSubReporter.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public PubSubReporter(Config config) {
    this.config = config;
    this.immediateReportTopic = getImmediateReportTopic(config);

    // Get the reporting interval from the config
    long interval = config.getLong("resource-reporting.reporting.interval");

    // Determine the first reporting interval - as much as possible, align
    // with clock boundaries
    long initial_delay = 2 * interval - (System.currentTimeMillis() % interval);

    // Schedule at a fixed rate
    executor.scheduleAtFixedRate(this, initial_delay, interval, TimeUnit.MILLISECONDS);
    System.out.println("Resource reporting executor started");
    
    Runtime.getRuntime().addShutdownHook(new Thread(this)); // Also publish once on shutdown
}
 
Example 4
Source File: AppConfiguration.java    From docker-nginx-consul with MIT License 6 votes vote down vote up
private AppConfiguration(final String appId){
  // load application.conf file
  Config config = ConfigFactory.load();

  this.appId = appId;
  this.serviceName = config.getString("service.name");
  this.host = config.getString("application.host");
  this.port = config.getInt("application.port");
  this.serviceDiscoveryConfiguration =
      new ServiceDiscoveryConfiguration(
          config.getString("discovery.host"),
          config.getInt("discovery.port"),
          config.getLong("discovery.healthcheck-timeout")
      );

}
 
Example 5
Source File: UserProfileAggregatorExecutor.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@Override
public void prepareConfig(Config config) {
    this.site = config.getString("eagleProps.site");
    if(config.hasPath("eagleProps.userProfileGranularity")){
        this.granularity = config.getString("eagleProps.userProfileGranularity");
        LOG.info("Override [userProfileGranularity] = [PT1m]");
    }else{
        LOG.info("Using default [userProfileGranularity] = [PT1m]");
        this.granularity = "PT1m";
    }
    if(config.hasPath("eagleProps.userProfileSafeWindowMs")){
        this.safeWindowMs = config.getLong("eagleProps.userProfileSafeWindowMs");
    }
    if(config.hasPath("eagleProps.userProfileCmdFeatures")){
        String cmdFeaturesStr = config.getString("eagleProps.userProfileCmdFeatures");
        LOG.info(String.format("Override [userProfileCmdFeatures] = [%s]",cmdFeaturesStr));
        this.cmdFeatures = cmdFeaturesStr.split(",");
    }else{
        LOG.info(String.format("Using default [userProfileCmdFeatures] = [%s]", StringUtils.join(this.cmdFeatures,",")));
    }
}
 
Example 6
Source File: Args.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void initRocksDbSettings(Config config) {
    String prefix = "storage.dbSettings.";
    int levelNumber = config.hasPath(prefix + "levelNumber")
            ? config.getInt(prefix + "levelNumber") : 7;
    int compactThreads = config.hasPath(prefix + "compactThreads")
            ? config.getInt(prefix + "compactThreads")
            : max(Runtime.getRuntime().availableProcessors(), 1);
    int blocksize = config.hasPath(prefix + "blocksize")
            ? config.getInt(prefix + "blocksize") : 16;
    long maxBytesForLevelBase = config.hasPath(prefix + "maxBytesForLevelBase")
            ? config.getInt(prefix + "maxBytesForLevelBase") : 256;
    double maxBytesForLevelMultiplier = config.hasPath(prefix + "maxBytesForLevelMultiplier")
            ? config.getDouble(prefix + "maxBytesForLevelMultiplier") : 10;
    int level0FileNumCompactionTrigger =
            config.hasPath(prefix + "level0FileNumCompactionTrigger") ? config
                    .getInt(prefix + "level0FileNumCompactionTrigger") : 2;
    long targetFileSizeBase = config.hasPath(prefix + "targetFileSizeBase") ? config
            .getLong(prefix + "targetFileSizeBase") : 64;
    int targetFileSizeMultiplier = config.hasPath(prefix + "targetFileSizeMultiplier") ? config
            .getInt(prefix + "targetFileSizeMultiplier") : 1;

    INSTANCE.rocksDBCustomSettings = RocksDbSettings
            .initCustomSettings(levelNumber, compactThreads, blocksize, maxBytesForLevelBase,
                    maxBytesForLevelMultiplier, level0FileNumCompactionTrigger,
                    targetFileSizeBase, targetFileSizeMultiplier);
    RocksDbSettings.loggingSettings();
}
 
Example 7
Source File: Configs.java    From kite with Apache License 2.0 5 votes vote down vote up
public long getLong(Config config, String path, long defaults) {
  addRecognizedArgument(path);
  if (config.hasPath(path)) {
    return config.getLong(path);
  } else {
    return defaults;
  }
}
 
Example 8
Source File: KafakOffsetMonitor.java    From cognition with Apache License 2.0 5 votes vote down vote up
public void action() throws IOException, KeeperException, InterruptedException {
  Watcher watcher = event -> logger.debug(event.toString());
  ZooKeeper zooKeeper = new ZooKeeper(zkHosts, 3000, watcher);

  Map<TopicAndPartition, Long> kafkaSpoutOffsets = new HashMap<>();
  Map<TopicAndPartition, SimpleConsumer> kafkaConsumers = new HashMap<>();

  List<String> children = zooKeeper.getChildren(zkRoot + "/" + spoutId, false);
  for (String child : children) {
    byte[] data = zooKeeper.getData(zkRoot + "/" + spoutId + "/" + child, false, null);
    String json = new String(data);
    Config kafkaSpoutOffset = ConfigFactory.parseString(json);

    String topic = kafkaSpoutOffset.getString("topic");
    int partition = kafkaSpoutOffset.getInt("partition");
    long offset = kafkaSpoutOffset.getLong("offset");
    String brokerHost = kafkaSpoutOffset.getString("broker.host");
    int brokerPort = kafkaSpoutOffset.getInt("broker.port");

    TopicAndPartition topicAndPartition = TopicAndPartition.apply(topic, partition);

    kafkaSpoutOffsets.put(topicAndPartition, offset);
    kafkaConsumers.put(topicAndPartition, new SimpleConsumer(brokerHost, brokerPort, 3000, 1024, "kafkaOffsetMonitor"));
  }
  zooKeeper.close();

  sendToLogstash(kafkaSpoutOffsets, kafkaConsumers);
}
 
Example 9
Source File: DagManagerUtils.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private static String generateDagId(Config jobConfig) {
  String flowGroup = jobConfig.getString(ConfigurationKeys.FLOW_GROUP_KEY);
  String flowName = jobConfig.getString(ConfigurationKeys.FLOW_NAME_KEY);
  long flowExecutionId = jobConfig.getLong(ConfigurationKeys.FLOW_EXECUTION_ID_KEY);

  return generateDagId(flowGroup, flowName, flowExecutionId);
}
 
Example 10
Source File: AggregationConfig.java    From eagle with Apache License 2.0 5 votes vote down vote up
/**
 * read configuration file and load hbase config etc.
 */
private void init(Config config) {
    this.config = config;

    //parse stormConfig
    this.stormConfig.site = config.getString("siteId");
    this.stormConfig.aggregationDuration = config.getLong("stormConfig.aggregationDuration");

    //parse eagle zk
    this.zkStateConfig.zkQuorum = config.getString("zookeeper.zkQuorum");
    this.zkStateConfig.zkSessionTimeoutMs = config.getInt("zookeeper.zkSessionTimeoutMs");
    this.zkStateConfig.zkRetryTimes = config.getInt("zookeeper.zkRetryTimes");
    this.zkStateConfig.zkRetryInterval = config.getInt("zookeeper.zkRetryInterval");
    this.zkStateConfig.zkRoot = ZK_ROOT_PREFIX + "/" + this.stormConfig.site;

    // parse eagle service endpoint
    this.eagleServiceConfig.eagleServiceHost = config.getString("service.host");
    String port = config.getString("service.port");
    this.eagleServiceConfig.eagleServicePort = (port == null ? 8080 : Integer.parseInt(port));
    this.eagleServiceConfig.username = config.getString("service.username");
    this.eagleServiceConfig.password = config.getString("service.password");

    LOG.info("Successfully initialized Aggregation Config");
    LOG.info("zookeeper.quorum: " + this.zkStateConfig.zkQuorum);
    LOG.info("service.host: " + this.eagleServiceConfig.eagleServiceHost);
    LOG.info("service.port: " + this.eagleServiceConfig.eagleServicePort);
}
 
Example 11
Source File: Simulator.java    From parity-extras with Apache License 2.0 5 votes vote down vote up
private static Model.Config modelConfig(Config config) {
    double n     = config.getDouble("model.n");
    double s     = config.getDouble("model.s");
    double mu    = config.getDouble("model.mu");
    double delta = config.getDouble("model.delta");
    long   sigma = config.getLong("model.sigma");

    return new Model.Config(n, s, mu, delta, sigma);
}
 
Example 12
Source File: Simulator.java    From parity-extras with Apache License 2.0 5 votes vote down vote up
private static Open open(Config config) throws IOException {
    double bidPrice = config.getDouble("open.bid.price");
    long   bidSize  = config.getLong("open.bid.size");
    double askPrice = config.getDouble("open.ask.price");
    long   askSize  = config.getLong("open.ask.size");

    String instrument = config.getString("instrument");

    return new Open(orderEntry(config), ASCII.packLong(instrument),
            (long)(bidPrice * PRICE_FACTOR), bidSize,
            (long)(askPrice * PRICE_FACTOR), askSize);
}
 
Example 13
Source File: TestStreamingStep.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Config config) {
  if (config.hasPath("batch.size")) {
    batchSize = config.getLong("batch.size") ;
  }
  if (config.hasPath("batch.partitions")) {
    partitions = config.getInt("batch.partitions") ;
  }
}
 
Example 14
Source File: CountDatasetRule.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Config config) {
  if (config.hasPath(EXPECTED_LITERAL_CONFIG)) {
    expected = config.getLong(EXPECTED_LITERAL_CONFIG);
  }
  if (config.hasPath(EXPECTED_DEPENDENCY_CONFIG)) {
    dependency = config.getString(EXPECTED_DEPENDENCY_CONFIG);
  }
}
 
Example 15
Source File: TimeBasedLimiter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
public Limiter buildLimiter(Config config) {
  if (!config.hasPath(MAX_SECONDS_KEY)) {
    throw new RuntimeException("Missing key " + MAX_SECONDS_KEY);
  }
  return new TimeBasedLimiter(config.getLong(MAX_SECONDS_KEY));
}
 
Example 16
Source File: PrintReporter.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PrintReporter(Config config) {
    this.config = config;

    long interval = config.getLong("resource-reporting.reporting.interval");

    // Determine the first reporting interval - as much as possible, align
    // with clock boundaries
    long initial_delay = 2 * interval - (System.currentTimeMillis() % interval);

    // Schedule at a fixed rate
    executor.scheduleAtFixedRate(this, initial_delay, interval, TimeUnit.MILLISECONDS);
    System.out.println("PrintReporter initialized");
}
 
Example 17
Source File: HBaseStorage.java    From cantor with Apache License 2.0 5 votes vote down vote up
HBaseStorage(Config config, String localId) throws Exception {
    this.localId = localId;
    this.hbaseTimeLatticeCol = Bytes.toBytes(localId);
    tableCount = config.hasPath("hbase.table.count") ? config.getInt(
            "hbase.table.count") : TABLE_COUNT;
    ttl = config.hasPath("hbase.ttl") ? config.getLong("hbase.ttl") * 1000L : DEFAULT_TTL;

    hbaseConf = HBaseConfiguration.create();
    hbaseConf.set("hbase.client.retries.number", "1");
    hbaseConf.set("hbase.zookeeper.quorum", config.getString("zookeeper.quorum"));
    hbaseConf.set("hbase.zookeeper.property.clientPort", config.getString("zookeeper.port"));
    hbaseConf.set("zookeeper.znode.parent", config.getString("zookeeper.znode.parent"));
    hbaseConf.set("hbase.hconnection.threads.max",
            config.getString("hbase.hconnection.threads.max"));
    hbaseConf.set("hbase.hconnection.threads.core",
            config.getString("hbase.hconnection.threads.core"));

    connection = ConnectionFactory.createConnection(hbaseConf);
    createTableConnections(tableCount);
    metaTable = getTable(NAMESPACE, META_TABLE);

    ThreadFactory factory = (new ThreadFactoryBuilder()).setDaemon(false)
                                                        .setNameFormat("hbase-probe-%s")
                                                        .setUncaughtExceptionHandler((t, e) -> {
                                                            if (log.isErrorEnabled())
                                                                log.error(
                                                                        "hbase heartbeat thread error [thread {}]",
                                                                        t.getId(), e);
                                                        })
                                                        .build();
    executorService = Executors.newSingleThreadScheduledExecutor(factory);
    checkConn();
    // tricky: check hbase again, interrupts the creation process by exceptions if it fails
    HBaseAdmin.checkHBaseAvailable(hbaseConf);
}
 
Example 18
Source File: StandardServiceConfig.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor from a typesafe config object
 * @param serviceCfg    the service configuration; must be local, i.e. any service namespace
 *                      prefix should be removed using {@link Config#getConfig(String)}.
 **/
public StandardServiceConfig(Config serviceCfg) {
  Config effectiveCfg = serviceCfg.withFallback(DEFAULT_CFG);
  this.startUpTimeoutMs = effectiveCfg.getLong(STARTUP_TIMEOUT_MS_PROP);
  this.shutDownTimeoutMs = effectiveCfg.getLong(SHUTDOWN_TIMEOUT_MS_PROP);
}
 
Example 19
Source File: GobblinInstanceLauncher.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
/** Config accessor from a no namespaced typesafe config. */
public ConfigAccessor(Config cfg) {
  Config effectiveCfg = cfg.withFallback(getDefaultConfig().getConfig(CONFIG_PREFIX));
  this.startTimeoutMs = effectiveCfg.getLong(START_TIMEOUT_MS);
  this.shutdownTimeoutMs = effectiveCfg.getLong(SHUTDOWN_TIMEOUT_MS);
}
 
Example 20
Source File: CountBasedPolicy.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Override
public ThrottlingPolicy createPolicy(SharedLimiterKey key, SharedResourcesBroker<ThrottlingServerScopes> broker, Config config) {
  Preconditions.checkArgument(config.hasPath(COUNT_KEY), "Missing key " + COUNT_KEY);
  return new CountBasedPolicy(config.getLong(COUNT_KEY));
}