Example usage for java.util.concurrent RejectedExecutionException getMessage

List of usage examples for java.util.concurrent RejectedExecutionException getMessage

Introduction

In this page you can find the example usage for java.util.concurrent RejectedExecutionException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:meme.singularsyntax.benchmark.Benchmark.java

public static void main(String[] argv) {
    Application app = new Application(argv);
    app.getThreadPool().prestartAllCoreThreads();

    int rejectedTasks = 0;
    long begTicks = System.currentTimeMillis();
    long endTicks;

    for (int seconds = 0; seconds < app.getRunTime(); seconds++) {
        try {/*from   www. j  a v  a  2 s . c om*/
            for (int requests = 0; requests < app.getRequestsPerSecond(); requests++) {
                Task task = new Task(app.getComputeSteps(), app.getServiceDispatch());

                try {
                    app.getCompletionService().submit(task);
                } catch (RejectedExecutionException e) {
                    rejectedTasks++;
                }
            }

            Thread.sleep(1000L);

        } catch (InterruptedException ignored) {
        }
    }

    int remaining = (app.getRequestsPerSecond() * app.getRunTime()) - rejectedTasks;
    while (remaining > 0) {
        try {
            Future<byte[]> future = app.getCompletionService().take();
            if (!app.isQuiet())
                System.out.println(toHexString(future.get()));
            remaining--;
        } catch (InterruptedException e) {
            // ignored
        } catch (ExecutionException e) {
            System.err.println(e.getMessage());
        }
    }

    endTicks = System.currentTimeMillis();
    System.out.printf("Finished processing in %d msec\n", endTicks - begTicks);

    System.out.println("Thread Pool Statistics:");
    System.out.println("  Active Count: " + app.getThreadPool().getActiveCount());
    System.out.println("  Completed Task Count: " + app.getThreadPool().getCompletedTaskCount());
    System.out.println("  Core Pool Size: " + app.getThreadPool().getCorePoolSize());
    System.out.println("  Largest Pool Size: " + app.getThreadPool().getLargestPoolSize());
    System.out.println("  Maximum Pool Size: " + app.getThreadPool().getMaximumPoolSize());
    System.out.println("  Pool Size: " + app.getThreadPool().getPoolSize());
    System.out.println("  Task Count: " + app.getThreadPool().getTaskCount());
    System.out.println("  Rejected Tasks: " + rejectedTasks);

    app.getRandomByteService().shutdown();
    app.getThreadPool().shutdown();
}

From source file:ch.cyberduck.core.threading.DefaultBackgroundExecutor.java

@Override
public <T> Future<T> execute(final Controller controller, final BackgroundActionRegistry registry,
        final BackgroundAction<T> action) {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Run action %s in background", action));
    }//from   ww  w .  j  a  v a2 s. c o m
    registry.add(action);
    action.init();
    // Start background task
    final Callable<T> command = new BackgroundCallable<T>(action, controller, registry);
    try {
        final Future<T> task = concurrentExecutor.execute(command);
        if (log.isInfoEnabled()) {
            log.info(String.format("Scheduled background runnable %s for execution", action));
        }
        return task;
    } catch (RejectedExecutionException e) {
        log.error(
                String.format("Error scheduling background task %s for execution. %s", action, e.getMessage()));
        action.cleanup();
        return ConcurrentUtils.constantFuture(null);
    }
}

From source file:org.jasig.cas.util.http.SimpleHttpClient.java

@Override
public boolean sendMessageToEndPoint(final HttpMessage message) {
    Assert.notNull(this.httpClient);

    try {/*from   w w w  .  j  a  v a2  s.c  om*/
        final HttpPost request = new HttpPost(message.getUrl().toURI());
        request.addHeader("Content-Type", message.getContentType());

        final StringEntity entity = new StringEntity(message.getMessage(),
                ContentType.create(message.getContentType()));
        request.setEntity(entity);

        final HttpRequestFutureTask<String> task = this.requestExecutorService.execute(request,
                HttpClientContext.create(), new BasicResponseHandler());

        if (message.isAsynchronous()) {
            return true;
        }

        return StringUtils.isNotBlank(task.get());
    } catch (final RejectedExecutionException e) {
        LOGGER.warn(e.getMessage(), e);
        return false;
    } catch (final Exception e) {
        LOGGER.trace(e.getMessage(), e);
        return false;
    }
}

