Package org.apache.pulsar.broker
Class PulsarService
java.lang.Object
org.apache.pulsar.broker.PulsarService
- All Implemented Interfaces:
AutoCloseable,ShutdownService
Main class for Pulsar broker service.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CompactionServiceFactoryprotected final io.netty.channel.EventLoopGroup -
Constructor Summary
ConstructorsConstructorDescriptionPulsarService(ServiceConfiguration config) PulsarService(ServiceConfiguration config, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator) PulsarService(ServiceConfiguration config, WorkerConfig workerConfig, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator) PulsarService(ServiceConfiguration config, WorkerConfig workerConfig, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator, Consumer<io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder> openTelemetrySdkBuilderCustomizer) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidaddPrometheusRawMetricsProvider(PrometheusRawMetricsProvider metricsProvider) static Stringprotected StringbrokerUrl(ServiceConfiguration config) Gets the broker service URL (non-TLS) associated with the internal listener.static StringbrokerUrlTls(String host, int port) brokerUrlTls(ServiceConfiguration config) Gets the broker service URL (TLS) associated with the internal listener.voidclose()Close the current pulsar service.protected CompletableFuture<Void>voidClose the session to the metadata service.createClientImpl(ClientConfigurationData clientConf) org.apache.pulsar.metadata.api.MetadataStorecreateConfigurationMetadataStore(PulsarMetadataEventSynchronizer synchronizer, io.opentelemetry.api.OpenTelemetry openTelemetry) org.apache.pulsar.metadata.api.extended.MetadataStoreExtendedcreateLocalMetadataStore(PulsarMetadataEventSynchronizer synchronizer, io.opentelemetry.api.OpenTelemetry openTelemetry) createManagedLedgerOffloader(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) Return the broker id.org.apache.pulsar.client.api.PulsarClientGet the current service configuration.org.apache.pulsar.common.conf.InternalConfigurationDataGet a reference of the currentLeaderElectionServiceinstance associated with the currentPulsarServiceinstance.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.Get a reference of the current namespace service instance.protected org.apache.bookkeeper.common.util.OrderedSchedulergetOffloaderScheduler(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) Deprecated.Get the current function worker service configuration.voidstatic WorkerConfiginitializeWorkerConfigFromBrokerConfig(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 BrokerInterceptorprotected BrokerServicenewBrokerService(PulsarService pulsar) protected ManagedLedgerStorageprotected org.apache.bookkeeper.common.util.OrderedExecutorprotected PulsarResourcesnewTopicCompactionService(String topic) voidrunWhenReadyForIncomingRequests(Runnable runnable) voidsetTransactionBufferProvider(TransactionBufferProvider transactionBufferProvider) 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.voidstatic StringwebAddress(String host, int port) webAddress(ServiceConfiguration config) static StringwebAddressTls(String host, int port) webAddressTls(ServiceConfiguration config)
-
Field Details
-
compactionServiceFactory
-
ioEventLoopGroup
protected final io.netty.channel.EventLoopGroup ioEventLoopGroup
-
-
Constructor Details
-
PulsarService
-
PulsarService
public PulsarService(ServiceConfiguration config, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator) -
PulsarService
public PulsarService(ServiceConfiguration config, WorkerConfig workerConfig, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator) -
PulsarService
public PulsarService(ServiceConfiguration config, WorkerConfig workerConfig, Optional<WorkerService> functionWorkerService, Consumer<Integer> processTerminator, Consumer<io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder> openTelemetrySdkBuilderCustomizer)
-
-
Method Details
-
createConfigurationMetadataStore
public org.apache.pulsar.metadata.api.MetadataStore createConfigurationMetadataStore(PulsarMetadataEventSynchronizer synchronizer, io.opentelemetry.api.OpenTelemetry openTelemetry) 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
- Specified by:
closein interfaceAutoCloseable- Throws:
PulsarServerException
-
closeAsync
Close the current pulsar service. All resources are released. -
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
Start the pulsar service instance.- Throws:
PulsarServerException
-
runWhenReadyForIncomingRequests
-
waitUntilReadyForIncomingRequests
-
newBrokerInterceptor
- Throws:
IOException
-
newOrderedExecutor
protected org.apache.bookkeeper.common.util.OrderedExecutor newOrderedExecutor() -
newManagedLedgerStorage
- Throws:
Exception
-
newPulsarResources
-
createLocalMetadataStore
public org.apache.pulsar.metadata.api.extended.MetadataStoreExtended createLocalMetadataStore(PulsarMetadataEventSynchronizer synchronizer, io.opentelemetry.api.OpenTelemetry openTelemetry) throws org.apache.pulsar.metadata.api.MetadataStoreException, PulsarServerException - Throws:
org.apache.pulsar.metadata.api.MetadataStoreExceptionPulsarServerException
-
closeLocalMetadataStore
- Throws:
Exception
-
startLeaderElectionService
protected void startLeaderElectionService() -
acquireSLANamespace
protected void acquireSLANamespace() -
waitUntilClosed
Block until the service is finally closed.- Throws:
InterruptedException
-
startNamespaceService
- Throws:
PulsarServerException
-
getNamespaceServiceProvider
- Throws:
PulsarServerException
-
startLoadManagementService
- Throws:
PulsarServerException
-
loadNamespaceTopics
Load all the topics contained in a namespace.- Parameters:
bundle-NamespaceBundleto identify the service unit
-
getStatusFilePath
-
getInternalConfigurationData
public org.apache.pulsar.common.conf.InternalConfigurationData getInternalConfigurationData() -
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
- Throws:
UnsupportedOperationException
-
getBookKeeperClient
-
getDefaultManagedLedgerFactory
-
getManagedLedgerOffloader
public 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 LedgerOffloader createManagedLedgerOffloader(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) throws PulsarServerException - Throws:
PulsarServerException
-
newBookKeeperClientFactory
-
getBookKeeperClientFactory
-
getCompactorExecutor
-
getNullableCompactor
-
newStrategicCompactor
- Throws:
PulsarServerException
-
getStrategicCompactor
- Throws:
PulsarServerException
-
getOffloaderScheduler
protected org.apache.bookkeeper.common.util.OrderedScheduler getOffloaderScheduler(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl offloadPolicies) -
createClientImpl
public PulsarClientImpl createClientImpl(ClientConfigurationData clientConf) throws org.apache.pulsar.client.api.PulsarClientException - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
getClient
- Throws:
PulsarServerException
-
getAdminClient
- Throws:
PulsarServerException
-
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. -
getBrokerId
Return the broker id. The broker id is used in the load manager to uniquely identify the broker at runtime. It should not be used for making connections to the broker. The broker id is available afterstart()has been called.- Returns:
- broker id
-
addPrometheusRawMetricsProvider
-
getPackagesManagement
- Throws:
UnsupportedOperationException
-
getListenPortHTTP
-
getListenPortHTTPS
-
getBrokerListenPort
-
getBrokerListenPortTls
-
getMonotonicSnapshotClock
-
initializeWorkerConfigFromBrokerConfig
public static WorkerConfig initializeWorkerConfigFromBrokerConfig(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 interfaceShutdownService
-
newBrokerService
- Throws:
Exception
-
setTransactionBufferProvider
-
newTopicCompactionService
-
initConfigMetadataSynchronizerIfNeeded
public void initConfigMetadataSynchronizerIfNeeded()
-