Class InVMKafkaCluster
java.lang.Object
io.kroxylicious.testing.kafka.invm.InVMKafkaCluster
- All Implemented Interfaces:
KafkaCluster,KafkaListenerSource,AdminSource,AutoCloseable
public class InVMKafkaCluster
extends Object
implements KafkaCluster, KafkaListenerSource, AdminSource
Configures and manages an in process (within the JVM) Kafka cluster.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.kroxylicious.testing.kafka.common.KafkaListenerSource
KafkaListenerSource.Listener -
Constructor Summary
ConstructorsConstructorDescriptionInVMKafkaCluster(KafkaClusterConfig clusterConfig) Instantiates a new in VM kafka cluster. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()org.apache.kafka.clients.admin.AdminCreates an admin client with administrator privileges.getKafkaClientConfiguration(String user, String password) getKafkaListener(KafkaListenerSource.Listener listener, int nodeId) Gets the kafka listen for the given listener and nodeId.intvoidremoveBroker(int nodeId) voidstart()voidstartNodes(IntPredicate nodeIdPredicate) voidstopNodes(IntPredicate nodeIdPredicate, TerminationStyle terminationStyle)
-
Constructor Details
-
InVMKafkaCluster
Instantiates a new in VM kafka cluster.- Parameters:
clusterConfig- the cluster config
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceKafkaCluster
-
getClusterId
- Specified by:
getClusterIdin interfaceKafkaCluster
-
getBootstrapServers
- Specified by:
getBootstrapServersin interfaceKafkaCluster
-
getBootstrapControllers
- Specified by:
getBootstrapControllersin interfaceKafkaCluster
-
getKafkaClientConfiguration
- Specified by:
getKafkaClientConfigurationin interfaceKafkaCluster
-
getKafkaClientConfiguration
- Specified by:
getKafkaClientConfigurationin interfaceKafkaCluster
-
getControllerAdminClientConfiguration
- Specified by:
getControllerAdminClientConfigurationin interfaceKafkaCluster
-
addBroker
public int addBroker()- Specified by:
addBrokerin interfaceKafkaCluster
-
removeBroker
- Specified by:
removeBrokerin interfaceKafkaCluster- Throws:
IllegalArgumentExceptionUnsupportedOperationException
-
stopNodes
- Specified by:
stopNodesin interfaceKafkaCluster
-
startNodes
- Specified by:
startNodesin interfaceKafkaCluster
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceKafkaCluster- Throws:
Exception
-
getNumOfBrokers
public int getNumOfBrokers()- Specified by:
getNumOfBrokersin interfaceKafkaCluster
-
getStoppedBrokers
- Specified by:
getStoppedBrokersin interfaceKafkaCluster
-
getKafkaListener
Description copied from interface:KafkaListenerSourceGets the kafka listen for the given listener and nodeId.- Specified by:
getKafkaListenerin interfaceKafkaListenerSource- Parameters:
listener- listenernodeId- kafkanode.id- Returns:
- kafka listener.
-
createAdmin
@NonNull public org.apache.kafka.clients.admin.Admin createAdmin()Description copied from interface:AdminSourceCreates an admin client with administrator privileges. It is the caller's responsibility to close the admin client returned.- Specified by:
createAdminin interfaceAdminSource- Returns:
- admin client
-