Skip to content

Commit

Permalink
[PulsarAdmin] Brokers to async (apache#6541)
Browse files Browse the repository at this point in the history
* brokers to async

* retrigger

* remove slash
  • Loading branch information
yjshen authored Mar 18, 2020
1 parent 33eea88 commit b9651a9
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.apache.pulsar.client.admin.PulsarAdminException.NotAuthorizedException;
import org.apache.pulsar.client.admin.PulsarAdminException.NotFoundException;
Expand Down Expand Up @@ -53,9 +54,25 @@ public interface Brokers {
*/
List<String> getActiveBrokers(String cluster) throws PulsarAdminException;

/**
* Get the list of active brokers in the cluster asynchronously.
* <p>
* Get the list of active brokers (web service addresses) in the cluster.
* <p>
* Response Example:
*
* <pre>
* <code>["prod1-broker1.messaging.use.example.com:8080", "prod1-broker2.messaging.use.example.com:8080", "prod1-broker3.messaging.use.example.com:8080"]</code>
* </pre>
*
* @param cluster
* Cluster name
* @return a list of (host:port)
*/
CompletableFuture<List<String>> getActiveBrokersAsync(String cluster);

/**
* Get the map of owned namespaces and their status from a single broker in the cluster
* Get the map of owned namespaces and their status from a single broker in the cluster.
* <p>
* The map is returned in a JSON object format below
* <p>
Expand All @@ -71,36 +88,85 @@ public interface Brokers {
* @throws PulsarAdminException
*/
Map<String, NamespaceOwnershipStatus> getOwnedNamespaces(String cluster, String brokerUrl) throws PulsarAdminException;

/**

/**
* Get the map of owned namespaces and their status from a single broker in the cluster asynchronously.
* <p>
* The map is returned in a JSON object format below
* <p>
* Response Example:
*
* <pre>
* <code>{"ns-1":{"broker_assignment":"shared","is_active":"true","is_controlled":"false"}, "ns-2":{"broker_assignment":"primary","is_active":"true","is_controlled":"true"}}</code>
* </pre>
*
* @param cluster
* @param brokerUrl
* @return
*/
CompletableFuture<Map<String, NamespaceOwnershipStatus>> getOwnedNamespacesAsync(String cluster, String brokerUrl);

/**
* Update a dynamic configuration value into ZooKeeper.
* <p>
* It updates dynamic configuration value in to Zk that triggers watch on
* brokers and all brokers can update {@link ServiceConfiguration} value
* locally
*
* @param key
* @param value
* @param configName
* @param configValue
* @throws PulsarAdminException
*/
void updateDynamicConfiguration(String configName, String configValue) throws PulsarAdminException;

/**
* Update a dynamic configuration value into ZooKeeper asynchronously.
* <p>
* It updates dynamic configuration value in to Zk that triggers watch on
* brokers and all brokers can update {@link ServiceConfiguration} value
* locally
*
* @param configName
* @param configValue
*/
CompletableFuture<Void> updateDynamicConfigurationAsync(String configName, String configValue);

/**
* It deletes dynamic configuration value in to Zk. It will not impact current value in broker but next time when
* It deletes dynamic configuration value into ZooKeeper.
* <p>
* It will not impact current value in broker but next time when
* broker restarts, it applies value from configuration file only.
*
* @param key
* @param value
* @param configName
* @throws PulsarAdminException
*/
void deleteDynamicConfiguration(String configName) throws PulsarAdminException;

/**
* It deletes dynamic configuration value into ZooKeeper asynchronously.
* <p>
* It will not impact current value in broker but next time when
* broker restarts, it applies value from configuration file only.
*
* @param configName
*/
CompletableFuture<Void> deleteDynamicConfigurationAsync(String configName);

/**
* Get list of updatable configuration name
* Get list of updatable configuration name.
*
* @return
* @throws PulsarAdminException
*/
List<String> getDynamicConfigurationNames() throws PulsarAdminException;

/**
* Get list of updatable configuration name asynchronously.
*
* @return
*/
CompletableFuture<List<String>> getDynamicConfigurationNamesAsync();

/**
* Get values of runtime configuration
*
Expand All @@ -109,6 +175,13 @@ public interface Brokers {
*/
Map<String, String> getRuntimeConfigurations() throws PulsarAdminException;

/**
* Get values of runtime configuration asynchronously.
*
* @return
*/
CompletableFuture<Map<String, String>> getRuntimeConfigurationsAsync();

/**
* Get values of all overridden dynamic-configs
*
Expand All @@ -117,17 +190,36 @@ public interface Brokers {
*/
Map<String, String> getAllDynamicConfigurations() throws PulsarAdminException;

/**
* Get values of all overridden dynamic-configs asynchronously.
*
* @return
*/
CompletableFuture<Map<String, String>> getAllDynamicConfigurationsAsync();

/**
* Get the internal configuration data.
*
* @return internal configuration data.
*/
InternalConfigurationData getInternalConfigurationData() throws PulsarAdminException;

/**
* Get the internal configuration data asynchronously.
*
* @return internal configuration data.
*/
CompletableFuture<InternalConfigurationData> getInternalConfigurationDataAsync();

/**
* Run a healthcheck on the broker.
*
* @throws an exception if the healthcheck fails.
* @throws PulsarAdminException if the healthcheck fails.
*/
void healthcheck() throws PulsarAdminException;

/**
* Run a healthcheck on the broker asynchronously.
*/
CompletableFuture<Void> healthcheckAsync();
}
Loading

0 comments on commit b9651a9

Please sign in to comment.