From source file:org.wso2.siddhi.extension.output.transport.http.HttpOutputTransport.java

@Override
public void publish(Object event, Map<String, String> dynamicTransportOptions)
        throws ConnectionUnavailableException {
    // TODO: 1/8/17 load dynamic properties and fix properly
    // String url = dynamicProperties.get(ADAPTER_MESSAGE_URL);
    // String username = dynamicProperties.get(ADAPTER_USERNAME);
    // String password = dynamicProperties.get(ADAPTER_PASSWORD);
    // Map<String, String> headers = this.extractHeaders(dynamicProperties.get(ADAPTER_HEADERS));

    String url = "http://0.0.0.0:8080/endpoint";
    String username = null;//from w  w  w  . jav  a 2s  .com
    String password = null;
    Map<String, String> headers = this.extractHeaders(null);
    String payload = event.toString();

    try {
        executorService.submit(new HTTPSender(url, payload, username, password, headers, httpClient));
    } catch (RejectedExecutionException e) {
        log.error("Job queue is full : " + e.getMessage(), e);
    }
}

From source file:org.duracloud.mill.manifest.builder.ManifestBuilder.java

/**
 * @param spaceId//from   w  w  w. j  a  v  a 2 s  . c o m
 * @param spaceId 
 * @param store
 */
