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

How to use
AdminZkClient
in
kafka.zk

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

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: apache/hive

 void deleteTopic(@SuppressWarnings("SameParameterValue") String topic) {
  adminZkClient.deleteTopic(topic);
 }
}
origin: linkedin/kafka-monitor

void maybeAddPartitions(int minPartitionNum) {
 KafkaZkClient zkClient = KafkaZkClient.apply(_zkConnect, JaasUtils.isZkSecurityEnabled(), ZK_SESSION_TIMEOUT_MS,
   ZK_CONNECTION_TIMEOUT_MS, Integer.MAX_VALUE, Time.SYSTEM, METRIC_GROUP_NAME, "SessionExpireListener");
 AdminZkClient adminZkClient = new AdminZkClient(zkClient);
 try {
  scala.collection.Map<Object, scala.collection.Seq<Object>> existingAssignment = getPartitionAssignment(zkClient, _topic);
  int partitionNum = existingAssignment.size();
  if (partitionNum < minPartitionNum) {
   LOG.info("MultiClusterTopicManagementService will increase partition of the topic {} "
     + "in cluster {} from {} to {}.", _topic, _zkConnect, partitionNum, minPartitionNum);
   scala.Option<scala.collection.Map<java.lang.Object, scala.collection.Seq<java.lang.Object>>> replicaAssignment = scala.Option.apply(null);
   scala.Option<Seq<Object>> brokerList = scala.Option.apply(null);
   adminZkClient.addPartitions(_topic, existingAssignment, adminZkClient.getBrokerMetadatas(RackAwareMode.Disabled$.MODULE$, brokerList), minPartitionNum, replicaAssignment, false);
  }
 } finally {
  zkClient.close();
 }
}
origin: debezium/debezium

  server.startup();
  LOGGER.info("Started Kafka server {} at {} with storage in {}", brokerId, getConnection(), logsDir.getAbsolutePath());
  adminZkClient = new AdminZkClient(server.zkClient());
  return this;
} catch (RuntimeException e) {
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: 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)
  );
}
origin: allegro/hermes

private AdminZkClient adminZkClient(KafkaZkClient kafkaZkClient) {
  return new AdminZkClient(kafkaZkClient);
}
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: allegro/hermes

@Override
public void removeTopic(Topic topic) {
  kafkaNamesMapper.toKafkaTopics(topic).forEach(k -> adminZkClient.deleteTopic(k.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());
        }
    );
  });
}
kafka.zkAdminZkClient

Most used methods

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

Popular in Java

  • Making http post requests using okhttp
  • setContentView (Activity)
  • compareTo (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JTable (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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