Search in sources :

Example 6 with DestinationName

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

the class PersistentTopicsImpl method grantPermission.

@Override
public void grantPermission(String destination, String role, Set<AuthAction> actions) throws PulsarAdminException {
    try {
        DestinationName ds = DestinationName.get(destination);
        request(persistentTopics.path(ds.getNamespace()).path(ds.getLocalName()).path("permissions").path(role)).post(Entity.entity(actions, MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) ServerErrorException(javax.ws.rs.ServerErrorException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 7 with DestinationName

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

the class PersistentTopicsImpl method expireMessagesAsync.

@Override
public CompletableFuture<Void> expireMessagesAsync(String destination, String subName, long expireTimeInSeconds) {
    DestinationName ds = validateTopic(destination);
    String encodedSubName = Codec.encode(subName);
    return asyncPostRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscription").path(encodedSubName).path("expireMessages").path(String.valueOf(expireTimeInSeconds)), Entity.entity("", MediaType.APPLICATION_JSON));
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName)

Example 8 with DestinationName

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

the class PersistentTopicsImpl method revokePermissions.

@Override
public void revokePermissions(String destination, String role) throws PulsarAdminException {
    try {
        DestinationName ds = DestinationName.get(destination);
        request(persistentTopics.path(ds.getNamespace()).path(ds.getLocalName()).path("permissions").path(role)).delete(ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) ServerErrorException(javax.ws.rs.ServerErrorException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 9 with DestinationName

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

the class PersistentTopicsImpl method skipAllMessagesAsync.

@Override
public CompletableFuture<Void> skipAllMessagesAsync(String destination, String subName) {
    DestinationName ds = validateTopic(destination);
    String encodedSubName = Codec.encode(subName);
    return asyncPostRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscription").path(encodedSubName).path("skip_all"), Entity.entity("", MediaType.APPLICATION_JSON));
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName)

Example 10 with DestinationName

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

the class PersistentTopicsImpl method getSubscriptionsAsync.

@Override
public CompletableFuture<List<String>> getSubscriptionsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscriptions"), 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;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) List(java.util.List)

Aggregations

DestinationName (com.yahoo.pulsar.common.naming.DestinationName)91 Test (org.testng.annotations.Test)36 PulsarClientException (com.yahoo.pulsar.client.api.PulsarClientException)33 PersistentTopic (com.yahoo.pulsar.broker.service.persistent.PersistentTopic)26 CompletableFuture (java.util.concurrent.CompletableFuture)24 KeeperException (org.apache.zookeeper.KeeperException)23 PreconditionFailedException (com.yahoo.pulsar.client.admin.PulsarAdminException.PreconditionFailedException)22 WebApplicationException (javax.ws.rs.WebApplicationException)21 IOException (java.io.IOException)20 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)19 RestException (com.yahoo.pulsar.broker.web.RestException)18 NotFoundException (com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException)18 PartitionedTopicMetadata (com.yahoo.pulsar.common.partition.PartitionedTopicMetadata)17 SubscriptionBusyException (com.yahoo.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException)16 TopicBusyException (com.yahoo.pulsar.broker.service.BrokerServiceException.TopicBusyException)16 Path (javax.ws.rs.Path)16 NotAllowedException (com.yahoo.pulsar.broker.service.BrokerServiceException.NotAllowedException)14 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 Field (java.lang.reflect.Field)14