當前位置: 首頁>>代碼示例>>Java>>正文


Java DescribeConfigsResult類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:SourceLabOrg,項目名稱:kafka-webview,代碼行數:25,代碼來源:KafkaOperations.java

示例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.");
  }
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:30,代碼來源:KafkaTopicClientImpl.java

示例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;
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:11,代碼來源:KafkaTopicClientTest.java


注:本文中的org.apache.kafka.clients.admin.DescribeConfigsResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。