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

The following examples show how to use com.typesafe.config.Config#getInt() . 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: HelloWorldSource.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Override
public List<WorkUnit> getWorkunits(SourceState state) {
  Config rootCfg = ConfigUtils.propertiesToConfig(state.getProperties());
  Config cfg = rootCfg.hasPath(CONFIG_NAMESPACE) ? rootCfg.getConfig(CONFIG_NAMESPACE) :
        ConfigFactory.empty();
  int numHellos = cfg.hasPath(NUM_HELLOS_KEY) ? cfg.getInt(NUM_HELLOS_KEY) : DEFAULT_NUM_HELLOS;

  Extract extract = new Extract(TableType.APPEND_ONLY,
       HelloWorldSource.class.getPackage().getName(),
       HelloWorldSource.class.getSimpleName());
  List<WorkUnit> wus = new ArrayList<>(numHellos);
  for (int i = 1; i <= numHellos; ++i) {
    WorkUnit wu = new WorkUnit(extract);
    wu.setProp(HELLO_ID_FULL_KEY, i);
    wus.add(wu);
  }

  return wus;
}
 
Example 2
Source File: BatchLayer.java    From oryx with Apache License 2.0 6 votes vote down vote up
public BatchLayer(Config config) {
  super(config);
  this.keyWritableClass = ClassUtils.loadClass(
      config.getString("oryx.batch.storage.key-writable-class"), Writable.class);
  this.messageWritableClass = ClassUtils.loadClass(
      config.getString("oryx.batch.storage.message-writable-class"), Writable.class);
  this.updateClassName = config.getString("oryx.batch.update-class");
  this.dataDirString = config.getString("oryx.batch.storage.data-dir");
  this.modelDirString = config.getString("oryx.batch.storage.model-dir");
  this.maxDataAgeHours = config.getInt("oryx.batch.storage.max-age-data-hours");
  this.maxModelAgeHours = config.getInt("oryx.batch.storage.max-age-model-hours");
  Preconditions.checkArgument(!dataDirString.isEmpty());
  Preconditions.checkArgument(!modelDirString.isEmpty());
  Preconditions.checkArgument(maxDataAgeHours >= 0 || maxDataAgeHours == NO_MAX_AGE);
  Preconditions.checkArgument(maxModelAgeHours >= 0 || maxModelAgeHours == NO_MAX_AGE);
}
 
Example 3
Source File: WebSocketDataCenterServer.java    From ts-reaktive with MIT License 6 votes vote down vote up
/**
 * Creates the web socket server and binds to the port, according to [config].
 */
public WebSocketDataCenterServer(ActorSystem system, Map<String,ActorRef> tagsAndShardRegions) {
    Config config = system.settings().config().getConfig("ts-reaktive.replication.server");
    ActorMaterializer materializer = SharedActorMaterializer.get(system);
    this.timeout = config.getDuration("timeout");
    this.maxInFlight = config.getInt("max-in-flight");
    Route route = pathPrefix("events", () -> route(
        tagsAndShardRegions.map(t ->
            path(t._1, () ->
                handleWebSocketMessages(flow(t._2))
            )
        ).toJavaArray(Route.class)
    ));
    ConnectHttp httpOpts = SSLFactory.createSSLContext(config).map(sslContext ->
        (ConnectHttp) new ConnectHttpsImpl(config.getString("host"), config.getInt("port"), Optional.of(
            ConnectionContext.https(sslContext, Optional.empty(), Optional.empty(),
                                    Optional.of(TLSClientAuth.need()), Optional.empty())),
                                           UseHttp2.never())
    ).getOrElse(() ->
        ConnectHttp.toHost(config.getString("host"), config.getInt("port"))
    );
    this.binding = Http.get(system).bindAndHandle(route.flow(system, materializer), httpOpts, materializer);
}
 
