本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}