@Override public synchronized void forEach( BiConsumer<? super Object, ? super Object> action ) { storageMap.forEach( action ); }
void forEach(BiConsumer<? super TableId, ? super TableImpl> action) { values.forEach(action); }
@Override public void entries(Handler<AsyncResult<Map<K, V>>> asyncResultHandler) { Map<K, V> result = new HashMap<>(map.size()); map.forEach((key, holder) -> { if (holder.hasNotExpired()) { result.put(key, holder.value); } }); asyncResultHandler.handle(Future.succeededFuture(result)); }
/** * Invalidate the cache, and call the action on the elements, if additional cleanup is required. */ public void clear(BiConsumer<? super K, ? super V> action) { cacheL1.invalidateAll(); cacheL2.asMap().forEach(action); cacheL2.invalidateAll(); }
/** * Mostly for checkpoints to serialize index-specific settings into the index header. */ public void visitIndexSpecificSettings( SettingVisitor visitor ) { visitor.count( specificIndexConfigCache.size() ); specificIndexConfigCache.forEach( visitor::visit ); }
/** Returns locks that have been successfully acquired */ protected synchronized List<Tuple<String,Owner>> getLockInfo() { List<Tuple<String,Owner>> l=new ArrayList<>(); // table.forEach((key, value) -> value.keySet().forEach(owner -> l.add(new Tuple<>(key, owner)))); table.forEach((k,v) -> v.forEach((owner, cl) -> { if(cl.acquired && !cl.denied) l.add(new Tuple<>(k, owner)); })); return l; }
/** * Gets services received to deploy from node with given id on joining. * * @param nodeId Joined node id. * @return Services to deploy. */ @NotNull Map<IgniteUuid, ServiceInfo> servicesReceivedFromJoin(UUID nodeId) { Map<IgniteUuid, ServiceInfo> descs = new HashMap<>(); registeredServices.forEach((srvcId, desc) -> { if (desc.staticallyConfigured() && desc.originNodeId().equals(nodeId)) descs.put(srvcId, desc); }); return descs; }
@Override public void updateState() { evictionTriggerMap.forEach((k, v) -> { final int ackCounter = v.removeDroppedInstances(); if (ackCounter == 0) { v.runTriggers(); } }); }
private Map<String, SubTaskSpecStatus> buildStateMap() { final Map<String, SubTaskSpecStatus> stateMap = new HashMap<>(); subTaskSpecs.forEach((specId, spec) -> { final List<TaskStatusPlus> taskHistory = taskHistories.get(specId); final TaskStatusPlus runningTaskStatus = runningSpecs.get(specId); stateMap.put( specId, new SubTaskSpecStatus(spec, runningTaskStatus, taskHistory == null ? Collections.emptyList() : taskHistory) ); }); return stateMap; }
/** * Peek the information for all the available entities of the current window. * * @return A map from all the entities to their current metric values. */ public Map<E, ValuesAndExtrapolations> peekCurrentWindow() { // prevent window rolling. _windowRollingLock.lock(); try { Map<E, ValuesAndExtrapolations> result = new HashMap<>(); _rawMetrics.forEach((entity, rawMetric) -> { ValuesAndExtrapolations vae = rawMetric.peekCurrentWindow(_currentWindowIndex, _metricDef); SortedSet<Long> currentWindows = new TreeSet<>(Collections.singleton(_currentWindowIndex)); vae.setWindows(toWindows(currentWindows)); result.put(entity, vae); }); return result; } finally { _windowRollingLock.unlock(); } }
private void resubscribe() { if (subscribedQueries.isEmpty() || subscribing) { return; } try { StreamObserver<QueryProviderOutbound> subscriberStreamObserver = getSubscriberObserver(); subscribedQueries.forEach((queryDefinition, handlers) -> subscriberStreamObserver.onNext(QueryProviderOutbound.newBuilder().setSubscribe( subscriptionBuilder(queryDefinition, handlers.size()) ).build()) ); } catch (Exception ex) { logger.warn("Error while resubscribing - {}", ex.getMessage()); } }
protected synchronized List<Request> getPendingRequests(Address sender) { List<Request> list=new ArrayList<>(); // add the pending LOCK requests table.forEach((k,v) -> v.forEach((owner, cl) -> { if(!cl.acquired && !cl.denied) { Request req=new Request(Type.GRANT_LOCK, cl.name, owner, cl.timeout, cl.is_trylock).lockId(cl.lock_id); list.add(req); } })); // add the pending UNLOCK requests pending_release_reqs.forEach(cl -> { if(cl.acquired && !cl.denied) { Request req=new Request(Type.RELEASE_LOCK, cl.name, cl.owner, cl.timeout, cl.is_trylock) .lockId(cl.lock_id).sender(sender); list.add(req); } }); return list; }
@Override public Task<Void> flush(Actor actor) { final RemoteReference actorReference = (RemoteReference) actor; masterCache.asMap().forEach((method, cache) -> { cache.invalidate(actorReference); }); return Task.done(); }
@Override public StandardRepositoryStatusReport reportTransferEvents(final long sinceEpochMillis) { final StandardRepositoryStatusReport report = new StandardRepositoryStatusReport(); componentEventMap.forEach((componentId, container) -> report.addReportEntry(container.generateReport(sinceEpochMillis), componentId)); return report; }
@SuppressWarnings("Duplicates") @Override protected void shutDown() throws Exception { eventBus.unregister(this); // take all tables offline liveTables.clear(); // take the caches and adapters offline and de-register their name/id mappings liveCaches.forEach((name, cache) -> { cache.addListener(new Listener() { @Override public void terminated(State from) { idToCache.remove(cache.id()); liveCaches.remove(name); } }, scheduler); cache.stopAsync(); }); liveAdapters.forEach((name, adapter) -> { adapter.addListener(new Listener() { @Override public void terminated(State from) { idToAdapter.remove(adapter.id()); liveAdapters.remove(name); } }, scheduler); adapter.stopAsync(); }); // Stop data adapter refresh service adapterRefreshService.stopAsync(); }
private void flush() { LOG.debug("Flushing modified partitions"); cache.asMap().forEach((pid, p) -> { Long pidToInvalidate = null; try {
private void unsubscribeAll() { subscribedQueries.forEach((d, count) -> { try { getSubscriberObserver().onNext(QueryProviderOutbound.newBuilder().setUnsubscribe( subscriptionBuilder(d, 1) ).build()); } catch (Exception ignored) { } }); outboundStreamObserver = null; }
public void setContext() { if (!isContextReady) return; if (contextMap == null) contextMap = api.getContextMap(); contextMap.forEach(MDC::put); }
public Map<String, ComputedNodeStats> getAllNodeStatistics() { final int clientNum = nodeIdToStats.size(); // Transform the mutable object internally used for accounting into the computed version Map<String, ComputedNodeStats> nodeStats = new HashMap<>(nodeIdToStats.size()); nodeIdToStats.forEach((k, v) -> { nodeStats.put(k, new ComputedNodeStats(clientNum, v)); }); return nodeStats; }
@Override public void clear() { handlers.forEach((s, handler) -> { try { handler.stop(); handlers.remove(handler.contextPath()); } catch (Exception e) { logger.error("Unable to un-register handler", e); } }); contextPaths.clear(); }