org.apache.flink.configuration.Configuration.contains()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中org.apache.flink.configuration.Configuration.contains()方法的一些代码示例,展示了Configuration.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.contains()方法的具体详情如下:
包路径:org.apache.flink.configuration.Configuration
类名称:Configuration
方法名:contains

Configuration.contains介绍

[英]Checks whether there is an entry for the given config option.
[中]检查是否存在给定配置选项的条目。

代码示例

代码示例来源:origin: apache/flink

@Override
public boolean contains(ConfigOption<?> configOption) {
  return backingConfig.contains(prefixOption(configOption, prefix));
}

代码示例来源:origin: apache/flink

private File getUploadDir(Configuration configuration) {
  File baseDir = new File(configuration.getString(WebOptions.UPLOAD_DIR,
    getBaseDirStr(configuration)));
  boolean uploadDirSpecified = configuration.contains(WebOptions.UPLOAD_DIR);
  return uploadDirSpecified ? baseDir : new File(baseDir, "flink-web-" + UUID.randomUUID());
}

代码示例来源:origin: apache/flink

/**
 * Creates a {@link LocalEnvironment} for local program execution that also starts the
 * web monitoring UI.
 *
 * <p>The local execution environment will run the program in a multi-threaded fashion in
 * the same JVM as the environment was created in. It will use the parallelism specified in the
 * parameter.
 *
 * <p>If the configuration key 'rest.port' was set in the configuration, that particular
 * port will be used for the web UI. Otherwise, the default port (8081) will be used.
 */
@PublicEvolving
public static ExecutionEnvironment createLocalEnvironmentWithWebUI(Configuration conf) {
  checkNotNull(conf, "conf");
  conf.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true);
  if (!conf.contains(RestOptions.PORT)) {
    // explicitly set this option so that it's not set to 0 later
    conf.setInteger(RestOptions.PORT, RestOptions.PORT.defaultValue());
  }
  return createLocalEnvironment(conf, -1);
}

代码示例来源:origin: apache/flink

/**
 * Creates a {@link LocalStreamEnvironment} for local program execution that also starts the
 * web monitoring UI.
 *
 * <p>The local execution environment will run the program in a multi-threaded fashion in
 * the same JVM as the environment was created in. It will use the parallelism specified in the
 * parameter.
 *
 * <p>If the configuration key 'rest.port' was set in the configuration, that particular
 * port will be used for the web UI. Otherwise, the default port (8081) will be used.
 */
@PublicEvolving
public static StreamExecutionEnvironment createLocalEnvironmentWithWebUI(Configuration conf) {
  checkNotNull(conf, "conf");
  conf.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true);
  if (!conf.contains(RestOptions.PORT)) {
    // explicitly set this option so that it's not set to 0 later
    conf.setInteger(RestOptions.PORT, RestOptions.PORT.defaultValue());
  }
  return createLocalEnvironment(defaultLocalParallelism, conf);
}

代码示例来源:origin: apache/flink

private JobExecutorService createJobExecutorService(Configuration configuration) throws Exception {
  if (!configuration.contains(RestOptions.PORT)) {
    configuration.setInteger(RestOptions.PORT, 0);
  }
  final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder()
    .setConfiguration(configuration)
    .setNumTaskManagers(
      configuration.getInteger(
        ConfigConstants.LOCAL_NUMBER_TASK_MANAGER,
        ConfigConstants.DEFAULT_LOCAL_NUMBER_TASK_MANAGER))
    .setRpcServiceSharing(RpcServiceSharing.SHARED)
    .setNumSlotsPerTaskManager(
      configuration.getInteger(
        TaskManagerOptions.NUM_TASK_SLOTS, 1))
    .build();
  final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration);
  miniCluster.start();
  configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().getPort());
  return miniCluster;
}

代码示例来源:origin: apache/flink

Protos.Credential.Builder credential = null;
if (!flinkConfig.contains(MesosOptions.MASTER_URL)) {
  throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured.");
  MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER));
if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) {
  frameworkInfo.setPrincipal(flinkConfig.getString(
    MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL));
  if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) {
    credential.setSecret(flinkConfig.getString(
      MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET));

代码示例来源:origin: apache/flink

if (!configuration.contains(RestOptions.PORT)) {
  configuration.setInteger(RestOptions.PORT, 0);

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

/**
 * Returns whether the new network buffer memory configuration is present in the configuration
 * object, i.e. at least one new parameter is given or the old one is not present.
 *
 * @param config configuration object
 * @return <tt>true</tt> if the new configuration method is used, <tt>false</tt> otherwise
 */
@SuppressWarnings("deprecation")
public static boolean hasNewNetworkBufConf(final Configuration config) {
  return config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX) ||
    !config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS);
}

代码示例来源:origin: org.apache.flink/flink-runtime

/**
 * Returns whether the new network buffer memory configuration is present in the configuration
 * object, i.e. at least one new parameter is given or the old one is not present.
 *
 * @param config configuration object
 * @return <tt>true</tt> if the new configuration method is used, <tt>false</tt> otherwise
 */
@SuppressWarnings("deprecation")
public static boolean hasNewNetworkBufConf(final Configuration config) {
  return config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX) ||
    !config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS);
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

/**
 * Returns whether the new network buffer memory configuration is present in the configuration
 * object, i.e. at least one new parameter is given or the old one is not present.
 *
 * @param config configuration object
 * @return <tt>true</tt> if the new configuration method is used, <tt>false</tt> otherwise
 */
@SuppressWarnings("deprecation")
public static boolean hasNewNetworkBufConf(final Configuration config) {
  return config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX) ||
    !config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS);
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

