Package org.apache.pulsar.broker.admin
Class AdminResource
- java.lang.Object
-
- org.apache.pulsar.broker.web.PulsarWebResource
-
- org.apache.pulsar.broker.admin.AdminResource
-
- Direct Known Subclasses:
Bookies,BrokerStatsBase,Functions,FunctionsBase,NamespacesBase,PackagesBase,PersistentTopicsBase,ResourceGroupsBase,SchemasResourceBase,SinksBase,SourcesBase,TransactionsBase,Worker,WorkerStats
public abstract class AdminResource extends PulsarWebResource
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.pulsar.common.naming.NamespaceNamenamespaceNameprotected org.apache.pulsar.common.naming.TopicNametopicName-
Fields inherited from class org.apache.pulsar.broker.web.PulsarWebResource
httpRequest, NOT_IMPLEMENTED, servletContext, uri
-
-
Constructor Summary
Constructors Constructor Description AdminResource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected org.apache.bookkeeper.client.BookKeeperbookKeeper()protected voidcheckArgument(boolean b, java.lang.String errorMessage)protected booleancheckBacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota quota, org.apache.pulsar.common.policies.data.RetentionPolicies retention)protected voidcheckNotNull(java.lang.Object o, java.lang.String errorMessage)static <T> TcheckNotNull(T reference)protected java.util.concurrent.CompletableFuture<java.lang.Boolean>checkTopicExistsAsync(org.apache.pulsar.common.naming.TopicName topicName)Check the exists topics contains the given topic.protected voidcheckTopicLevelPolicyEnable()protected java.util.Set<java.lang.String>clusters()protected org.apache.pulsar.common.policies.data.impl.DispatchRateImpldispatchRate()protected java.lang.Stringdomain()Get the domain of the topic (whether it's persistent or non-persistent).protected static org.apache.pulsar.common.partition.PartitionedTopicMetadatafetchPartitionedTopicMetadata(PulsarService pulsar, org.apache.pulsar.common.naming.TopicName topicName)protected static org.apache.pulsar.common.partition.PartitionedTopicMetadatafetchPartitionedTopicMetadataCheckAllowAutoCreation(PulsarService pulsar, org.apache.pulsar.common.naming.TopicName topicName)protected org.apache.pulsar.common.policies.data.PoliciesgetNamespacePolicies(java.lang.String tenant, java.lang.String cluster, java.lang.String namespace)protected org.apache.pulsar.common.policies.data.PoliciesgetNamespacePolicies(org.apache.pulsar.common.naming.NamespaceName namespaceName)protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.Policies>getNamespacePoliciesAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName)protected java.util.Set<java.lang.String>getNamespaceReplicatedClusters(org.apache.pulsar.common.naming.NamespaceName namespaceName)protected java.util.List<java.lang.String>getPartitionedTopicList(org.apache.pulsar.common.naming.TopicDomain topicDomain)protected org.apache.pulsar.common.partition.PartitionedTopicMetadatagetPartitionedTopicMetadata(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative, boolean checkAllowAutoCreation)protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata>getPartitionedTopicMetadataAsync(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative, boolean checkAllowAutoCreation)protected static java.lang.StringgetPartitionedTopicNotFoundErrorMessage(java.lang.String topic)protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy>getSchemaCompatibilityStrategyAsync()protected java.util.List<java.lang.String>getTopicPartitionList(org.apache.pulsar.common.naming.TopicDomain topicDomain)protected java.util.concurrent.CompletableFuture<java.util.Optional<org.apache.pulsar.common.policies.data.TopicPolicies>>getTopicPoliciesAsyncWithRetry(org.apache.pulsar.common.naming.TopicName topicName)protected voidinternalCreatePartitionedTopic(javax.ws.rs.container.AsyncResponse asyncResponse, int numPartitions, boolean createLocalTopicOnly)protected booleanisLeaderBroker()protected booleanisManagedLedgerNotFoundException(java.lang.Exception e)protected booleanisNamespaceReplicated(org.apache.pulsar.common.naming.NamespaceName namespaceName)protected static booleanisRedirectException(java.lang.Throwable ex)Check current exception whether is redirect exception.static com.fasterxml.jackson.databind.ObjectMapperjsonMapper()protected voidmergeNamespaceWithDefaults(org.apache.pulsar.common.policies.data.Policies policies, java.lang.String namespace, java.lang.String namespacePath)protected org.apache.pulsar.common.policies.data.BacklogQuotanamespaceBacklogQuota(org.apache.pulsar.common.naming.NamespaceName namespace, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType)protected org.apache.pulsar.common.policies.data.impl.DispatchRateImplreplicatorDispatchRate()protected voidresumeAsyncResponseExceptionally(javax.ws.rs.container.AsyncResponse asyncResponse, java.lang.Throwable throwable)protected voidsetServletContext(javax.servlet.ServletContext servletContext)protected org.apache.pulsar.common.policies.data.SubscribeRatesubscribeRate()protected org.apache.pulsar.common.policies.data.impl.DispatchRateImplsubscriptionDispatchRate()protected java.util.concurrent.CompletableFuture<java.lang.Void>tryCreatePartitionsAsync(int numPartitions)protected voidvalidateAdminAccessForTenant(java.lang.String property)Checks that the http client role has admin access to the specified tenant.protected org.apache.pulsar.functions.worker.WorkerServicevalidateAndGetWorkerService()protected voidvalidateBundleOwnership(java.lang.String property, java.lang.String cluster, java.lang.String namespace, boolean authoritative, boolean readOnly, NamespaceBundle bundle)protected voidvalidateClusterExists(java.lang.String cluster)protected voidvalidateGlobalNamespaceOwnership()protected voidvalidateNamespaceName(java.lang.String property, java.lang.String namespace)protected voidvalidateNamespaceName(java.lang.String property, java.lang.String cluster, java.lang.String namespace)Deprecated.protected voidvalidatePartitionedTopicMetadata(java.lang.String tenant, java.lang.String namespace, java.lang.String encodedTopic)protected voidvalidatePartitionedTopicName(java.lang.String tenant, java.lang.String namespace, java.lang.String encodedTopic)protected voidvalidatePersistencePolicies(org.apache.pulsar.common.policies.data.PersistencePolicies persistence)protected voidvalidatePersistentTopicName(java.lang.String property, java.lang.String namespace, java.lang.String encodedTopic)protected voidvalidatePersistentTopicName(java.lang.String property, java.lang.String cluster, java.lang.String namespace, java.lang.String encodedTopic)Deprecated.voidvalidatePoliciesReadOnlyAccess()Checks whether the broker is allowed to do read-write operations based on the existence of a node in configuration metadata-store.voidvalidateSuperUserAccess()Checks whether the user has Pulsar Super-User access to the system.protected voidvalidateTopicName(java.lang.String property, java.lang.String namespace, java.lang.String encodedTopic)protected voidvalidateTopicName(java.lang.String property, java.lang.String cluster, java.lang.String namespace, java.lang.String encodedTopic)Deprecated.-
Methods inherited from class org.apache.pulsar.broker.web.PulsarWebResource
bookieResources, canUpdateCluster, checkAuthorizationAsync, checkLocalOrGetPeerReplicationCluster, checkLocalOrGetPeerReplicationCluster, clientAppId, clientAuthData, clusterResources, config, dynamicConfigurationResources, getClusterDataIfDifferentCluster, getLocalPolicies, getPulsarResources, handleCommonRestAsyncException, hasActiveNamespace, hasSuperUserAccess, isBundleOwnedByAnyBroker, isClientAuthenticated, isLeaderBroker, isRequestHttps, namespaceIsolationPolicies, namespaceResources, originalPrincipal, pulsar, resourceGroupResources, setPulsar, splitPath, tenantResources, topicResources, validateAdminAccessForTenant, validateAdminAccessForTenantAsync, validateBrokerName, validateBundleOwnership, validateClusterForTenant, validateClusterOwnership, validateGlobalNamespaceOwnership, validateGlobalNamespaceOwnershipAsync, validateNamespaceBundleOwnership, validateNamespaceBundleRange, validateNamespaceOperation, validateNamespaceOperationAsync, validateNamespacePolicyOperation, validateTenantOperation, validateTopicOperation, validateTopicOperation, validateTopicOperationAsync, validateTopicOperationAsync, validateTopicOwnership, validateTopicOwnershipAsync, validateTopicPolicyOperation
-
-
-
-
Method Detail
-
bookKeeper
protected org.apache.bookkeeper.client.BookKeeper bookKeeper()
-
domain
protected java.lang.String domain()
Get the domain of the topic (whether it's persistent or non-persistent).
-
validateSuperUserAccess
public void validateSuperUserAccess()
Description copied from class:PulsarWebResourceChecks whether the user has Pulsar Super-User access to the system.- Overrides:
validateSuperUserAccessin classPulsarWebResource
-
validateAdminAccessForTenant
protected void validateAdminAccessForTenant(java.lang.String property)
Description copied from class:PulsarWebResourceChecks that the http client role has admin access to the specified tenant.- Overrides:
validateAdminAccessForTenantin classPulsarWebResource- Parameters:
property- the tenant id
-
validateBundleOwnership
protected void validateBundleOwnership(java.lang.String property, java.lang.String cluster, java.lang.String namespace, boolean authoritative, boolean readOnly, NamespaceBundle bundle)- Overrides:
validateBundleOwnershipin classPulsarWebResource
-
isLeaderBroker
protected boolean isLeaderBroker()
- Overrides:
isLeaderBrokerin classPulsarWebResource
-
validatePoliciesReadOnlyAccess
public void validatePoliciesReadOnlyAccess()
Checks whether the broker is allowed to do read-write operations based on the existence of a node in configuration metadata-store.- Overrides:
validatePoliciesReadOnlyAccessin classPulsarWebResource- Throws:
javax.ws.rs.WebApplicationException- if broker has a read only access if broker is not connected to the configuration metadata-store
-
tryCreatePartitionsAsync
protected java.util.concurrent.CompletableFuture<java.lang.Void> tryCreatePartitionsAsync(int numPartitions)
-
validateNamespaceName
protected void validateNamespaceName(java.lang.String property, java.lang.String namespace)
-
validateGlobalNamespaceOwnership
protected void validateGlobalNamespaceOwnership()
-
validateNamespaceName
@Deprecated protected void validateNamespaceName(java.lang.String property, java.lang.String cluster, java.lang.String namespace)Deprecated.
-
validateTopicName
protected void validateTopicName(java.lang.String property, java.lang.String namespace, java.lang.String encodedTopic)
-
validatePersistentTopicName
protected void validatePersistentTopicName(java.lang.String property, java.lang.String namespace, java.lang.String encodedTopic)
-
validatePartitionedTopicName
protected void validatePartitionedTopicName(java.lang.String tenant, java.lang.String namespace, java.lang.String encodedTopic)
-
validatePartitionedTopicMetadata
protected void validatePartitionedTopicMetadata(java.lang.String tenant, java.lang.String namespace, java.lang.String encodedTopic)
-
validateTopicName
@Deprecated protected void validateTopicName(java.lang.String property, java.lang.String cluster, java.lang.String namespace, java.lang.String encodedTopic)Deprecated.
-
validatePersistentTopicName
@Deprecated protected void validatePersistentTopicName(java.lang.String property, java.lang.String cluster, java.lang.String namespace, java.lang.String encodedTopic)Deprecated.
-
validateAndGetWorkerService
protected org.apache.pulsar.functions.worker.WorkerService validateAndGetWorkerService()
-
getNamespacePolicies
protected org.apache.pulsar.common.policies.data.Policies getNamespacePolicies(org.apache.pulsar.common.naming.NamespaceName namespaceName)
-
getNamespacePoliciesAsync
protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.Policies> getNamespacePoliciesAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName)
-
mergeNamespaceWithDefaults
protected void mergeNamespaceWithDefaults(org.apache.pulsar.common.policies.data.Policies policies, java.lang.String namespace, java.lang.String namespacePath)
-
namespaceBacklogQuota
protected org.apache.pulsar.common.policies.data.BacklogQuota namespaceBacklogQuota(org.apache.pulsar.common.naming.NamespaceName namespace, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType)
-
getTopicPoliciesAsyncWithRetry
protected java.util.concurrent.CompletableFuture<java.util.Optional<org.apache.pulsar.common.policies.data.TopicPolicies>> getTopicPoliciesAsyncWithRetry(org.apache.pulsar.common.naming.TopicName topicName)
-
checkBacklogQuota
protected boolean checkBacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota quota, org.apache.pulsar.common.policies.data.RetentionPolicies retention)
-
checkTopicLevelPolicyEnable
protected void checkTopicLevelPolicyEnable()
-
dispatchRate
protected org.apache.pulsar.common.policies.data.impl.DispatchRateImpl dispatchRate()
-
subscriptionDispatchRate
protected org.apache.pulsar.common.policies.data.impl.DispatchRateImpl subscriptionDispatchRate()
-
replicatorDispatchRate
protected org.apache.pulsar.common.policies.data.impl.DispatchRateImpl replicatorDispatchRate()
-
subscribeRate
protected org.apache.pulsar.common.policies.data.SubscribeRate subscribeRate()
-
jsonMapper
public static com.fasterxml.jackson.databind.ObjectMapper jsonMapper()
-
clusters
protected java.util.Set<java.lang.String> clusters()
-
setServletContext
protected void setServletContext(javax.servlet.ServletContext servletContext)
-
getPartitionedTopicMetadataAsync
protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadataAsync(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative, boolean checkAllowAutoCreation)
-
getPartitionedTopicMetadata
protected org.apache.pulsar.common.partition.PartitionedTopicMetadata getPartitionedTopicMetadata(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative, boolean checkAllowAutoCreation)
-
fetchPartitionedTopicMetadata
protected static org.apache.pulsar.common.partition.PartitionedTopicMetadata fetchPartitionedTopicMetadata(PulsarService pulsar, org.apache.pulsar.common.naming.TopicName topicName)
-
fetchPartitionedTopicMetadataCheckAllowAutoCreation
protected static org.apache.pulsar.common.partition.PartitionedTopicMetadata fetchPartitionedTopicMetadataCheckAllowAutoCreation(PulsarService pulsar, org.apache.pulsar.common.naming.TopicName topicName)
-
validateClusterExists
protected void validateClusterExists(java.lang.String cluster)
- Overrides:
validateClusterExistsin classPulsarWebResource
-
getNamespacePolicies
protected org.apache.pulsar.common.policies.data.Policies getNamespacePolicies(java.lang.String tenant, java.lang.String cluster, java.lang.String namespace)
-
isNamespaceReplicated
protected boolean isNamespaceReplicated(org.apache.pulsar.common.naming.NamespaceName namespaceName)
-
getNamespaceReplicatedClusters
protected java.util.Set<java.lang.String> getNamespaceReplicatedClusters(org.apache.pulsar.common.naming.NamespaceName namespaceName)
-
getPartitionedTopicList
protected java.util.List<java.lang.String> getPartitionedTopicList(org.apache.pulsar.common.naming.TopicDomain topicDomain)
-
getTopicPartitionList
protected java.util.List<java.lang.String> getTopicPartitionList(org.apache.pulsar.common.naming.TopicDomain topicDomain)
-
internalCreatePartitionedTopic
protected void internalCreatePartitionedTopic(javax.ws.rs.container.AsyncResponse asyncResponse, int numPartitions, boolean createLocalTopicOnly)
-
checkTopicExistsAsync
protected java.util.concurrent.CompletableFuture<java.lang.Boolean> checkTopicExistsAsync(org.apache.pulsar.common.naming.TopicName topicName)
Check the exists topics contains the given topic. Since there are topic partitions and non-partitioned topics in Pulsar, must ensure both partitions and non-partitioned topics are not duplicated. So, if compare with a partition name, we should compare to the partitioned name of this partition.- Parameters:
topicName- given topic name
-
resumeAsyncResponseExceptionally
protected void resumeAsyncResponseExceptionally(javax.ws.rs.container.AsyncResponse asyncResponse, java.lang.Throwable throwable)
-
getSchemaCompatibilityStrategyAsync
protected java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy> getSchemaCompatibilityStrategyAsync()
-
checkNotNull
@CanIgnoreReturnValue public static <T> T checkNotNull(T reference)
-
checkNotNull
protected void checkNotNull(java.lang.Object o, java.lang.String errorMessage)
-
isManagedLedgerNotFoundException
protected boolean isManagedLedgerNotFoundException(java.lang.Exception e)
-
checkArgument
protected void checkArgument(boolean b, java.lang.String errorMessage)
-
validatePersistencePolicies
protected void validatePersistencePolicies(org.apache.pulsar.common.policies.data.PersistencePolicies persistence)
-
isRedirectException
protected static boolean isRedirectException(java.lang.Throwable ex)
Check current exception whether is redirect exception.- Parameters:
ex- The throwable.- Returns:
- Whether is redirect exception
-
getPartitionedTopicNotFoundErrorMessage
protected static java.lang.String getPartitionedTopicNotFoundErrorMessage(java.lang.String topic)
-
-