Search in sources :

Example 6 with OwnershipCache

use of org.apache.pulsar.broker.namespace.OwnershipCache in project incubator-pulsar by apache.

the class NamespacesTest method testRetention.

@Test
public void testRetention() throws Exception {
    try {
        URL localWebServiceUrl = new URL(pulsar.getWebServiceAddress());
        String bundledNsLocal = "test-bundled-namespace-1";
        BundlesData bundleData = new BundlesData(Lists.newArrayList("0x00000000", "0xffffffff"));
        createBundledTestNamespaces(this.testProperty, this.testLocalCluster, bundledNsLocal, bundleData);
        final NamespaceName testNs = NamespaceName.get(this.testProperty, this.testLocalCluster, bundledNsLocal);
        mockWebUrl(localWebServiceUrl, testNs);
        OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
        doNothing().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.testProperty, this.testLocalCluster, bundledNsLocal, retention);
        RetentionPolicies retention2 = namespaces.getRetention(this.testProperty, this.testLocalCluster, bundledNsLocal);
        assertEquals(retention, retention2);
    } catch (RestException e) {
        fail("ValidateNamespaceOwnershipWithBundles failed");
    }
}
Also used : NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Field(java.lang.reflect.Field) OwnershipCache(org.apache.pulsar.broker.namespace.OwnershipCache) BundlesData(org.apache.pulsar.common.policies.data.BundlesData) RestException(org.apache.pulsar.broker.web.RestException) URL(java.net.URL) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 7 with OwnershipCache

use of org.apache.pulsar.broker.namespace.OwnershipCache in project incubator-pulsar by apache.

the class NamespacesTest method testValidateNamespaceOwnershipWithBundles.

@Test
public void testValidateNamespaceOwnershipWithBundles() throws Exception {
    try {
        URL localWebServiceUrl = new URL(pulsar.getWebServiceAddress());
        String bundledNsLocal = "test-bundled-namespace-1";
        BundlesData bundleData = new BundlesData(Lists.newArrayList("0x00000000", "0xffffffff"));
        createBundledTestNamespaces(this.testProperty, this.testLocalCluster, bundledNsLocal, bundleData);
        final NamespaceName testNs = NamespaceName.get(this.testProperty, this.testLocalCluster, bundledNsLocal);
        mockWebUrl(localWebServiceUrl, testNs);
        OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
        doNothing().when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
        Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
        ownership.setAccessible(true);
        ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
        namespaces.validateNamespaceOwnershipWithBundles(this.testProperty, this.testLocalCluster, bundledNsLocal, false, true, bundleData);
    } catch (RestException e) {
        fail("ValidateNamespaceOwnershipWithBundles failed");
    }
}
Also used : NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Field(java.lang.reflect.Field) OwnershipCache(org.apache.pulsar.broker.namespace.OwnershipCache) BundlesData(org.apache.pulsar.common.policies.data.BundlesData) RestException(org.apache.pulsar.broker.web.RestException) URL(java.net.URL) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Aggregations

OwnershipCache (org.apache.pulsar.broker.namespace.OwnershipCache)7 Test (org.testng.annotations.Test)7 Field (java.lang.reflect.Field)6 NamespaceBundle (org.apache.pulsar.common.naming.NamespaceBundle)6 URL (java.net.URL)5 MockedPulsarServiceBaseTest (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)5 RestException (org.apache.pulsar.broker.web.RestException)5 NamespaceName (org.apache.pulsar.common.naming.NamespaceName)5 BundlesData (org.apache.pulsar.common.policies.data.BundlesData)5 PersistentTopics (org.apache.pulsar.broker.admin.v1.PersistentTopics)1 PreconditionFailedException (org.apache.pulsar.client.admin.PulsarAdminException.PreconditionFailedException)1 TopicName (org.apache.pulsar.common.naming.TopicName)1 RetentionPolicies (org.apache.pulsar.common.policies.data.RetentionPolicies)1