List of usage examples for java.util Map forEach
default void forEach(BiConsumer<? super K, ? super V> action)
From source file:org.apache.hadoop.hbase.client.AsyncBatchRpcRetryingCaller.java
private void send(Map<ServerName, ServerRequest> actionsByServer, int tries) { long remainingNs; if (operationTimeoutNs > 0) { remainingNs = remainingTimeNs(); if (remainingNs <= 0) { failAll(actionsByServer.values().stream().flatMap(m -> m.actionsByRegion.values().stream()) .flatMap(r -> r.actions.stream()), tries); return; }//from ww w . ja v a 2s . c o m } else { remainingNs = Long.MAX_VALUE; } actionsByServer.forEach((sn, serverReq) -> { ClientService.Interface stub; try { stub = conn.getRegionServerStub(sn); } catch (IOException e) { onError(serverReq.actionsByRegion, tries, e, sn); return; } ClientProtos.MultiRequest req; List<CellScannable> cells = new ArrayList<>(); try { req = buildReq(serverReq.actionsByRegion, cells); } catch (IOException e) { onError(serverReq.actionsByRegion, tries, e, sn); return; } HBaseRpcController controller = conn.rpcControllerFactory.newController(); resetController(controller, Math.min(rpcTimeoutNs, remainingNs)); if (!cells.isEmpty()) { controller.setCellScanner(createCellScanner(cells)); } stub.multi(controller, req, resp -> { if (controller.failed()) { onError(serverReq.actionsByRegion, tries, controller.getFailed(), sn); } else { try { onComplete(serverReq.actionsByRegion, tries, sn, ResponseConverter.getResults(req, resp, controller.cellScanner())); } catch (Exception e) { onError(serverReq.actionsByRegion, tries, e, sn); return; } } }); }); }
From source file:com.vmware.xenon.swagger.SwaggerAssembler.java
private void addFactory(String uri, ServiceDocument doc) { this.swagger.path(uri, path2Factory(doc)); if (!this.excludeUtilities) { this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_STATS, path2UtilStats(null)); this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_CONFIG, path2UtilConfig(null)); this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_SUBSCRIPTIONS, path2UtilSubscriptions(null)); this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_TEMPLATE, path2UtilTemplate(null)); this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_AVAILABLE, path2UtilAvailable(null)); }//w w w . j a v a 2 s . co m Parameter idParam = paramId(); String base = uri + PREFIX_ID; Map<String, Path> paths = path2Instance(doc); paths.forEach((suffix, path) -> { this.swagger.path(base + suffix, path); }); if (!this.excludeUtilities) { this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_STATS, path2UtilStats(idParam)); this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_CONFIG, path2UtilConfig(idParam)); this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_SUBSCRIPTIONS, path2UtilSubscriptions(idParam)); this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_TEMPLATE, path2UtilTemplate(idParam)); this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_AVAILABLE, path2UtilAvailable(idParam)); } }
From source file:org.commonjava.indy.client.core.IndyClientHttp.java
public HttpResources getRaw(final String path, final Map<String, String> headers) throws IndyClientException { connect();// w ww . ja v a 2 s . c o m CloseableHttpResponse response; try { final HttpGet req = newRawGet(buildUrl(baseUrl, path)); if (headers != null) { headers.forEach((k, v) -> { req.setHeader(k, v); }); } final CloseableHttpClient client = newClient(); response = client.execute(req, newContext()); return new HttpResources(req, response, client); } catch (final IOException e) { throw new IndyClientException("Indy request failed: %s", e, e.getMessage()); } finally { // DO NOT CLOSE!!!! We're handing off control of the response to the caller! // closeQuietly( response ); } }
From source file:nu.yona.server.analysis.service.ActivityService.java
private void createInactivityEntities(Set<IntervalInactivityDto> missingInactivities) { Map<UUID, Set<IntervalInactivityDto>> activitiesByUserAnonymizedId = missingInactivities.stream() .collect(Collectors.groupingBy(mia -> mia.getUserAnonymizedId().get(), Collectors.toSet())); activitiesByUserAnonymizedId .forEach((u, mias) -> analysisEngineProxyService.createInactivityEntities(u, mias)); }
From source file:net.minecraftforge.registries.ForgeRegistry.java
public MissingMappings<?> getMissingEvent(ResourceLocation name, Map<ResourceLocation, Integer> map) { List<MissingMappings.Mapping<V>> lst = Lists.newArrayList(); ForgeRegistry<V> pool = RegistryManager.ACTIVE.getRegistry(name); map.forEach((rl, id) -> lst.add(new MissingMappings.Mapping<V>(this, pool, rl, id))); return new MissingMappings<V>(name, this, lst); }
From source file:com.yfiton.cli.YfitonCli.java
private String getNotifierHelp(Notifier notifier, Map<String, Parameter> parameters, boolean describeParameters) { StringBuilder buf = new StringBuilder(); buf.append(notifier.getKey());// w ww .j ava 2 s .c o m buf.append("\n"); if (notifier.getDescription().isPresent()) { buf.append(" "); buf.append(Joiner.on("\n ").join(notifier.getDescription().get().split("\\r?\\n"))); buf.append("\n"); } if (notifier.getUrl().isPresent()) { buf.append(" "); buf.append(notifier.getUrl().get()); buf.append("\n"); } if (describeParameters && parameters.size() > 0) { buf.append("\n"); buf.append(" Accepted parameters:"); buf.append("\n"); parameters.forEach((parameterName, parameter) -> { buf.append(" "); buf.append(parameterName); if (parameter.isRequired()) { buf.append(" (required)"); } buf.append("\n"); if (!parameter.getDescription().isEmpty()) { buf.append(" "); buf.append(WordUtils.wrap(parameter.getDescription(), 66, "\n ", true)); buf.append("\n"); } buf.append(" "); buf.append("Type: " + parameter.getType().getSimpleName()); buf.append("\n"); if (!parameter.isRequired()) { buf.append(" "); buf.append("Default: "); buf.append(getDefaultValue(parameter)); buf.append("\n"); } }); } return buf.toString(); }
From source file:org.finra.herd.dao.impl.IndexFunctionsDaoImpl.java
@Override public void createIndexDocuments(String indexName, String documentType, Map<String, String> documentMap) { LOGGER.info("Creating Elasticsearch index documents, indexName={}, documentType={}", indexName, documentType);//from w w w. j a v a 2 s . c o m List<String> allIndices = getAliases(indexName); allIndices.forEach((index) -> { // Prepare a bulk request builder //final BulkRequestBuilder bulkRequestBuilder = new BulkRequestBuilder(new ElasticsearchClientImpl(), BulkAction.INSTANCE); Bulk.Builder bulkBuilder = new Bulk.Builder(); // For each document prepare an insert request and add it to the bulk request builder documentMap.forEach((id, jsonString) -> { BulkableAction createIndex = new Index.Builder(jsonString).index(index).type(documentType).id(id) .build(); bulkBuilder.addAction(createIndex); }); JestResult jestResult = jestClientHelper.execute(bulkBuilder.build()); // If there are failures log them if (!jestResult.isSucceeded()) { LOGGER.error("Bulk response error = {}", jestResult.getErrorMessage()); } }); }
From source file:io.github.jeddict.jcode.util.POMManager.java
public void setPluginConfiguration(String groupId, String artifactId, Map<String, String> configs) { if (getPOMProject().getBuild() != null) { Plugin plugin = getPOMProject().getBuild().findPluginById(groupId, artifactId); if (plugin != null && plugin.getConfiguration() != null) { Configuration configuration = plugin.getConfiguration(); configs.forEach((key, value) -> configuration.setSimpleParameter(key, value)); }//from w w w . j a v a 2s.c om } }
From source file:io.swagger.v3.core.util.AnnotationsUtils.java
public static Schema resolveSchemaFromType(Class<?> schemaImplementation, Components components, JsonView jsonViewAnnotation) {//from w w w . j av a 2s. com Schema schemaObject = new Schema(); if (schemaImplementation.getName().startsWith("java.lang")) { schemaObject.setType(schemaImplementation.getSimpleName().toLowerCase()); } else { ResolvedSchema resolvedSchema = ModelConverters.getInstance().readAllAsResolvedSchema( new AnnotatedType().type(schemaImplementation).jsonViewAnnotation(jsonViewAnnotation)); Map<String, Schema> schemaMap; if (resolvedSchema != null) { schemaMap = resolvedSchema.referencedSchemas; schemaMap.forEach((key, referencedSchema) -> { if (components != null) { components.addSchemas(key, referencedSchema); } }); schemaObject.set$ref(COMPONENTS_REF + resolvedSchema.schema.getName()); } } if (StringUtils.isBlank(schemaObject.get$ref()) && StringUtils.isBlank(schemaObject.getType())) { // default to string schemaObject.setType("string"); } return schemaObject; }
From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java
/** * Detect if the given handler has any methods that can handle messages and if * so register it with the extracted mapping information. * @param handler the handler to check, either an instance of a Spring bean name *//*from ww w. ja v a 2 s . c om*/ protected final void detectHandlerMethods(final Object handler) { Class<?> handlerType; if (handler instanceof String) { ApplicationContext context = getApplicationContext(); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); handlerType = context.getType((String) handler); } else { handlerType = handler.getClass(); } if (handlerType != null) { final Class<?> userType = ClassUtils.getUserClass(handlerType); Map<Method, T> methods = MethodIntrospector.selectMethods(userType, (MethodIntrospector.MetadataLookup<T>) method -> getMappingForMethod(method, userType)); if (logger.isDebugEnabled()) { logger.debug(methods.size() + " message handler methods found on " + userType + ": " + methods); } methods.forEach((key, value) -> registerHandlerMethod(handler, key, value)); } }