Search in sources :

Example 46 with NamespaceName

use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.

the class NamespacesImpl method clearNamespaceBundleBacklog.

@Override
public void clearNamespaceBundleBacklog(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("clearBacklog")).post(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Example 47 with NamespaceName

use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.

the class NamespacesImpl method setNamespaceReplicationClusters.

@Override
public void setNamespaceReplicationClusters(String namespace, List<String> clusterIds) throws PulsarAdminException {
    try {
        NamespaceName ns = new NamespaceName(namespace);
        request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path("replication")).post(Entity.entity(clusterIds, MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Example 48 with NamespaceName

use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.

the class NamespacesImpl method clearNamespaceBacklogForSubscription.

@Override
public void clearNamespaceBacklogForSubscription(String namespace, String subscription) throws PulsarAdminException {
    try {
        NamespaceName ns = new NamespaceName(namespace);
        request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path("clearBacklog").path(subscription)).post(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Example 49 with NamespaceName

use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.

the class NamespacesImpl method unloadNamespaceBundle.

@Override
public void unloadNamespaceBundle(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("unload")).put(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Example 50 with NamespaceName

use of com.yahoo.pulsar.common.naming.NamespaceName in project pulsar by yahoo.

the class NamespaceBundleTest method testConstructor.

@Test
public void testConstructor() {
    try {
        new NamespaceBundle(null, null, null);
        fail("Should have failed w/ null pointer exception");
    } catch (NullPointerException npe) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar.old.ns"), null, null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.CLOSED, 0L, BoundType.OPEN), null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.OPEN, 1L, BoundType.OPEN), null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(1L, BoundType.CLOSED, 1L, BoundType.OPEN), null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.CLOSED, 1L, BoundType.CLOSED), null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.CLOSED, NamespaceBundles.FULL_UPPER_BOUND, BoundType.OPEN), null);
        fail("Should have failed w/ illegal argument exception");
    } catch (IllegalArgumentException iae) {
    // OK, expected
    }
    try {
        new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.CLOSED, NamespaceBundles.FULL_UPPER_BOUND, BoundType.CLOSED), null);
        fail("Should have failed w/ null pointer exception");
    } catch (NullPointerException npe) {
    // OK, expected
    }
    NamespaceBundle bundle = new NamespaceBundle(new NamespaceName("pulsar/use/ns"), Range.range(0L, BoundType.CLOSED, 1L, BoundType.OPEN), factory);
    assertTrue(bundle.getKeyRange().lowerEndpoint().equals(0L));
    assertEquals(bundle.getKeyRange().lowerBoundType(), BoundType.CLOSED);
    assertTrue(bundle.getKeyRange().upperEndpoint().equals(1L));
    assertEquals(bundle.getKeyRange().upperBoundType(), BoundType.OPEN);
    assertEquals(bundle.getNamespaceObject().toString(), "pulsar/use/ns");
}
Also used : NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) Test(org.testng.annotations.Test)

Aggregations

NamespaceName (com.yahoo.pulsar.common.naming.NamespaceName)93 NamespaceBundle (com.yahoo.pulsar.common.naming.NamespaceBundle)41 Test (org.testng.annotations.Test)40 PulsarAdminException (com.yahoo.pulsar.client.admin.PulsarAdminException)38 RestException (com.yahoo.pulsar.broker.web.RestException)25 Policies (com.yahoo.pulsar.common.policies.data.Policies)18 ApiOperation (io.swagger.annotations.ApiOperation)17 ApiResponses (io.swagger.annotations.ApiResponses)17 Path (javax.ws.rs.Path)17 KeeperException (org.apache.zookeeper.KeeperException)17 PulsarServerException (com.yahoo.pulsar.broker.PulsarServerException)16 MockedPulsarServiceBaseTest (com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)14 RetentionPolicies (com.yahoo.pulsar.common.policies.data.RetentionPolicies)14 NamespaceBundles (com.yahoo.pulsar.common.naming.NamespaceBundles)13 Field (java.lang.reflect.Field)13 URL (java.net.URL)13 WebApplicationException (javax.ws.rs.WebApplicationException)13 PersistencePolicies (com.yahoo.pulsar.common.policies.data.PersistencePolicies)12 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)10 SubscriptionBusyException (com.yahoo.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException)9