Package com.linkedin.venice.unit.kafka
Class MockInMemoryAdminAdapter
- java.lang.Object
-
- com.linkedin.venice.unit.kafka.MockInMemoryAdminAdapter
-
- All Implemented Interfaces:
PubSubAdminAdapter
,java.io.Closeable
,java.lang.AutoCloseable
public class MockInMemoryAdminAdapter extends java.lang.Object implements PubSubAdminAdapter
-
-
Constructor Summary
Constructors Constructor Description MockInMemoryAdminAdapter(InMemoryKafkaBroker inMemoryKafkaBroker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
containsTopic(PubSubTopic topic)
Checks if a PubSub topic exists.boolean
containsTopicWithPartitionCheck(PubSubTopicPartition pubSubTopicPartition)
Checks if a PubSub topic exists and has the given partitionvoid
createTopic(PubSubTopic topic, int numPartitions, int replication, PubSubTopicConfiguration topicPubSubTopicConfiguration)
Creates a new topic in the PubSub system with the given parameters.void
deleteTopic(PubSubTopic topicName, java.time.Duration timeout)
Delete a given topic.java.util.Map<PubSubTopic,java.lang.Long>
getAllTopicRetentions()
Retrieves the retention settings for all PubSub topics.java.lang.String
getClassName()
java.util.List<java.lang.Class<? extends java.lang.Throwable>>
getRetriableExceptions()
java.util.Map<PubSubTopic,PubSubTopicConfiguration>
getSomeTopicConfigs(java.util.Set<PubSubTopic> topicNames)
Retrieves the configurations for a set of PubSub topics.PubSubTopicConfiguration
getTopicConfig(PubSubTopic topic)
Retrieves the configuration of a PubSub topic.PubSubTopicConfiguration
getTopicConfigWithRetry(PubSubTopic pubSubTopic)
java.util.Set<PubSubTopic>
listAllTopics()
Retrieves a set of all available PubSub topics from the PubSub cluster.java.util.List<PubSubTopicPartitionInfo>
partitionsFor(PubSubTopic topic)
void
setTopicConfig(PubSubTopic topicName, PubSubTopicConfiguration topicPubSubTopicConfiguration)
Sets the configuration for a PubSub topic.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.venice.pubsub.api.PubSubAdminAdapter
containsTopicWithExpectationAndRetry, containsTopicWithExpectationAndRetry, containsTopicWithPartitionCheckExpectationAndRetry, containsTopicWithPartitionCheckExpectationAndRetry, getTopicConfigMaxRetryInMs
-
-
-
-
Constructor Detail
-
MockInMemoryAdminAdapter
public MockInMemoryAdminAdapter(InMemoryKafkaBroker inMemoryKafkaBroker)
-
-
Method Detail
-
createTopic
public void createTopic(PubSubTopic topic, int numPartitions, int replication, PubSubTopicConfiguration topicPubSubTopicConfiguration)
Description copied from interface:PubSubAdminAdapter
Creates a new topic in the PubSub system with the given parameters.- Specified by:
createTopic
in interfacePubSubAdminAdapter
- Parameters:
topic
- The topic to be created.numPartitions
- The number of partitions to be created for the topic.replication
- The number of replicas for each partition.topicPubSubTopicConfiguration
- Additional topic configuration such as retention, compaction policy, etc.
-
deleteTopic
public void deleteTopic(PubSubTopic topicName, java.time.Duration timeout)
Description copied from interface:PubSubAdminAdapter
Delete a given topic. The calling thread will block until the topic is deleted or the timeout is reached.- Specified by:
deleteTopic
in interfacePubSubAdminAdapter
- Parameters:
topicName
- The topic to delete.timeout
- The maximum duration to wait for the deletion to complete.
-
listAllTopics
public java.util.Set<PubSubTopic> listAllTopics()
Description copied from interface:PubSubAdminAdapter
Retrieves a set of all available PubSub topics from the PubSub cluster.- Specified by:
listAllTopics
in interfacePubSubAdminAdapter
- Returns:
- A Set of PubSubTopic objects representing all available topics.
-
setTopicConfig
public void setTopicConfig(PubSubTopic topicName, PubSubTopicConfiguration topicPubSubTopicConfiguration) throws PubSubTopicDoesNotExistException
Description copied from interface:PubSubAdminAdapter
Sets the configuration for a PubSub topic.- Specified by:
setTopicConfig
in interfacePubSubAdminAdapter
- Parameters:
topicName
- The PubSubTopic for which to set the configuration.topicPubSubTopicConfiguration
- The configuration to be set for the specified PubSub topic.- Throws:
PubSubTopicDoesNotExistException
- If the specified PubSub topic does not exist.
-
getAllTopicRetentions
public java.util.Map<PubSubTopic,java.lang.Long> getAllTopicRetentions()
Description copied from interface:PubSubAdminAdapter
Retrieves the retention settings for all PubSub topics.- Specified by:
getAllTopicRetentions
in interfacePubSubAdminAdapter
- Returns:
- A map of pub-sub topics and their corresponding retention settings in milliseconds.
If a topic does not have a retention setting, it will be mapped to
PubSubConstants.PUBSUB_TOPIC_UNKNOWN_RETENTION
.
-
getTopicConfig
public PubSubTopicConfiguration getTopicConfig(PubSubTopic topic) throws PubSubTopicDoesNotExistException
Description copied from interface:PubSubAdminAdapter
Retrieves the configuration of a PubSub topic.- Specified by:
getTopicConfig
in interfacePubSubAdminAdapter
- Parameters:
topic
- The PubSubTopic for which to retrieve the configuration.- Returns:
- The configuration of the specified PubSubTopic as a PubSubTopicConfiguration object.
- Throws:
PubSubTopicDoesNotExistException
- If the specified PubSubTopic topic does not exist.
-
getTopicConfigWithRetry
public PubSubTopicConfiguration getTopicConfigWithRetry(PubSubTopic pubSubTopic)
- Specified by:
getTopicConfigWithRetry
in interfacePubSubAdminAdapter
-
containsTopic
public boolean containsTopic(PubSubTopic topic)
Description copied from interface:PubSubAdminAdapter
Checks if a PubSub topic exists.- Specified by:
containsTopic
in interfacePubSubAdminAdapter
- Parameters:
topic
- The PubSubTopic to check for existence.- Returns:
- true if the specified topic exists, false otherwise.
-
containsTopicWithPartitionCheck
public boolean containsTopicWithPartitionCheck(PubSubTopicPartition pubSubTopicPartition)
Description copied from interface:PubSubAdminAdapter
Checks if a PubSub topic exists and has the given partition- Specified by:
containsTopicWithPartitionCheck
in interfacePubSubAdminAdapter
- Parameters:
pubSubTopicPartition
- The PubSubTopicPartition representing th topic and partition to check.- Returns:
- true if the specified topic partition exists, false otherwise.
-
getRetriableExceptions
public java.util.List<java.lang.Class<? extends java.lang.Throwable>> getRetriableExceptions()
- Specified by:
getRetriableExceptions
in interfacePubSubAdminAdapter
- Returns:
- Returns a list of exceptions that are retriable for this PubSubClient.
-
getSomeTopicConfigs
public java.util.Map<PubSubTopic,PubSubTopicConfiguration> getSomeTopicConfigs(java.util.Set<PubSubTopic> topicNames)
Description copied from interface:PubSubAdminAdapter
Retrieves the configurations for a set of PubSub topics.- Specified by:
getSomeTopicConfigs
in interfacePubSubAdminAdapter
- Parameters:
topicNames
- The set of PubSub topics to retrieve configurations for.- Returns:
- A map of PubSub topics and their corresponding configurations.
-
partitionsFor
public java.util.List<PubSubTopicPartitionInfo> partitionsFor(PubSubTopic topic)
-
getClassName
public java.lang.String getClassName()
- Specified by:
getClassName
in interfacePubSubAdminAdapter
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-