Codota Logo
ConcurrentOpenHashMap
Code IndexAdd Codota to your IDE (free)

How to use
ConcurrentOpenHashMap
in
com.yahoo.pulsar.common.util.collections

Best Java code snippets using com.yahoo.pulsar.common.util.collections.ConcurrentOpenHashMap (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: com.yahoo.pulsar/pulsar-common

public List<V> values() {
  List<V> values = Lists.newArrayList();
  forEach((key, value) -> values.add(value));
  return values;
}
origin: com.yahoo.pulsar/pulsar-broker

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;
}
origin: com.yahoo.pulsar/pulsar-broker

public PersistentReplicator getPersistentReplicator(String remoteCluster) {
  return replicators.get(remoteCluster);
}
origin: com.yahoo.pulsar/pulsar-broker

public int getNumberOfNamespaceBundles() {
  this.numberOfNamespaceBundles = 0;
  this.multiLayerTopicsMap.forEach((namespaceName, bundles) -> {
    this.numberOfNamespaceBundles += bundles.size();
  });
  return this.numberOfNamespaceBundles;
}
origin: com.yahoo.pulsar/pulsar-broker

public List<PersistentTopic> getAllTopicsFromNamespaceBundle(String namespace, String bundle) {
  return multiLayerTopicsMap.get(namespace).get(bundle).values();
}

origin: com.yahoo.pulsar/pulsar-common

  private static <K, V> void insertKeyValueNoLock(Object[] table, int capacity, K key, V value) {
    int bucket = signSafeMod(hash(key), capacity);
    while (true) {
      K storedKey = (K) table[bucket];
      if (storedKey == EmptyKey) {
        // The bucket is empty, so we can use it
        table[bucket] = key;
        table[bucket + 1] = value;
        return;
      }
      bucket = (bucket + 2) & (table.length - 1);
    }
  }
}
origin: com.yahoo.pulsar/pulsar-broker

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);
}
origin: com.yahoo.pulsar/managed-ledger

