public static boolean isDynamicConfiguration(String key) { return dynamicConfigurationMap.containsKey(key); }
public static boolean validateDynamicConfiguration(String key, String value) { if (dynamicConfigurationMap.containsKey(key) && dynamicConfigurationMap.get(key).validator != null) { return dynamicConfigurationMap.get(key).validator.test(value); } return true; }
private void addDynamicConfigValidator(String key, Predicate<String> validator) { validateConfigKey(key); if (dynamicConfigurationMap.containsKey(key)) { dynamicConfigurationMap.get(key).validator = validator; } }
public boolean removeReader(ReaderHandler reader) { final String topicName = reader.getConsumer().getTopic(); if (topicReaderMap.containsKey(topicName)) { return topicReaderMap.get(topicName).remove(reader); } return false; }
public boolean removeProducer(ProducerHandler producer) { final String topicName = producer.getProducer().getTopic(); if (topicProducerMap.containsKey(topicName)) { return topicProducerMap.get(topicName).remove(producer); } return false; }
public boolean removeConsumer(ConsumerHandler consumer) { final String topicName = consumer.getConsumer().getTopic(); if (topicConsumerMap.containsKey(topicName)) { return topicConsumerMap.get(topicName).remove(consumer); } return false; }
configCache.get().forEach((key, value) -> { if (dynamicConfigurationMap.containsKey(key) && dynamicConfigurationMap.get(key).validator != null) { if (!dynamicConfigurationMap.get(key).validator.test(value)) { log.error("Failed to validate dynamic config {} with value {}", key, value);
private ProxyTopicStat getStat(TopicName topicName) { String topicNameStr = topicName.toString(); if (!service().getProducers().containsKey(topicNameStr) && !service().getConsumers().containsKey(topicNameStr) && !service().getReaders().containsKey(topicNameStr)) { LOG.warn("topic doesn't exist {}", topicNameStr); throw new RestException(Status.NOT_FOUND, "Topic does not exist"); } ProxyTopicStat topicStat = new ProxyTopicStat(); if (service().getProducers().containsKey(topicNameStr)) { service().getProducers().get(topicNameStr).forEach(handler -> { ProducerStats stat = new ProducerStats(handler); topicStat.producerStats.add(stat); }); } if (service().getConsumers().containsKey(topicNameStr)) { service().getConsumers().get(topicNameStr).forEach(handler -> { topicStat.consumerStats.add(new ConsumerStats(handler)); }); } if (service().getReaders().containsKey(topicNameStr)) { service().getReaders().get(topicNameStr).forEach(handler -> { topicStat.consumerStats.add(new ConsumerStats(handler)); }); } return topicStat; }
if (topic.getSubscriptions().containsKey(subscriptionName)) { throw new RestException(Status.CONFLICT, "Subscription already exists for topic");
if (!replicators.containsKey(cluster)) { futures.add(startReplicator(cluster));
if (!replicators.containsKey(cluster)) { if (!startReplicator(cluster)) {
public List<String> getListOfNonPersistentTopics(NamespaceName namespaceName) throws Exception { List<String> topics = Lists.newArrayList(); ClusterData peerClusterData; try { peerClusterData = PulsarWebResource.checkLocalOrGetPeerReplicationCluster(pulsar, namespaceName) .get(cacheTimeOutInSec, SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Failed to contact peer replication cluster.", e); } // if peer-cluster-data is present it means namespace is owned by that peer-cluster and request should be // redirect to the peer-cluster if (peerClusterData != null) { return getNonPersistentTopicsFromPeerCluster(peerClusterData, namespaceName); } // Non-persistent topics don't have managed ledgers so we have to retrieve them from local cache. synchronized (pulsar.getBrokerService().getMultiLayerTopicMap()) { if (pulsar.getBrokerService().getMultiLayerTopicMap().containsKey(namespaceName.toString())) { pulsar.getBrokerService().getMultiLayerTopicMap().get(namespaceName.toString()).values() .forEach(bundle -> { bundle.forEach((topicName, topic) -> { if (topic instanceof NonPersistentTopic && ((NonPersistentTopic)topic).isActive()) { topics.add(topicName); } }); }); } } topics.sort(null); return topics; }