Package org.apache.kafka.common.test
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 kafka.network.SocketServerReturn any one of the broker servers.default kafka.network.SocketServerReturn any one of the controller servers.kafka.network.SocketServerdefault 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()default Collection<kafka.network.SocketServer> A collection of all brokers in the cluster.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.ListenerNamedefault Optional<org.apache.kafka.common.network.ListenerName> The listener for the kraft cluster controller configured by controller.listener.names.Collection<kafka.network.SocketServer> A collection of all controllers in the cluster.default voidcreateTopic(String topicName, int partitions, short replicas) duplicateCluster(Consumer<org.apache.kafka.common.test.api.ClusterConfig.Builder> builderConsumer) 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) voidshutdownBroker(int brokerId) voidstart()voidstartBroker(int brokerId) voidstop()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 voidwaitForTopic(String topic, int partitions) default voidwaitTopicDeletion(String topic)
-
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
Return the set of all controller IDs configured for this test. For kraft, this will return only the nodes which have the "controller" role enabled in `process.roles`. -
brokerIds
Return the set of all broker IDs configured for this test. -
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
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. -
brokerSocketServers
A collection of all brokers in the cluster. -
controllerSocketServers
Collection<kafka.network.SocketServer> controllerSocketServers()A collection of all controllers in the cluster. -
anyBrokerSocketServer
default kafka.network.SocketServer anyBrokerSocketServer()Return any one of the broker servers. Throw an error if none are found -
anyNonControllerBrokerSocketServer
kafka.network.SocketServer anyNonControllerBrokerSocketServer() -
anyControllerSocketServer
default kafka.network.SocketServer anyControllerSocketServer()Return any one of the controller servers. Throw an error if none are found -
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() -
stop
void stop() -
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
-
waitForReadyBrokers
- Throws:
InterruptedException
-
brokersMap
-
waitForTopic
- 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.
-