Tabnine Logo
AdminZkClient.createTopic
Code IndexAdd Tabnine to your IDE (free)

How to use
createTopic
method
in
kafka.zk.AdminZkClient

Best Java code snippets using kafka.zk.AdminZkClient.createTopic (Showing top 6 results out of 315)

origin: debezium/debezium

/**
 * Create the specified topic.
 * 
 * @param topic the name of the topic to create
 * @param numPartitions the number of partitions for the topic
 * @param replicationFactor the replication factor for the topic
 */
public void createTopic( String topic, int numPartitions, int replicationFactor ) {
  RackAwareMode rackAwareMode = null;
  getAdminZkClient().createTopic(topic, numPartitions, replicationFactor, new Properties(), rackAwareMode);
}
origin: apache/hive

/**
 * Override to set up your specific external resource.
 *
 * @throws Throwable if setup fails (which will disable {@code after}
 */
@Override protected void before() throws Throwable {
 // Start the ZK and the Broker
 LOG.info("init embedded Zookeeper");
 zkServer = new EmbeddedZookeeper();
 tmpLogDir = Files.createTempDirectory("kafka-log-dir-").toAbsolutePath();
 String zkConnect = "127.0.0.1:" + zkServer.port();
 LOG.info("init kafka broker");
 Properties brokerProps = new Properties();
 brokerProps.setProperty("zookeeper.connect", zkConnect);
 brokerProps.setProperty("broker.id", "0");
 brokerProps.setProperty("log.dir", tmpLogDir.toString());
 brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKER_IP_PORT);
 brokerProps.setProperty("offsets.topic.replication.factor", "1");
 brokerProps.setProperty("transaction.state.log.replication.factor", "1");
 brokerProps.setProperty("transaction.state.log.min.isr", "1");
 KafkaConfig config = new KafkaConfig(brokerProps);
 kafkaServer = TestUtils.createServer(config, Time.SYSTEM);
 kafkaServer.startup();
 kafkaServer.zkClient();
 adminZkClient = new AdminZkClient(kafkaServer.zkClient());
 LOG.info("Creating kafka TOPIC [{}]", TOPIC);
 adminZkClient.createTopic(TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
}
origin: allegro/hermes

@Override
public void createTopic(Topic topic) {
  Properties config = createTopicConfig(topic.getRetentionTime().getDuration(), topicProperties, topic);
  kafkaNamesMapper.toKafkaTopics(topic).forEach(k ->
      adminZkClient.createTopic(
          k.name().asString(),
          topicProperties.getPartitions(),
          topicProperties.getReplicationFactor(),
          config,
          kafka.admin.RackAwareMode.Enforced$.MODULE$
      )
  );
}
origin: allegro/hermes

private void createTopic(String topicName, KafkaZkClient kafkaZkClient) {
  Topic topic = topic(topicName).build();
  kafkaNamesMapper.toKafkaTopics(topic).forEach(kafkaTopic -> {
    AdminZkClient adminZkClient = new AdminZkClient(kafkaZkClient);
    adminZkClient.createTopic(kafkaTopic.name().asString(), DEFAULT_PARTITIONS, DEFAULT_REPLICATION_FACTOR, new Properties(), RackAwareMode.Enforced$.MODULE$);
    waitAtMost(adjust(Duration.ONE_MINUTE)).until(() -> {
          kafkaZkClient.topicExists(kafkaTopic.name().asString());
        }
    );
  });
}
origin: pl.allegro.tech.hermes/hermes-test-helper

private void createTopic(String topicName, KafkaZkClient kafkaZkClient) {
  Topic topic = topic(topicName).build();
  kafkaNamesMapper.toKafkaTopics(topic).forEach(kafkaTopic -> {
    AdminZkClient adminZkClient = new AdminZkClient(kafkaZkClient);
    adminZkClient.createTopic(kafkaTopic.name().asString(), DEFAULT_PARTITIONS, DEFAULT_REPLICATION_FACTOR, new Properties(), RackAwareMode.Enforced$.MODULE$);
    waitAtMost(adjust(Duration.ONE_MINUTE)).until(() -> {
          kafkaZkClient.topicExists(kafkaTopic.name().asString());
        }
    );
  });
}
origin: allegro/hermes

@Override
public void updateTopic(Topic topic) {
  Properties config = createTopicConfig(topic.getRetentionTime().getDuration(), topicProperties, topic);
  KafkaTopics kafkaTopics = kafkaNamesMapper.toKafkaTopics(topic);
  if (isMigrationToNewKafkaTopic(kafkaTopics)) {
    adminZkClient.createTopic(
        kafkaTopics.getPrimary().name().asString(),
        topicProperties.getPartitions(),
        topicProperties.getReplicationFactor(),
        config,
        kafka.admin.RackAwareMode.Enforced$.MODULE$
    );
  } else {
    adminZkClient.changeTopicConfig(kafkaTopics.getPrimary().name().asString(), config);
  }
  kafkaTopics.getSecondary().ifPresent(secondary ->
      adminZkClient.changeTopicConfig(secondary.name().asString(), config)
  );
}
kafka.zkAdminZkClientcreateTopic

Popular methods of AdminZkClient

  • <init>
  • deleteTopic
  • addPartitions
  • changeTopicConfig
  • getBrokerMetadatas

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getApplicationContext (Context)
  • setScale (BigDecimal)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Permission (java.security)
    Legacy security code; do not use.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now