public void createTopic(String topicName, Integer numPartitions) { // setup String[] arguments = new String[9]; arguments[0] = "--create"; arguments[1] = "--zookeeper"; arguments[2] = zookeeperString; arguments[3] = "--replication-factor"; arguments[4] = "1"; arguments[5] = "--partitions"; arguments[6] = "" + Integer.valueOf(numPartitions); arguments[7] = "--topic"; arguments[8] = topicName; TopicCommand.TopicCommandOptions opts = new TopicCommand.TopicCommandOptions(arguments); ZkUtils zkUtils = ZkUtils.apply(opts.options().valueOf(opts.zkConnectOpt()), 30000, 30000, JaasUtils.isZkSecurityEnabled()); // run LOGGER.info("Executing: CreateTopic " + Arrays.toString(arguments)); TopicCommand.createTopic(zkUtils, opts); }
public void createTopic(String topicName, int numPartitions) { // setup String[] arguments = new String[9]; arguments[0] = "--create"; arguments[1] = "--zookeeper"; arguments[2] = zookeeperString; arguments[3] = "--replication-factor"; arguments[4] = "1"; arguments[5] = "--partitions"; arguments[6] = String.valueOf(numPartitions); arguments[7] = "--topic"; arguments[8] = topicName; TopicCommand.TopicCommandOptions opts = new TopicCommand.TopicCommandOptions(arguments); ZkUtils zkUtils = ZkUtils.apply(opts.options().valueOf(opts.zkConnectOpt()), 30000, 30000, JaasUtils.isZkSecurityEnabled()); try{ // run LOGGER.info("Executing: CreateTopic " + Arrays.toString(arguments)); TopicCommand.createTopic(zkUtils, opts); } finally { zkUtils.close(); } }
/** * Delete a topic. * @param topicName The name of the topic to delete */ public void deleteTopic(String topicName) { String[] arguments = new String[5]; arguments[0] = "--zookeeper"; arguments[1] = zookeeperString; arguments[2] = "--delete"; arguments[3] = "--topic"; arguments[4] = topicName; TopicCommand.TopicCommandOptions opts = new TopicCommand.TopicCommandOptions(arguments); ZkUtils zkUtils = ZkUtils.apply(opts.options().valueOf(opts.zkConnectOpt()), 30000, 30000, JaasUtils.isZkSecurityEnabled()); try { // run LOGGER.info("Executing: DeleteTopic " + Arrays.toString(arguments)); TopicCommand.deleteTopic(zkUtils, opts); } finally { zkUtils.close(); } }
TopicCommand.TopicCommandOptions opts = new TopicCommand.TopicCommandOptions(arguments); ZkUtils zkUtils = ZkUtils.apply(opts.options().valueOf(opts.zkConnectOpt()), 30000, 30000, JaasUtils.isZkSecurityEnabled()); final List<String> topics = new ArrayList<>();