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

The following examples show how to use com.typesafe.config.Config#getString() . 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: Stargraph.java    From Stargraph with MIT License 6 votes vote down vote up
IndicesFactory getIndicesFactory(KBId kbId) {
    final String idxStorePath = "index-store.factory.class";
    if (kbId != null) {
        //from model configuration
        Config modelCfg = getModelConfig(kbId);
        if (modelCfg.hasPath(idxStorePath)) {
            String className = modelCfg.getString(idxStorePath);
            logger.info(marker, "Using '{}'.", className);
            return createIndicesFactory(className);
        }
    }

    if (indicesFactory == null) {
        //from main configuration if not already set
        indicesFactory = createIndicesFactory(getMainConfig().getString(idxStorePath));
    }

    return indicesFactory;
}
 
Example 2
Source File: SchemaPublication.java    From kafka-tutorials with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        Config config = ConfigFactory.load();

        String registryUrl = config.getString("schema.registry.url");

        CachedSchemaRegistryClient schemaRegistryClient  = new CachedSchemaRegistryClient(registryUrl, 10);

        try {
            logger.info(String.format("Schemas publication at: %s", registryUrl));

            schemaRegistryClient.register(
                    String.format("%s-value", config.getString("input.topic.name")),
                    PressureAlert.SCHEMA$
            );
        } catch (IOException | RestClientException e) {
            e.printStackTrace();
        }
    }
 
Example 3
Source File: PivotTracing.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Initialize the PivotTracing agent.  This call will subscribe to pubsub
 * in order to receive weave commands, and attempt to connect to the process's debug port */
public static synchronized void initialize() {
    // Only initialize once
    if (agent != null) {
        return;
    }
    
    // Get the PT agent config
    Config config = ConfigFactory.load();
    boolean useBaggage = config.getBoolean("pivot-tracing.agent.use_baggage");
    boolean useDynamic = config.getBoolean("pivot-tracing.agent.use_dynamic");
    boolean emitIfNoResults = config.getBoolean("pivot-tracing.agent.emit_if_no_results");
    String resultsTopic = config.getString("pivot-tracing.pubsub.results_topic");
    int reportInterval = config.getInt("pivot-tracing.agent.report_interval_ms");
        
    // Create APIs
    BaggageAPI baggageApi = useBaggage ? new BaggageAPIImpl() : new BaggageAPIDisabled();
    EmitAPI emitApi = new EmitAPIImpl(reportInterval, resultsTopic, emitIfNoResults);
    DynamicManager dynamic = useDynamic ? DynamicInstrumentation.get() : null;
    
    // Create the agent and register it with the privileged proxy
    agent = new PTAgent(baggageApi, emitApi, dynamic);
    PrivilegedProxy.Register(agent);
    
    System.out.println("Pivot Tracing initialized");
}
 
Example 4
Source File: WalletClient.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * constructor.
 */

public static boolean init(int itype) {
    Config config = Configuration.getByPath("testng.conf");
    dbPath = config.getString("CityDb.DbPath");
    txtPath = System.getProperty("user.dir") + '/' + config.getString("CityDb.TxtPath");

    String fullNodepathname = "";

    if (1000 == itype) {
        fullNodepathname = "checkfullnode.ip.list";
    } else {
        fullNodepathname = "fullnode.ip.list";
    }
    String fullNode = "";
    String confirmednode = "";
    if (config.hasPath("confirmednode.ip.list")) {
        confirmednode = config.getStringList("confirmednode.ip.list").get(0);
    }
    if (config.hasPath(fullNodepathname)) {
        fullNode = config.getStringList(fullNodepathname).get(itype);
    }
    WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE);
    rpcCli = new GrpcClient(fullNode, confirmednode);
    return true;
}
 
