Interface ClusterInstance
- All Known Implementing Classes:
RaftClusterInvocationContext.RaftClusterInstance
public interface ClusterInstance
-
Method Summary
Modifier and TypeMethodDescriptionkafka.network.SocketServerdefault org.apache.kafka.clients.admin.Adminadmin()default org.apache.kafka.clients.admin.Admindefault org.apache.kafka.clients.admin.Admindefault List<org.apache.kafka.server.authorizer.Authorizer> The broker connect string which can be used by clients for bootstrapping to the controller quorum.The broker connect string which can be used by clients for bootstrappingReturn the set of all broker IDs configured for this test.brokers()org.apache.kafka.common.network.ListenerNameThe listener for this cluster as configured byClusterTestor byClusterConfig.org.apache.kafka.common.test.api.ClusterConfigconfig()The immutable cluster configuration used to create this cluster.default <K,V> org.apache.kafka.clients.consumer.Consumer <K, V> consumer()default <K,V> org.apache.kafka.clients.consumer.Consumer <K, V> Return the set of all controller IDs configured for this test.org.apache.kafka.common.network.ListenerNameorg.apache.kafka.common.network.ListenerNameThe listener for the kraft cluster controller configured by controller.listener.names.default voidcreateTopic(String topicName, int partitions, short replicas) default voidcreateTopic(String topicName, int partitions, short replicas, Map<String, String> props) default voiddeleteTopic(String topicName) Deletes a topic and waits for the deletion to complete.duplicateCluster(Consumer<org.apache.kafka.common.test.api.ClusterConfig.Builder> builderConsumer) default voiddefault voidensureConsistentMetadata(Collection<kafka.server.KafkaBroker> brokers, Collection<kafka.server.ControllerServer> controllers) Optional<org.apache.kafka.server.fault.FaultHandlerException> Returns the first recorded fatal exception, if any.Optional<org.apache.kafka.server.fault.FaultHandlerException> Return the first recorded non-fatal exception, if any.default intgetLeaderBrokerId(org.apache.kafka.common.TopicPartition topicPartition) Returns the broker id of leader partition.voidkafka.network.SocketServerlinkCoordinator(String linkName) default <K,V> org.apache.kafka.clients.producer.Producer <K, V> producer()default <K,V> org.apache.kafka.clients.producer.Producer <K, V> voidsetClientSaslConfig(Map<String, Object> configs) default <K,V> org.apache.kafka.clients.consumer.ShareConsumer <K, V> default <K,V> org.apache.kafka.clients.consumer.ShareConsumer <K, V> shareConsumer(Map<String, Object> configs) default <K,V> org.apache.kafka.clients.consumer.ShareConsumer <K, V> shareConsumer(Map<String, Object> configs, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer) voidshutdownBroker(int brokerId) voidstart()voidstartBroker(int brokerId) booleanstarted()voidstop()booleanstopped()default Set<org.apache.kafka.clients.consumer.GroupProtocol> org.apache.kafka.common.test.api.Typetype()default voidwaitAcls(org.apache.kafka.common.acl.AclBindingFilter filter, Collection<org.apache.kafka.common.acl.AccessControlEntry> entries) voiddefault voidwaitTopicCreation(String topic, int partitions) default voidwaitTopicDeletion(String topic) default intwaitUntilLeaderIsElectedOrChangedWithAdmin(org.apache.kafka.clients.admin.Admin admin, String topic, int partitionNumber, long timeoutMs) Wait for a leader to be elected or changed using the provided admin client.
-
Method Details
-
type
org.apache.kafka.common.test.api.Type type() -
brokers
-
aliveBrokers
-
controllers
-
config
org.apache.kafka.common.test.api.ClusterConfig config()The immutable cluster configuration used to create this cluster. -
controllerIds
-
brokerIds
-
clientListener
org.apache.kafka.common.network.ListenerName clientListener()The listener for this cluster as configured byClusterTestor byClusterConfig. If unspecified by those sources, this will return the listener for the default security protocol PLAINTEXT -
controllerListener
org.apache.kafka.common.network.ListenerName controllerListener() -
controllerListenerName
org.apache.kafka.common.network.ListenerName controllerListenerName()The listener for the kraft cluster controller configured by controller.listener.names. -
bootstrapServers
String bootstrapServers()The broker connect string which can be used by clients for bootstrapping -
bootstrapControllers
String bootstrapControllers()The broker connect string which can be used by clients for bootstrapping to the controller quorum. -
controllerBoundPorts
-
brokerBoundPorts
-
activeController
- Throws:
InterruptedException
-
linkCoordinator
-
clusterId
String clusterId() -
duplicateCluster
ClusterInstance duplicateCluster(Consumer<org.apache.kafka.common.test.api.ClusterConfig.Builder> builderConsumer) -
producer
-
producer
default <K,V> org.apache.kafka.clients.producer.Producer<K,V> producer() -
consumer
-
consumer
default <K,V> org.apache.kafka.clients.consumer.Consumer<K,V> consumer() -
admin
-
setClientSaslConfig
-
admin
-
admin
default org.apache.kafka.clients.admin.Admin admin() -
supportedGroupProtocols
-
firstFatalException
Optional<org.apache.kafka.server.fault.FaultHandlerException> firstFatalException()Returns the first recorded fatal exception, if any. -
firstNonFatalException
Optional<org.apache.kafka.server.fault.FaultHandlerException> firstNonFatalException()Return the first recorded non-fatal exception, if any. -
start
void start() -
started
boolean started() -
stop
void stop() -
stopped
boolean stopped() -
shutdownBroker
void shutdownBroker(int brokerId) -
startBroker
void startBroker(int brokerId) -
rollingBrokerRestart
void rollingBrokerRestart() -
killAllBrokers
void killAllBrokers() -
waitTopicDeletion
- Throws:
InterruptedException
-
createTopic
default void createTopic(String topicName, int partitions, short replicas) throws InterruptedException - Throws:
InterruptedException
-
createTopic
default void createTopic(String topicName, int partitions, short replicas, Map<String, String> props) throws InterruptedException- Throws:
InterruptedException
-
deleteTopic
Deletes a topic and waits for the deletion to complete.- Parameters:
topicName- The name of the topic to delete- Throws:
InterruptedException- If the operation is interruptedExecutionException
-
waitForReadyBrokers
- Throws:
InterruptedException
-
brokersMap
-
waitTopicCreation
- Throws:
InterruptedException
-
ensureConsistentMetadata
- Throws:
InterruptedException
-
ensureConsistentMetadata
default void ensureConsistentMetadata(Collection<kafka.server.KafkaBroker> brokers, Collection<kafka.server.ControllerServer> controllers) throws InterruptedException - Throws:
InterruptedException
-
authorizers
-
waitAcls
default void waitAcls(org.apache.kafka.common.acl.AclBindingFilter filter, Collection<org.apache.kafka.common.acl.AccessControlEntry> entries) throws InterruptedException - Throws:
InterruptedException
-
getLeaderBrokerId
default int getLeaderBrokerId(org.apache.kafka.common.TopicPartition topicPartition) throws ExecutionException, InterruptedException Returns the broker id of leader partition. -
waitUntilLeaderIsElectedOrChangedWithAdmin
-