final CountDownLatch allCursorsCounter = new CountDownLatch(1);
final long errorInReadingCursor = (long) -1;
ConcurrentOpenHashMap<String, Long> ledgerRetryMap = new ConcurrentOpenHashMap<>();
if (accurate && ledgerRetryMap.size() > 0) {
  ledgerRetryMap.forEach((cursorName, ledgerId) -> {
    if (log.isDebugEnabled()) {
      log.debug("Cursor {} Ledger {} Trying to obtain MD from BkAdmin", cursorName, ledgerId);
origin: com.yahoo.pulsar/pulsar-broker

topicsMap.forEach((namespaceName, bundles) -> {
  if (bundles.isEmpty()) {
    return;
    bundles.forEach((bundle, topics) -> {
      NamespaceBundleStats currentBundleStats = bundleStats.computeIfAbsent(bundle,
          k -> new NamespaceBundleStats());
      currentBundleStats.reset();
      currentBundleStats.topics = topics.size();
      topics.forEach((name, topic) -> {
        try {
          topic.updateRates(nsStats, currentBundleStats, topicStatsStream,
origin: com.yahoo.pulsar/pulsar-broker

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();
}
origin: com.yahoo.pulsar/pulsar-common

public V remove(K key) {
  checkNotNull(key);
  long h = hash(key);
  return getSection(h).remove(key, null, (int) h);
}
origin: com.yahoo.pulsar/pulsar-broker

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);
  }
}
origin: com.yahoo.pulsar/pulsar-broker

public CompletableFuture<Topic> getTopic(final String topic) {
  try {
    CompletableFuture<Topic> topicFuture = topics.get(topic);
    if (topicFuture != null) {
      if (topicFuture.isCompletedExceptionally()) {
        // Exceptional topics should be recreated.
        topics.remove(topic, topicFuture);
      } else {
        return topicFuture;
      }
    }
    return topics.computeIfAbsent(topic, this::createPersistentTopic);
  } catch (IllegalArgumentException e) {
    log.warn("[{}] Illegalargument exception when loading topic", topic, e);
    return failedFuture(e);
  } catch (RuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof ServiceUnitNotReadyException) {
      log.warn("[{}] Service unit is not ready when loading the topic", topic);
    } else {
      log.warn("[{}] Unexpected exception when loading topic: {}", topic, cause);
    }
    return failedFuture(cause);
  }
}
origin: com.yahoo.pulsar/pulsar-broker

if (!subscriptions.isEmpty()) {
  isFenced = false;
  deleteFuture.completeExceptionally(new TopicBusyException("Topic has subscriptions"));
subscriptions.forEach((s, sub) -> futures.add(sub.delete()));
origin: com.yahoo.pulsar/pulsar-broker

  if (!replicators.containsKey(cluster)) {
    futures.add(startReplicator(cluster));
replicators.forEach((cluster, replicator) -> {
origin: com.yahoo.pulsar/pulsar-broker

public void remove(String namespaceCluster) {
  ReplicationMetrics replicationMetrics = metricsMap.get(namespaceCluster);
  if (replicationMetrics != null) {
    replicationMetrics.recycle();
    metricsMap.remove(namespaceCluster);
  }
}
origin: com.yahoo.pulsar/pulsar-broker

public PulsarClient getReplicationClient(String cluster) {
  PulsarClient client = replicationClients.get(cluster);
  if (client != null) {
    return client;
  }
  return replicationClients.computeIfAbsent(cluster, key -> {
    try {
      String path = PulsarWebResource.path("clusters", cluster);
      ClusterData data = this.pulsar.getConfigurationCache().clustersCache().get(path)
          .orElseThrow(() -> new KeeperException.NoNodeException(path));
      ClientConfiguration configuration = new ClientConfiguration();
      configuration.setUseTcpNoDelay(false);
      configuration.setConnectionsPerBroker(pulsar.getConfiguration().getReplicationConnectionsPerBroker());
      configuration.setStatsInterval(0, TimeUnit.SECONDS);
      if (pulsar.getConfiguration().isAuthenticationEnabled()) {
        configuration.setAuthentication(pulsar.getConfiguration().getBrokerClientAuthenticationPlugin(),
            pulsar.getConfiguration().getBrokerClientAuthenticationParameters());
      }
      String clusterUrl = configuration.isUseTls()
          ? (isNotBlank(data.getBrokerServiceUrlTls()) ? data.getBrokerServiceUrlTls()
              : data.getServiceUrlTls())
          : null;
      clusterUrl = (isNotBlank(clusterUrl)) ? clusterUrl
          : (isNotBlank(data.getBrokerServiceUrl()) ? data.getBrokerServiceUrl() : data.getServiceUrl());
      return new PulsarClientImpl(clusterUrl, configuration, this.workerGroup);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  });
}
origin: com.yahoo.pulsar/pulsar-broker

public ClusterReplicationMetrics(String localCluster, boolean metricsEnabled) {
  metricsList = new ArrayList<>();
  this.localCluster = localCluster;
  metricsMap = new ConcurrentOpenHashMap<>();
  this.metricsEnabled = metricsEnabled;
}
origin: com.yahoo.pulsar/pulsar-broker

private CompletableFuture<? extends Subscription> getNonDurableSubscription(String subscriptionName, MessageId startMessageId) {
  CompletableFuture<Subscription> subscriptionFuture = new CompletableFuture<>();
  Subscription subscription = subscriptions.computeIfAbsent(subscriptionName, name -> {
    // Create a new non-durable cursor only for the first consumer that connects
    MessageIdImpl msgId = startMessageId != null ? (MessageIdImpl) startMessageId
        : (MessageIdImpl) MessageId.latest;
    Position startPosition = new PositionImpl(msgId.getLedgerId(), msgId.getEntryId());
    ManagedCursor cursor = null;
    try {
      cursor = ledger.newNonDurableCursor(startPosition);
    } catch (ManagedLedgerException e) {
      subscriptionFuture.completeExceptionally(e);
    }
    return new PersistentSubscription(this, subscriptionName, cursor);
  });
  if (!subscriptionFuture.isDone()) {
    subscriptionFuture.complete(subscription);
  } else {
    // failed to initialize managed-cursor: clean up created subscription
    subscriptions.remove(subscriptionName);
  }
  return subscriptionFuture;
}
origin: com.yahoo.pulsar/pulsar-broker

@Override
public void openCursorComplete(ManagedCursor cursor, Object ctx) {
  if (log.isDebugEnabled()) {
    log.debug("[{}][{}] Opened cursor", topic, subscriptionName);
  }
  subscriptionFuture.complete(subscriptions.computeIfAbsent(subscriptionName,
      name -> new PersistentSubscription(PersistentTopic.this, subscriptionName, cursor)));
}
com.yahoo.pulsar.common.util.collectionsConcurrentOpenHashMap

Javadoc

Concurrent hash map Provides similar methods as a ConcurrentMap but since it's an open hash map with linear probing, no node allocations are required to store the values

Most used methods

  • forEach
  • <init>
  • get
  • size
  • computeIfAbsent
  • containsKey
  • getSection
  • hash
  • isEmpty
  • keys
  • put
  • remove
  • put,
  • remove,
  • signSafeMod,
  • values

Popular in Java

  • Finding current android device location
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now