本文整理匯總了Java中org.apache.kafka.clients.admin.DescribeConfigsResult類的典型用法代碼示例。如果您正苦於以下問題:Java DescribeConfigsResult類的具體用法?Java DescribeConfigsResult怎麽用?Java DescribeConfigsResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DescribeConfigsResult類屬於org.apache.kafka.clients.admin包,在下文中一共展示了DescribeConfigsResult類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: describeResource
import org.apache.kafka.clients.admin.DescribeConfigsResult; //導入依賴的package包/類
private List<ConfigItem> describeResource(final ConfigResource configResource) {
final DescribeConfigsResult result = adminClient.describeConfigs(Collections.singleton(configResource));
final List<ConfigItem> configItems = new ArrayList<>();
try {
final Map<ConfigResource, Config> configMap = result.all().get();
final Config config = configMap.get(configResource);
for (final ConfigEntry configEntry : config.entries()) {
// Skip sensitive entries
if (configEntry.isSensitive()) {
continue;
}
configItems.add(
new ConfigItem(configEntry.name(), configEntry.value(), configEntry.isDefault())
);
}
return configItems;
} catch (InterruptedException | ExecutionException e) {
// TODO Handle this
throw new RuntimeException(e.getMessage(), e);
}
}
示例2: init
import org.apache.kafka.clients.admin.DescribeConfigsResult; //導入依賴的package包/類
private void init() {
try {
DescribeClusterResult describeClusterResult = adminClient.describeCluster();
List<Node> nodes = new ArrayList<>(describeClusterResult.nodes().get());
if (!nodes.isEmpty()) {
ConfigResource resource = new ConfigResource(ConfigResource.Type.BROKER,
String.valueOf(nodes.get(0).id()));
DescribeConfigsResult
describeConfigsResult = adminClient.describeConfigs(Collections.singleton(resource));
Map<ConfigResource, Config> config = describeConfigsResult.all().get();
this.isDeleteTopicEnabled = config.get(resource)
.entries()
.stream()
.anyMatch(configEntry -> configEntry.name().equalsIgnoreCase("delete.topic.enable")
&& configEntry.value().equalsIgnoreCase("true"));
} else {
log.warn("No available broker found to fetch config info.");
throw new KsqlException("Could not fetch broker information. KSQL cannot initialize "
+ "AdminCLient.");
}
} catch (InterruptedException | ExecutionException ex) {
log.error("Failed to initialize TopicClient: {}", ex.getMessage());
throw new KsqlException("Could not fetch broker information. KSQL cannot initialize "
+ "AdminCLient.");
}
}
示例3: getDescribeConfigsResult
import org.apache.kafka.clients.admin.DescribeConfigsResult; //導入依賴的package包/類
private DescribeConfigsResult getDescribeConfigsResult() {
DescribeConfigsResult describeConfigsResult = mock(DescribeConfigsResult.class);
ConfigEntry configEntry = new ConfigEntry("delete.topic.enable", "true");
Map<ConfigResource, Config> config = new HashMap<>();
config.put(new ConfigResource(ConfigResource.Type.BROKER, "1"), new Config
(Collections.singletonList(configEntry)));
expect(describeConfigsResult.all()).andReturn(KafkaFuture.completedFuture(config));
replay(describeConfigsResult);
return describeConfigsResult;
}