Class PulsarWebResource

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.servlet.http.HttpServletRequest httpRequest  
      protected static int NOT_IMPLEMENTED  
      protected javax.servlet.ServletContext servletContext  
      protected javax.ws.rs.core.UriInfo uri  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.apache.pulsar.broker.resources.BookieResources bookieResources()  
      protected java.util.concurrent.CompletableFuture<java.lang.Void> canUpdateCluster​(java.lang.String tenant, java.util.Set<java.lang.String> oldClusters, java.util.Set<java.lang.String> newClusters)  
      protected static java.util.concurrent.CompletableFuture<java.lang.Void> checkAuthorizationAsync​(PulsarService pulsarService, org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)  
      static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> checkLocalOrGetPeerReplicationCluster​(PulsarService pulsarService, org.apache.pulsar.common.naming.NamespaceName namespace)  
      static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> checkLocalOrGetPeerReplicationCluster​(PulsarService pulsarService, org.apache.pulsar.common.naming.NamespaceName namespace, boolean allowDeletedNamespace)  
      java.lang.String clientAppId()
      Gets a caller id (IP + role).
      org.apache.pulsar.broker.authentication.AuthenticationDataHttps clientAuthData()  
      protected org.apache.pulsar.broker.resources.ClusterResources clusterResources()  
      protected org.apache.pulsar.broker.ServiceConfiguration config()  
      protected org.apache.pulsar.broker.resources.DynamicConfigurationResources dynamicConfigurationResources()  
      protected static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> getClusterDataIfDifferentCluster​(PulsarService pulsar, java.lang.String cluster, java.lang.String clientAppId)  
      protected org.apache.pulsar.broker.resources.LocalPoliciesResources getLocalPolicies()  
      protected org.apache.pulsar.broker.resources.PulsarResources getPulsarResources()  
      protected java.lang.Void handleCommonRestAsyncException​(javax.ws.rs.container.AsyncResponse asyncResponse, java.lang.Throwable ex)  
      protected java.util.concurrent.CompletableFuture<java.lang.Void> hasActiveNamespace​(java.lang.String tenant)  
      protected boolean hasSuperUserAccess()  
      protected java.util.concurrent.CompletableFuture<java.lang.Boolean> isBundleOwnedByAnyBroker​(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, java.lang.String bundleRange)
      Checks whether a given bundle is currently loaded by any broker.
      static boolean isClientAuthenticated​(java.lang.String appId)  
      protected boolean isLeaderBroker()  
      protected static boolean isLeaderBroker​(PulsarService pulsar)  
      boolean isRequestHttps()  
      static com.fasterxml.jackson.databind.ObjectMapper jsonMapper()  
      protected org.apache.pulsar.broker.resources.NamespaceResources.IsolationPolicyResources namespaceIsolationPolicies()  
      protected org.apache.pulsar.broker.resources.NamespaceResources namespaceResources()  
      java.lang.String originalPrincipal()  
      protected PulsarService pulsar()  
      protected org.apache.pulsar.broker.resources.ResourceGroupResources resourceGroupResources()  
      void setPulsar​(PulsarService pulsar)  
      static java.lang.String splitPath​(java.lang.String source, int slice)  
      protected org.apache.pulsar.broker.resources.TenantResources tenantResources()  
      protected org.apache.pulsar.broker.resources.TopicResources topicResources()  
      protected void validateAdminAccessForTenant​(java.lang.String tenant)
      Checks that the http client role has admin access to the specified tenant.
      protected static void validateAdminAccessForTenant​(PulsarService pulsar, java.lang.String clientAppId, java.lang.String originalPrincipal, java.lang.String tenant, org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)  
      protected static java.util.concurrent.CompletableFuture<java.lang.Void> validateAdminAccessForTenantAsync​(PulsarService pulsar, java.lang.String clientAppId, java.lang.String originalPrincipal, java.lang.String tenant, org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)  
      protected void validateBrokerName​(java.lang.String broker)
      Redirect the call to the specified broker.
      protected void validateBundleOwnership​(java.lang.String tenant, java.lang.String cluster, java.lang.String namespace, boolean authoritative, boolean readOnly, NamespaceBundle bundle)  
      void validateBundleOwnership​(NamespaceBundle bundle, boolean authoritative, boolean readOnly)  
      protected void validateClusterExists​(java.lang.String cluster)  
      protected void validateClusterForTenant​(java.lang.String tenant, java.lang.String cluster)  
      protected void validateClusterOwnership​(java.lang.String cluster)
      Check if the cluster exists and redirect the call to the owning cluster.
      protected void validateGlobalNamespaceOwnership​(org.apache.pulsar.common.naming.NamespaceName namespace)
      If the namespace is global, validate the following - 1.
      protected java.util.concurrent.CompletableFuture<java.lang.Void> validateGlobalNamespaceOwnershipAsync​(org.apache.pulsar.common.naming.NamespaceName namespace)  
      protected NamespaceBundle validateNamespaceBundleOwnership​(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, java.lang.String bundleRange, boolean authoritative, boolean readOnly)  
      protected NamespaceBundle validateNamespaceBundleRange​(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, java.lang.String bundleRange)  
      void validateNamespaceOperation​(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.NamespaceOperation operation)  
      java.util.concurrent.CompletableFuture<java.lang.Void> validateNamespaceOperationAsync​(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.NamespaceOperation operation)  
      void validateNamespacePolicyOperation​(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation)  
      void validatePoliciesReadOnlyAccess()  
      void validateSuperUserAccess()
      Checks whether the user has Pulsar Super-User access to the system.
      void validateTenantOperation​(java.lang.String tenant, org.apache.pulsar.common.policies.data.TenantOperation operation)  
      void validateTopicOperation​(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicOperation operation)  
      void validateTopicOperation​(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicOperation operation, java.lang.String subscription)  
      java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOperationAsync​(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicOperation operation)  
      java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOperationAsync​(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicOperation operation, java.lang.String subscription)  
      protected void validateTopicOwnership​(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative)
      Checks whether the broker is the owner of the namespace.
      protected java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOwnershipAsync​(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative)  
      void validateTopicPolicyOperation​(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • servletContext

        @Context
        protected javax.servlet.ServletContext servletContext
      • httpRequest

        @Context
        protected javax.servlet.http.HttpServletRequest httpRequest
      • uri

        @Context
        protected javax.ws.rs.core.UriInfo uri
    • Constructor Detail

      • PulsarWebResource

        public PulsarWebResource()
    • Method Detail

      • config

        protected org.apache.pulsar.broker.ServiceConfiguration config()
      • splitPath

        public static java.lang.String splitPath​(java.lang.String source,
                                                 int slice)
      • clientAppId

        public java.lang.String clientAppId()
        Gets a caller id (IP + role).
        Returns:
        the web service caller identification
      • originalPrincipal

        public java.lang.String originalPrincipal()
      • clientAuthData

        public org.apache.pulsar.broker.authentication.AuthenticationDataHttps clientAuthData()
      • isRequestHttps

        public boolean isRequestHttps()
      • isClientAuthenticated

        public static boolean isClientAuthenticated​(java.lang.String appId)
      • hasSuperUserAccess

        protected boolean hasSuperUserAccess()
      • validateSuperUserAccess

        public void validateSuperUserAccess()
        Checks whether the user has Pulsar Super-User access to the system.
        Throws:
        javax.ws.rs.WebApplicationException - if not authorized
      • validateAdminAccessForTenant

        protected void validateAdminAccessForTenant​(java.lang.String tenant)
        Checks that the http client role has admin access to the specified tenant.
        Parameters:
        tenant - the tenant id
        Throws:
        javax.ws.rs.WebApplicationException - if not authorized
      • validateAdminAccessForTenantAsync

        protected static java.util.concurrent.CompletableFuture<java.lang.Void> validateAdminAccessForTenantAsync​(PulsarService pulsar,
                                                                                                                  java.lang.String clientAppId,
                                                                                                                  java.lang.String originalPrincipal,
                                                                                                                  java.lang.String tenant,
                                                                                                                  org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)
      • validateAdminAccessForTenant

        protected static void validateAdminAccessForTenant​(PulsarService pulsar,
                                                           java.lang.String clientAppId,
                                                           java.lang.String originalPrincipal,
                                                           java.lang.String tenant,
                                                           org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • validateClusterForTenant

        protected void validateClusterForTenant​(java.lang.String tenant,
                                                java.lang.String cluster)
      • validateClusterOwnership

        protected void validateClusterOwnership​(java.lang.String cluster)
                                         throws javax.ws.rs.WebApplicationException
        Check if the cluster exists and redirect the call to the owning cluster.
        Parameters:
        cluster - Cluster name
        Throws:
        java.lang.Exception - In case the redirect happens
        javax.ws.rs.WebApplicationException
      • getClusterDataIfDifferentCluster

        protected static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> getClusterDataIfDifferentCluster​(PulsarService pulsar,
                                                                                                                                                     java.lang.String cluster,
                                                                                                                                                     java.lang.String clientAppId)
      • validateBundleOwnership

        protected void validateBundleOwnership​(java.lang.String tenant,
                                               java.lang.String cluster,
                                               java.lang.String namespace,
                                               boolean authoritative,
                                               boolean readOnly,
                                               NamespaceBundle bundle)
      • validateNamespaceBundleRange

        protected NamespaceBundle validateNamespaceBundleRange​(org.apache.pulsar.common.naming.NamespaceName fqnn,
                                                               org.apache.pulsar.common.policies.data.BundlesData bundles,
                                                               java.lang.String bundleRange)
      • isBundleOwnedByAnyBroker

        protected java.util.concurrent.CompletableFuture<java.lang.Boolean> isBundleOwnedByAnyBroker​(org.apache.pulsar.common.naming.NamespaceName fqnn,
                                                                                                     org.apache.pulsar.common.policies.data.BundlesData bundles,
                                                                                                     java.lang.String bundleRange)
        Checks whether a given bundle is currently loaded by any broker.
      • validateNamespaceBundleOwnership

        protected NamespaceBundle validateNamespaceBundleOwnership​(org.apache.pulsar.common.naming.NamespaceName fqnn,
                                                                   org.apache.pulsar.common.policies.data.BundlesData bundles,
                                                                   java.lang.String bundleRange,
                                                                   boolean authoritative,
                                                                   boolean readOnly)
      • validateBundleOwnership

        public void validateBundleOwnership​(NamespaceBundle bundle,
                                            boolean authoritative,
                                            boolean readOnly)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • validateTopicOwnership

        protected void validateTopicOwnership​(org.apache.pulsar.common.naming.TopicName topicName,
                                              boolean authoritative)
        Checks whether the broker is the owner of the namespace. Otherwise it will raise an exception to redirect the client to the appropriate broker. If no broker owns the namespace yet, this function will try to acquire the ownership by default.
        Parameters:
        topicName - topic name
        authoritative -
      • validateTopicOwnershipAsync

        protected java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOwnershipAsync​(org.apache.pulsar.common.naming.TopicName topicName,
                                                                                                     boolean authoritative)
      • validateGlobalNamespaceOwnership

        protected void validateGlobalNamespaceOwnership​(org.apache.pulsar.common.naming.NamespaceName namespace)
        If the namespace is global, validate the following - 1. If replicated clusters are configured for this global namespace 2. If local cluster belonging to this namespace is replicated 3. If replication is enabled for this namespace
        It validates if local cluster is part of replication-cluster. If local cluster is not part of the replication cluster then it redirects request to peer-cluster if any of the peer-cluster is part of replication-cluster of this namespace. If none of the cluster is part of the replication cluster then it fails the validation.
        Parameters:
        namespace -
        Throws:
        java.lang.Exception
      • validateGlobalNamespaceOwnershipAsync

        protected java.util.concurrent.CompletableFuture<java.lang.Void> validateGlobalNamespaceOwnershipAsync​(org.apache.pulsar.common.naming.NamespaceName namespace)
      • checkLocalOrGetPeerReplicationCluster

        public static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> checkLocalOrGetPeerReplicationCluster​(PulsarService pulsarService,
                                                                                                                                                           org.apache.pulsar.common.naming.NamespaceName namespace)
      • checkLocalOrGetPeerReplicationCluster

        public static java.util.concurrent.CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> checkLocalOrGetPeerReplicationCluster​(PulsarService pulsarService,
                                                                                                                                                           org.apache.pulsar.common.naming.NamespaceName namespace,
                                                                                                                                                           boolean allowDeletedNamespace)
      • checkAuthorizationAsync

        protected static java.util.concurrent.CompletableFuture<java.lang.Void> checkAuthorizationAsync​(PulsarService pulsarService,
                                                                                                        org.apache.pulsar.common.naming.TopicName topicName,
                                                                                                        java.lang.String role,
                                                                                                        org.apache.pulsar.broker.authentication.AuthenticationDataSource authenticationData)
      • isLeaderBroker

        protected boolean isLeaderBroker()
      • isLeaderBroker

        protected static boolean isLeaderBroker​(PulsarService pulsar)
      • validateTenantOperation

        public void validateTenantOperation​(java.lang.String tenant,
                                            org.apache.pulsar.common.policies.data.TenantOperation operation)
      • validateNamespaceOperation

        public void validateNamespaceOperation​(org.apache.pulsar.common.naming.NamespaceName namespaceName,
                                               org.apache.pulsar.common.policies.data.NamespaceOperation operation)
      • validateNamespaceOperationAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> validateNamespaceOperationAsync​(org.apache.pulsar.common.naming.NamespaceName namespaceName,
                                                                                                      org.apache.pulsar.common.policies.data.NamespaceOperation operation)
      • validateNamespacePolicyOperation

        public void validateNamespacePolicyOperation​(org.apache.pulsar.common.naming.NamespaceName namespaceName,
                                                     org.apache.pulsar.common.policies.data.PolicyName policy,
                                                     org.apache.pulsar.common.policies.data.PolicyOperation operation)
      • getPulsarResources

        protected org.apache.pulsar.broker.resources.PulsarResources getPulsarResources()
      • tenantResources

        protected org.apache.pulsar.broker.resources.TenantResources tenantResources()
      • clusterResources

        protected org.apache.pulsar.broker.resources.ClusterResources clusterResources()
      • bookieResources

        protected org.apache.pulsar.broker.resources.BookieResources bookieResources()
      • topicResources

        protected org.apache.pulsar.broker.resources.TopicResources topicResources()
      • namespaceResources

        protected org.apache.pulsar.broker.resources.NamespaceResources namespaceResources()
      • resourceGroupResources

        protected org.apache.pulsar.broker.resources.ResourceGroupResources resourceGroupResources()
      • getLocalPolicies

        protected org.apache.pulsar.broker.resources.LocalPoliciesResources getLocalPolicies()
      • namespaceIsolationPolicies

        protected org.apache.pulsar.broker.resources.NamespaceResources.IsolationPolicyResources namespaceIsolationPolicies()
      • dynamicConfigurationResources

        protected org.apache.pulsar.broker.resources.DynamicConfigurationResources dynamicConfigurationResources()
      • jsonMapper

        public static com.fasterxml.jackson.databind.ObjectMapper jsonMapper()
      • validatePoliciesReadOnlyAccess

        public void validatePoliciesReadOnlyAccess()
      • hasActiveNamespace

        protected java.util.concurrent.CompletableFuture<java.lang.Void> hasActiveNamespace​(java.lang.String tenant)
      • validateClusterExists

        protected void validateClusterExists​(java.lang.String cluster)
      • canUpdateCluster

        protected java.util.concurrent.CompletableFuture<java.lang.Void> canUpdateCluster​(java.lang.String tenant,
                                                                                          java.util.Set<java.lang.String> oldClusters,
                                                                                          java.util.Set<java.lang.String> newClusters)
      • validateBrokerName

        protected void validateBrokerName​(java.lang.String broker)
        Redirect the call to the specified broker.
        Parameters:
        broker - Broker name
      • validateTopicPolicyOperation

        public void validateTopicPolicyOperation​(org.apache.pulsar.common.naming.TopicName topicName,
                                                 org.apache.pulsar.common.policies.data.PolicyName policy,
                                                 org.apache.pulsar.common.policies.data.PolicyOperation operation)
      • validateTopicOperation

        public void validateTopicOperation​(org.apache.pulsar.common.naming.TopicName topicName,
                                           org.apache.pulsar.common.policies.data.TopicOperation operation)
      • validateTopicOperation

        public void validateTopicOperation​(org.apache.pulsar.common.naming.TopicName topicName,
                                           org.apache.pulsar.common.policies.data.TopicOperation operation,
                                           java.lang.String subscription)
      • validateTopicOperationAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOperationAsync​(org.apache.pulsar.common.naming.TopicName topicName,
                                                                                                  org.apache.pulsar.common.policies.data.TopicOperation operation)
      • validateTopicOperationAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> validateTopicOperationAsync​(org.apache.pulsar.common.naming.TopicName topicName,
                                                                                                  org.apache.pulsar.common.policies.data.TopicOperation operation,
                                                                                                  java.lang.String subscription)
      • handleCommonRestAsyncException

        protected java.lang.Void handleCommonRestAsyncException​(javax.ws.rs.container.AsyncResponse asyncResponse,
                                                                java.lang.Throwable ex)