use of com.yahoo.pulsar.common.naming.DestinationName in project pulsar by yahoo.
the class PersistentTopicsImpl method getStatsAsync.
@Override
public CompletableFuture<PersistentTopicStats> getStatsAsync(String destination) {
DestinationName ds = validateTopic(destination);
final CompletableFuture<PersistentTopicStats> future = new CompletableFuture<>();
asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("stats"), new InvocationCallback<PersistentTopicStats>() {
@Override
public void completed(PersistentTopicStats response) {
future.complete(response);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of com.yahoo.pulsar.common.naming.DestinationName in project pulsar by yahoo.
the class PersistentTopicsImpl method getPartitionedTopicMetadataAsync.
@Override
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadataAsync(String destination) {
DestinationName ds = validateTopic(destination);
final CompletableFuture<PartitionedTopicMetadata> future = new CompletableFuture<>();
asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("partitions"), new InvocationCallback<PartitionedTopicMetadata>() {
@Override
public void completed(PartitionedTopicMetadata response) {
future.complete(response);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of com.yahoo.pulsar.common.naming.DestinationName in project pulsar by yahoo.
the class PersistentTopicsImpl method resetCursorAsync.
@Override
public CompletableFuture<Void> resetCursorAsync(String destination, String subName, long timestamp) {
DestinationName ds = validateTopic(destination);
String encodedSubName = Codec.encode(subName);
return asyncPostRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscription").path(encodedSubName).path("resetcursor").path(String.valueOf(timestamp)), Entity.entity("", MediaType.APPLICATION_JSON));
}
use of com.yahoo.pulsar.common.naming.DestinationName in project pulsar by yahoo.
the class BacklogQuotaManager method handleExceededBacklogQuota.
/**
* Handle exceeded backlog by using policies set in the zookeeper for given topic
*
* @param persistentTopic
* Topic on which backlog has been exceeded
*/
public void handleExceededBacklogQuota(PersistentTopic persistentTopic) {
DestinationName destination = DestinationName.get(persistentTopic.getName());
String namespace = destination.getNamespace();
String policyPath = AdminResource.path("policies", namespace);
BacklogQuota quota = getBacklogQuota(namespace, policyPath);
log.info("Backlog quota exceeded for topic [{}]. Applying [{}] policy", persistentTopic.getName(), quota.getPolicy());
switch(quota.getPolicy()) {
case consumer_backlog_eviction:
dropBacklog(persistentTopic, quota);
break;
case producer_exception:
case producer_request_hold:
disconnectProducers(persistentTopic);
break;
default:
break;
}
}
use of com.yahoo.pulsar.common.naming.DestinationName in project pulsar by yahoo.
the class BrokerService method removeTopicFromCache.
public void removeTopicFromCache(String topic) {
try {
DestinationName destination = DestinationName.get(topic);
NamespaceBundle namespaceBundle = pulsar.getNamespaceService().getBundle(destination);
checkArgument(namespaceBundle instanceof NamespaceBundle);
String bundleName = namespaceBundle.toString();
String namespaceName = destination.getNamespaceObject().toString();
synchronized (multiLayerTopicsMap) {
ConcurrentOpenHashMap<String, ConcurrentOpenHashMap<String, PersistentTopic>> namespaceMap = multiLayerTopicsMap.get(namespaceName);
ConcurrentOpenHashMap<String, PersistentTopic> bundleMap = namespaceMap.get(bundleName);
bundleMap.remove(topic);
if (bundleMap.isEmpty()) {
namespaceMap.remove(bundleName);
}
if (namespaceMap.isEmpty()) {
multiLayerTopicsMap.remove(namespaceName);
final ClusterReplicationMetrics clusterReplicationMetrics = pulsarStats.getClusterReplicationMetrics();
replicationClients.forEach((cluster, client) -> {
clusterReplicationMetrics.remove(clusterReplicationMetrics.getKeyName(namespaceName, cluster));
});
}
}
} catch (Exception e) {
log.warn("Got exception when retrieving bundle name during removeTopicFromCache", e);
}
topics.remove(topic);
}
Aggregations