public void forEachEmitter(BiConsumer<URI, HttpPostEmitter> action) { emitters.forEach(action); }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { data.forEach(action); }
public void forEach(final BiConsumer<? super K, ? super V> action) { backingMap.forEach(action); }
public void forEach(BiConsumer<K, V> callable) { this.observers.forEach(callable); }
@Override public void resume() { consumers.forEach((name, consumer) -> consumer.resume()); }
@Override public void pause() { consumers.forEach((name, consumer) -> consumer.pause()); }
/** * Clears all entries from the map. This is not threadsafe, and requires external synchronization * to prevent concurrent modifications to the cache. */ public void clear() { mMap.forEach((key, value) -> { onCacheUpdate(key, value.mValue); onRemove(key); }); mMap.clear(); }
public synchronized void shutdown() { if (defaultCacheMonitorManager != null) { defaultCacheMonitorManager.stop(); } ConcurrentHashMap<String, Cache> m = cacheManager; cacheManager = null; m.forEach((k, c) -> c.close()); defaultCacheMonitorManager = null; }
public void close() { System.out.println("Closing all sockets..."); DefaultChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); userSession.forEach((userKey, session) -> { allChannels.addAll(session.appChannels); allChannels.addAll(session.hardwareChannels); }); allChannels.close().awaitUninterruptibly(); }
private void checkMap(UnboundedLocalCache<K, V> map, DescriptionBuilder desc) { if (map.isEmpty()) { desc.expectThat("empty map", map, emptyMap()); } map.data.forEach((key, value) -> { desc.expectThat("non null key", key, is(not(nullValue()))); desc.expectThat("non null value", value, is(not(nullValue()))); if (value instanceof CompletableFuture<?>) { CompletableFuture<?> future = (CompletableFuture<?>) value; boolean success = future.isDone() && !future.isCompletedExceptionally(); desc.expectThat("future is done", success, is(true)); desc.expectThat("not null value", future.getNow(null), is(not(nullValue()))); } }); }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { data.forEach(action); }
recoveryBallotBoxes.forEach((nearNodeId, ballotBox) -> {
private static void testForEach() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(); map.putIfAbsent("foo", "bar"); map.putIfAbsent("han", "solo"); map.putIfAbsent("r2", "d2"); map.putIfAbsent("c3", "p0"); map.forEach(1, (key, value) -> System.out.printf("key: %s; value: %s; thread: %s\n", key, value, Thread.currentThread().getName())); // map.forEach(5, (key, value) -> System.out.printf("key: %s; value: %s; thread: %s\n", key, value, Thread.currentThread().getName())); System.out.println(map.mappingCount()); }
private void executeTriggers(TransactionData txData, String phase) { if (triggers.containsKey("")) updateTriggers(null,null); GraphDatabaseService db = properties.getGraphDatabase(); Map<String,String> exceptions = new LinkedHashMap<>(); Map<String, Object> params = txDataParams(txData, phase); triggers.forEach((name, data) -> { if( data.get("paused").equals(false)) { if( data.get( "params" ) != null) { params.putAll( (Map<String,Object>) data.get( "params" ) ); } try (Transaction tx = db.beginTx()) { Map<String,Object> selector = (Map<String, Object>) data.get("selector"); if (when(selector, phase)) { params.put("trigger", name); Result result = db.execute((String) data.get("kernelTransaction"), params); Iterators.count(result); result.close(); } tx.success(); } catch(Exception e) { log.warn("Error executing trigger "+name+" in phase "+phase,e); exceptions.put(name, e.getMessage()); } } }); if (!exceptions.isEmpty()) { throw new RuntimeException("Error executing triggers "+exceptions.toString()); } }
private void writeMap() { // Files.write(path, "".getBytes(), StandardOpenOption.TRUNCATE_EXISTING); serviceNameToURI.forEach((k, v) -> { try { Files.write(path, (k + "=" + v + "\n").getBytes(), StandardOpenOption.APPEND); } catch (IOException ex) { throw new RuntimeException(ex); } }); } }
/*package-testing*/ static void clearLocksProcessState() { synchronized(sync) { try { locks.forEach((path,lock)->lock.free()); locks.clear(); } catch (Exception ex) { // Shouldn't happen - trace and then ignore. ex.printStackTrace(); } } }
@Override public Collection<CacheChannel.Region> regions() { Collection<CacheChannel.Region> regions = new ArrayList<>(); caches.forEach((k,c) -> regions.add(new CacheChannel.Region(k, c.size(), c.ttl()))); return regions; }
@Override public Collection<CacheChannel.Region> regions() { Collection<CacheChannel.Region> regions = new ArrayList<>(); caches.forEach((k,c) -> regions.add(new CacheChannel.Region(k, c.size(), c.ttl()))); return regions; }