Package org.apache.pulsar.broker
Class PulsarService
java.lang.Object
org.apache.pulsar.broker.PulsarService
- All Implemented Interfaces:
AutoCloseable,org.apache.pulsar.broker.ShutdownService
public class PulsarService
extends Object
implements AutoCloseable, org.apache.pulsar.broker.ShutdownService
Main class for Pulsar broker service.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.netty.channel.EventLoopGroup -
Constructor Summary
ConstructorsConstructorDescriptionPulsarService(org.apache.pulsar.broker.ServiceConfiguration config) PulsarService(org.apache.pulsar.broker.ServiceConfiguration config, Optional<org.apache.pulsar.functions.worker.WorkerService> functionWorkerService, Consumer<Integer> processTerminator) PulsarService(org.apache.pulsar.broker.ServiceConfiguration config, org.apache.pulsar.functions.worker.WorkerConfig workerConfig, Optional<org.apache.pulsar.functions.worker.WorkerService> functionWorkerService, Consumer<Integer> processTerminator) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidaddPrometheusRawMetricsProvider(org.apache.pulsar.broker.stats.prometheus.PrometheusRawMetricsProvider metricsProvider) static Stringprotected StringbrokerUrl(org.apache.pulsar.broker.ServiceConfiguration config) Gets the broker service URL (non-TLS) associated with the internal listener.static StringbrokerUrlTls(String host, int port) brokerUrlTls(org.apache.pulsar.broker.ServiceConfiguration config) Gets the broker service URL (TLS) associated with the internal listener.voidclose()Close the current pulsar service.protected voidvoidClose the session to the metadata service.org.apache.pulsar.client.impl.PulsarClientImplcreateClientImpl(org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf) org.apache.pulsar.metadata.api.MetadataStoreorg.apache.pulsar.metadata.api.extended.MetadataStoreExtendedcreateLocalMetadataStore(PulsarMetadataEventSynchronizer synchronizer) org.apache.bookkeeper.mledger.LedgerOffloadercreateManagedLedgerOffloader(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) org.apache.pulsar.client.admin.PulsarAdminorg.apache.bookkeeper.client.BookKeeperGet a reference of the currentBrokerServiceinstance associated with the currentPulsarServiceinstance.org.apache.pulsar.client.api.PulsarClientprotected ScheduledExecutorServiceorg.apache.pulsar.broker.ServiceConfigurationGet the current service configuration.org.apache.pulsar.metadata.api.coordination.CoordinationServiceorg.apache.pulsar.common.conf.InternalConfigurationDataGet a reference of the currentLeaderElectionServiceinstance associated with the currentPulsarServiceinstance.org.apache.pulsar.metadata.api.extended.MetadataStoreExtendedorg.apache.bookkeeper.mledger.ManagedLedgerFactoryorg.apache.bookkeeper.mledger.LedgerOffloadergetManagedLedgerOffloader(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) First, getLedgerOffloaderfrom local map cache, create newLedgerOffloaderif not in cache or theOffloadPolicieschanged, return theLedgerOffloaderdirectly if exist in cache and theOffloadPoliciesnot changed.Get a reference of the current namespace service instance.protected org.apache.bookkeeper.common.util.OrderedSchedulergetOffloaderScheduler(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) org.apache.bookkeeper.common.util.OrderedExecutororg.apache.pulsar.packages.management.core.PackagesManagementDeprecated.getState()Get the current pulsar state.org.apache.pulsar.client.api.transaction.TransactionBufferClientorg.apache.pulsar.client.util.ExecutorProviderOptional<org.apache.pulsar.functions.worker.WorkerConfig>Get the current function worker service configuration.org.apache.pulsar.functions.worker.WorkerServiceOptional<org.apache.pulsar.functions.worker.WorkerService>static org.apache.pulsar.functions.worker.WorkerConfiginitializeWorkerConfigFromBrokerConfig(org.apache.pulsar.broker.ServiceConfiguration brokerConfig, String workerConfigFile) booleancheck the current pulsar service is running, including Started and Init state.voidloadNamespaceTopics(NamespaceBundle bundle) Load all the topics contained in a namespace.protected BrokerServicenewBrokerService(PulsarService pulsar) voidShutdown the broker immediately, without waiting for all resources to be released.voidstart()Start the pulsar service instance.protected voidprotected voidprotected voidvoidBlock until the service is finally closed.static StringwebAddress(String host, int port) webAddress(org.apache.pulsar.broker.ServiceConfiguration config) static StringwebAddressTls(String host, int port) webAddressTls(org.apache.pulsar.broker.ServiceConfiguration config)
-
Field Details
-
ioEventLoopGroup
protected final io.netty.channel.EventLoopGroup ioEventLoopGroup
-
-
Constructor Details
-
PulsarService
public PulsarService(org.apache.pulsar.broker.ServiceConfiguration config) -
PulsarService
-
PulsarService
-
-
Method Details
-
createConfigurationMetadataStore
public org.apache.pulsar.metadata.api.MetadataStore createConfigurationMetadataStore(PulsarMetadataEventSynchronizer synchronizer) throws org.apache.pulsar.metadata.api.MetadataStoreException - Throws:
org.apache.pulsar.metadata.api.MetadataStoreException
-
closeMetadataServiceSession
Close the session to the metadata service. This will immediately release all the resource locks held by this broker on the coordination service.- Throws:
Exception- if the close operation fails
-
close
public void close() throws org.apache.pulsar.broker.PulsarServerException- Specified by:
closein interfaceAutoCloseable- Throws:
org.apache.pulsar.broker.PulsarServerException
-
closeAsync
Close the current pulsar service. All resources are released. -
getConfiguration
public org.apache.pulsar.broker.ServiceConfiguration getConfiguration()Get the current service configuration.- Returns:
- the current service configuration
-
getWorkerConfig
Get the current function worker service configuration.- Returns:
- the current function worker service configuration.
-
getProtocolDataToAdvertise
-
start
public void start() throws org.apache.pulsar.broker.PulsarServerExceptionStart the pulsar service instance.- Throws:
org.apache.pulsar.broker.PulsarServerException
-
createLocalMetadataStore
public org.apache.pulsar.metadata.api.extended.MetadataStoreExtended createLocalMetadataStore(PulsarMetadataEventSynchronizer synchronizer) throws org.apache.pulsar.metadata.api.MetadataStoreException, org.apache.pulsar.broker.PulsarServerException - Throws:
org.apache.pulsar.metadata.api.MetadataStoreExceptionorg.apache.pulsar.broker.PulsarServerException
-
closeLocalMetadataStore
- Throws:
Exception
-
startLeaderElectionService
protected void startLeaderElectionService() -
acquireSLANamespace
protected void acquireSLANamespace() -
waitUntilClosed
Block until the service is finally closed.- Throws:
InterruptedException
-
startNamespaceService
protected void startNamespaceService() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
getNamespaceServiceProvider
public Supplier<NamespaceService> getNamespaceServiceProvider() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
startLoadManagementService
protected void startLoadManagementService() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
loadNamespaceTopics
Load all the topics contained in a namespace.- Parameters:
bundle-NamespaceBundleto identify the service unit- Throws:
Exception
-
getStatusFilePath
-
getInternalConfigurationData
public org.apache.pulsar.common.conf.InternalConfigurationData getInternalConfigurationData() -
getState
Get the current pulsar state. -
isRunning
public boolean isRunning()check the current pulsar service is running, including Started and Init state. -
getLeaderElectionService
Get a reference of the currentLeaderElectionServiceinstance associated with the currentPulsarServiceinstance.- Returns:
- a reference of the current
LeaderElectionServiceinstance.
-
getNamespaceService
Get a reference of the current namespace service instance.- Returns:
- a reference of the current namespace service instance.
-
getWorkerServiceOpt
-
getWorkerService
public org.apache.pulsar.functions.worker.WorkerService getWorkerService() throws UnsupportedOperationException- Throws:
UnsupportedOperationException
-
getBrokerService
Get a reference of the currentBrokerServiceinstance associated with the currentPulsarServiceinstance.- Returns:
- a reference of the current
BrokerServiceinstance.
-
getBookKeeperClient
public org.apache.bookkeeper.client.BookKeeper getBookKeeperClient() -
getManagedLedgerFactory
public org.apache.bookkeeper.mledger.ManagedLedgerFactory getManagedLedgerFactory() -
getManagedLedgerClientFactory
-
getManagedLedgerOffloader
public org.apache.bookkeeper.mledger.LedgerOffloader getManagedLedgerOffloader(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) First, getLedgerOffloaderfrom local map cache, create newLedgerOffloaderif not in cache or theOffloadPolicieschanged, return theLedgerOffloaderdirectly if exist in cache and theOffloadPoliciesnot changed.- Parameters:
namespaceName- NamespaceNameoffloadPolicies- the OffloadPolicies- Returns:
- LedgerOffloader
-
createManagedLedgerOffloader
public org.apache.bookkeeper.mledger.LedgerOffloader createManagedLedgerOffloader(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) throws org.apache.pulsar.broker.PulsarServerException - Throws:
org.apache.pulsar.broker.PulsarServerException
-
getExecutor
-
getCacheExecutor
-
getTransactionExecutorProvider
public org.apache.pulsar.client.util.ExecutorProvider getTransactionExecutorProvider() -
getLoadManagerExecutor
-
getOrderedExecutor
public org.apache.bookkeeper.common.util.OrderedExecutor getOrderedExecutor() -
newBookKeeperClientFactory
-
getBookKeeperClientFactory
-
getCompactorExecutor
-
newCompactor
- Throws:
org.apache.pulsar.broker.PulsarServerException
-
getCompactor
- Throws:
org.apache.pulsar.broker.PulsarServerException
-
getNullableCompactor
-
getOffloaderScheduler
protected org.apache.bookkeeper.common.util.OrderedScheduler getOffloaderScheduler(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) -
createClientImpl
public org.apache.pulsar.client.impl.PulsarClientImpl createClientImpl(org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf) throws org.apache.pulsar.client.api.PulsarClientException - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
getClient
public org.apache.pulsar.client.api.PulsarClient getClient() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
getAdminClient
public org.apache.pulsar.client.admin.PulsarAdmin getAdminClient() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
getMetricsGenerator
-
getTransactionMetadataStoreService
-
getTransactionBufferProvider
-
getTransactionBufferClient
public org.apache.pulsar.client.api.transaction.TransactionBufferClient getTransactionBufferClient() -
brokerUrl
Gets the broker service URL (non-TLS) associated with the internal listener. -
brokerUrl
-
brokerUrlTls
Gets the broker service URL (TLS) associated with the internal listener. -
brokerUrlTls
-
webAddress
-
webAddress
-
webAddressTls
-
webAddressTls
-
getSafeWebServiceAddress
-
getSafeBrokerServiceUrl
Deprecated. -
getTopicPoliciesService
-
getResourceUsageTransportManager
-
addPrometheusRawMetricsProvider
public void addPrometheusRawMetricsProvider(org.apache.pulsar.broker.stats.prometheus.PrometheusRawMetricsProvider metricsProvider) -
getPackagesManagement
public org.apache.pulsar.packages.management.core.PackagesManagement getPackagesManagement() throws UnsupportedOperationException- Throws:
UnsupportedOperationException
-
getListenPortHTTP
-
getListenPortHTTPS
-
getBrokerListenPort
-
getBrokerListenPortTls
-
getLocalMetadataStore
public org.apache.pulsar.metadata.api.extended.MetadataStoreExtended getLocalMetadataStore() -
getCoordinationService
public org.apache.pulsar.metadata.api.coordination.CoordinationService getCoordinationService() -
initializeWorkerConfigFromBrokerConfig
public static org.apache.pulsar.functions.worker.WorkerConfig initializeWorkerConfigFromBrokerConfig(org.apache.pulsar.broker.ServiceConfiguration brokerConfig, String workerConfigFile) throws IOException - Throws:
IOException
-
shutdownNow
public void shutdownNow()Shutdown the broker immediately, without waiting for all resources to be released. This possibly is causing the JVM process to exit, depending on how th PulsarService was constructed.- Specified by:
shutdownNowin interfaceorg.apache.pulsar.broker.ShutdownService
-
newBrokerService
- Throws:
Exception
-