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


Java PreferredReplicaLeaderElectionCommand類代碼示例

本文整理匯總了Java中kafka.admin.PreferredReplicaLeaderElectionCommand的典型用法代碼示例。如果您正苦於以下問題:Java PreferredReplicaLeaderElectionCommand類的具體用法?Java PreferredReplicaLeaderElectionCommand怎麽用?Java PreferredReplicaLeaderElectionCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: triggerPreferredLeaderElection

import kafka.admin.PreferredReplicaLeaderElectionCommand; //導入依賴的package包/類
private static void triggerPreferredLeaderElection(ZkUtils zkUtils, List<PartitionInfo> partitionInfoList) {
  scala.collection.mutable.HashSet<TopicAndPartition> scalaPartitionInfoSet = new scala.collection.mutable.HashSet<>();
  for (PartitionInfo javaPartitionInfo : partitionInfoList) {
    scalaPartitionInfoSet.add(new TopicAndPartition(javaPartitionInfo.topic(), javaPartitionInfo.partition()));
  }
  PreferredReplicaLeaderElectionCommand.writePreferredReplicaElectionData(zkUtils, scalaPartitionInfoSet);
}
 
開發者ID:linkedin,項目名稱:kafka-monitor,代碼行數:8,代碼來源:MultiClusterTopicManagementService.java

示例2: handleDataChange

import kafka.admin.PreferredReplicaLeaderElectionCommand; //導入依賴的package包/類
@Override
public void handleDataChange(String dataPath, Object data) throws Exception {
    logger.debug("Preferred replica election listener fired for path {}. Record partitions to undergo preferred replica election {}",
            dataPath, data.toString());
    Set<TopicAndPartition> partitionsForPreferredReplicaElection = PreferredReplicaLeaderElectionCommand.parsePreferredReplicaElectionData(data.toString());

    synchronized (controllerContext.controllerLock) {
        logger.info("These partitions are already undergoing preferred replica election: {}",
                controllerContext.partitionsUndergoingPreferredReplicaElection);
        Set<TopicAndPartition> newPartitions = Utils.minus(partitionsForPreferredReplicaElection, controllerContext.partitionsUndergoingPreferredReplicaElection);
        controller.onPreferredReplicaElection(newPartitions);
    }
}
 
開發者ID:bingoohuang,項目名稱:buka,代碼行數:14,代碼來源:KafkaController.java

示例3: moveLeaderToPreferredReplica

import kafka.admin.PreferredReplicaLeaderElectionCommand; //導入依賴的package包/類
public void moveLeaderToPreferredReplica(String topic, int partition) {
  ZkClient client = new ZkClient(zkConnects, 10000, 10000, ZKStringSerializer$.MODULE$);

  TopicAndPartition topicAndPartition = new TopicAndPartition(topic, partition);
  //move leader to broker 1
  Set<TopicAndPartition> topicsAndPartitions = asScalaSet(Collections.singleton(topicAndPartition));
  PreferredReplicaLeaderElectionCommand commands = new PreferredReplicaLeaderElectionCommand(client, topicsAndPartitions);
  commands.moveLeaderToPreferredReplica();
  client.close();
}
 
開發者ID:DemandCube,項目名稱:Scribengin,代碼行數:11,代碼來源:KafkaTool.java

示例4: getPartitionsUndergoingPreferredReplicaElection

import kafka.admin.PreferredReplicaLeaderElectionCommand; //導入依賴的package包/類
public static Set<TopicAndPartition> getPartitionsUndergoingPreferredReplicaElection(ZkClient zkClient) {
    // read the partitions and their new replica list
    String jsonPartitionList = readDataMaybeNull(zkClient, PreferredReplicaLeaderElectionPath)._1;

    Set<TopicAndPartition> ret = Sets.newHashSet();

    if (jsonPartitionList == null) return ret;

    return PreferredReplicaLeaderElectionCommand.parsePreferredReplicaElectionData(jsonPartitionList);
}
 
開發者ID:bingoohuang,項目名稱:buka,代碼行數:11,代碼來源:ZkUtils.java


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