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


Java PartitionInfo.leader方法代碼示例

本文整理匯總了Java中org.apache.kafka.common.PartitionInfo.leader方法的典型用法代碼示例。如果您正苦於以下問題:Java PartitionInfo.leader方法的具體用法?Java PartitionInfo.leader怎麽用?Java PartitionInfo.leader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.kafka.common.PartitionInfo的用法示例。


在下文中一共展示了PartitionInfo.leader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: populateSnapshots

import org.apache.kafka.common.PartitionInfo; //導入方法依賴的package包/類
private void populateSnapshots(Cluster kafkaCluster,
                               ClusterModel clusterModel,
                               TopicPartition tp,
                               Snapshot[] leaderLoadSnapshots) throws ModelInputException {
  PartitionInfo partitionInfo = kafkaCluster.partition(tp);
  // If partition info does not exist, the topic may have been deleted.
  if (partitionInfo != null) {
    for (Node replica : partitionInfo.replicas()) {
      boolean isLeader = partitionInfo.leader() != null && replica.id() == partitionInfo.leader().id();
      String rack = getRackHandleNull(replica);
      // Note that we assume the capacity resolver can still return the broker capacity even if the broker
      // is dead. We need this to get the host resource capacity.
      Map<Resource, Double> brokerCapacity =
          _brokerCapacityConfigResolver.capacityForBroker(rack, replica.host(), replica.id());
      clusterModel.createReplicaHandleDeadBroker(rack, replica.id(), tp, isLeader, brokerCapacity);
      // Push the load snapshot to the replica one by one.
      for (int i = 0; i < leaderLoadSnapshots.length; i++) {
        clusterModel.pushLatestSnapshot(rack, replica.id(), tp,
                                        isLeader ? leaderLoadSnapshots[i].duplicate() : MonitorUtils.toFollowerSnapshot(leaderLoadSnapshots[i]));
      }
    }
  }
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:24,代碼來源:LoadMonitor.java

示例2: getBrokerLeaderPartitions

import org.apache.kafka.common.PartitionInfo; //導入方法依賴的package包/類
public Map<Integer, List<TopicPartition>> getBrokerLeaderPartitions(
    Map<String, List<PartitionInfo>> topicPartitonInfoMap) {
  Map<Integer, List<TopicPartition>> result = new HashMap<>();

  for (String topic : topicPartitonInfoMap.keySet()) {
    List<PartitionInfo> partitionInfoList = topicPartitonInfoMap.get(topic);
    if (partitionInfoList == null) {
      LOG.error("Failed to get partition info for {}", topic);
      continue;
    }

    for (PartitionInfo info : partitionInfoList) {
      Node leaderNode = info.leader();
      if (leaderNode != null) {
        result.putIfAbsent(leaderNode.id(), new ArrayList<>());
        TopicPartition topicPartiton = new TopicPartition(info.topic(), info.partition());
        result.get(leaderNode.id()).add(topicPartiton);
      }
    }
  }
  return result;
}
 
開發者ID:pinterest,項目名稱:doctorkafka,代碼行數:23,代碼來源:KafkaClusterManager.java

示例3: leaderChanged

import org.apache.kafka.common.PartitionInfo; //導入方法依賴的package包/類
private static boolean leaderChanged(PartitionInfo prevPartInfo, PartitionInfo currPartInfo) {
  Node prevLeader = prevPartInfo.leader();
  Node currLeader = currPartInfo.leader();
  return !(prevLeader == null && currLeader == null) && !(prevLeader != null && currLeader != null
      && prevLeader.id() == currLeader.id());
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:7,代碼來源:MonitorUtils.java

示例4: OutOfSyncReplica

import org.apache.kafka.common.PartitionInfo; //導入方法依賴的package包/類
public OutOfSyncReplica(PartitionInfo partitionInfo) {
  this.topicPartition = new TopicPartition(partitionInfo.topic(), partitionInfo.partition());
  this.inSyncBrokers = getInSyncReplicas(partitionInfo);
  this.outOfSyncBrokers = getOutOfSyncReplicas(partitionInfo);
  this.leader = partitionInfo.leader();
}
 
開發者ID:pinterest,項目名稱:doctorkafka,代碼行數:7,代碼來源:OutOfSyncReplica.java


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