Managing Brokers

Brokers - 图1tip

This page only shows some frequently used operations. For the latest and complete information, see the reference docs below.

CategoryMethodIf you want to manage brokers…
Pulsar CLIpulsar-admin, which lists all commands, flags, descriptions, and more.See the broker command
Pulsar admin APIsREST API, which lists all parameters, responses, samples, and more.See the /admin/v2/brokers endpoint
Pulsar admin APIsJava admin API, which lists all classes, methods, descriptions, and more.See the brokers method of the PulsarAdmin object

List active broker

Fetch all available active brokers that are serving traffic with cluster name.

  • pulsar-admin
  • REST API
  • Java
  1. pulsar-admin brokers list use

Example output:

  1. localhost:8080

GET /admin/v2/brokers/:cluster/getActiveBrokers

  1. admin.brokers().getActiveBrokers(clusterName)

List namespace owned by broker

You can list all namespaces which are owned and served by a given broker.

  • pulsar-admin
  • REST API
  • Java
  1. pulsar-admin brokers namespaces use \
  2. --url localhost:8080

Example output:

  1. public/default/0x00000000_0x40000000 [broker_assignment=shared is_controlled=false is_active=true]
  2. public/default/0xc0000000_0xffffffff [broker_assignment=shared is_controlled=false is_active=true]
  3. public/functions/0x40000000_0x80000000 [broker_assignment=shared is_controlled=false is_active=true]
  4. public/functions/0x00000000_0x40000000 [broker_assignment=shared is_controlled=false is_active=true]
  5. pulsar/standalone/localhost:8080/0x00000000_0xffffffff [broker_assignment=shared is_controlled=false is_active=true]
  6. pulsar/localhost:8080/0x00000000_0xffffffff [broker_assignment=shared is_controlled=false is_active=true]
  7. public/functions/0x80000000_0xc0000000 [broker_assignment=shared is_controlled=false is_active=true]
  8. public/default/0x80000000_0xc0000000 [broker_assignment=shared is_controlled=false is_active=true]

GET /admin/v2/brokers/:cluster/:broker/ownedNamespaces/getOwnedNamespaes

  1. admin.brokers().getOwnedNamespaces(cluster,brokerUrl);

Update broker conf

You can update broker configurations using one of the following ways:

  • Supply configurations when starting up brokers.

  • Update configurations dynamically when running brokers.

    Since all broker configurations in Pulsar are stored in ZooKeeper, configuration values can also be dynamically updated when brokers are running. When you update broker configurations dynamically, ZooKeeper will notify the broker of the change and then the broker will override any existing configuration values.

List updatable broker conf

Fetch a list of all potentially updatable configuration parameters.

  • pulsar-admin
  • REST API
  • Java
  1. pulsar-admin brokers list-dynamic-config

Example output:

  1. forceDeleteNamespaceAllowed
  2. loadBalancerMemoryResourceWeight
  3. allowAutoTopicCreation
  4. brokerDeleteInactivePartitionedTopicMetadataEnabled
  5. managedLedgerInactiveLedgerRolloverTimeSeconds
  6. loadBalancerNamespaceBundleMaxMsgRate
  7. resourceUsageTransportPublishIntervalInSecs
  8. # omit...

GET /admin/v2/brokers/configuration/getDynamicConfigurationName

  1. admin.brokers().getDynamicConfigurationNames();

Update broker conf dynamically

  • pulsar-admin
  • REST API
  • Java

The update-dynamic-config subcommand will update existing configuration. It takes two arguments: the name of the parameter and the new value using the config and value flag respectively. Here’s an example of the brokerShutdownTimeoutMs parameter:

  1. pulsar-admin brokers update-dynamic-config --config brokerShutdownTimeoutMs --value 100

POST /admin/v2/brokers/configuration/:configName/:configValue/updateDynamicConfiguration

  1. admin.brokers().updateDynamicConfiguration(configName, configValue);

List updated broker conf

Fetch a list of all parameters that have been dynamically updated.

  • pulsar-admin
  • REST API
  • Java
  1. pulsar-admin brokers get-all-dynamic-config

Example output:

  1. brokerShutdownTimeoutMs 100

GET /admin/v2/brokers/configuration/values/getAllDynamicConfigurations

  1. admin.brokers().getAllDynamicConfigurations();

Get info of leader broker

Fetch the information of the leader broker, for example, the service URL.

  • pulsar-admin
  • REST API
  • Java
  1. pulsar-admin brokers leader-broker

Example output:

  1. {
  2. "serviceUrl" : "http://localhost:8080"
  3. }

GET /admin/v2/brokers/leaderBroker/getLeaderBroker

  1. admin.brokers().getLeaderBroker()

For the detail of the code above, see here