/**
 * Returns whether the new network buffer memory configuration is present in the configuration
 * object, i.e. at least one new parameter is given or the old one is not present.
 *
 * @param config configuration object
 * @return <tt>true</tt> if the new configuration method is used, <tt>false</tt> otherwise
 */
@SuppressWarnings("deprecation")
public static boolean hasNewNetworkBufConf(final Configuration config) {
  return config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN) ||
    config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX) ||
    !config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS);
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public boolean contains(ConfigOption<?> configOption) {
  return backingConfig.contains(prefixOption(configOption, prefix));
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public boolean contains(ConfigOption<?> configOption) {
  return backingConfig.contains(prefixOption(configOption, prefix));
}

代码示例来源:origin: org.apache.flink/flink-runtime-web_2.11

private File getUploadDir(Configuration configuration) {
  File baseDir = new File(configuration.getString(WebOptions.UPLOAD_DIR,
    getBaseDirStr(configuration)));
  boolean uploadDirSpecified = configuration.contains(WebOptions.UPLOAD_DIR);
  return uploadDirSpecified ? baseDir : new File(baseDir, "flink-web-" + UUID.randomUUID());
}

代码示例来源:origin: org.apache.flink/flink-runtime-web

private File getUploadDir(Configuration configuration) {
  File baseDir = new File(configuration.getString(WebOptions.UPLOAD_DIR,
    getBaseDirStr(configuration)));
  boolean uploadDirSpecified = configuration.contains(WebOptions.UPLOAD_DIR);
  return uploadDirSpecified ? baseDir : new File(baseDir, "flink-web-" + UUID.randomUUID());
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

/**
 * Set temporary configuration directories if necessary.
 *
 * @param configuration flink config to patch
 * @param defaultDirs in case no tmp directories is set, next directories will be applied
 */
public static void updateTmpDirectoriesInConfiguration(
    Configuration configuration,
    @Nullable String defaultDirs) {
  if (configuration.contains(CoreOptions.TMP_DIRS)) {
    LOG.info("Overriding Fink's temporary file directories with those " +
      "specified in the Flink config: {}", configuration.getValue(CoreOptions.TMP_DIRS));
  } else if (defaultDirs != null) {
    LOG.info("Setting directories for temporary files to: {}", defaultDirs);
    configuration.setString(CoreOptions.TMP_DIRS, defaultDirs);
    configuration.setBoolean(USE_LOCAL_DEFAULT_TMP_DIRS, true);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime

/**
 * Set temporary configuration directories if necessary.
 *
 * @param configuration flink config to patch
 * @param defaultDirs in case no tmp directories is set, next directories will be applied
 */
public static void updateTmpDirectoriesInConfiguration(
    Configuration configuration,
    @Nullable String defaultDirs) {
  if (configuration.contains(CoreOptions.TMP_DIRS)) {
    LOG.info("Overriding Fink's temporary file directories with those " +
      "specified in the Flink config: {}", configuration.getValue(CoreOptions.TMP_DIRS));
  } else if (defaultDirs != null) {
    LOG.info("Setting directories for temporary files to: {}", defaultDirs);
    configuration.setString(CoreOptions.TMP_DIRS, defaultDirs);
    configuration.setBoolean(USE_LOCAL_DEFAULT_TMP_DIRS, true);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

private static Time getSlotRequestTimeout(final Configuration configuration) {
    final long slotRequestTimeoutMs;
    if (configuration.contains(ResourceManagerOptions.SLOT_REQUEST_TIMEOUT)) {
      LOGGER.warn("Config key {} is deprecated; use {} instead.",
        ResourceManagerOptions.SLOT_REQUEST_TIMEOUT,
        JobManagerOptions.SLOT_REQUEST_TIMEOUT);
      slotRequestTimeoutMs = configuration.getLong(ResourceManagerOptions.SLOT_REQUEST_TIMEOUT);
    } else {
      slotRequestTimeoutMs = configuration.getLong(JobManagerOptions.SLOT_REQUEST_TIMEOUT);
    }
    return Time.milliseconds(slotRequestTimeoutMs);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime

private static Time getSlotRequestTimeout(final Configuration configuration) {
    final long slotRequestTimeoutMs;
    if (configuration.contains(ResourceManagerOptions.SLOT_REQUEST_TIMEOUT)) {
      LOGGER.warn("Config key {} is deprecated; use {} instead.",
        ResourceManagerOptions.SLOT_REQUEST_TIMEOUT,
        JobManagerOptions.SLOT_REQUEST_TIMEOUT);
      slotRequestTimeoutMs = configuration.getLong(ResourceManagerOptions.SLOT_REQUEST_TIMEOUT);
    } else {
      slotRequestTimeoutMs = configuration.getLong(JobManagerOptions.SLOT_REQUEST_TIMEOUT);
    }
    return Time.milliseconds(slotRequestTimeoutMs);
  }
}

代码示例来源:origin: DTStack/flinkx

/**
 * Creates a {@link LocalEnvironment} for local program execution that also starts the
 * web monitoring UI.
 *
 * <p>The local execution environment will run the program in a multi-threaded fashion in
 * the same JVM as the environment was created in. It will use the parallelism specified in the
 * parameter.
 *
 * <p>If the configuration key 'rest.port' was set in the configuration, that particular
 * port will be used for the web UI. Otherwise, the default port (8081) will be used.
 */
@PublicEvolving
public static ExecutionEnvironment createLocalEnvironmentWithWebUI(Configuration conf) {
  checkNotNull(conf, "conf");
  conf.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true);
  if (!conf.contains(RestOptions.PORT)) {
    // explicitly set this option so that it's not set to 0 later
    conf.setInteger(RestOptions.PORT, RestOptions.PORT.defaultValue());
  }
  return createLocalEnvironment(conf, -1);
}

相关文章

微信公众号

最新文章

更多