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


Java Config.getString方法代码示例

本文整理汇总了Java中com.typesafe.config.Config.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getString方法的具体用法?Java Config.getString怎么用?Java Config.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.typesafe.config.Config的用法示例。


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

示例1: getAppContext

import com.typesafe.config.Config; //导入方法依赖的package包/类
private static ListIterable<IntToObjectFunction<DbDeployerAppContext>> getAppContext(final Config config) {
    final String sourcePath = config.getString("sourcePath");
    String env = getStringOptional(config, "env");

    final String[] envArgs = env != null ? env.split(",") : new String[] { null };
    final String username = getStringOptional(config, "username");
    final String password = getStringOptional(config, "password");
    return ArrayAdapter.adapt(envArgs).collect(new Function<String, IntToObjectFunction<DbDeployerAppContext>>() {
        @Override
        public IntToObjectFunction<DbDeployerAppContext> valueOf(final String envArg) {
            return new IntToObjectFunction<DbDeployerAppContext>() {
                @Override
                public DbDeployerAppContext valueOf(int stepNumber) {
                    String stepSourcePath = replaceStepNumber(sourcePath, stepNumber, config);

                    DbEnvironment dbEnvironment = DbEnvironmentFactory.getInstance().readOneFromSourcePath(stepSourcePath, envArg != null ? new String[] {envArg} : new String[0]);
                    if (username != null && password != null) {
                        return dbEnvironment.buildAppContext(username, password);
                    } else {
                        return dbEnvironment.buildAppContext();
                    }
                }
            };
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:27,代码来源:ParamReader.java

示例2: MLUpdate

import com.typesafe.config.Config; //导入方法依赖的package包/类
protected MLUpdate(Config config) {
  this.testFraction = config.getDouble("oryx.ml.eval.test-fraction");
  int candidates = config.getInt("oryx.ml.eval.candidates");
  this.evalParallelism = config.getInt("oryx.ml.eval.parallelism");
  this.threshold = ConfigUtils.getOptionalDouble(config, "oryx.ml.eval.threshold");
  this.maxMessageSize = config.getInt("oryx.update-topic.message.max-size");
  Preconditions.checkArgument(testFraction >= 0.0 && testFraction <= 1.0);
  Preconditions.checkArgument(candidates > 0);
  Preconditions.checkArgument(evalParallelism > 0);
  Preconditions.checkArgument(maxMessageSize > 0);
  if (testFraction == 0.0) {
    if (candidates > 1) {
      log.info("Eval is disabled (test fraction = 0) so candidates is overridden to 1");
      candidates = 1;
    }
  }
  this.candidates = candidates;
  this.hyperParamSearch = config.getString("oryx.ml.eval.hyperparam-search");
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:20,代码来源:MLUpdate.java

示例3: apply

import com.typesafe.config.Config; //导入方法依赖的package包/类
/**
 * @param config      the akka configuration object
 * @param actorSystem the akk actor system
 * @return the created snapshot ignite cache
 */
@Override
public IgniteCache<Long, SnapshotItem> apply(Config config, ActorSystem actorSystem) {
    final IgniteExtension extension = IgniteExtensionProvider.EXTENSION.get(actorSystem);
    final String cachePrefix = config.getString(CACHE_PREFIX_PROPERTY);
    final int cacheBackups = config.getInt(CACHE_BACKUPS);
    final CacheConfiguration<Long, SnapshotItem> eventStore = new CacheConfiguration();
    eventStore.setCopyOnRead(false);
    if (cacheBackups > 0) {
        eventStore.setBackups(cacheBackups);
    } else {
        eventStore.setBackups(1);
    }
    eventStore.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    eventStore.setName(cachePrefix + "_SNAPSHOT");
    eventStore.setCacheMode(CacheMode.PARTITIONED);
    eventStore.setReadFromBackup(true);
    eventStore.setIndexedTypes(Long.class, SnapshotItem.class);
    eventStore.setIndexedTypes(String.class, SnapshotItem.class);
    return extension.getIgnite().getOrCreateCache(eventStore);
}
 
开发者ID:Romeh,项目名称:akka-persistance-ignite,代码行数:26,代码来源:SnapshotCacheProvider.java

示例4: KafkaOutputConfiguration

import com.typesafe.config.Config; //导入方法依赖的package包/类
@Inject
public KafkaOutputConfiguration(@Assisted String id,
                                @Assisted Config config,
                                KafkaOutput.Factory outputFactory) {
    super(id, config);
    this.outputFactory = outputFactory;
    if (config.hasPath("host")) {
        this.host = config.getString("host");
    }
    if (config.hasPath("topic")) {
        this.topic = config.getString("topic");
    }
    if (config.hasPath("port")) {
        this.port = config.getInt("port");
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:17,代码来源:KafkaOutputConfiguration.java

示例5: WindowsEventlogInputConfiguration

import com.typesafe.config.Config; //导入方法依赖的package包/类
@Inject
public WindowsEventlogInputConfiguration(@Assisted String id,
                                         @Assisted Config config,
                                         WindowsEventlogInput.Factory inputFactory) {
    super(id, config);
    this.inputFactory = inputFactory;

    if (config.hasPath("source-name")) {
        this.sourceName = config.getString("source-name");
    } else {
        this.sourceName = "Application";
    }

    if (config.hasPath("poll-interval")) {
        this.pollInterval = config.getDuration("poll-interval", TimeUnit.MILLISECONDS);
    } else {
        this.pollInterval = 1000L;
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:20,代码来源:WindowsEventlogInputConfiguration.java

示例6: GrapheneRESTServer

import com.typesafe.config.Config; //导入方法依赖的package包/类
GrapheneRESTServer() {

		Config config = ConfigFactory.load()
			.withFallback(ConfigFactory.load("reference"))
			.withFallback(ConfigFactory.load("application"));

		log.debug("initializing Graphene");
		Graphene graphene = new Graphene(config);
		log.debug("Graphene initialized");

		ResourceConfig rc = generateResourceConfig(config, graphene);

		String uri = "http://" + config.getString("graphene.server.host-name");
		uri += config.hasPath("graphene.server.port") ? ":" + config.getInt("graphene.server.port") : "";
		uri += "/";
		uri += config.hasPath("graphene.server.path") ? config.getString("graphene.server.path") : "";

		log.info("Server will run at: '{}'", uri);

		server = JettyHttpContainerFactory.createServer(
				URI.create(uri),
				rc,
				false);

		log.info("Server successfully initialized, waiting for start.");
	}
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:27,代码来源:GrapheneRESTServer.java

示例7: KMeansUpdate

import com.typesafe.config.Config; //导入方法依赖的package包/类
public KMeansUpdate(Config config) {
  super(config);
  initializationStrategy = config.getString("oryx.kmeans.initialization-strategy");
  evaluationStrategy = Enum.valueOf(KMeansEvalStrategy.class, config.getString("oryx.kmeans.evaluation-strategy"));
  numberOfRuns = config.getInt("oryx.kmeans.runs");
  maxIterations = config.getInt("oryx.kmeans.iterations");
  hyperParamValues = new ArrayList<>();
  hyperParamValues.add(HyperParams.fromConfig(config, "oryx.kmeans.hyperparams.k"));
  inputSchema = new InputSchema(config);
  Preconditions.checkArgument(maxIterations > 0);
  Preconditions.checkArgument(numberOfRuns > 0);
  Preconditions.checkArgument(
      initializationStrategy.equals(KMeans.K_MEANS_PARALLEL()) ||
          initializationStrategy.equals(KMeans.RANDOM()));
  // Should be an unsupervised problem. This impl only supports numeric features.
  Preconditions.checkArgument(!inputSchema.hasTarget());
  for (int i = 0; i < inputSchema.getNumFeatures(); i++) {
    Preconditions.checkArgument(!inputSchema.isCategorical(i));
  }
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:21,代码来源:KMeansUpdate.java

示例8: RelationExtractionRunner

import com.typesafe.config.Config; //导入方法依赖的package包/类
public RelationExtractionRunner(Config config) {

		// load boolean values
		this.exploitCore = config.getBoolean("exploit-core");
		this.exploitContexts = config.getBoolean("exploit-contexts");
		this.separateNounBased = config.getBoolean("separate-noun-based");
		this.separatePurposes = config.getBoolean("separate-purposes");
		this.separateAttributions = config.getBoolean("separate-attributions");

		// instantiate extractor
		String extractorClassName = config.getString("relation-extractor");
		try {
			Class<?> extractorClass = Class.forName(extractorClassName);
			Constructor<?> extractorConst = extractorClass.getConstructor();
			this.extractor = (RelationExtractor) extractorConst.newInstance();
		} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
			logger.error("Failed to create instance of {}", extractorClassName);
			throw new ConfigException.BadValue("relation-extractor." + extractorClassName, "Failed to create instance.");
		}

		this.elementCoreExtractionMap = new LinkedHashMap<>();
	}
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:23,代码来源:RelationExtractionRunner.java

示例9: getJdbcDs

import com.typesafe.config.Config; //导入方法依赖的package包/类
private static DataSource getJdbcDs(final Config config, final int numConnections) {
    String jdbcUrl = config.getString("jdbcUrl");
    final String username = config.getString("username");
    final String password = config.getString("password");
    final String driver = config.getString("driver");
    try {
        return JdbcDataSourceFactory.createFromJdbcUrl(
                (Class<? extends Driver>) Class.forName(driver),
                jdbcUrl,
                new Credential(username, password),
                numConnections);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:16,代码来源:ParamReader.java

示例10: ModelParams

import com.typesafe.config.Config; //导入方法依赖的package包/类
public ModelParams(Config config, String prefix) {
    data_path = config.getString(prefix + KEY + "data_path");
    delim = config.getString(prefix + KEY + "delim");
    need_dict = config.getBoolean(prefix + KEY + "need_dict");
    dict_path = config.getString(prefix + KEY + "dict_path");
    dump_freq = config.getInt(prefix + KEY + "dump_freq");
    need_bias = config.getBoolean(prefix + KEY + "need_bias");
    bias_feature_name = config.getString(prefix + KEY + "bias_feature_name");
    continue_train = config.getBoolean(prefix + KEY + "continue_train");
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:11,代码来源:ModelParams.java

示例11: ServingLayer

import com.typesafe.config.Config; //导入方法依赖的package包/类
/**
 * Creates a new instance with the given configuration.
 *
 * @param config configuration for the serving layer
 */
public ServingLayer(Config config) {
  Objects.requireNonNull(config);
  log.info("Configuration:\n{}", ConfigUtils.prettyPrint(config));
  this.config = config;
  this.id = ConfigUtils.getOptionalString(config, "oryx.id");
  this.port = config.getInt("oryx.serving.api.port");
  this.securePort = config.getInt("oryx.serving.api.secure-port");
  this.userName = ConfigUtils.getOptionalString(config, "oryx.serving.api.user-name");
  this.password = ConfigUtils.getOptionalString(config, "oryx.serving.api.password");
  String keystoreFileString =
      ConfigUtils.getOptionalString(config, "oryx.serving.api.keystore-file");
  this.keystoreFile = keystoreFileString == null ? null : Paths.get(keystoreFileString);
  this.keystorePassword =
      ConfigUtils.getOptionalString(config, "oryx.serving.api.keystore-password");
  this.keyAlias = ConfigUtils.getOptionalString(config, "oryx.serving.api.key-alias");
  String contextPathString = config.getString("oryx.serving.api.context-path");
  if (contextPathString == null ||
      contextPathString.isEmpty() ||
      "/".equals(contextPathString)) {
    contextPathString = "";
  }
  this.contextPathURIBase = contextPathString;
  this.appResourcesPackages =
      config.getString("oryx.serving.application-resources") + "," +
      "com.cloudera.oryx.lambda.serving"; // Always append package for e.g. error page
  // For tests only:
  this.doNotInitTopics = config.getBoolean("oryx.serving.no-init-topics");
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:34,代码来源:ServingLayer.java

示例12: CollectorIdConfiguration

import com.typesafe.config.Config; //导入方法依赖的package包/类
@Inject
public CollectorIdConfiguration(Config config) {
    if (config.hasPath(collectorIdStatement)) {
        this.collectorId = config.getString(collectorIdStatement);
    } else {
        this.collectorId = "file:config/collector-id";
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:9,代码来源:CollectorIdConfiguration.java

示例13: LocalSnapshotStore

import com.typesafe.config.Config; //导入方法依赖的package包/类
public LocalSnapshotStore(final Config config) {
    this.executionContext = context().system().dispatchers().lookup(config.getString("stream-dispatcher"));
    snapshotDir = new File(config.getString("dir"));

    int localMaxLoadAttempts = config.getInt("max-load-attempts");
    maxLoadAttempts = localMaxLoadAttempts > 0 ? localMaxLoadAttempts : 1;

    LOG.debug("LocalSnapshotStore ctor: snapshotDir: {}, maxLoadAttempts: {}", snapshotDir, maxLoadAttempts);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:LocalSnapshotStore.java

示例14: AbstractSparkLayer

import com.typesafe.config.Config; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected AbstractSparkLayer(Config config) {
  Objects.requireNonNull(config);
  log.info("Configuration:\n{}", ConfigUtils.prettyPrint(config));

  String group = getConfigGroup();
  this.config = config;
  String configuredID = ConfigUtils.getOptionalString(config, "oryx.id");
  this.id = configuredID == null ? UUID.randomUUID().toString() : configuredID;
  this.streamingMaster = config.getString("oryx." + group + ".streaming.master");
  this.inputTopic = config.getString("oryx.input-topic.message.topic");
  this.inputTopicLockMaster = config.getString("oryx.input-topic.lock.master");
  this.inputBroker = config.getString("oryx.input-topic.broker");
  this.updateTopic = ConfigUtils.getOptionalString(config, "oryx.update-topic.message.topic");
  this.updateTopicLockMaster = ConfigUtils.getOptionalString(config, "oryx.update-topic.lock.master");
  this.keyClass = ClassUtils.loadClass(config.getString("oryx.input-topic.message.key-class"));
  this.messageClass =
      ClassUtils.loadClass(config.getString("oryx.input-topic.message.message-class"));
  this.keyDecoderClass = (Class<? extends Deserializer<K>>) ClassUtils.loadClass(
      config.getString("oryx.input-topic.message.key-decoder-class"), Deserializer.class);
  this.messageDecoderClass = (Class<? extends Deserializer<M>>) ClassUtils.loadClass(
      config.getString("oryx.input-topic.message.message-decoder-class"), Deserializer.class);
  this.generationIntervalSec = config.getInt("oryx." + group + ".streaming.generation-interval-sec");

  this.extraSparkConfig = new HashMap<>();
  config.getConfig("oryx." + group + ".streaming.config").entrySet().forEach(e ->
    extraSparkConfig.put(e.getKey(), e.getValue().unwrapped())
  );

  Preconditions.checkArgument(generationIntervalSec > 0);
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:32,代码来源:AbstractSparkLayer.java

示例15: loadProvider

import com.typesafe.config.Config; //导入方法依赖的package包/类
/**
 * Look for the configuration key "remote-configuration.provider" and
 * try to instantiate class.
 *
 * @param localConfiguration The local configuration
 * @return An optional {@code RemoteConfigProvider}
 * @since 17.08.20
 */
private RemoteConfigProvider loadProvider(final Config localConfiguration) {
    final String provider = localConfiguration.getString("remote-configuration.provider");
    if (!provider.isEmpty()) {
        final ServiceLoader<RemoteConfigProvider> serviceLoaderRCP = ServiceLoader.load(RemoteConfigProvider.class);
        for (final RemoteConfigProvider rcp : serviceLoaderRCP) {
            if (rcp.getShortName().compareToIgnoreCase(provider) == 0) {
                return rcp;
            }
        }
        throw new RuntimeException("Can't resolve the remote configuration provider '" + provider + "'");
    }
    return null;
}
 
开发者ID:payintech,项目名称:play-remote-configuration,代码行数:22,代码来源:PlayApplicationLoader.java


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