• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AdminOperationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中kafka.admin.AdminOperationException的典型用法代码示例。如果您正苦于以下问题:Java AdminOperationException类的具体用法?Java AdminOperationException怎么用?Java AdminOperationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AdminOperationException类属于kafka.admin包,在下文中一共展示了AdminOperationException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createTopic

import kafka.admin.AdminOperationException; //导入依赖的package包/类
/**
 * Create a topic
 *
 * @param connection        Connection
 * @param topicName         Topic name
 * @param partitions        The number of partitions for the topic being created
 * @param replicationFactor The replication factor for each partition in the topic being created
 * @param topicProperties   A topic configuration override for an existing topic
 * @throws TopicOperationException if topic was not created.
 */
public void createTopic(final ZkUtils connection, final String topicName,
                        final int partitions,
                        final int replicationFactor,
                        final Properties topicProperties) {

    try {
        AdminUtils.createTopic(connection,
                topicName,
                partitions,
                replicationFactor,
                topicProperties);

    } catch (IllegalArgumentException | KafkaException | AdminOperationException e) {
        throw new TopicOperationException(topicName, e.getMessage(), e, this.getClass());
    }
}
 
开发者ID:mcafee,项目名称:management-sdk-for-kafka,代码行数:27,代码来源:ClusterTools.java


示例2: createTopic

import kafka.admin.AdminOperationException; //导入依赖的package包/类
/**
 * Creates a Topic.
 *
 * @param topicName             Topic name.
 * @param partitions        Number of partitions for the topic.
 * @param replicationFactor Replication factor.
 * @param curatorFramework CuratorFramework.
 */
public static void createTopic(String topicName, int partitions, int replicationFactor, CuratorFramework curatorFramework) {
    if (partitions <= 0)
        throw new AdminOperationException("number of partitions must be larger than 0");

    if (replicationFactor <= 0)
        throw new AdminOperationException("replication factor must be larger than 0");

    if (!topicExists(topicName, curatorFramework)) {
        m_logger.info(String.format("Topic %s not found, creating...", topicName));
        ZkClient zkClient = fromCurator(curatorFramework);
        try {
            AdminUtils.createTopic(zkClient, topicName, partitions, replicationFactor, new Properties());
            m_logger.info("Topic created. name: {}, partitions: {}, replicationFactor: {}", topicName,
                    partitions, replicationFactor);
        } catch (TopicExistsException ignore) {
            m_logger.info("Topic exists. name: {}", topicName);
        } finally {
            if (zkClient != null) {
                zkClient.close();
            }
        }
    } else {
        m_logger.info(String.format("Topic %s found!", topicName));
    }
}
 
开发者ID:Microsoft,项目名称:Availability-Monitor-for-Kafka,代码行数:34,代码来源:KafkaUtils.java


示例3: updatePartitionReassignmentData

import kafka.admin.AdminOperationException; //导入依赖的package包/类
public static void updatePartitionReassignmentData(ZkClient zkClient, Multimap<TopicAndPartition, Integer> partitionsToBeReassigned) {
    String zkPath = ZkUtils.ReassignPartitionsPath;
    int size = partitionsToBeReassigned.size();
    switch (size) {
        case 0: // need to delete the /admin/reassign_partitions path
            deletePath(zkClient, zkPath);
            logger.info("No more partitions need to be reassigned. Deleting zk path {}", zkPath);
            break;
        default:
            String jsonData = getPartitionReassignmentZkData(partitionsToBeReassigned);
            try {
                updatePersistentPath(zkClient, zkPath, jsonData);
                logger.info("Updated partition reassignment path with {}", jsonData);
            } catch (ZkNoNodeException nne) {
                ZkUtils.createPersistentPath(zkClient, zkPath, jsonData);
                logger.debug("Created path {} with {} for partition reassignment", zkPath, jsonData);
            } catch (Throwable e) {
                throw new AdminOperationException(e.toString());
            }
    }
}
 
开发者ID:bingoohuang,项目名称:buka,代码行数:22,代码来源:ZkUtils.java


示例4: overrideTopicProperties

import kafka.admin.AdminOperationException; //导入依赖的package包/类
/**
 * Override topic configuration
 *
 * @param connection zookeeper util API
 * @param topicName  topic name
 * @param configs    topic properties
 */
public void overrideTopicProperties(final ZkUtils connection, final String topicName, final Properties configs) {
    try {
        AdminUtils.changeTopicConfig(connection, topicName, configs);
    } catch (AdminOperationException | KafkaException e) {
        throw new TopicOperationException(topicName, e.getMessage(), e, this.getClass());
    }
}
 
开发者ID:mcafee,项目名称:management-sdk-for-kafka,代码行数:15,代码来源:ClusterTools.java


示例5: createTopic

import kafka.admin.AdminOperationException; //导入依赖的package包/类
@Override
public KafkaTopic createTopic(final KafkaTopic topic) throws RestException {
  if (!listTopics().contains(topic.getName())) {
    try {
      adminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$);
    } catch (AdminOperationException e) {
      throw new RestException(e);
    }
  }
  return topic;
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:KafkaServiceImpl.java


示例6: modifyTopicPartitioning

import kafka.admin.AdminOperationException; //导入依赖的package包/类
/**
 * Modify number of partition of a Kafka topic.
 *
 * @param topicName     name of topic.
 * @param numPartitions
 * @throws kafka.common.KafkaException
 */
public void modifyTopicPartitioning(String topicName, int numPartitions) throws KafkaException {
    if (AdminUtils.topicExists(zkUtils, topicName)) {
        logger.debug("Altering topic {}", topicName);
        try {
            AdminUtils.addPartitions(zkUtils, topicName, numPartitions, "", true, RackAwareMode.Enforced$.MODULE$);
            logger.debug("Topic {} altered with partitions : {}", topicName, partitions);
        } catch (AdminOperationException aoe) {
            logger.debug("Error while altering partitions for topic : {}", topicName, aoe);
        }
    } else {
        logger.debug("Topic {} doesn't exists", topicName);
    }
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:21,代码来源:KafkaUtils.java


示例7: whenAdminUtilsThrowsAdminOperationExceptionCreateTopicShouldProperlyWrapExceptionInRestException

import kafka.admin.AdminOperationException; //导入依赖的package包/类
@Test
public void whenAdminUtilsThrowsAdminOperationExceptionCreateTopicShouldProperlyWrapExceptionInRestException() throws Exception {
  exception.expect(RestException.class);

  final Map<String, List<PartitionInfo>> topics = new HashMap<>();
  topics.put("1", new ArrayList<>());

  when(kafkaConsumer.listTopics()).thenReturn(topics);

  doThrow(AdminOperationException.class).when(adminUtils).createTopic(eq(zkUtils), eq("t"), eq(1), eq(2), eq(new Properties()), eq(RackAwareMode.Disabled$.MODULE$));

  kafkaService.createTopic(VALID_KAFKA_TOPIC);
}
 
开发者ID:apache,项目名称:metron,代码行数:14,代码来源:KafkaServiceImplTest.java



注:本文中的kafka.admin.AdminOperationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteArray类代码示例发布时间:2022-05-22
下一篇:
Java Pair类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap