public void clear() { writeLock.lock(); try { messageIdPartitionMap.clear(); timePartitions.clear(); int blankPartitions = (int)Math.ceil((double)ackTimeoutMillis / tickDurationInMs); for (int i = 0; i < blankPartitions + 1; i++) { timePartitions.add(new ConcurrentOpenHashSet<>()); } } finally { writeLock.unlock(); } }
@Override public void run(Timeout t) throws Exception { Set<MessageId> messageIds = new HashSet<>(); writeLock.lock(); try { timePartitions.addLast(new ConcurrentOpenHashSet<>()); ConcurrentOpenHashSet<MessageId> headPartition = timePartitions.removeFirst(); if (!headPartition.isEmpty()) { log.warn("[{}] {} messages have timed-out", consumerBase, timePartitions.size()); headPartition.forEach(messageId -> { messageIds.add(messageId); messageIdPartitionMap.remove(messageId); }); } } finally { writeLock.unlock(); } if (messageIds.size() > 0) { consumerBase.redeliverUnacknowledgedMessages(messageIds); } timeout = client.timer().newTimeout(this, tickDurationInMs, TimeUnit.MILLISECONDS); } }, this.tickDurationInMs, TimeUnit.MILLISECONDS);
timePartitions.add(new ConcurrentOpenHashSet<>());
public UnAckedMessageTracker(PulsarClientImpl client, ConsumerBase<?> consumerBase, long ackTimeoutMillis) { currentSet = new ConcurrentOpenHashSet<MessageId>(); oldOpenSet = new ConcurrentOpenHashSet<MessageId>(); readWriteLock = new ReentrantReadWriteLock(); readLock = readWriteLock.readLock(); writeLock = readWriteLock.writeLock(); start(client, consumerBase, ackTimeoutMillis); }
public boolean addConsumer(ConsumerHandler consumer) { return topicConsumerMap .computeIfAbsent(consumer.getConsumer().getTopic(), topic -> new ConcurrentOpenHashSet<>()) .add(consumer); }
public boolean addProducer(ProducerHandler producer) { return topicProducerMap .computeIfAbsent(producer.getProducer().getTopic(), topic -> new ConcurrentOpenHashSet<>()) .add(producer); }
public boolean addReader(ReaderHandler reader) { return topicReaderMap.computeIfAbsent(reader.getConsumer().getTopic(), topic -> new ConcurrentOpenHashSet<>()) .add(reader); }
public NonPersistentTopic(String topic, BrokerService brokerService) { this.topic = topic; this.brokerService = brokerService; this.producers = new ConcurrentOpenHashSet<Producer>(16, 1); this.subscriptions = new ConcurrentOpenHashMap<>(16, 1); this.replicators = new ConcurrentOpenHashMap<>(16, 1); this.isFenced = false; this.replicatorPrefix = brokerService.pulsar().getConfiguration().getReplicatorPrefix(); this.executor = brokerService.getTopicOrderedExecutor(); USAGE_COUNT_UPDATER.set(this, 0); this.lastActive = System.nanoTime(); try { Policies policies = brokerService.pulsar().getConfigurationCache().policiesCache() .get(AdminResource.path(POLICIES, TopicName.get(topic).getNamespace())) .orElseThrow(() -> new KeeperException.NoNodeException()); isEncryptionRequired = policies.encryption_required; } catch (Exception e) { log.warn("[{}] Error getting policies {} and isEncryptionRequired will be set to false", topic, e.getMessage()); isEncryptionRequired = false; } }
this.blockedDispatchers = new ConcurrentOpenHashSet<>();
this.ledger = ledger; this.brokerService = brokerService; this.producers = new ConcurrentOpenHashSet<Producer>(16, 1); this.subscriptions = new ConcurrentOpenHashMap<>(16, 1); this.replicators = new ConcurrentOpenHashMap<>(16, 1);