Example 5
Source File: LossParams.java    From ytk-learn with MIT License 6 votes vote down vote up
public LossParams(Config config, String prefix) {
    loss_function = config.getString(prefix + KEY + "loss_function");
    regularization = new Regularization(config, prefix + KEY);
    evaluate_metric = config.getStringList(prefix + KEY + "evaluate_metric");
    just_evaluate = config.getBoolean(prefix + KEY + "just_evaluate");

    for (String metric : evaluate_metric) {
        if (!EvaluatorFactory.EvalNameSet.contains(metric)) {
            boolean hit = false;
            for (String eval : EvaluatorFactory.EvalNameSet) {
                if (metric.startsWith(eval)) {
                    hit = true;
                }
            }
            CheckUtils.check(hit, "%sevaluate_metric:%s, only support:%s",
                    prefix + KEY, metric, EvaluatorFactory.EvalNameSet);
        }
    }

}
 
Example 6
Source File: HttpEventSink.java    From mewbase with MIT License 6 votes vote down vote up
public HttpEventSink(Config cfg) {

        final String hostname = cfg.getString(HOSTNAME_CONFIG_PATH);
        final int port = cfg.getInt(PORT_CONFIG_PATH);

        final HttpClientOptions options = new HttpClientOptions()
                    .setDefaultHost(hostname)
                    .setDefaultPort(port);
                    // TODO lookup and set various security / protocol options here
                    // TODO - replace with Java 10 SE Library for HttpClient when able
        client = Vertx.vertx().createHttpClient(options);

        publishURI = cfg.getString(URL_PREFIX_PATH) + PUBLISH_ROUTE;

        logger.info("Created HTTP Event Sink for "+hostname+":"+port+" on "+publishURI);
    }
 
Example 7
Source File: KafkaDispatcher.java    From haystack-agent with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(final Config config) {
    final String agentName = config.hasPath("agentName") ? config.getString("agentName") : "";

    Validate.notNull(config.getString(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG));

    // remove the producer topic from the configuration and use it during send() call
    topic = config.getString(PRODUCER_TOPIC);
    producer = new KafkaProducer<>(ConfigurationHelpers.generatePropertiesFromMap(ConfigurationHelpers.convertToPropertyMap(config)),
            new ByteArraySerializer(),
            new ByteArraySerializer());

    dispatchTimer = newTimer(buildMetricName(agentName, "kafka.dispatch.timer"));
    dispatchFailure = newMeter(buildMetricName(agentName, "kafka.dispatch.failure"));

    LOGGER.info("Successfully initialized the kafka dispatcher with config={}", config);
}
 
Example 8
Source File: EagleServiceProfileInitializer.java    From Eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    Config config = ConfigFactory.load();
    String SPRING_ACTIVE_PROFILE = "eagle.service.springActiveProfile";
    String profile = "sandbox";
    if (config.hasPath(SPRING_ACTIVE_PROFILE)) {
        profile = config.getString(SPRING_ACTIVE_PROFILE);
    }
    logger.info("Eagle service use env: " + profile);
    applicationContext.getEnvironment().setActiveProfiles(profile);
    applicationContext.refresh();
}
 
Example 9
Source File: SwaggerUIConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
private String getDescription(String filename) {

    Config config = getSwaggerConfig();
    String hostname = config.getString(SWAGGER_HOSTNAME);

    try {
        InputStream is = new ClassPathResource("description.md").getInputStream();
        String         line;
        StringBuilder  stringBuilder = new StringBuilder();
        String         ls = System.getProperty("line.separator");

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
                stringBuilder.append(ls);
            }

            return stringBuilder.toString().replace("<HOSTNAME>", hostname);
        }

    } catch (IOException e) {
        LOGGER.error("Error getting description.html content...", e);
        return "";
    }

}
 
Example 10
Source File: NestDeriver.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Config config) {
  this.intoDependency = config.getString(NEST_INTO_CONFIG_NAME);
  this.fromDependency = config.getString(NEST_FROM_CONFIG_NAME);
  this.keyFieldNames = config.getStringList(KEY_FIELD_NAMES_CONFIG_NAME);
  this.nestedFieldName = config.getString(NESTED_FIELD_NAME_CONFIG_NAME);
}
 
