org.apache.pulsar.common.naming.NamespaceName Java Examples
The following examples show how to use
org.apache.pulsar.common.naming.NamespaceName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Namespaces.java From pulsar with Apache License 2.0 | 6 votes |
@GET @Path("/{property}/{cluster}/{namespace}/destinations") @ApiOperation(hidden = true, value = "Get the list of all the topics under a certain namespace.", response = String.class, responseContainer = "Set") @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist") }) public void getTopics(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace, @QueryParam("mode") @DefaultValue("PERSISTENT") Mode mode, @Suspended AsyncResponse asyncResponse) { validateNamespaceName(property, cluster, namespace); validateNamespaceOperation(NamespaceName.get(property, namespace), NamespaceOperation.GET_TOPICS); // Validate that namespace exists, throws 404 if it doesn't exist getNamespacePolicies(namespaceName); pulsar().getNamespaceService().getListOfTopics(namespaceName, mode) .thenAccept(asyncResponse::resume) .exceptionally(ex -> { log.error("Failed to get topics list for namespace {}", namespaceName, ex); asyncResponse.resume(ex); return null; }); }
Example #2
Source File: ResourceQuotaCacheTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testGetSetBundleQuota() throws Exception { ResourceQuotaCache cache = new ResourceQuotaCache(zkCache); NamespaceBundle testBundle = bundleFactory.getFullBundle(NamespaceName.get("pulsar/test/ns-2")); ResourceQuota quota1 = ResourceQuotaCache.getInitialQuotaValue(); ResourceQuota quota2 = new ResourceQuota(); quota2.setMsgRateIn(10); quota2.setMsgRateOut(20); quota2.setBandwidthIn(10000); quota2.setBandwidthOut(20000); quota2.setMemory(100); quota2.setDynamic(false); assertEquals(cache.getQuota(testBundle), quota1); cache.setQuota(testBundle, quota2); assertEquals(cache.getQuota(testBundle), quota2); cache.unsetQuota(testBundle); assertEquals(cache.getQuota(testBundle), quota1); }
Example #3
Source File: NamespaceServiceTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testremoveOwnershipNamespaceBundle() throws Exception { OwnershipCache ownershipCache = spy(pulsar.getNamespaceService().getOwnershipCache()); ManagedLedger ledger = mock(ManagedLedger.class); when(ledger.getCursors()).thenReturn(Lists.newArrayList()); doReturn(CompletableFuture.completedFuture(null)).when(ownershipCache).disableOwnership(any(NamespaceBundle.class)); Field ownership = NamespaceService.class.getDeclaredField("ownershipCache"); ownership.setAccessible(true); ownership.set(pulsar.getNamespaceService(), ownershipCache); NamespaceService namespaceService = pulsar.getNamespaceService(); NamespaceName nsname = NamespaceName.get("prop/use/ns1"); NamespaceBundles bundles = namespaceService.getNamespaceBundleFactory().getBundles(nsname); NamespaceBundle bundle = bundles.getBundles().get(0); assertNotNull(ownershipCache.tryAcquiringOwnership(bundle)); assertNotNull(ownershipCache.getOwnedBundle(bundle)); ownershipCache.removeOwnership(bundles).get(); assertNull(ownershipCache.getOwnedBundle(bundle)); }
Example #4
Source File: TopicsImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<List<String>> getListInBundleAsync(String namespace, String bundleRange) { NamespaceName ns = NamespaceName.get(namespace); final CompletableFuture<List<String>> future = new CompletableFuture<>(); WebTarget path = namespacePath("non-persistent", ns, bundleRange); asyncGetRequest(path, new InvocationCallback<List<String>>() { @Override public void completed(List<String> response) { future.complete(response); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #5
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Map<BacklogQuotaType, BacklogQuota>> getBacklogQuotaMapAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "backlogQuotaMap"); final CompletableFuture<Map<BacklogQuotaType, BacklogQuota>> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<Map<BacklogQuotaType, BacklogQuota>>() { @Override public void completed(Map<BacklogQuotaType, BacklogQuota> quotaMap) { future.complete(quotaMap); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #6
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Integer> getSubscriptionExpirationTimeAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "subscriptionExpirationTime"); final CompletableFuture<Integer> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<Integer>() { @Override public void completed(Integer expirationTime) { future.complete(expirationTime); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #7
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<DispatchRate> getDispatchRateAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "dispatchRate"); final CompletableFuture<DispatchRate> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<DispatchRate>() { @Override public void completed(DispatchRate dispatchRate) { future.complete(dispatchRate); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #8
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<SchemaCompatibilityStrategy> getSchemaCompatibilityStrategyAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "schemaCompatibilityStrategy"); final CompletableFuture<SchemaCompatibilityStrategy> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<SchemaCompatibilityStrategy>() { @Override public void completed(SchemaCompatibilityStrategy schemaCompatibilityStrategy) { future.complete(schemaCompatibilityStrategy); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #9
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<DelayedDeliveryPolicies> getDelayedDeliveryAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "delayedDelivery"); final CompletableFuture<DelayedDeliveryPolicies> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<DelayedDeliveryPolicies>() { @Override public void completed(DelayedDeliveryPolicies delayedDeliveryPolicies) { future.complete(delayedDeliveryPolicies); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #10
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<BookieAffinityGroupData> getBookieAffinityGroupAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "persistence", "bookieAffinity"); final CompletableFuture<BookieAffinityGroupData> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<BookieAffinityGroupData>() { @Override public void completed(BookieAffinityGroupData bookieAffinityGroupData) { future.complete(bookieAffinityGroupData); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #11
Source File: NamespaceService.java From pulsar with Apache License 2.0 | 6 votes |
/** * Return the URL of the broker who's owning a particular service unit. * * If the service unit is not owned, return an empty optional */ public Optional<URL> getWebServiceUrl(ServiceUnitId suName, boolean authoritative, boolean isRequestHttps, boolean readOnly) throws Exception { if (suName instanceof TopicName) { TopicName name = (TopicName) suName; if (LOG.isDebugEnabled()) { LOG.debug("Getting web service URL of topic: {} - auth: {}", name, authoritative); } return this.internalGetWebServiceUrl(getBundle(name), authoritative, isRequestHttps, readOnly) .get(pulsar.getConfiguration().getZooKeeperOperationTimeoutSeconds(), SECONDS); } if (suName instanceof NamespaceName) { return this.internalGetWebServiceUrl(getFullBundle((NamespaceName) suName), authoritative, isRequestHttps, readOnly).get(pulsar.getConfiguration().getZooKeeperOperationTimeoutSeconds(), SECONDS); } if (suName instanceof NamespaceBundle) { return this.internalGetWebServiceUrl((NamespaceBundle) suName, authoritative, isRequestHttps, readOnly) .get(pulsar.getConfiguration().getZooKeeperOperationTimeoutSeconds(), SECONDS); } throw new IllegalArgumentException("Unrecognized class of NamespaceBundle: " + suName.getClass().getName()); }
Example #12
Source File: NamespaceServiceTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testIsServiceUnitDisabled() throws Exception { OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache()); ManagedLedger ledger = mock(ManagedLedger.class); when(ledger.getCursors()).thenReturn(Lists.newArrayList()); doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class)); Field ownership = NamespaceService.class.getDeclaredField("ownershipCache"); ownership.setAccessible(true); ownership.set(pulsar.getNamespaceService(), MockOwnershipCache); NamespaceService namespaceService = pulsar.getNamespaceService(); NamespaceName nsname = NamespaceName.get("pulsar/global/ns1"); TopicName topicName = TopicName.get("persistent://pulsar/global/ns1/topic-1"); NamespaceBundles bundles = namespaceService.getNamespaceBundleFactory().getBundles(nsname); NamespaceBundle originalBundle = bundles.findBundle(topicName); assertFalse(namespaceService.isNamespaceBundleDisabled(originalBundle)); }
Example #13
Source File: PersistentTopicsTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test(expectedExceptions = RestException.class) public void testUpdatePartitionedTopicHavingNonPartitionTopicWithPartitionSuffix() throws Exception { // Already have non partition topic special-topic-partition-10, shouldn't able to update number of partitioned topic to more than 10. final String nonPartitionTopicName2 = "special-topic-partition-10"; final String partitionedTopicName = "special-topic"; LocalZooKeeperCacheService mockLocalZooKeeperCacheService = mock(LocalZooKeeperCacheService.class); ZooKeeperManagedLedgerCache mockZooKeeperChildrenCache = mock(ZooKeeperManagedLedgerCache.class); doReturn(mockLocalZooKeeperCacheService).when(pulsar).getLocalZkCacheService(); doReturn(mockZooKeeperChildrenCache).when(mockLocalZooKeeperCacheService).managedLedgerListCache(); doReturn(ImmutableSet.of(nonPartitionTopicName2)).when(mockZooKeeperChildrenCache).get(anyString()); doReturn(CompletableFuture.completedFuture(ImmutableSet.of(nonPartitionTopicName2))).when(mockZooKeeperChildrenCache).getAsync(anyString()); doAnswer(invocation -> { persistentTopics.namespaceName = NamespaceName.get("tenant", "namespace"); persistentTopics.topicName = TopicName.get("persistent", "tenant", "cluster", "namespace", "topicname"); return null; }).when(persistentTopics).validatePartitionedTopicName(any(), any(), any()); doNothing().when(persistentTopics).validateAdminAccessForTenant(anyString()); AsyncResponse response = mock(AsyncResponse.class); ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class); persistentTopics.createPartitionedTopic(response, testTenant, testNamespace, partitionedTopicName, 5); verify(response, timeout(5000).times(1)).resume(responseCaptor.capture()); Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode()); persistentTopics.updatePartitionedTopic(testTenant, testNamespace, partitionedTopicName, true, false, 10); }
Example #14
Source File: PulsarWebResource.java From pulsar with Apache License 2.0 | 6 votes |
/** * Checks whether the broker is the owner of all the namespace bundles. Otherwise, if authoritative is false, it * will throw an exception to redirect to assigned owner or leader; if authoritative is true then it will try to * acquire all the namespace bundles. * * @param fqnn * @param authoritative * @param readOnly * @param bundleData */ protected void validateNamespaceOwnershipWithBundles(String tenant, String cluster, String namespace, boolean authoritative, boolean readOnly, BundlesData bundleData) { NamespaceName fqnn = NamespaceName.get(tenant, cluster, namespace); try { NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(fqnn, bundleData); for (NamespaceBundle bundle : bundles.getBundles()) { validateBundleOwnership(bundle, authoritative, readOnly); } } catch (WebApplicationException wae) { // propagate already wrapped-up WebApplicationExceptions throw wae; } catch (Exception oe) { log.debug("Failed to find owner for namespace {}", fqnn, oe); throw new RestException(oe); } }
Example #15
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<List<String>> getTopicsAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); String action = ns.isV2() ? "topics" : "destinations"; WebTarget path = namespacePath(ns, action); final CompletableFuture<List<String>> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<List<String>>() { @Override public void completed(List<String> topics) { future.complete(topics); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #16
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Integer> getMaxUnackedMessagesPerConsumerAsync(String namespace) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "maxUnackedMessagesPerConsumer"); final CompletableFuture<Integer> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<Integer>() { @Override public void completed(Integer max) { future.complete(max); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #17
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Void> createNamespaceAsync(String namespace, Set<String> clusters) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns); if (ns.isV2()) { // For V2 API we pass full Policy class instance Policies policies = new Policies(); policies.replication_clusters = clusters; return asyncPutRequest(path, Entity.entity(policies, MediaType.APPLICATION_JSON)); } else { // For V1 API, we pass the BundlesData on creation return asyncPutRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)).thenAccept(ignore -> { // For V1, we need to do it in 2 steps setNamespaceReplicationClustersAsync(namespace, clusters); }); } }
Example #18
Source File: NamespaceBundlesTest.java From pulsar with Apache License 2.0 | 6 votes |
private void assertBundles(NamespaceBundleFactory utilityFactory, NamespaceName nsname, NamespaceBundle bundle, Pair<NamespaceBundles, List<NamespaceBundle>> splitBundles, int numBundles) throws Exception { NamespaceBundle bundle1 = splitBundles.getRight().get(0); NamespaceBundle bundle2 = splitBundles.getRight().get(1); NamespaceBundles nspaceBundles = splitBundles.getLeft(); Pair<NamespaceBundles, List<NamespaceBundle>> bundle1Split = splitBundlesUtilFactory(utilityFactory, nsname, nspaceBundles, bundle1, numBundles); assertBundleDivideInTwo(bundle1, bundle1Split.getRight(), numBundles); Pair<NamespaceBundles, List<NamespaceBundle>> bundle2Split = splitBundlesUtilFactory(utilityFactory, nsname, nspaceBundles, bundle2, numBundles); assertBundleDivideInTwo(bundle2, bundle2Split.getRight(), numBundles); }
Example #19
Source File: NamespacesTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testRetention() throws Exception { try { URL localWebServiceUrl = new URL(pulsar.getSafeWebServiceAddress()); String bundledNsLocal = "test-bundled-namespace-1"; BundlesData bundleData = new BundlesData(Lists.newArrayList("0x00000000", "0xffffffff")); createBundledTestNamespaces(this.testTenant, this.testLocalCluster, bundledNsLocal, bundleData); final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal); mockWebUrl(localWebServiceUrl, testNs); OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache()); doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class)); Field ownership = NamespaceService.class.getDeclaredField("ownershipCache"); ownership.setAccessible(true); ownership.set(pulsar.getNamespaceService(), MockOwnershipCache); RetentionPolicies retention = new RetentionPolicies(10, 10); namespaces.setRetention(this.testTenant, this.testLocalCluster, bundledNsLocal, retention); RetentionPolicies retention2 = namespaces.getRetention(this.testTenant, this.testLocalCluster, bundledNsLocal); assertEquals(retention, retention2); } catch (RestException e) { fail("ValidateNamespaceOwnershipWithBundles failed"); } }
Example #20
Source File: PulsarClusterMetadataSetup.java From pulsar with Apache License 2.0 | 5 votes |
static void createNamespaceIfAbsent(ZooKeeper configStoreZk, NamespaceName namespaceName, String cluster) throws KeeperException, InterruptedException, IOException { String namespacePath = POLICIES_ROOT + "/" +namespaceName.toString(); Policies policies; Stat stat = configStoreZk.exists(namespacePath, false); if (stat == null) { policies = new Policies(); policies.bundles = getBundles(16); policies.replication_clusters = Collections.singleton(cluster); createZkNode( configStoreZk, namespacePath, ObjectMapperFactory.getThreadLocal().writeValueAsBytes(policies), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } else { byte[] content = configStoreZk.getData(namespacePath, false, null); policies = ObjectMapperFactory.getThreadLocal().readValue(content, Policies.class); // Only update z-node if the list of clusters should be modified if (!policies.replication_clusters.contains(cluster)) { policies.replication_clusters.add(cluster); configStoreZk.setData(namespacePath, ObjectMapperFactory.getThreadLocal().writeValueAsBytes(policies), stat.getVersion()); } } }
Example #21
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> clearNamespaceBundleBacklogForSubscriptionAsync(String namespace, String bundle, String subscription) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, bundle, "clearBacklog", subscription); return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)); }
Example #22
Source File: Namespaces.java From pulsar with Apache License 2.0 | 5 votes |
@GET @Path("/{tenant}/{namespace}/replication") @ApiOperation(value = "Get the replication clusters for a namespace.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Tenant or cluster or namespace doesn't exist"), @ApiResponse(code = 412, message = "Namespace is not global") }) public Set<String> getNamespaceReplicationClusters(@PathParam("tenant") String tenant, @PathParam("namespace") String namespace) { validateNamespaceName(tenant, namespace); validateNamespacePolicyOperation(NamespaceName.get(tenant, namespace), PolicyName.REPLICATION, PolicyOperation.READ); return internalGetNamespaceReplicationClusters(); }
Example #23
Source File: NamespacesTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testValidateTopicOwnership() throws Exception { URL localWebServiceUrl = new URL(pulsar.getSafeWebServiceAddress()); String bundledNsLocal = "test-bundled-namespace-1"; BundlesData bundleData = new BundlesData(Lists.newArrayList("0x00000000", "0xffffffff")); createBundledTestNamespaces(this.testTenant, this.testLocalCluster, bundledNsLocal, bundleData); final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal); OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache()); doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class)); Field ownership = NamespaceService.class.getDeclaredField("ownershipCache"); ownership.setAccessible(true); ownership.set(pulsar.getNamespaceService(), MockOwnershipCache); TopicName topicName = TopicName.get(testNs.getPersistentTopicName("my-topic")); PersistentTopics topics = spy(new PersistentTopics()); topics.setServletContext(new MockServletContext()); topics.setPulsar(pulsar); doReturn(false).when(topics).isRequestHttps(); doReturn("test").when(topics).clientAppId(); doReturn(null).when(topics).originalPrincipal(); doReturn(null).when(topics).clientAuthData(); mockWebUrl(localWebServiceUrl, testNs); doReturn("persistent").when(topics).domain(); topics.validateTopicName(topicName.getTenant(), topicName.getCluster(), topicName.getNamespacePortion(), topicName.getEncodedLocalName()); topics.validateAdminOperationOnTopic(false); }
Example #24
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> setMaxUnackedMessagesPerConsumerAsync( String namespace, int maxUnackedMessagesPerConsumer) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, "maxUnackedMessagesPerConsumer"); return asyncPostRequest(path, Entity.entity(maxUnackedMessagesPerConsumer, MediaType.APPLICATION_JSON)); }
Example #25
Source File: NamespaceEventsSystemTopicFactory.java From pulsar with Apache License 2.0 | 5 votes |
public SystemTopicClient createSystemTopic(NamespaceName namespaceName, EventType eventType) { TopicName topicName = getSystemTopicName(namespaceName, eventType); if (topicName != null) { log.info("Create system topic {} for {}", topicName.toString(), eventType); return new TopicPoliciesSystemTopicClient(client, topicName); } else { return null; } }
Example #26
Source File: NamespaceService.java From pulsar with Apache License 2.0 | 5 votes |
public CompletableFuture<List<String>> getListOfTopics(NamespaceName namespaceName, Mode mode) { switch (mode) { case ALL: return getFullListOfTopics(namespaceName); case NON_PERSISTENT: return getListOfNonPersistentTopics(namespaceName); case PERSISTENT: default: return getListOfPersistentTopics(namespaceName); } }
Example #27
Source File: Namespaces.java From pulsar with Apache License 2.0 | 5 votes |
@GET @Path("/{property}/{cluster}/{namespace}/backlogQuotaMap") @ApiOperation(hidden = true, value = "Get backlog quota map on a namespace.") @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Namespace does not exist") }) public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) { validateNamespaceName(property, cluster, namespace); validateNamespacePolicyOperation(NamespaceName.get(property, namespace), PolicyName.BACKLOG, PolicyOperation.READ); Policies policies = getNamespacePolicies(namespaceName); return policies.backlog_quota_map; }
Example #28
Source File: NamespacesTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testPersistenceUnauthorized() throws Exception { try { NamespaceName testNs = this.testLocalNamespaces.get(3); PersistencePolicies persistence = new PersistencePolicies(3, 2, 1, 0.0); namespaces.setPersistence(testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), persistence); fail("Should fail"); } catch (RestException e) { assertEquals(e.getResponse().getStatus(), Status.UNAUTHORIZED.getStatusCode()); } }
Example #29
Source File: SystemTopicBasedTopicPoliciesService.java From pulsar with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> removeOwnedNamespaceBundleAsync(NamespaceBundle namespaceBundle) { NamespaceName namespace = namespaceBundle.getNamespaceObject(); AtomicInteger bundlesCount = ownedBundlesCountPerNamespace.get(namespace); if (bundlesCount == null || bundlesCount.decrementAndGet() <= 0) { CompletableFuture<SystemTopicClient.Reader> readerCompletableFuture = readerCaches.remove(namespace); if (readerCompletableFuture != null) { readerCompletableFuture.thenAccept(SystemTopicClient.Reader::closeAsync); ownedBundlesCountPerNamespace.remove(namespace); policyCacheInitMap.remove(namespace); policiesCache.entrySet().removeIf(entry -> entry.getKey().getNamespaceObject().equals(namespace)); } } return CompletableFuture.completedFuture(null); }
Example #30
Source File: NamespacesImpl.java From pulsar with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> unsubscribeNamespaceBundleAsync(String namespace, String bundle, String subscription) { NamespaceName ns = NamespaceName.get(namespace); WebTarget path = namespacePath(ns, bundle, "unsubscribe", subscription); return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)); }