/** * Adds a collection of players to this boss bar. * * @param players The players to add * @return This boss bar */ default ServerBossBar addPlayers(Collection<Player> players) { checkNotNull(players, "players"); ImmutableSet.copyOf(players).forEach(this::addPlayer); return this; }
/** * Removes a collection of players from this boss bar. * * @param players The players to remove * @return This boss bar */ default ServerBossBar removePlayers(Collection<Player> players) { checkNotNull(players, "players"); ImmutableSet.copyOf(players).forEach(this::removePlayer); return this; }
partitionNamesToQuery.build().forEach(partitionName -> resultBuilder.put(partitionName, PartitionStatistics.empty()));
@Subscribe public void handleAdapterUpdate(DataAdaptersUpdated updated) { scheduler.schedule(() -> { // when a data adapter is updated, the lookup tables that use it need to be updated as well // first we create the new adapter instance and start it // then we retrieve the old one so we can safely stop it later // then we build a new lookup table instance with the new adapter instance // last we can remove the old lookup table instance and stop the original adapter final Collection<LookupTableDto> tablesToUpdate = dbTables.findByDataAdapterIds(updated.ids()); // collect old adapter instances final ImmutableSet.Builder<LookupDataAdapter> existingAdapters = ImmutableSet.builder(); // create new adapter and lookup table instances final Set<LookupDataAdapter> newAdapters = dbAdapters.findByIds(updated.ids()).stream() .map(dto -> createAdapter(dto, existingAdapters)) .filter(Objects::nonNull) .collect(Collectors.toSet()); final CountDownLatch runningLatch = new CountDownLatch(newAdapters.size()); newAdapters.forEach(adapter -> { adapter.addListener(new LatchUpdaterListener(runningLatch), scheduler); adapter.startAsync(); }); // wait until everything is either running or failed before starting the awaitUninterruptibly(runningLatch); tablesToUpdate.forEach(this::createLookupTable); // stop old adapters existingAdapters.build().forEach(AbstractIdleService::stopAsync); }, 0, TimeUnit.SECONDS); }
@Subscribe public void handleCacheUpdate(CachesUpdated updated) { scheduler.schedule(() -> { // when a cache is updated, the lookup tables that use it need to be updated as well // first we create the new cache instance and start it // then we retrieve the old one so we can safely stop it later // then we build a new lookup table instance with the new cache instance // last we can remove the old lookup table instance and stop the original cache final Collection<LookupTableDto> tablesToUpdate = dbTables.findByCacheIds(updated.ids()); // collect old cache instances final ImmutableSet.Builder<LookupCache> existingCaches = ImmutableSet.builder(); // create new cache and lookup table instances final Set<LookupCache> newCaches = dbCaches.findByIds(updated.ids()).stream() .map(dto -> createCache(dto, existingCaches)) .filter(Objects::nonNull) .collect(Collectors.toSet()); final CountDownLatch runningLatch = new CountDownLatch(newCaches.size()); newCaches.forEach(cache -> { cache.addListener(new LatchUpdaterListener(runningLatch), scheduler); cache.startAsync(); }); // wait until everything is either running or failed before starting the awaitUninterruptibly(runningLatch); tablesToUpdate.forEach(this::createLookupTable); // stop old caches existingCaches.build().forEach(AbstractIdleService::stopAsync); }, 0, TimeUnit.SECONDS); }
final String indexName = types.indexName(); types.fields().forEach(fieldType -> { final String fieldName = fieldType.fieldName(); final String physicalType = fieldType.physicalType();
private void assertMemoryRevokingRequestedFor(OperatorContext... operatorContexts) { ImmutableSet<OperatorContext> operatorContextsSet = ImmutableSet.copyOf(operatorContexts); operatorContextsSet.forEach( operatorContext -> assertTrue(operatorContext.isMemoryRevokingRequested(), "expected memory requested for operator " + operatorContext.getOperatorId())); Sets.difference(allOperatorContexts, operatorContextsSet).forEach( operatorContext -> assertFalse(operatorContext.isMemoryRevokingRequested(), "expected memory not requested for operator " + operatorContext.getOperatorId())); }
support.allowedClasses.forEach(unsupportedMembers::removeAll);
Type restype = fieldAccess.sym.type.asMethodType().restype; findUnannotatedTypeVarRefs(tvs, restype, node) .forEach( resRef -> rcvrReferences.forEach( rcvrRef -> qualifierConstraints.putEdge(resRef, rcvrRef))); Streams.forEachPair( (formal, actual) -> findUnannotatedTypeVarRefs(tvs, formal, actual) .forEach( argRef -> rcvrReferences.forEach( rcvrRef -> qualifierConstraints.putEdge(argRef, rcvrRef))));
public void getProperties(Map<String,String> props, Predicate<String> filter, boolean useDefaults) { if (useDefaults) { parent.getProperties(props, filter); } config.keySet().forEach(k -> { if (filter.test(k)) props.put(k, config.get(k)); }); } }
private void createLocalObjectStoreBeanDefinitions() { AtomicBoolean anyBaseStoreWasRedefined = new AtomicBoolean(false); OBJECT_STORE_NAME_TO_LOCAL_OBJECT_STORE_NAME.entrySet().forEach(objectStoreLocal -> customServiceRegistry .getOverriddenService(objectStoreLocal.getKey()).ifPresent(customService -> { anyBaseStoreWasRedefined.set(true); beanDefinitionRegistry.registerBeanDefinition(objectStoreLocal.getKey(), getCustomServiceBeanDefinition(customService, objectStoreLocal .getKey())); })); if (anyBaseStoreWasRedefined.get()) { final AbstractBeanDefinition beanDefinition = getBeanDefinitionBuilder(MuleObjectStoreManager.class) .addPropertyValue("basePersistentStoreKey", OBJECT_LOCAL_STORE_PERSISTENT) .addPropertyValue("baseTransientStoreKey", OBJECT_LOCAL_STORE_IN_MEMORY) .getBeanDefinition(); beanDefinition.setPrimary(false); beanDefinitionRegistry.registerBeanDefinition(LOCAL_OBJECT_STORE_MANAGER, beanDefinition); } else { beanDefinitionRegistry.registerAlias(OBJECT_STORE_MANAGER, LOCAL_OBJECT_STORE_MANAGER); } }
private Map<String, Object> generateOutstandingLocksYaml(Map<LockClient, Set<LockRequest>> outstandingLockRequestsMap) { Map<String, SimpleLockRequestsWithSameDescriptor> outstandingRequestMap = Maps.newHashMap(); outstandingLockRequestsMap.forEach((client, requestSet) -> { if (requestSet != null) { ImmutableSet<LockRequest> lockRequests = ImmutableSet.copyOf(requestSet); lockRequests.forEach(lockRequest -> { List<SimpleLockRequest> requestList = getDescriptorSimpleRequestMap(client, lockRequest); requestList.forEach(request -> { outstandingRequestMap.putIfAbsent(request.getLockDescriptor(), new SimpleLockRequestsWithSameDescriptor(request.getLockDescriptor())); outstandingRequestMap.get(request.getLockDescriptor()).addLockRequest(request); }); }); } }); List<SimpleLockRequestsWithSameDescriptor> sortedOutstandingRequests = sortOutstandingRequests(outstandingRequestMap.values()); return nameObjectForYamlConversion(OUTSTANDING_LOCK_REQUESTS_TITLE, sortedOutstandingRequests); }
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") // Unpacking it seems less readable private CassandraClientPoolImpl clientPoolWith( ImmutableSet<InetSocketAddress> servers, ImmutableSet<InetSocketAddress> serversInPool, Optional<Exception> failureMode) { when(config.servers()).thenReturn(servers); CassandraClientPoolImpl cassandraClientPool = CassandraClientPoolImpl.createImplForTest( MetricsManagers.of(metricRegistry, taggedMetricRegistry), config, CassandraClientPoolImpl.StartupChecks.DO_NOT_RUN, blacklist); serversInPool.forEach(address -> cassandraClientPool.getCurrentPools() .put(address, getMockPoolingContainerForHost(address, failureMode))); return cassandraClientPool; }
public void addConfigurationBindingListener(ConfigurationBindingListener listener) { ConfigurationProviderConsumer consumer = new ConfigurationProviderConsumer(listener); ImmutableSet<ConfigurationProvider<?>> currentProviders; synchronized (this) { configurationBindingListeners.add(consumer); currentProviders = ImmutableSet.copyOf(registeredProviders); } currentProviders.forEach(consumer); }
private CassandraService clientPoolWith( ImmutableSet<InetSocketAddress> servers, ImmutableSet<InetSocketAddress> serversInPool) { config = ImmutableCassandraKeyValueServiceConfig.builder() .replicationFactor(3) .addServers(servers.toArray(new InetSocketAddress[0])) .build(); blacklist = new Blacklist(config); CassandraService service = new CassandraService(MetricsManagers.createForTests(), config, blacklist); service.cacheInitialCassandraHosts(); serversInPool.forEach(service::addPool); return service; } }
private NavigableSet<NodeRank> getNodeRanks() { NavigableSet<NodeRank> nodes = new TreeSet<>(); graph.keySet().forEach(node -> { int numConnected = graph.get(node).getConnected(); nodes.add(new NodeRank(node, numConnected)); }); return nodes; }
@Override public Document toDocument(final Type type) { requireNonNull(type); final Document doc = new Document(); doc.append(ID, type.getId().getData()); final List<String> propertyNames = new ArrayList<>(); type.getPropertyNames().forEach(field -> propertyNames.add(field.getData())); doc.append(PROPERTY_NAMES, propertyNames); return doc; }
@Override public void visitGraph(BindingGraph graph, DiagnosticReporter diagnosticReporter) { if (graph.isModuleBindingGraph() || graph.isPartialBindingGraph()) { return; // Don't report missing bindings when validating a module or a partial binding graph } graph .missingBindings() .forEach(missingBinding -> reportMissingBinding(missingBinding, graph, diagnosticReporter)); }
@Override public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) { mapMultibindings(bindingGraph) .forEach( binding -> { ImmutableSet<ContributionBinding> contributions = mapBindingContributions(binding, bindingGraph); checkForDuplicateMapKeys(binding, contributions, diagnosticReporter); checkForInconsistentMapKeyAnnotationTypes(binding, contributions, diagnosticReporter); }); }
private void renderNodes(PrintWriter pw) { graph.getNodes().forEach(node -> { String entityUrl = placeUrl.getEntityUrl(projectId, node.getEntity()); pw.printf("\"%s\" [href=\"%s\"; color=\"%s\"]\n", node.getBrowserText(), entityUrl, node.getEntity().isOWLClass() ? "${node.color}" : "${node.ind.color}"); }); }