Example 11
Source File: ServerMain.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
public static void run(Module coreSettings) throws PersistenceException,
    ConfigurationException, WaveServerException {
  Injector injector = Guice.createInjector(coreSettings);
  Module profilingModule = injector.getInstance(StatModule.class);
  ExecutorsModule executorsModule = injector.getInstance(ExecutorsModule.class);
  injector = injector.createChildInjector(profilingModule, executorsModule);

  Config config = injector.getInstance(Config.class);

  Module serverModule = injector.getInstance(ServerModule.class);
  Module federationModule = buildFederationModule(injector);
  Module robotApiModule = new RobotApiModule();
  PersistenceModule persistenceModule = injector.getInstance(PersistenceModule.class);
  Module searchModule = injector.getInstance(SearchModule.class);
  Module profileFetcherModule = injector.getInstance(ProfileFetcherModule.class);
  injector = injector.createChildInjector(serverModule, persistenceModule, robotApiModule,
      federationModule, searchModule, profileFetcherModule);

  ServerRpcProvider server = injector.getInstance(ServerRpcProvider.class);
  WaveBus waveBus = injector.getInstance(WaveBus.class);

  String domain = config.getString("core.wave_server_domain");
  if (!ParticipantIdUtil.isDomainAddress(ParticipantIdUtil.makeDomainAddress(domain))) {
    throw new WaveServerException("Invalid wave domain: " + domain);
  }

  initializeServer(injector, domain);
  initializeServlets(server, config);
  initializeRobotAgents(server);
  initializeRobots(injector, waveBus);
  initializeFrontend(injector, server, waveBus);
  initializeFederation(injector);
  initializeSearch(injector, waveBus);
  initializeShutdownHandler(server);

  LOG.info("Starting server");
  server.startWebSocketServer(injector);
}
 
Example 12
Source File: StageableTableMetadata.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public StageableTableMetadata(Config config, @Nullable Table referenceTable) {
  Preconditions.checkArgument(config.hasPath(DESTINATION_TABLE_KEY), String.format("Key %s is not specified", DESTINATION_TABLE_KEY));
  Preconditions.checkArgument(config.hasPath(DESTINATION_DB_KEY), String.format("Key %s is not specified", DESTINATION_DB_KEY));
  Preconditions.checkArgument(config.hasPath(DESTINATION_DATA_PATH_KEY),
      String.format("Key %s is not specified", DESTINATION_DATA_PATH_KEY));

  // Required
  this.destinationTableName = referenceTable == null ? config.getString(DESTINATION_TABLE_KEY)
      : HiveDataset.resolveTemplate(config.getString(DESTINATION_TABLE_KEY), referenceTable);
  this.destinationStagingTableName = String.format("%s_%s", this.destinationTableName, "staging"); // Fixed and non-configurable
  this.destinationDbName = referenceTable == null ? config.getString(DESTINATION_DB_KEY)
      : HiveDataset.resolveTemplate(config.getString(DESTINATION_DB_KEY), referenceTable);
  this.destinationDataPath = referenceTable == null ? config.getString(DESTINATION_DATA_PATH_KEY)
      : HiveDataset.resolveTemplate(config.getString(DESTINATION_DATA_PATH_KEY), referenceTable);

  // By default, this value is true and subDir "/final" is being added into orc output location.
  this.dataDstPathUseSubdir = !config.hasPath(DESTINATION_DATA_PATH_ADD_SUBDIR) || config.getBoolean(DESTINATION_DATA_PATH_ADD_SUBDIR);

  // Optional
  this.destinationTableProperties =
      convertKeyValueListToProperties(ConfigUtils.getStringList(config, DESTINATION_TABLE_PROPERTIES_LIST_KEY));
  this.clusterBy = ConfigUtils.getStringList(config, CLUSTER_BY_KEY);
  this.numBuckets = Optional.fromNullable(ConfigUtils.getInt(config, NUM_BUCKETS_KEY, null));

  this.hiveRuntimeProperties =
      convertKeyValueListToProperties(ConfigUtils.getStringList(config, HIVE_RUNTIME_PROPERTIES_LIST_KEY));
  this.evolutionEnabled = ConfigUtils.getBoolean(config, EVOLUTION_ENABLED, false);
  this.casePreserved = ConfigUtils.getBoolean(config, OUTPUT_FILE_CASE_PRESERVED, false);
  this.rowLimit = Optional.fromNullable(ConfigUtils.getInt(config, ROW_LIMIT_KEY, null));
  this.sourceDataPathIdentifier = ConfigUtils.getStringList(config, SOURCE_DATA_PATH_IDENTIFIER_KEY);
}
 
