当前位置: 首页>>代码示例>>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;未经允许,请勿转载。