public class BrokerService extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected PublishRateLimiter |
brokerPublishRateLimiter |
protected AtomicReference<Semaphore> |
lookupRequestSemaphore |
static String |
MANAGED_LEDGER_PATH_ZNODE |
int |
maxUnackedMsgsPerDispatcher |
static String |
PRODUCER_NAME_GENERATOR_PATH |
protected AtomicReference<Semaphore> |
topicLoadRequestSemaphore |
| Constructor and Description |
|---|
BrokerService(PulsarService pulsar,
io.netty.channel.EventLoopGroup eventLoopGroup) |
| Modifier and Type | Method and Description |
|---|---|
void |
addUnAckedMessages(PersistentDispatcherMultipleConsumers dispatcher,
int numberOfMessages)
If per-broker unacked message reached to limit then it blocks dispatcher if its unacked message limit has been
reached to
maxUnackedMsgsPerDispatcher. |
void |
cacheOfflineTopicStats(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.PersistentOfflineTopicStats offlineTopicStats) |
void |
checkBrokerPublishThrottlingRate() |
void |
checkCompaction() |
void |
checkGC() |
void |
checkInactiveSubscriptions() |
void |
checkMessageDeduplicationInfo() |
void |
checkMessageExpiry() |
void |
checkReplicationPolicies() |
CompletableFuture<Void> |
checkTopicNsOwnership(String topic) |
void |
checkTopicPublishThrottlingRate() |
void |
checkUnAckMessageDispatching()
Adds given dispatcher's unackMessage count to broker-unack message count and if it reaches to the
maxUnackedMessages then it blocks all the dispatchers which has unack-messages higher than
maxUnackedMsgsPerDispatcher. |
void |
cleanUnloadedTopicFromCache(NamespaceBundle serviceUnit) |
void |
close() |
CompletableFuture<Void> |
closeAndRemoveReplicationClient(String clusterName) |
CompletableFuture<Void> |
closeAsync() |
CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> |
deleteSchemaStorage(String topic) |
CompletableFuture<Void> |
deleteTopic(String topic,
boolean forceDelete) |
CompletableFuture<Void> |
deleteTopic(String topic,
boolean forceDelete,
boolean deleteSchema) |
void |
deleteTopicAuthenticationWithRetry(String topic,
CompletableFuture<Void> future,
int count) |
CompletableFuture<Void> |
deleteTopicPolicies(org.apache.pulsar.common.naming.TopicName topicName) |
io.netty.channel.EventLoopGroup |
executor() |
static Optional<Topic> |
extractTopic(CompletableFuture<Optional<Topic>> topicFuture)
Safely extract optional topic instance from a future, in a way to avoid unchecked exceptions and race conditions.
|
CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> |
fetchPartitionedTopicMetadataAsync(org.apache.pulsar.common.naming.TopicName topicName) |
CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> |
fetchPartitionedTopicMetadataCheckAllowAutoCreationAsync(org.apache.pulsar.common.naming.TopicName topicName) |
void |
forEachTopic(Consumer<Topic> consumer)
Iterates over all loaded topics in the broker.
|
String |
generateUniqueProducerName() |
List<Topic> |
getAllTopicsFromNamespaceBundle(String namespace,
String bundle) |
AuthenticationService |
getAuthenticationService() |
AuthorizationService |
getAuthorizationService() |
BacklogQuotaManager |
getBacklogQuotaManager() |
Set<org.apache.pulsar.common.intercept.BrokerEntryMetadataInterceptor> |
getBrokerEntryMetadataInterceptors() |
Map<String,org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats> |
getBundleStats() |
PulsarAdmin |
getClusterPulsarAdmin(String cluster,
Optional<org.apache.pulsar.common.policies.data.ClusterData> clusterDataOp) |
int |
getDefaultNumPartitions(org.apache.pulsar.common.naming.TopicName topicName) |
DelayedDeliveryTrackerFactory |
getDelayedDeliveryTrackerFactory() |
void |
getDimensionMetrics(Consumer<io.netty.buffer.ByteBuf> consumer) |
static List<String> |
getDynamicConfiguration() |
int |
getKeepAliveIntervalSeconds() |
Optional<Integer> |
getListenPort() |
Optional<Integer> |
getListenPortTls() |
Semaphore |
getLookupRequestSemaphore() |
CompletableFuture<ManagedLedgerConfig> |
getManagedLedgerConfig(org.apache.pulsar.common.naming.TopicName topicName) |
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,Topic>>> |
getMultiLayerTopicMap() |
int |
getNumberOfNamespaceBundles() |
org.apache.pulsar.common.policies.data.PersistentOfflineTopicStats |
getOfflineTopicStat(org.apache.pulsar.common.naming.TopicName topicName) |
CompletableFuture<Topic> |
getOrCreateTopic(String topic) |
long |
getPausedConnections() |
org.apache.pulsar.client.api.PulsarClient |
getReplicationClient(String cluster,
Optional<org.apache.pulsar.common.policies.data.ClusterData> clusterDataOp) |
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.client.api.PulsarClient> |
getReplicationClients() |
Map<String,String> |
getRuntimeConfiguration() |
CompletableFuture<Optional<Topic>> |
getTopic(String topic,
boolean createIfMissing) |
CompletableFuture<Optional<Topic>> |
getTopicIfExists(String topic) |
List<org.apache.pulsar.common.stats.Metrics> |
getTopicMetrics() |
org.apache.bookkeeper.common.util.OrderedExecutor |
getTopicOrderedExecutor() |
Optional<org.apache.pulsar.common.policies.data.TopicPolicies> |
getTopicPolicies(org.apache.pulsar.common.naming.TopicName topicName)
Get
TopicPolicies for the parameterized topic. |
Optional<Topic> |
getTopicReference(String topic)
Get a reference to a topic that is currently loaded in the broker.
|
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,CompletableFuture<Optional<Topic>>> |
getTopics() |
Map<String,org.apache.pulsar.common.policies.data.stats.TopicStatsImpl> |
getTopicStats() |
void |
invalidateOfflineTopicStatCache(org.apache.pulsar.common.naming.TopicName topicName) |
boolean |
isAllowAutoSubscriptionCreation(String topic) |
boolean |
isAllowAutoSubscriptionCreation(org.apache.pulsar.common.naming.TopicName topicName) |
boolean |
isAllowAutoTopicCreation(String topic) |
boolean |
isAllowAutoTopicCreation(org.apache.pulsar.common.naming.TopicName topicName) |
boolean |
isAuthenticationEnabled() |
boolean |
isAuthorizationEnabled() |
boolean |
isBrokerDispatchingBlocked() |
boolean |
isBrokerEntryMetadataEnabled() |
boolean |
isDefaultTopicTypePartitioned(org.apache.pulsar.common.naming.TopicName topicName) |
static boolean |
isDynamicConfiguration(String key) |
boolean |
isSystemTopic(String topic) |
boolean |
isSystemTopic(org.apache.pulsar.common.naming.TopicName topicName) |
boolean |
isTopicNsOwnedByBroker(org.apache.pulsar.common.naming.TopicName topicName) |
protected CompletableFuture<Optional<Topic>> |
loadOrCreatePersistentTopic(String topic,
boolean createIfMissing)
It creates a topic async and returns CompletableFuture.
|
void |
monitorBacklogQuota() |
void |
pausedConnections(int numberOfConnections) |
PulsarService |
pulsar() |
void |
refreshTopicToStatsMaps(NamespaceBundle oldBundle) |
<T> void |
registerConfigurationListener(String configKey,
Consumer<T> listener)
Allows a listener to listen on update of
ServiceConfiguration change, so listener can take appropriate
action if any specific config-field value has been changed. |
CompletableFuture<Void> |
removeTopicFromCache(String topic) |
void |
removeTopicFromCache(String topic,
NamespaceBundle namespaceBundle) |
void |
resumedConnections(int numberOfConnections) |
void |
setInterceptor(BrokerInterceptor interceptor) |
void |
setPulsarChannelInitializerFactory(PulsarChannelInitializer.Factory factory) |
void |
setupBrokerPublishRateLimiterMonitor()
Schedules and monitors publish-throttling for broker that has publish-throttling configured.
|
void |
setupTopicPublishRateLimiterMonitor()
Schedules and monitors publish-throttling for all owned topics that has publish-throttling configured.
|
void |
start() |
protected void |
startBacklogQuotaChecker() |
protected void |
startCheckReplicationPolicies() |
protected void |
startCompactionMonitor() |
protected void |
startConsumedLedgersMonitor() |
protected void |
startDeduplicationSnapshotMonitor() |
protected void |
startInactivityMonitor() |
protected void |
startMessageExpiryMonitor() |
void |
startProtocolHandlers(Map<String,Map<InetSocketAddress,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>>> protocolHandlers) |
protected void |
startStatsUpdater(int statsUpdateInitialDelayInSecs,
int statsUpdateFrequencyInSecs) |
void |
unblockDispatchersOnUnAckMessages(List<PersistentDispatcherMultipleConsumers> dispatcherList)
Unblocks the dispatchers and removes it from the
blockedDispatchers list. |
void |
unloadNamespaceBundlesGracefully()
It unloads all owned namespacebundles gracefully.
|
CompletableFuture<Integer> |
unloadServiceUnit(NamespaceBundle serviceUnit,
boolean closeWithoutWaitingClientDisconnect,
long timeout,
TimeUnit unit) |
void |
updateRates() |
static boolean |
validateDynamicConfiguration(String key,
String value) |
protected final AtomicReference<Semaphore> lookupRequestSemaphore
protected final AtomicReference<Semaphore> topicLoadRequestSemaphore
protected volatile PublishRateLimiter brokerPublishRateLimiter
public static final String PRODUCER_NAME_GENERATOR_PATH
public static final String MANAGED_LEDGER_PATH_ZNODE
public final int maxUnackedMsgsPerDispatcher
public BrokerService(PulsarService pulsar, io.netty.channel.EventLoopGroup eventLoopGroup) throws Exception
Exceptionpublic void startProtocolHandlers(Map<String,Map<InetSocketAddress,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>>> protocolHandlers)
protected void startStatsUpdater(int statsUpdateInitialDelayInSecs,
int statsUpdateFrequencyInSecs)
protected void startDeduplicationSnapshotMonitor()
protected void startInactivityMonitor()
protected void startMessageExpiryMonitor()
protected void startCheckReplicationPolicies()
protected void startCompactionMonitor()
protected void startConsumedLedgersMonitor()
protected void startBacklogQuotaChecker()
public void setupTopicPublishRateLimiterMonitor()
public void setupBrokerPublishRateLimiterMonitor()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic CompletableFuture<Void> closeAndRemoveReplicationClient(String clusterName)
public CompletableFuture<Void> closeAsync()
public void unloadNamespaceBundlesGracefully()
public CompletableFuture<Optional<Topic>> getTopicIfExists(String topic)
public CompletableFuture<Topic> getOrCreateTopic(String topic)
public CompletableFuture<Optional<Topic>> getTopic(String topic, boolean createIfMissing)
public CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> deleteSchemaStorage(String topic)
public CompletableFuture<Void> deleteTopic(String topic, boolean forceDelete)
public CompletableFuture<Void> deleteTopic(String topic, boolean forceDelete, boolean deleteSchema)
public void deleteTopicAuthenticationWithRetry(String topic, CompletableFuture<Void> future, int count)
public org.apache.pulsar.client.api.PulsarClient getReplicationClient(String cluster, Optional<org.apache.pulsar.common.policies.data.ClusterData> clusterDataOp)
public PulsarAdmin getClusterPulsarAdmin(String cluster, Optional<org.apache.pulsar.common.policies.data.ClusterData> clusterDataOp)
protected CompletableFuture<Optional<Topic>> loadOrCreatePersistentTopic(String topic, boolean createIfMissing) throws RuntimeException
topic - persistent-topic nameRuntimeExceptionpublic CompletableFuture<ManagedLedgerConfig> getManagedLedgerConfig(org.apache.pulsar.common.naming.TopicName topicName)
public void refreshTopicToStatsMaps(NamespaceBundle oldBundle)
public org.apache.pulsar.common.policies.data.PersistentOfflineTopicStats getOfflineTopicStat(org.apache.pulsar.common.naming.TopicName topicName)
public void cacheOfflineTopicStats(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.PersistentOfflineTopicStats offlineTopicStats)
public void invalidateOfflineTopicStatCache(org.apache.pulsar.common.naming.TopicName topicName)
public Optional<Topic> getTopicReference(String topic)
public void updateRates()
public void getDimensionMetrics(Consumer<io.netty.buffer.ByteBuf> consumer)
public List<org.apache.pulsar.common.stats.Metrics> getTopicMetrics()
public Map<String,org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats> getBundleStats()
public Semaphore getLookupRequestSemaphore()
public void checkGC()
public void checkMessageExpiry()
public void checkReplicationPolicies()
public void checkCompaction()
public void checkMessageDeduplicationInfo()
public void checkInactiveSubscriptions()
public void checkTopicPublishThrottlingRate()
public void checkBrokerPublishThrottlingRate()
public void forEachTopic(Consumer<Topic> consumer)
public BacklogQuotaManager getBacklogQuotaManager()
public void monitorBacklogQuota()
public boolean isTopicNsOwnedByBroker(org.apache.pulsar.common.naming.TopicName topicName)
public CompletableFuture<Void> checkTopicNsOwnership(String topic)
public CompletableFuture<Integer> unloadServiceUnit(NamespaceBundle serviceUnit, boolean closeWithoutWaitingClientDisconnect, long timeout, TimeUnit unit)
public void cleanUnloadedTopicFromCache(NamespaceBundle serviceUnit)
public AuthorizationService getAuthorizationService()
public CompletableFuture<Void> removeTopicFromCache(String topic)
public void removeTopicFromCache(String topic, NamespaceBundle namespaceBundle)
public int getNumberOfNamespaceBundles()
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,CompletableFuture<Optional<Topic>>> getTopics()
public PulsarService pulsar()
public io.netty.channel.EventLoopGroup executor()
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.client.api.PulsarClient> getReplicationClients()
public boolean isAuthenticationEnabled()
public boolean isAuthorizationEnabled()
public int getKeepAliveIntervalSeconds()
public String generateUniqueProducerName()
public Map<String,org.apache.pulsar.common.policies.data.stats.TopicStatsImpl> getTopicStats()
public AuthenticationService getAuthenticationService()
public List<Topic> getAllTopicsFromNamespaceBundle(String namespace, String bundle)
public <T> void registerConfigurationListener(String configKey, Consumer<T> listener)
ServiceConfiguration change, so listener can take appropriate
action if any specific config-field value has been changed.
On notification, listener should first check if config value has been changed and after taking appropriate
action, listener should update config value with new value if it has been changed (so, next time listener can
compare values on configMap change).T - configKey - : configuration field namelistener - : listener which takes appropriate action on config-value changepublic DelayedDeliveryTrackerFactory getDelayedDeliveryTrackerFactory()
public static boolean isDynamicConfiguration(String key)
public static boolean validateDynamicConfiguration(String key, String value)
public CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> fetchPartitionedTopicMetadataCheckAllowAutoCreationAsync(org.apache.pulsar.common.naming.TopicName topicName)
public CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> fetchPartitionedTopicMetadataAsync(org.apache.pulsar.common.naming.TopicName topicName)
public org.apache.bookkeeper.common.util.OrderedExecutor getTopicOrderedExecutor()
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,Topic>>> getMultiLayerTopicMap()
public void addUnAckedMessages(PersistentDispatcherMultipleConsumers dispatcher, int numberOfMessages)
maxUnackedMsgsPerDispatcher.dispatcher - numberOfMessages - public void checkUnAckMessageDispatching()
maxUnackedMessages then it blocks all the dispatchers which has unack-messages higher than
maxUnackedMsgsPerDispatcher. It unblocks all dispatchers once broker-unack message counts decreased to
(maxUnackedMessages/2)public boolean isBrokerDispatchingBlocked()
public void unblockDispatchersOnUnAckMessages(List<PersistentDispatcherMultipleConsumers> dispatcherList)
blockedDispatchers list.dispatcherList - public static Optional<Topic> extractTopic(CompletableFuture<Optional<Topic>> topicFuture)
public boolean isAllowAutoTopicCreation(String topic)
public boolean isAllowAutoTopicCreation(org.apache.pulsar.common.naming.TopicName topicName)
public boolean isDefaultTopicTypePartitioned(org.apache.pulsar.common.naming.TopicName topicName)
public int getDefaultNumPartitions(org.apache.pulsar.common.naming.TopicName topicName)
public boolean isAllowAutoSubscriptionCreation(String topic)
public boolean isAllowAutoSubscriptionCreation(org.apache.pulsar.common.naming.TopicName topicName)
public boolean isSystemTopic(String topic)
public boolean isSystemTopic(org.apache.pulsar.common.naming.TopicName topicName)
public Optional<org.apache.pulsar.common.policies.data.TopicPolicies> getTopicPolicies(org.apache.pulsar.common.naming.TopicName topicName)
TopicPolicies for the parameterized topic.topicName - public CompletableFuture<Void> deleteTopicPolicies(org.apache.pulsar.common.naming.TopicName topicName)
public void setInterceptor(BrokerInterceptor interceptor)
public Set<org.apache.pulsar.common.intercept.BrokerEntryMetadataInterceptor> getBrokerEntryMetadataInterceptors()
public boolean isBrokerEntryMetadataEnabled()
public void pausedConnections(int numberOfConnections)
public void resumedConnections(int numberOfConnections)
public long getPausedConnections()
public void setPulsarChannelInitializerFactory(PulsarChannelInitializer.Factory factory)
Copyright © 2017–2022 Apache Software Foundation. All rights reserved.