Example 13
Source File: AvroApacheHttpJoinConverter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
protected ApacheHttpRequestBuilder createRequestBuilder(Config config) {
  String urlTemplate = config.getString(HttpConstants.URL_TEMPLATE);
  String verb = config.getString(HttpConstants.VERB);
  String contentType = config.getString(HttpConstants.CONTENT_TYPE);

  return new ApacheHttpRequestBuilder(urlTemplate, verb, contentType);
}
 
Example 14
Source File: SampleClient1.java    From eagle with Apache License 2.0 5 votes vote down vote up
public static KafkaProducer<String, String> createProceduer(Config config) {
    String servers = config.getString("kafkaProducer.bootstrapServers");
    Properties configMap = new Properties();
    configMap.put("bootstrap.servers", servers);
    // configMap.put("metadata.broker.list", broker_list);
    configMap.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    configMap.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    configMap.put("request.required.acks", "1");
    configMap.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    configMap.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    KafkaProducer<String, String> proceduer = new KafkaProducer<String, String>(configMap);
    return proceduer;
}
 
Example 15
Source File: MatrixFederationHostForDomain.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Inject
public MatrixFederationHostForDomain(final String domain, MatrixPacketHandler handler,
    MatrixRoomManager room, Config config) {
  this.remoteDomain = domain;
  this.handler = handler;
  this.id = config.getString("federation.matrix_id");
  this.room = room;
}
 
Example 16
Source File: SphereClientFixtures.java    From commercetools-sunrise-java with Apache License 2.0 5 votes vote down vote up
private static SphereClientConfig provideSphereClientConfig() {
    final Config configuration = ConfigFactory.load("it.conf");
    final String projectKey = configuration.getString("ctp.it.projectKey");
    final String clientId = configuration.getString("ctp.it.clientId");
    final String clientSecret = configuration.getString("ctp.it.clientSecret");
    return SphereClientConfig.of(projectKey, clientId, clientSecret);
}
 
Example 17
Source File: Connections.java    From styx with Apache License 2.0 5 votes vote down vote up
public static Connection createBigTableConnection(Config config) {
  final String projectId = config.getString(BIGTABLE_PROJECT_ID);
  final String instanceId = config.getString(BIGTABLE_INSTANCE_ID);

  LOG.info("Creating Bigtable connection for project:{}, instance:{}",
           projectId, instanceId);

  final Configuration bigtableConfiguration = new Configuration();
  bigtableConfiguration.set("google.bigtable.project.id", projectId);
  bigtableConfiguration.set("google.bigtable.instance.id", instanceId);
  bigtableConfiguration.setBoolean("google.bigtable.rpc.use.timeouts", true);

  return BigtableConfiguration.connect(bigtableConfiguration);
}
 
Example 18
Source File: SSLFactory.java    From ts-reaktive with MIT License 4 votes vote down vote up
private static String getStringOrEmpty(Config config, String path) {
    return config.hasPath(path) ? config.getString(path) : "";
}
 
Example 19
Source File: KerberosUtils.java    From envelope with Apache License 2.0 4 votes vote down vote up
static String getKerberosKeytab(Config config) {
  if (config.hasPath(KEYTAB_CONFIG)) return config.getString(KEYTAB_CONFIG);
  else return getSparkConf().get("spark.yarn.keytab");
}
 
Example 20
Source File: FileSignerInfoStore.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Inject
public FileSignerInfoStore(Config config) {
  this.signerInfoStoreBasePath = config.getString("core.signer_info_store_directory");
}