org.apache.kafka.common.errors.InvalidReplicationFactorException Java Examples
The following examples show how to use
org.apache.kafka.common.errors.InvalidReplicationFactorException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TopicOperator.java From strimzi-kafka-operator with Apache License 2.0 | 6 votes |
@Override public void handle(Void v) throws OperatorException { kafka.createTopic(topic).onComplete(ar -> { if (ar.succeeded()) { LOGGER.debug("{}: Created topic '{}' for KafkaTopic '{}'", logContext, topic.getTopicName(), topic.getResourceName()); handler.handle(ar); } else { handler.handle(ar); if (ar.cause() instanceof TopicExistsException) { // TODO reconcile } else if (ar.cause() instanceof InvalidReplicationFactorException) { // error message is printed in the `reconcile` method } else { throw new OperatorException(involvedObject, ar.cause()); } } }); }
Example #2
Source File: KafkaAdminClientTest.java From common-kafka with Apache License 2.0 | 4 votes |
@Test(expected = InvalidReplicationFactorException.class) public void createTopic_replicationFactorMoreThanAvailableBrokers() { client.createTopic(topic, 1, 2); }
Example #3
Source File: KafkaExceptionMapperTest.java From rest-utils with Apache License 2.0 | 4 votes |
@Test public void testKafkaExceptions() { //exceptions mapped in KafkaExceptionMapper verifyMapperResponse(new BrokerNotAvailableException("some message"), Status.SERVICE_UNAVAILABLE, BROKER_NOT_AVAILABLE_ERROR_CODE); verifyMapperResponse(new InvalidReplicationFactorException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new SecurityDisabledException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new UnsupportedVersionException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new InvalidPartitionsException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new InvalidRequestException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new UnknownServerException("some message"),Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new UnknownTopicOrPartitionException("some message"), Status.NOT_FOUND, KAFKA_UNKNOWN_TOPIC_PARTITION_CODE); verifyMapperResponse(new PolicyViolationException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new TopicExistsException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); verifyMapperResponse(new InvalidConfigurationException("some message"), Status.BAD_REQUEST, KAFKA_BAD_REQUEST_ERROR_CODE); //test couple of retriable exceptions verifyMapperResponse(new NotCoordinatorException("some message"), Status.INTERNAL_SERVER_ERROR, KAFKA_RETRIABLE_ERROR_ERROR_CODE); verifyMapperResponse(new NotEnoughReplicasException("some message"), Status.INTERNAL_SERVER_ERROR, KAFKA_RETRIABLE_ERROR_ERROR_CODE); //test couple of kafka exception verifyMapperResponse(new CommitFailedException(), Status.INTERNAL_SERVER_ERROR, KAFKA_ERROR_ERROR_CODE); verifyMapperResponse(new ConcurrentTransactionsException("some message"), Status.INTERNAL_SERVER_ERROR, KAFKA_ERROR_ERROR_CODE); //test few general exceptions verifyMapperResponse(new NullPointerException("some message"), Status.INTERNAL_SERVER_ERROR, Status.INTERNAL_SERVER_ERROR.getStatusCode()); verifyMapperResponse(new IllegalArgumentException("some message"), Status.INTERNAL_SERVER_ERROR, Status.INTERNAL_SERVER_ERROR.getStatusCode()); }