private static Map<String, PropertyGetter> serialization( Class<? extends ObjectRepresentation> type ) { Map<String, PropertyGetter> serialization = serializations.computeIfAbsent( type, ObjectRepresentation::buildSerialization ); return serialization; }
ThreadPool getThreadPool( Group group ) { return pools.computeIfAbsent( group, poolBuilder ); }
private synchronized void compileColonPatterns() { if (colonsPat == null) { colonsPat = new Pattern[colons.length]; for (int i = 0; i < colons.length; i++) { Character colon = colons[i]; colonsPat[i] = patternMap.computeIfAbsent(WHITE + colon + WHITE, (s) -> Pattern.compile(s)); } } }
private synchronized void compileColonsWhitePatterns(String numPat) { if (colonsWhitePat == null) { colonsWhitePat = new Pattern[colons.length]; for (int i = 0; i < colons.length; i++) { Character colon = colons[i]; String pattern = "(" + numPat + ")" + WHITEPLUS + colon + WHITEPLUS + "(" + numPat + ")"; colonsWhitePat[i] = patternMap.computeIfAbsent(pattern, (s) -> Pattern.compile(s)); } } }
private T getLog( String name, Supplier<T> logSupplier ) { return logCache.computeIfAbsent( name, s -> logSupplier.get() ); }
@VisibleForTesting public void moveTaskGroupToPendingCompletion(int taskGroupId) { final TaskGroup taskGroup = activelyReadingTaskGroups.remove(taskGroupId); if (taskGroup != null) { pendingCompletionTaskGroups.computeIfAbsent(taskGroupId, k -> new CopyOnWriteArrayList<>()).add(taskGroup); } }
private Pattern[] compilePunctuationPatterns() { Pattern[] puncsPat = new Pattern[puncs.length]; for (int i = 0; i < puncs.length; i++) { Character punc = puncs[i]; puncsPat[i] = patternMap.computeIfAbsent(getEscapedPuncPattern(punc), (s) -> Pattern.compile(s)); } return puncsPat; }
private LocalizedResource getUserArchive(String user, String key) { assert user != null : "All user archives require a user present"; ConcurrentMap<String, LocalizedResource> keyToResource = userArchives.computeIfAbsent(user, (u) -> new ConcurrentHashMap<>()); return keyToResource.computeIfAbsent(key, (k) -> new LocalizedResource(key, localBaseDir, true, fsOps, conf, user, metricsRegistry)); }
/** * Go through all executors and time them out if needed. * @param topoId the id of the topology to look at. * @param taskTimeoutSecs the timeout to know if they are too old. */ public void timeoutOldHeartbeats(String topoId, Integer taskTimeoutSecs) { Map<List<Integer>, ExecutorCache> topoCache = cache.computeIfAbsent(topoId, MAKE_MAP); for (ExecutorCache ec : topoCache.values()) { ec.updateTimeout(taskTimeoutSecs); } }
@Override public BasicNettyOrigin getOrigin(String name, String vip, String uri, SessionContext ctx) { return originMappings.computeIfAbsent(name, n -> createOrigin(name, vip, uri, false, ctx)); }
public Timing get(String name) { return additionalTimings.computeIfAbsent(name, (newName) -> new Timing(newName)); }
private LocalizedResource getUserFile(String user, String key) { assert user != null : "All user archives require a user present"; ConcurrentMap<String, LocalizedResource> keyToResource = userFiles.computeIfAbsent(user, (u) -> new ConcurrentHashMap<>()); return keyToResource.computeIfAbsent(key, (k) -> new LocalizedResource(key, localBaseDir, false, fsOps, conf, user, metricsRegistry)); }
@Override public <R> R withLease(Function<LookupSourceLease, R> action) { lock.readLock().lock(); try { LookupSource lookupSource = suppliedLookupSources.computeIfAbsent(this, k -> lookupSourceSupplier.getLookupSource()); LookupSourceLease lease = new SpillAwareLookupSourceLease(lookupSource, spillingInfo); return action.apply(lease); } finally { lock.readLock().unlock(); } }
private boolean offer0(Channel channel, Object partitionKey, long now) { ConcurrentLinkedDeque<IdleChannel> partition = partitions.get(partitionKey); if (partition == null) { partition = partitions.computeIfAbsent(partitionKey, pk -> new ConcurrentLinkedDeque<>()); } return partition.offerFirst(new IdleChannel(channel, now)); }
@Override public @Nullable V putIfAbsent(K key, V value) { requireNonNull(value); boolean[] wasAbsent = new boolean[1]; V val = data.computeIfAbsent(key, k -> { writer.write(key, value); wasAbsent[0] = true; return value; }); return wasAbsent[0] ? null : val; }
@Override public BasicNettyOrigin getOrigin(String name, String vip, String uri, SessionContext ctx) { return originMappings.computeIfAbsent(name, n -> createOrigin(name, vip, uri, false, ctx)); }
public Timing get(String name) { return additionalTimings.computeIfAbsent(name, (newName) -> new Timing(newName)); }
@Override public long addMachine(MachineInfo machineInfo) { AppInfo appInfo = apps.computeIfAbsent(machineInfo.getApp(), app -> new AppInfo(app)); appInfo.addMachine(machineInfo); return 1; }
private void handleSubmission( BoltConnection connection ) { activeWorkItems.computeIfAbsent( connection.id(), key -> scheduleBatchOrHandleError( connection ).whenCompleteAsync( ( result, error ) -> handleCompletion( connection, result, error ), forkJoinPool ) ); }
@VisibleForTesting CompletableFuture<Void> requestDownloadBaseTopologyBlobs(PortAndAssignment pna, BlobChangingCallback cb) { final String topologyId = pna.getToplogyId(); final LocallyCachedBlob topoJar = getTopoJar(topologyId, pna.getAssignment().get_owner()); topoJar.addReference(pna, cb); final LocallyCachedBlob topoCode = getTopoCode(topologyId, pna.getAssignment().get_owner()); topoCode.addReference(pna, cb); final LocallyCachedBlob topoConf = getTopoConf(topologyId, pna.getAssignment().get_owner()); topoConf.addReference(pna, cb); return topologyBasicDownloaded.computeIfAbsent(topologyId, (tid) -> downloadOrUpdate(topoJar, topoCode, topoConf)); }