@Override public synchronized void addListener(String subject, Consumer<byte[]> listener) { listeners.computeIfAbsent(subject, s -> Sets.newCopyOnWriteArraySet()).add(listener); }
@Override public synchronized CompletableFuture<Void> addListener(String topic, LeadershipEventListener<byte[]> listener) { if (topicListeners.isEmpty()) { return getProxyClient().acceptBy(topic, service -> service.listen()) .thenRun(() -> topicListeners.computeIfAbsent(topic, t -> Sets.newCopyOnWriteArraySet()).add(listener)); } else { topicListeners.computeIfAbsent(topic, t -> Sets.newCopyOnWriteArraySet()).add(listener); } return CompletableFuture.completedFuture(null); }
@GwtIncompatible // CopyOnWriteArraySet public void testNewCOWASEmpty() { CopyOnWriteArraySet<Integer> set = Sets.newCopyOnWriteArraySet(); verifySetContents(set, EMPTY_COLLECTION); }
@GwtIncompatible // CopyOnWriteArraySet public void testNewCOWASFromIterable() { CopyOnWriteArraySet<Integer> set = Sets.newCopyOnWriteArraySet(SOME_ITERABLE); verifySetContents(set, SOME_COLLECTION); }
@Override public Set<Variable> get() { return Sets.newCopyOnWriteArraySet(); } });
private void checkUtilisedKeyAttributePaths() { if (utilisedKeyAttributePaths == null) { utilisedKeyAttributePaths = Sets.newCopyOnWriteArraySet(); } }
private void ensureAttributePaths() { if (attributePaths == null) { attributePaths = Sets.newCopyOnWriteArraySet(); } }
public Set<String> getRequiredGroups() { return Sets.newCopyOnWriteArraySet(requiredGroups); }
private Set<TypedStoredFlowEntry> getFlowEntriesInternal(FlowId flowId) { return flowEntries.computeIfAbsent(flowId, id -> Sets.newCopyOnWriteArraySet()); }
@Override public synchronized void addListener(String subject, Consumer<byte[]> listener) { listeners.computeIfAbsent(subject, s -> Sets.newCopyOnWriteArraySet()).add(listener); }
/** * Adds a new input component to the collection of input components of this component.<br> * Created by: tgaengler * * @param inputComponent a new input component */ public void addInputComponent(final Component inputComponent) { if (inputComponent != null) { if (inputComponents == null) { inputComponents = Sets.newCopyOnWriteArraySet(); } if (!inputComponents.contains(inputComponent)) { inputComponents.add(inputComponent); inputComponent.addOutputComponent(this); } } }
/** * Adds a new configuration to the collection of configurations of this resource.<br> * Created by: tgaengler * * @param configuration a new export definition revision */ public void addConfiguration(final Configuration configuration) { if (configuration != null) { if (configurations == null) { configurations = Sets.newCopyOnWriteArraySet(); } if (!configurations.contains(configuration)) { configurations.add(configuration); configuration.addResource(this); } } }
/** * Adds a new resource to the collection of resources of this configuration.<br> * Created by: tgaengler * * @param resource a new export definition revision */ public void addResource(final Resource resource) { if (resource != null) { if (resources == null) { resources = Sets.newCopyOnWriteArraySet(); } if (!resources.contains(resource)) { resources.add(resource); resource.addConfiguration(this); } } }
/** * Adds a new output component to the collection of output components of this component.<br> * Created by: tgaengler * * @param outputComponent a new output component */ public void addOutputComponent(final Component outputComponent) { if (outputComponent != null) { if (outputComponents == null) { outputComponents = Sets.newCopyOnWriteArraySet(); } if (!outputComponents.contains(outputComponent)) { outputComponents.add(outputComponent); outputComponent.addInputComponent(this); } } }
@Override public synchronized CompletableFuture<Void> addListener(String topic, LeadershipEventListener<byte[]> listener) { if (topicListeners.isEmpty()) { return getProxyClient().acceptBy(topic, service -> service.listen()) .thenRun(() -> topicListeners.computeIfAbsent(topic, t -> Sets.newCopyOnWriteArraySet()).add(listener)); } else { topicListeners.computeIfAbsent(topic, t -> Sets.newCopyOnWriteArraySet()).add(listener); } return CompletableFuture.completedFuture(null); }
public ZKBrokerService(ZKClient zkClient) { this.zkClient = zkClient; this.brokerInfos = CacheBuilder.newBuilder().build(createCacheLoader(new CacheInvalidater<BrokerId>() { @Override public void invalidate(BrokerId key) { brokerInfos.invalidate(key); } }, BrokerInfo.class)); this.partitionInfos = CacheBuilder.newBuilder().build(createCacheLoader( new CacheInvalidater<KeyPathTopicPartition>() { @Override public void invalidate(KeyPathTopicPartition key) { partitionInfos.invalidate(key); } }, PartitionInfo.class)); // Use CopyOnWriteArraySet so that it's thread safe and order of listener is maintain as the insertion order. this.listeners = Sets.newCopyOnWriteArraySet(); }
public ZKBrokerService(ZKClient zkClient) { this.zkClient = zkClient; this.brokerInfos = CacheBuilder.newBuilder().build(createCacheLoader(new CacheInvalidater<BrokerId>() { @Override public void invalidate(BrokerId key) { brokerInfos.invalidate(key); } }, BrokerInfo.class)); this.partitionInfos = CacheBuilder.newBuilder().build(createCacheLoader( new CacheInvalidater<KeyPathTopicPartition>() { @Override public void invalidate(KeyPathTopicPartition key) { partitionInfos.invalidate(key); } }, PartitionInfo.class)); // Use CopyOnWriteArraySet so that it's thread safe and order of listener is maintain as the insertion order. this.listeners = Sets.newCopyOnWriteArraySet(); }
/** * Replaces an existing resource, i.e., the resource with the same identifier will be replaced.<br> * Created by: tgaengler * * @param resource an existing, updated resource */ public void replaceResource(final Resource resource) { if (resource != null) { if (resources == null) { resources = Sets.newCopyOnWriteArraySet(); } if (resources.contains(resource)) { resources.remove(resource); } resources.add(resource); resource.removeConfiguration(this); resource.addConfiguration(this); } }
@GwtIncompatible // CopyOnWriteArraySet public void testNewCOWASEmpty() { CopyOnWriteArraySet<Integer> set = Sets.newCopyOnWriteArraySet(); verifySetContents(set, EMPTY_COLLECTION); }
@GwtIncompatible // CopyOnWriteArraySet public void testNewCOWASFromIterable() { CopyOnWriteArraySet<Integer> set = Sets.newCopyOnWriteArraySet(SOME_ITERABLE); verifySetContents(set, SOME_COLLECTION); }