Example 4
Source File: ServerRpcProvider.java    From swellrt with Apache License 2.0 6 votes vote down vote up
@Inject
public ServerRpcProvider(Config config, SessionManager sessionManager,
    org.eclipse.jetty.server.SessionManager jettySessionManager,
    @ClientServerExecutor Executor executorService) {
  this(
      parseAddressList(config.getStringList("core.http_frontend_addresses"),
          config.getString("core.http_websocket_public_address")),
      config.getStringList("core.resource_bases").toArray(new String[0]), sessionManager,
      jettySessionManager, config.getString("core.sessions_store_directory"),
      config.getBoolean("security.enable_ssl"), config.getString("security.ssl_keystore_path"),
      config.getString("security.ssl_keystore_password"), executorService,
      config.getInt("network.websocket_max_idle_time"),
      config.getInt("network.websocket_max_message_size"),
      config.getInt("network.websocket_heartbeat"),
      config.getInt("network.session_max_inactive_time"),
      config.getInt("network.session_cookie_max_age"),
      config.hasPath("network.session_cookie_domain") ? config.getString("network.session_cookie_domain") : null);
}
 
Example 5
Source File: ServerRpcProvider.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Inject
public WaveWebSocketServlet(ServerRpcProvider provider, Config config) {
  super();
  this.provider = provider;
  this.websocketMaxIdleTime = config.getInt("network.websocket_max_idle_time");
  this.websocketMaxMessageSize = config.getInt("network.websocket_max_message_size");
}
 
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 initBackupProperty(Config config) {
    INSTANCE.backupPriority = config.hasPath("node.backup.priority")
            ? config.getInt("node.backup.priority") : 0;
    INSTANCE.backupPort = config.hasPath("node.backup.port")
            ? config.getInt("node.backup.port") : 5555;
    INSTANCE.backupMembers = config.hasPath("node.backup.members")
            ? config.getStringList("node.backup.members") : new ArrayList<>();
}
 
Example 7
Source File: HBaseUtils.java    From envelope with Apache License 2.0 5 votes vote down vote up
public static int batchSizeFor(Config config) {
  if (config.hasPath(HBASE_BATCH_SIZE)) {
    return config.getInt(HBASE_BATCH_SIZE);
  } else {
    return DEFAULT_HBASE_BATCH_SIZE;
  }
}
 
Example 8
Source File: RDFUpdate.java    From oryx with Apache License 2.0 5 votes vote down vote up
public RDFUpdate(Config config) {
  super(config);
  numTrees = config.getInt("oryx.rdf.num-trees");
  Preconditions.checkArgument(numTrees >= 1);
  hyperParamValues = Arrays.asList(
      HyperParams.fromConfig(config, "oryx.rdf.hyperparams.max-split-candidates"),
      HyperParams.fromConfig(config, "oryx.rdf.hyperparams.max-depth"),
      HyperParams.fromConfig(config, "oryx.rdf.hyperparams.impurity"));

  inputSchema = new InputSchema(config);
  Preconditions.checkArgument(inputSchema.hasTarget());
}
 
Example 9
Source File: RandomParams.java    From ytk-learn with MIT License 5 votes vote down vote up
public RandomParams(Config config, String prefix) {
    mode = Mode.getMode(config.getString(prefix + KEY + "mode"));
    seed = config.getInt(prefix + KEY + "seed");
    normal = new Normal(config, prefix + KEY);
    uniform = new Uniform(config, prefix + KEY);

    CheckUtils.check(mode != Mode.UNKNOWN, "unknown %smode:%s, only support:%s",
            prefix + KEY, mode, Mode.allToString());
}
 
