Class KafkaClusterTestKit
java.lang.Object
org.apache.kafka.common.test.KafkaClusterTestKit
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.kafka.clients.admin.Adminadmin()org.apache.kafka.clients.admin.Adminorg.apache.kafka.clients.admin.Adminbrokers()voidclose()voidformat()scala.Option<CompletableFuture<Integer>> nodes()voidrestartBroker(int nodeId, Map<String, Object> propOverrides) Shuts down the given broker (if it isn't already) and starts it back up with a possibly modified static configuration.voidrestartBrokersWithSwappedClientListenerPorts(int nodeId1, int nodeId2) Stops and restarts the brokers with swapped client listener ports.voidvoidstartup()org.apache.kafka.controller.ControllervoidWait for a controller to mark all the brokers as ready (registered and unfenced).
-
Method Details
-
format
-
startup
-
restartBrokersWithSwappedClientListenerPorts
public void restartBrokersWithSwappedClientListenerPorts(int nodeId1, int nodeId2) throws IOException Stops and restarts the brokers with swapped client listener ports. This simulates a network routing anomaly, such as a misconfigured proxy. Clients should rebootstrap, reconnect and continue working.- Parameters:
nodeId1- The ID of the first broker.nodeId2- The ID of the second broker.- Throws:
IOException
-
restartBroker
Shuts down the given broker (if it isn't already) and starts it back up with a possibly modified static configuration. This allows tests to change read-only configs, such aslog.dirs, which can only be applied when the broker process (re)starts.The broker keeps its identity (node ID, cluster metadata, bound ports): a new
SharedServer/BrokerServerpair is created from the previous broker'sMetaPropertiesEnsembleand socket factory, but with aKafkaConfigderived from the previous one withpropOverridesapplied on top.- Parameters:
nodeId- The ID of the broker to restart.propOverrides- Configs to override in the broker's static configuration.
-
waitForReadyBrokers
Wait for a controller to mark all the brokers as ready (registered and unfenced). And also wait for the metadata cache up-to-date in each broker server. -
admin
public org.apache.kafka.clients.admin.Admin admin() -
admin
-
admin
-
bootstrapServers
-
bootstrapControllers
-
controllers
-
interBrokerPortFuture
-
waitForActiveController
- Throws:
InterruptedException
-
brokers
-
raftManagers
-
nodes
-
fatalFaultHandler
-
nonFatalFaultHandler
-
sslManager
-
shutdownAll
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
clusterId
-