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 voidauthenticateSocket(Socket socket) Performs any required authentication (e.g.default 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 bootstrappingdefault intbrokerBoundPort(int brokerId) intbrokerBoundPort(int brokerId, org.apache.kafka.common.network.ListenerName listenerName) Returns the port bound to the specified listener on the specified broker.Return 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 voiddefault 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 voidwaitUntilAclsPropagated(org.apache.kafka.clients.admin.Admin admin, org.apache.kafka.common.resource.ResourcePattern resource, String principal, Collection<org.apache.kafka.common.acl.AccessControlEntry> expectedAcls) Wait for ACLs to be visible after async creation.default voidwaitUntilAclsRemoved(org.apache.kafka.clients.admin.Admin admin, org.apache.kafka.common.resource.ResourcePattern resource, String principal, Collection<org.apache.kafka.common.acl.AccessControlEntry> deletedAcls) Wait for ACLs to be removed after async deletion.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 -
authenticateSocket
Performs any required authentication (e.g. SASL handshake) on a raw socket connected to a broker's client listener. Implementations should send the necessary protocol messages to authenticate the connection so that subsequent Kafka requests succeed.The default implementation is a no-op, suitable for PLAINTEXT listeners that require no authentication.
- Throws:
IOException
-
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
-
brokerBoundPort
int brokerBoundPort(int brokerId, org.apache.kafka.common.network.ListenerName listenerName) Returns the port bound to the specified listener on the specified broker. -
brokerBoundPort
default int brokerBoundPort(int brokerId) -
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
-
createTopicWithAssignment
default void createTopicWithAssignment(String topicName, Map<Integer, List<Integer>> replicaAssignment) 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
-
waitUntilAclsPropagated
default void waitUntilAclsPropagated(org.apache.kafka.clients.admin.Admin admin, org.apache.kafka.common.resource.ResourcePattern resource, String principal, Collection<org.apache.kafka.common.acl.AccessControlEntry> expectedAcls) throws InterruptedException Wait for ACLs to be visible after async creation.- Parameters:
admin- the admin client to use for describing ACLsresource- the resource pattern to check ACLs forprincipal- the principal to filter by (e.g., "User:alice"), or null for any principalexpectedAcls- ACLs that are expected to be created- Throws:
InterruptedException
-
waitUntilAclsRemoved
default void waitUntilAclsRemoved(org.apache.kafka.clients.admin.Admin admin, org.apache.kafka.common.resource.ResourcePattern resource, String principal, Collection<org.apache.kafka.common.acl.AccessControlEntry> deletedAcls) throws InterruptedException Wait for ACLs to be removed after async deletion.- Parameters:
admin- the admin client to use for describing ACLsresource- the resource pattern to check ACLs forprincipal- the principal to filter by (e.g., "User:alice"), or null for any principaldeletedAcls- ACLs that are expected to be removed- Throws:
InterruptedException
-