public ClusterReplicationMetrics(String localCluster, boolean metricsEnabled) { metricsList = new ArrayList<>(); this.localCluster = localCluster; metricsMap = new ConcurrentOpenHashMap<>(); this.metricsEnabled = metricsEnabled; }
private static ConcurrentOpenHashMap<String, Field> prepareDynamicConfigurationMap() { ConcurrentOpenHashMap<String, Field> dynamicConfigurationMap = new ConcurrentOpenHashMap<>(); for (Field field : ServiceConfiguration.class.getDeclaredFields()) { if (field != null && field.isAnnotationPresent(FieldContext.class)) { field.setAccessible(true); if (((FieldContext) field.getAnnotation(FieldContext.class)).dynamic()) { dynamicConfigurationMap.put(field.getName(), field); } } } return dynamicConfigurationMap; }
private void addTopicToStatsMaps(DestinationName topicName, PersistentTopic topic) { try { NamespaceBundle namespaceBundle = pulsar.getNamespaceService().getBundle(topicName); if (namespaceBundle != null) { synchronized (multiLayerTopicsMap) { String serviceUnit = namespaceBundle.toString(); multiLayerTopicsMap // .computeIfAbsent(topicName.getNamespace(), k -> new ConcurrentOpenHashMap<>()) // .computeIfAbsent(serviceUnit, k -> new ConcurrentOpenHashMap<>()) // .put(topicName.toString(), topic); } } invalidateOfflineTopicStatCache(topicName); } catch (Exception e) { log.warn("Got exception when retrieving bundle name during create persistent topic", e); } }
this.port = new URI(pulsar.getBrokerServiceUrl()).getPort(); this.tlsPort = new URI(pulsar.getBrokerServiceUrlTls()).getPort(); this.topics = new ConcurrentOpenHashMap<>(); this.replicationClients = new ConcurrentOpenHashMap<>(); this.keepAliveIntervalSeconds = pulsar.getConfiguration().getKeepAliveIntervalSeconds(); this.configRegisteredListeners = new ConcurrentOpenHashMap<>(); this.pendingTopicLoadingQueue = Queues.newConcurrentLinkedQueue(); this.multiLayerTopicsMap = new ConcurrentOpenHashMap<>(); this.pulsarStats = new PulsarStats(pulsar); this.offlineTopicStatCache = new ConcurrentOpenHashMap<>();
final CountDownLatch allCursorsCounter = new CountDownLatch(1); final long errorInReadingCursor = (long) -1; ConcurrentOpenHashMap<String, Long> ledgerRetryMap = new ConcurrentOpenHashMap<>();
public PersistentTopic(String topic, ManagedLedger ledger, BrokerService brokerService) { this.topic = topic; this.ledger = ledger; this.brokerService = brokerService; this.producers = new ConcurrentOpenHashSet<Producer>(); this.subscriptions = new ConcurrentOpenHashMap<>(); this.replicators = new ConcurrentOpenHashMap<>(); this.isFenced = false; this.replicatorPrefix = brokerService.pulsar().getConfiguration().getReplicatorPrefix(); USAGE_COUNT_UPDATER.set(this, 0); for (ManagedCursor cursor : ledger.getCursors()) { if (cursor.getName().startsWith(replicatorPrefix)) { String localCluster = brokerService.pulsar().getConfiguration().getClusterName(); String remoteCluster = PersistentReplicator.getRemoteCluster(cursor.getName()); replicators.put(remoteCluster, new PersistentReplicator(this, cursor, localCluster, remoteCluster, brokerService)); } else { final String subscriptionName = Codec.decode(cursor.getName()); subscriptions.put(subscriptionName, new PersistentSubscription(this, subscriptionName, cursor)); // subscription-cursor gets activated by default: deactivate as there is no active subscription right // now subscriptions.get(subscriptionName).deactivateCursor(); } } this.lastActive = System.nanoTime(); }