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


Java AbstractConfig.getString方法代码示例

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


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

示例1: createChannelBuilder

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
/**
 * @param config client configs
 * @return configured ChannelBuilder based on the configs.
 */
public static ChannelBuilder createChannelBuilder(AbstractConfig config) {
    // 根据security.protocol配置项的值,得到对应的securityprotocal对象
    SecurityProtocol securityProtocol = SecurityProtocol.forName(config.getString(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG));
    if (!SecurityProtocol.nonTestingValues().contains(securityProtocol))
        throw new ConfigException("Invalid SecurityProtocol " + securityProtocol);

    // 获取sasl.mechanism配置项的值
    String clientSaslMechanism = config.getString(SaslConfigs.SASL_MECHANISM);

    // 创建对应的ChannelBuilder对象
    return ChannelBuilders.clientChannelBuilder(securityProtocol, JaasContext.Type.CLIENT, config, null,
            clientSaslMechanism, true);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:18,代码来源:ClientUtils.java

示例2: getAbsoluteFile

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
/**
 * Method is used to return a File checking to ensure that it is an absolute path.
 *
 * @param config config to read the value from
 * @param key    key for the value
 * @return File for the config value.
 */
public static File getAbsoluteFile(AbstractConfig config, String key) {
  Preconditions.checkNotNull(config, "config cannot be null");
  String path = config.getString(key);
  File file = new File(path);
  Preconditions.checkState(file.isAbsolute(), "'%s' must be an absolute path.", key);
  return new File(path);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:15,代码来源:ConfigUtils.java

示例3: HiveMetaStore

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
public HiveMetaStore(Configuration conf, AbstractConfig connectorConfig)
    throws HiveMetaStoreException {
  HiveConf hiveConf = new HiveConf(conf, HiveConf.class);
  String hiveConfDir = connectorConfig.getString(HiveConfig.HIVE_CONF_DIR_CONFIG);
  String hiveMetaStoreUris = connectorConfig.getString(HiveConfig.HIVE_METASTORE_URIS_CONFIG);
  if (hiveMetaStoreUris.isEmpty()) {
    log.warn(
        "hive.metastore.uris empty, an embedded Hive metastore will be created in the directory"
        + " the connector is started. You need to start Hive in that specific directory to "
        + "query the data."
    );
  }
  if (!hiveConfDir.equals("")) {
    String hiveSitePath = hiveConfDir + "/hive-site.xml";
    File hiveSite = new File(hiveSitePath);
    if (!hiveSite.exists()) {
      log.warn(
          "hive-site.xml does not exist in provided Hive configuration directory {}.",
          hiveConf
      );
    }
    hiveConf.addResource(new Path(hiveSitePath));
  }
  hiveConf.set("hive.metastore.uris", hiveMetaStoreUris);
  try {
    client = HCatUtil.getHiveMetastoreClient(hiveConf);
  } catch (IOException | MetaException e) {
    throw new HiveMetaStoreException(e);
  }
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-common,代码行数:31,代码来源:HiveMetaStore.java

示例4: HiveUtil

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
public HiveUtil(AbstractConfig connectorConfig, HiveMetaStore hiveMetaStore) {
  this.url = connectorConfig.getString(StorageCommonConfig.STORE_URL_CONFIG);
  this.hiveMetaStore = hiveMetaStore;
  this.delim = connectorConfig.getString(StorageCommonConfig.DIRECTORY_DELIM_CONFIG);
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-common,代码行数:6,代码来源:HiveUtil.java

示例5: getEnum

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
/**
 * Method is used to return an enum value from a given string.
 *
 * @param enumClass Class for the resulting enum value
 * @param config    config to read the value from
 * @param key       key for the value
 * @param <T>       Enum class to return type for.
 * @return enum value for the given key.
 * @see ValidEnum
 */
public static <T extends Enum<T>> T getEnum(Class<T> enumClass, AbstractConfig config, String key) {
  Preconditions.checkNotNull(enumClass, "enumClass cannot be null");
  Preconditions.checkState(enumClass.isEnum(), "enumClass must be an enum.");
  String textValue = config.getString(key);
  return Enum.valueOf(enumClass, textValue);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:17,代码来源:ConfigUtils.java

示例6: inetSocketAddress

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
/**
 * Method is used to return an InetSocketAddress from a hostname:port string.
 *
 * @param config config to read the value from
 * @param key    key for the value
 * @return InetSocketAddress for the supplied string.
 */
public static InetSocketAddress inetSocketAddress(AbstractConfig config, String key) {
  Preconditions.checkNotNull(config, "config cannot be null");
  String value = config.getString(key);
  return parseInetSocketAddress(value);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:13,代码来源:ConfigUtils.java

示例7: hostAndPort

import org.apache.kafka.common.config.AbstractConfig; //导入方法依赖的package包/类
/**
 * Method is used to parse a string ConfigDef item to a HostAndPort
 * @param config Config to read from
 * @param key ConfigItem to get the host string from.
 * @param defaultPort The default port to use if a port was not specified. Can be null.
 * @return HostAndPort based on the ConfigItem.
 */
public static HostAndPort hostAndPort(AbstractConfig config, String key, Integer defaultPort) {
  final String input = config.getString(key);
  return hostAndPort(input, defaultPort);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:12,代码来源:ConfigUtils.java


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