Example 10
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 11
Source File: PubSub.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static synchronized void createDefaultClient() {
    if (defaultClient == null) {
        Config conf = ConfigFactory.load();
        String hostname = conf.getString("pubsub.server.hostname");
        int port = conf.getInt("pubsub.server.port");
        int maxPendingMessages = conf.getInt("pubsub.client.maxPendingMessages");
        boolean daemon = conf.getBoolean("pubsub.client.daemon");
        try {
            defaultClient = startClient(hostname, port, maxPendingMessages, daemon);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 12
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 13
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 14
Source File: AsyncHttpWriterBuilder.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
AsyncHttpWriterBuilder<D, RQ, RP> fromState(State state) {
  if (!(state instanceof WorkUnitState)) {
    throw new IllegalStateException(String.format("AsyncHttpWriterBuilder requires a %s on construction.", WorkUnitState.class.getSimpleName()));
  }

  this.state = (WorkUnitState) state;
  this.metricContext = Instrumented.getMetricContext(this.state, AsyncHttpWriter.class);
  this.broker = this.state.getTaskBroker();
  Config config = ConfigBuilder.create().loadProps(state.getProperties(), CONF_PREFIX).build();
  config = config.withFallback(FALLBACK);
  this.maxOutstandingWrites = config.getInt(MAX_OUTSTANDING_WRITES);
  this.maxAttempts = config.getInt(MAX_ATTEMPTS);
  return fromConfig(config);
}
 
Example 15
Source File: UnitTopologyRunner.java    From eagle with Apache License 2.0 5 votes vote down vote up
private void run(String topologyId,
                 int numOfTotalWorkers,
                 int numOfSpoutTasks,
                 int numOfRouterBolts,
                 int numOfAlertBolts,
                 int numOfPublishExecutors,
                 int numOfPublishTasks,
                 Config config,
                 boolean localMode) {

    backtype.storm.Config stormConfig = givenStormConfig == null ? new backtype.storm.Config() : givenStormConfig;
    // TODO: Configurable metric consumer instance number

    int messageTimeoutSecs = config.hasPath(MESSAGE_TIMEOUT_SECS) ? config.getInt(MESSAGE_TIMEOUT_SECS) : DEFAULT_MESSAGE_TIMEOUT_SECS;
    LOG.info("Set topology.message.timeout.secs as {}", messageTimeoutSecs);
    stormConfig.setMessageTimeoutSecs(messageTimeoutSecs);

    if (config.hasPath("metric")) {
        stormConfig.registerMetricsConsumer(StormMetricTaggedConsumer.class, config.root().render(ConfigRenderOptions.concise()), 1);
    }

    stormConfig.setNumWorkers(numOfTotalWorkers);
    StormTopology topology = buildTopology(topologyId, numOfSpoutTasks, numOfRouterBolts, numOfAlertBolts, numOfPublishExecutors, numOfPublishTasks, config).createTopology();

    if (localMode) {
        LOG.info("Submitting as local mode");
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology(topologyId, stormConfig, topology);
        Utils.sleep(Long.MAX_VALUE);
    } else {
        LOG.info("Submitting as cluster mode");
        try {
            StormSubmitter.submitTopologyWithProgressBar(topologyId, stormConfig, topology);
        } catch (Exception ex) {
            LOG.error("fail submitting topology {}", topology, ex);
            throw new IllegalStateException(ex);
        }
    }
}
 
Example 16
Source File: ServerMain.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private static void initializeServlets(ServerRpcProvider server, Config config) {
  server.addServlet("/gadget/gadgetlist", GadgetProviderServlet.class);

  server.addServlet(AttachmentServlet.ATTACHMENT_URL + "/*", AttachmentServlet.class);
  server.addServlet(AttachmentServlet.THUMBNAIL_URL + "/*", AttachmentServlet.class);
  server.addServlet(AttachmentInfoServlet.ATTACHMENTS_INFO_URL, AttachmentInfoServlet.class);

  server.addServlet(SessionManager.SIGN_IN_URL, AuthenticationServlet.class);
  server.addServlet("/auth/signout", SignOutServlet.class);
  server.addServlet("/auth/register", UserRegistrationServlet.class);

  server.addServlet("/locale/*", LocaleServlet.class);
  server.addServlet("/fetch/*", FetchServlet.class);
  server.addServlet("/search/*", SearchServlet.class);
  server.addServlet("/notification/*", NotificationServlet.class);

  server.addServlet("/robot/dataapi", DataApiServlet.class);
  server.addServlet(DataApiOAuthServlet.DATA_API_OAUTH_PATH + "/*", DataApiOAuthServlet.class);
  server.addServlet("/robot/dataapi/rpc", DataApiServlet.class);
  server.addServlet("/robot/register/*", RobotRegistrationServlet.class);
  server.addServlet("/robot/rpc", ActiveApiServlet.class);
  server.addServlet("/webclient/remote_logging", RemoteLoggingServiceImpl.class);
  server.addServlet("/profile/*", FetchProfilesServlet.class);
  server.addServlet("/iniavatars/*", InitialsAvatarsServlet.class);
  server.addServlet("/waveref/*", WaveRefServlet.class);

  String gadgetServerHostname = config.getString("core.gadget_server_hostname");
  int gadgetServerPort = config.getInt("core.gadget_server_port");
  LOG.info("Starting GadgetProxyServlet for " + gadgetServerHostname + ":" + gadgetServerPort);
  server.addTransparentProxy("/gadgets/*",
      "http://" + gadgetServerHostname + ":" + gadgetServerPort + "/gadgets", "/gadgets");

  server.addServlet("/", WaveClientServlet.class);

  // Profiling
  server.addFilter("/*", RequestScopeFilter.class);
  boolean enableProfiling = config.getBoolean("core.enable_profiling");
  if (enableProfiling) {
    server.addFilter("/*", TimingFilter.class);
    server.addServlet(StatService.STAT_URL, StatuszServlet.class);
  }
}
 
Example 17
Source File: XConfig.java    From xrpc with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a config object using the provided configuration, falling back on the default
 * configuration values <a
 * href="https://github.com/Nordstrom/xrpc/blob/master/src/main/resources/com/nordstrom/xrpc/xrpc.conf">here</a>.
 *
 * @throws RuntimeException if there is an error reading one of path_to_cert or path_to_key
 */
public XConfig(Config configOverrides) {
  Config defaultConfig = ConfigFactory.parseResources(this.getClass(), "xrpc.conf");
  Config config = configOverrides.withFallback(defaultConfig);

  readerIdleTimeout = config.getInt("reader_idle_timeout_seconds");
  writerIdleTimeout = config.getInt("writer_idle_timeout_seconds");
  allIdleTimeout = config.getInt("all_idle_timeout_seconds");
  workerNameFormat = config.getString("worker_name_format");
  bossThreadCount = config.getInt("boss_thread_count");
  workerThreadCount = config.getInt("worker_thread_count");
  asyncHealthCheckThreadCount = config.getInt("async_health_check_thread_count");
  long maxPayloadBytesLong = config.getBytes("max_payload_bytes");
  Preconditions.checkArgument(
      maxPayloadBytesLong <= Integer.MAX_VALUE,
      String.format(
          "value %d for max_payload_bytes must be less than or equal to %d",
          maxPayloadBytesLong, Integer.MAX_VALUE));
  maxPayloadBytes = (int) maxPayloadBytesLong;
  maxConnections = config.getInt("max_connections");
  rateLimiterPoolSize = config.getInt("rate_limiter_pool_size");
  softReqPerSec = config.getDouble("soft_req_per_sec");
  hardReqPerSec = config.getDouble("hard_req_per_sec");
  adminRoutesEnableInfo = config.getBoolean("admin_routes.enable_info");
  adminRoutesEnableUnsafe = config.getBoolean("admin_routes.enable_unsafe");
  defaultContentType = config.getString("default_content_type");
  globalSoftReqPerSec = config.getDouble("global_soft_req_per_sec");
  globalHardReqPerSec = config.getDouble("global_hard_req_per_sec");
  port = config.getInt("server.port");
  slf4jReporter = config.getBoolean("slf4j_reporter");
  jmxReporter = config.getBoolean("jmx_reporter");
  consoleReporter = config.getBoolean("console_reporter");
  slf4jReporterPollingRate = config.getInt("slf4j_reporter_polling_rate");
  consoleReporterPollingRate = config.getInt("console_reporter_polling_rate");
  enableWhiteList = config.getBoolean("enable_white_list");
  enableBlackList = config.getBoolean("enable_black_list");

  ipBlackList =
      ImmutableSet.<String>builder().addAll(config.getStringList("ip_black_list")).build();
  ipWhiteList =
      ImmutableSet.<String>builder().addAll(config.getStringList("ip_white_list")).build();

  corsConfig = buildCorsConfig(config.getConfig("cors"));

  sslContext = SslContextFactory.buildServerContext(buildTlsConfig(config.getConfig("tls")));

  populateClientOverrideList(config.getObjectList("req_per_second_override"));
}
 
Example 18
Source File: RestClient.java    From healenium-web with Apache License 2.0 4 votes vote down vote up
public RestClient(Config config) {
    objectMapper = initMapper();
    baseUrl = "http://" + config.getString("serverHost") + ":" + config.getInt("serverPort") + "/healenium";
    sessionKey = config.hasPath("sessionKey") ? config.getString("sessionKey") : "";
    mapper = new HealeniumMapperImpl();
}
 
Example 19
Source File: SparkHistoryJobAppConfig.java    From eagle with Apache License 2.0 4 votes vote down vote up
private void init(Config config) {
    this.config = config;

    this.zkStateConfig.zkQuorum = config.getString("zookeeper.zkQuorum");
    this.zkStateConfig.zkRetryInterval = config.getInt("zookeeper.zkRetryInterval");
    this.zkStateConfig.zkRetryTimes = config.getInt("zookeeper.zkRetryTimes");
    this.zkStateConfig.zkSessionTimeoutMs = config.getInt("zookeeper.zkSessionTimeoutMs");
    this.zkStateConfig.zkRoot = DEFAULT_SPARK_JOB_HISTORY_ZOOKEEPER_ROOT;
    if (config.hasPath("zookeeper.zkRoot")) {
        this.zkStateConfig.zkRoot = config.getString("zookeeper.zkRoot");
    }

    jobHistoryConfig.rms = config.getString("dataSourceConfig.rm.url").split(",\\s*");
    jobHistoryConfig.baseDir = config.getString("dataSourceConfig.hdfs.baseDir");
    for (Map.Entry<String, ConfigValue> entry : config.getConfig("dataSourceConfig.hdfs").entrySet()) {
        this.jobHistoryConfig.hdfs.put(entry.getKey(), entry.getValue().unwrapped().toString());
    }

    this.eagleInfo.host = config.getString("service.host");
    this.eagleInfo.port = config.getInt("service.port");
    this.eagleInfo.username = config.getString("service.username");
    this.eagleInfo.password = config.getString("service.password");
    this.eagleInfo.timeout = 2;
    if (config.hasPath("service.readTimeOutSeconds")) {
        this.eagleInfo.timeout = config.getInt("service.readTimeOutSeconds");
    }
    this.eagleInfo.basePath = EagleServiceBaseClient.DEFAULT_BASE_PATH;
    if (config.hasPath("service.basePath")) {
        this.eagleInfo.basePath = config.getString("service.basePath");
    }
    this.eagleInfo.flushLimit = 500;
    if (config.hasPath("service.flushLimit")) {
        this.eagleInfo.flushLimit = config.getInt("service.flushLimit");
    }

    this.stormConfig.siteId = config.getString("siteId");
    this.stormConfig.spoutCrawlInterval = config.getInt("topology.spoutCrawlInterval");
    this.stormConfig.numOfSpoutExecutors = config.getInt("topology.numOfSpoutExecutors");
    this.stormConfig.numOfSpoutTasks = config.getInt("topology.numOfSpoutTasks");
    this.stormConfig.numOfParserBoltExecutors = config.getInt("topology.numOfParseBoltExecutors");
    this.stormConfig.numOfParserBoltTasks = config.getInt("topology.numOfParserBoltTasks");
    this.stormConfig.requestLimit = "";
    if (config.hasPath("topology.requestLimit")) {
        this.stormConfig.requestLimit = config.getString("topology.requestLimit");
    }

}
 
Example 20
Source File: Instrument.java    From parity with Apache License 2.0 4 votes vote down vote up
static Instrument fromConfig(Config config, String path) {
    int priceFractionDigits = config.getInt(path + ".price-fraction-digits");
    int sizeFractionDigits  = config.getInt(path + ".size-fraction-digits");

    return new Instrument(path, priceFractionDigits, sizeFractionDigits);
}