public <K, V> void testSynchronizedMultimapSampleCodeCompilation() { K key = null; Multimap<K, V> multimap = Multimaps.synchronizedMultimap(HashMultimap.<K, V>create()); Collection<V> values = multimap.get(key); // Needn't be in synchronized block synchronized (multimap) { // Synchronizing on multimap, not values! Iterator<V> i = values.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } } }
public void testOrderingSynchronized() { Multimap<String, Integer> multimap = initializeMultimap5(); assertOrderingReadOnly(Multimaps.synchronizedMultimap(multimap)); }
@Inject public ConfigurationManager(ServiceProperties props) { this.serviceProps = props; this.callbackListeners = Multimaps.synchronizedMultimap(ArrayListMultimap.create()); this.lastProperties = new HashMap<>(props.getAllProperties()); }
public ElectionRegistry(ZKClient zkClient) { this.zkClient = zkClient; Multimap<String, LeaderElection> multimap = HashMultimap.create(); this.registry = Multimaps.synchronizedMultimap(multimap); }
public QueryStatsDClient(String queryId, String host, int port, int maxCacheSize) { this.queryId = queryId; this.host = host; this.port = port; this.maxCacheSize = maxCacheSize; Multimap<String,Long> temp = HashMultimap.create(); this.timings = Multimaps.synchronizedMultimap(temp); this.prefix = queryId + ".dwquery."; }
public ElectionRegistry(ZKClient zkClient) { this.zkClient = zkClient; Multimap<String, LeaderElection> multimap = HashMultimap.create(); this.registry = Multimaps.synchronizedMultimap(multimap); }
public WebSocketRegistryImpl() { this.idToSession = Maps.newConcurrentMap(); this.groupToId = Multimaps.synchronizedMultimap( HashMultimap.create() ); }
private ShortFormCache(int capacity) { this.entity2ShortFormMap = new ConcurrentHashMap<>(DEFAULT_CAPACITY); // It might be wasteful to build this map up front. It's only really used if // users edit the project. With large ontologies there could be an unfortable delay // after project load though. this.shortForm2EntityMap = Multimaps.synchronizedMultimap(HashMultimap.create(capacity, 1)); }
public InMemoryStreamMetaStore() { this.streams = Multimaps.synchronizedMultimap(HashMultimap.<String, String>create()); }
public WebSocketRegistryImpl() { this.idToSession = Maps.newConcurrentMap(); this.groupToId = Multimaps.synchronizedMultimap( HashMultimap.create() ); }
@Inject public MemoryNotificationRegistry(ZonedDateTimeProvider zonedDateTimeProvider) { this.zonedDateTimeProvider = zonedDateTimeProvider; this.registrations = Multimaps.synchronizedMultimap(HashMultimap.create()); }
public MailboxListenerRegistry() { this.globalListeners = new ConcurrentLinkedQueue<>(); this.listeners = Multimaps.synchronizedMultimap(HashMultimap.<MailboxPath, MailboxListener>create()); }
public ParameterServer() { tree = Maps.newConcurrentMap(); subscribers = Multimaps.synchronizedMultimap(HashMultimap.<GraphName, NodeIdentifier>create()); masterName = GraphName.of("/master"); }
private void refillCache() { try { logger.info("Starting filling TopicOwnerCache cache"); long start = System.currentTimeMillis(); Multimap<OwnerId, TopicName> cache = ArrayListMultimap.create(); groupService.listGroupNames().stream() .flatMap(groupName -> topicRepository.listTopics(groupName).stream()) .forEach(topic -> cache.put(topic.getOwner(), topic.getName())); this.cache = Multimaps.synchronizedMultimap(cache); long end = System.currentTimeMillis(); logger.info("TopicOwnerCache filled. Took {}ms", end - start); } catch (Exception e) { logger.error("Error while filling TopicOwnerCache", e); } }
public ArtifactoryBuildTriggerService(@NotNull final PluginDescriptor descriptor, @NotNull final WebControllerManager wcm, @NotNull final DeployableArtifactoryServers deployableServers) { this.deployableServers = deployableServers; this.watchedItems = HashMultimap.create(); this.watchedItems = Multimaps.synchronizedMultimap(watchedItems); actualUrl = descriptor.getPluginResourcesPath("editArtifactoryTrigger.html"); final String actualJsp = descriptor.getPluginResourcesPath("editArtifactoryTrigger.jsp"); wcm.registerController(actualUrl, new EditArtifactoryTriggerController(actualUrl, actualJsp, deployableServers)); }
private void refillCache() { try { logger.info("Starting filling SubscriptionOwnerCache"); long start = System.currentTimeMillis(); Multimap<OwnerId, SubscriptionName> cache = ArrayListMultimap.create(); topicService.getAllTopics().stream() .flatMap(topic -> subscriptionRepository.listSubscriptions(topic.getName()).stream()) .forEach(subscription -> cache.put(subscription.getOwner(), subscription.getQualifiedName())); this.cache = Multimaps.synchronizedMultimap(cache); long end = System.currentTimeMillis(); logger.info("SubscriptionOwnerCache filled. Took {}ms", end - start); } catch (Exception e) { logger.error("Error while filling SubscriptionOwnerCache", e); } } }
public <K, V> void testSynchronizedMultimapSampleCodeCompilation() { K key = null; Multimap<K, V> multimap = Multimaps.synchronizedMultimap( HashMultimap.<K, V>create()); Collection<V> values = multimap.get(key); // Needn't be in synchronized block synchronized (multimap) { // Synchronizing on multimap, not values! Iterator<V> i = values.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } } }
@Override @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { super.setUp(); mgmts = Lists.newCopyOnWriteArrayList(ImmutableList.<ManagementContext>of(origManagementContext)); machines = Multimaps.synchronizedMultimap(ArrayListMultimap.<ManagementContext, JcloudsSshMachineLocation>create()); }
public void testOrderingSynchronized() { Multimap<String, Integer> multimap = initializeMultimap5(); assertOrderingReadOnly(Multimaps.synchronizedMultimap(multimap)); }
@Override @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { super.setUp(); RecordingSshTool.clear(); RecordingWinRmTool.clear(); mgmts = Lists.newCopyOnWriteArrayList(ImmutableList.<ManagementContext>of(origManagementContext)); machines = Multimaps.synchronizedMultimap(ArrayListMultimap.<ManagementContext, JcloudsSshMachineLocation>create()); }