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

How to use
CreatePartitionsResult
in
org.apache.kafka.clients.admin

Best Java code snippets using org.apache.kafka.clients.admin.CreatePartitionsResult (Showing top 7 results out of 315)

origin: apache/kafka

@Test
public void testCreatePartitions() throws Exception {
  try (AdminClientUnitTestEnv env = mockClientEnv()) {
    env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
    Map<String, ApiError> m = new HashMap<>();
    m.put("my_topic", ApiError.NONE);
    m.put("other_topic", ApiError.fromThrowable(new InvalidTopicException("some detailed reason")));
    // Test a call where one filter has an error.
    env.kafkaClient().prepareResponse(new CreatePartitionsResponse(0, m));
    Map<String, NewPartitions> counts = new HashMap<>();
    counts.put("my_topic", NewPartitions.increaseTo(3));
    counts.put("other_topic", NewPartitions.increaseTo(3, asList(asList(2), asList(3))));
    CreatePartitionsResult results = env.adminClient().createPartitions(counts);
    Map<String, KafkaFuture<Void>> values = results.values();
    KafkaFuture<Void> myTopicResult = values.get("my_topic");
    myTopicResult.get();
    KafkaFuture<Void> otherTopicResult = values.get("other_topic");
    try {
      otherTopicResult.get();
      fail("get() should throw ExecutionException");
    } catch (ExecutionException e0) {
      assertTrue(e0.getCause() instanceof InvalidTopicException);
      InvalidTopicException e = (InvalidTopicException) e0.getCause();
      assertEquals("some detailed reason", e.getMessage());
    }
  }
}
origin: apache/kafka

return new CreatePartitionsResult(new HashMap<>(futures));
origin: apache/kafka

  counts.put("my_topic", NewPartitions.increaseTo(3));
  counts.put("other_topic", NewPartitions.increaseTo(3, asList(asList(2), asList(3))));
  env.adminClient().createPartitions(counts).all().get();
  fail("Expected an authentication error.");
} catch (ExecutionException e) {
origin: spring-projects/spring-kafka

private void modifyTopics(AdminClient adminClient, Map<String, NewPartitions> topicsToModify) {
  CreatePartitionsResult partitionsResult = adminClient.createPartitions(topicsToModify);
  try {
    partitionsResult.all().get(this.operationTimeout, TimeUnit.SECONDS);
  }
  catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    logger.error("Interrupted while waiting for partition creation results", e);
  }
  catch (TimeoutException e) {
    throw new KafkaException("Timed out waiting for create partitions results", e);
  }
  catch (ExecutionException e) {
    if (e.getCause() instanceof InvalidPartitionsException) { // Possible race with another app instance
      logger.debug("Failed to create partitions", e.getCause());
    }
    else {
      logger.error("Failed to create partitions", e.getCause());
      if (!(e.getCause() instanceof UnsupportedVersionException)) {
        throw new KafkaException("Failed to create partitions", e.getCause()); // NOSONAR
      }
    }
  }
}
origin: spring-cloud/spring-cloud-stream-binder-kafka

CreatePartitionsResult partitions = adminClient.createPartitions(
    Collections.singletonMap(topicName, NewPartitions.increaseTo(effectivePartitionCount)));
partitions.all().get(this.operationTimeout, TimeUnit.SECONDS);
origin: strimzi/strimzi-kafka-operator

@Override
public void increasePartitions(Topic topic, Handler<AsyncResult<Void>> handler) {
  final NewPartitions newPartitions = NewPartitions.increaseTo(topic.getNumPartitions());
  final Map<String, NewPartitions> request = Collections.singletonMap(topic.getTopicName().toString(), newPartitions);
  KafkaFuture<Void> future = adminClient.createPartitions(request).values().get(topic.getTopicName().toString());
  queueWork(new UniWork<>("increasePartitions", future, handler));
}
origin: org.springframework.cloud/spring-cloud-stream-binder-kafka-core

CreatePartitionsResult partitions = adminClient.createPartitions(
    Collections.singletonMap(topicName, NewPartitions.increaseTo(effectivePartitionCount)));
partitions.all().get(this.operationTimeout, TimeUnit.SECONDS);
org.apache.kafka.clients.adminCreatePartitionsResult

Javadoc

The result of the AdminClient#createPartitions(Map) call. The API of this class is evolving, see AdminClient for details.

Most used methods

  • all
  • values
    Return a map from topic names to futures, which can be used to check the status of individual partit
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top plugins for Android Studio
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