Example usage for java.util.concurrent ForkJoinPool commonPool

List of usage examples for java.util.concurrent ForkJoinPool commonPool

Introduction

In this page you can find the example usage for java.util.concurrent ForkJoinPool commonPool.

Prototype

public static ForkJoinPool commonPool() 

Source Link

Document

Returns the common pool instance.

Usage

From source file:org.apache.hadoop.mapred.CollectiveMapper.java

/**
 * Expert users can override this method for
 * more complete control over the execution of
 * the Mapper./*from  w w  w  . ja va2 s . c  om*/
 * 
 * @param context
 * @throws IOException
 */
public void run(Context context) throws IOException, InterruptedException {
    // Logger.getLogger("net.openhft").setLevel(Level.OFF);
    long time1 = System.currentTimeMillis();
    boolean success = initCollCommComponents(context);
    long time2 = System.currentTimeMillis();
    LOG.info("Initialize Harp components (ms): " + (time2 - time1));
    if (!success) {
        if (client != null) {
            client.stop();
        }
        // Stop the server
        if (server != null) {
            server.stop();
        }
        throw new IOException("Fail to do master barrier.");
    }
    setup(context);
    KeyValReader reader = new KeyValReader(context);
    try {
        mapCollective(reader, context);
        ResourcePool.get().log();
        ConnPool.get().log();
    } catch (Throwable t) {
        LOG.error("Fail to do map-collective.", t);
        throw new IOException(t);
    } finally {
        cleanup(context);
        ConnPool.get().clean();
        client.stop();
        server.stop();
        ForkJoinPool.commonPool().awaitQuiescence(Constant.TERMINATION_TIMEOUT, TimeUnit.SECONDS);
    }
}

From source file:org.codice.ddf.catalog.ui.query.monitor.impl.WorkspaceQueryService.java

private Map<String, Pair<WorkspaceMetacardImpl, Long>> executeWorkspaceTasks(List<WorkspaceTask> workspaceTasks,
        long timeout, TimeUnit timeoutUnit) {
    Map<String, Pair<WorkspaceMetacardImpl, Long>> results = new ConcurrentHashMap<>();

    workspaceTasks.stream().map(ForkJoinPool.commonPool()::submit)
            .map(task -> getTaskResult(task, timeout, timeoutUnit)).filter(Objects::nonNull)
            .forEach(pair -> results.put(pair.getLeft().getId(),
                    new ImmutablePair<>(pair.getLeft(), pair.getRight())));

    return results;
}