private void buildSpace(final String storeId, final String spaceId, final ContentStore store) throws Exception {
    log.info("starting manifest rebuild for storeId={} spaceId={}", storeId, spaceId);
    Iterator<String> contentIds = store.getSpaceContents(spaceId);
    while (contentIds.hasNext()) {
        final String contentId = contentIds.next();

        while (true) {
            try {
                this.executor.execute(new Runnable() {
                    /* (non-Javadoc)
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        try {
                            updateContentId(storeId, spaceId, contentId, store);
                            successes++;
                        } catch (Exception e) {
                            errors++;
                            log.error(MessageFormat.format(
                                    "failed to update manifest for storeId={0} spaceId={1} contentId={2} message={3}",
                                    storeId, spaceId, contentId, e.getMessage()), e);
                        }

                    }

                });

                break;
            } catch (RejectedExecutionException ex) {
                log.debug("failed to add new task: {} : thread executor -> taskCount={}, current pool size={}",
                        ex.getMessage(), executor.getTaskCount(), executor.getPoolSize());
                log.debug("Thread pool busy sleeping for 10ms");
                sleep();
            }
        }

        this.totalProcessed++;

    }

    log.info("all manifest rebuild tasks scheduled for  for storeId={} spaceId={}", storeId, spaceId);

}

From source file:eagle.jobrunning.crawler.RunningJobCrawlerImpl.java

private void startJobConfigProcessThread() {
    int configThreadCount = DEFAULT_CONFIG_THREAD_COUNT;
    LOG.info("Job Config crawler main thread started, pool size: " + DEFAULT_CONFIG_THREAD_COUNT);

    ThreadFactory factory = new ThreadFactory() {
        private final AtomicInteger count = new AtomicInteger(0);

        public Thread newThread(Runnable runnable) {
            count.incrementAndGet();/*from  w  w  w.  j  a v  a 2  s .c  o  m*/
            Thread thread = Executors.defaultThreadFactory().newThread(runnable);
            thread.setName("config-crawler-workthread-" + count.get());
            return thread;
        }
    };

    ThreadPoolExecutor pool = new ThreadPoolExecutor(configThreadCount, configThreadCount, 0L,
            TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);

    while (true) {
        JobContext context;
        try {
            context = queueOfConfig.take();
            LOG.info("queueOfConfig size: " + queueOfConfig.size());
            Runnable configCrawlerThread = new ConfigWorkTask(new JobContext(context), fetcher, callback, this);
            pool.execute(configCrawlerThread);
        } catch (InterruptedException e) {
            LOG.warn("Got an InterruptedException: " + e.getMessage());
        } catch (RejectedExecutionException e2) {
            LOG.warn("Got RejectedExecutionException: " + e2.getMessage());
        } catch (Throwable t) {
            LOG.warn("Got an throwable t, " + t.getMessage());
        }
    }
}

From source file:com.navercorp.pinpoint.collector.receiver.tcp.TCPReceiver.java

private void requestResponse(RequestPacket requestPacket, PinpointSocket pinpointSocket) {
    try {//  w w  w. j  a  v  a  2 s. c o m
        worker.execute(new RequestResponseDispatch(requestPacket, pinpointSocket));
    } catch (RejectedExecutionException e) {
        // cause is clear - full stack trace not necessary
        logger.warn("RejectedExecutionException Caused:{}", e.getMessage());
    }
}

From source file:com.navercorp.pinpoint.collector.receiver.tcp.TCPReceiver.java

private void receive(SendPacket sendPacket, PinpointSocket pinpointSocket) {
    try {//from  ww w .  ja va  2s . c om
        worker.execute(new Dispatch(sendPacket.getPayload(), pinpointSocket.getRemoteAddress()));
    } catch (RejectedExecutionException e) {
        // cause is clear - full stack trace not necessary 
        logger.warn("RejectedExecutionException Caused:{}", e.getMessage());
    }
}

From source file:com.predic8.membrane.core.transport.http.HttpEndpointListener.java

@Override
public void run() {
    while (!closed) {
        try {//from   www  . ja v a  2  s .  c o  m
            Socket socket = serverSocket.accept();
            openSockets.put(socket, Boolean.TRUE);
            try {
                transport.getExecutorService().execute(new HttpServerHandler(socket, this));
            } catch (RejectedExecutionException e) {
                openSockets.remove(socket);
                log.error(
                        "HttpServerHandler execution rejected. Might be due to a proxies.xml hot deployment in progress or a low"
                                + " value for <transport maxThreadPoolSize=\"...\">.");
                socket.close();
            }
        } catch (SocketException e) {
            String message = e.getMessage();
            if (message != null && (message.endsWith("socket closed") || message.endsWith("Socket closed"))) {
                log.debug("socket closed.");
                break;
            } else
                log.error(e);
        } catch (NullPointerException e) {
            // Ignore this. serverSocket variable is set null during a loop in the process of closing server socket.
        } catch (Exception e) {
            log.error(e);
        }
    }
}

From source file:org.dcache.xrootd.door.XrootdDoor.java

/**
 * List the contents of a path, usually a directory. In order to make
 * fragmented responses, as supported by the xrootd protocol, possible and
 * not block the processing thread in the door, this will register the
 * passed callback along with the UUID of the message that is sent to
 * PNFS-manager.//from w w  w. j a v a2s. com
 *
 * Once PNFS-manager replies to the message, that callback is retrieved and
 * the response is processed by the callback.
 *
 * @param path The path that is listed
 * @param subject Representation of user that request listing
 * @param callback The callback that will process the response
 */
public void listPath(FsPath path, Subject subject, MessageCallback<PnfsListDirectoryMessage> callback) {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject);

    PnfsListDirectoryMessage msg = new PnfsListDirectoryMessage(path.toString(), null, Ranges.<Integer>all(),
            EnumSet.noneOf(FileAttribute.class));
    UUID uuid = msg.getUUID();

    try {
        DirlistRequestHandler requestHandler = new DirlistRequestHandler(uuid, pnfsHandler.getPnfsTimeout(),
                callback);
        _requestHandlers.put(uuid, requestHandler);
        pnfsHandler.send(msg);
        requestHandler.resetTimeout();
    } catch (NoRouteToCellException e) {
        _requestHandlers.remove(uuid);
        callback.noroute(e.getDestinationPath());
    } catch (RejectedExecutionException ree) {
        _requestHandlers.remove(uuid);
        callback.failure(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, ree.getMessage());
    }
}