當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。