use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.
the class NamespaceBundleTest method testCompareTo.
@Test
public void testCompareTo() throws Exception {
NamespaceBundle bundle = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0l, BoundType.CLOSED, 0x40000000L, BoundType.OPEN));
NamespaceBundle bundle2 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0x20000000l, BoundType.CLOSED, 0x40000000L, BoundType.OPEN));
try {
bundle.compareTo(bundle2);
fail("Should have failed due to overlap ranges");
} catch (IllegalArgumentException iae) {
// OK, expected
}
NamespaceBundle bundle0 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0l, BoundType.CLOSED, 0x10000000L, BoundType.OPEN));
assertTrue(bundle0.compareTo(bundle2) < 0);
assertTrue(bundle2.compareTo(bundle0) > 0);
NamespaceBundle bundle1 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0l, BoundType.CLOSED, 0x20000000L, BoundType.OPEN));
assertTrue(bundle1.compareTo(bundle2) < 0);
NamespaceBundle bundle3 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0l, BoundType.CLOSED, 0x40000000L, BoundType.OPEN));
assertTrue(bundle.compareTo(bundle3) == 0);
NamespaceBundle otherBundle = factory.getBundle(new NamespaceName("pulsar/use/ns2"), Range.range(0x10000000l, BoundType.CLOSED, 0x30000000L, BoundType.OPEN));
assertTrue(otherBundle.compareTo(bundle0) > 0);
}
use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.
the class NamespaceBundleTest method testToString.
@Test
public void testToString() throws Exception {
NamespaceBundle bundle0 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0l, BoundType.CLOSED, 0x10000000L, BoundType.OPEN));
assertEquals(bundle0.toString(), "pulsar/use/ns1/0x00000000_0x10000000");
bundle0 = factory.getBundle(new NamespaceName("pulsar/use/ns1"), Range.range(0x10000000l, BoundType.CLOSED, NamespaceBundles.FULL_UPPER_BOUND, BoundType.CLOSED));
assertEquals(bundle0.toString(), "pulsar/use/ns1/0x10000000_0xffffffff");
}
use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.
the class NamespacesImpl method deleteNamespaceBundle.
@Override
public void deleteNamespaceBundle(String namespace, String bundleRange) throws PulsarAdminException {
try {
NamespaceName ns = new NamespaceName(namespace);
request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path(bundleRange)).delete(ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.
the class NamespacesImpl method splitNamespaceBundle.
@Override
public void splitNamespaceBundle(String namespace, String bundle) throws PulsarAdminException {
try {
NamespaceName ns = new NamespaceName(namespace);
request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path(bundle).path("split")).put(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.
the class NamespacesImpl method unsubscribeNamespace.
@Override
public void unsubscribeNamespace(String namespace, String subscription) throws PulsarAdminException {
try {
NamespaceName ns = new NamespaceName(namespace);
request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path("unsubscribe").path(subscription)).post(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
Aggregations