Search in sources :

Example 91 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project geode by apache.

the class DistributionMessage method schedule.

/**
   * Schedule this message's process() method in a thread determined by getExecutor()
   */
protected void schedule(final DistributionManager dm) {
    boolean inlineProcess = DistributionManager.INLINE_PROCESS && getProcessorType() == DistributionManager.SERIAL_EXECUTOR && !isPreciousThread();
    boolean forceInline = this.acker != null || getInlineProcess() || Connection.isDominoThread();
    if (inlineProcess && !forceInline && isSharedReceiver()) {
        // do it inline.
        if (mayAddToMultipleSerialGateways(dm)) {
            inlineProcess = false;
        }
    }
    inlineProcess |= forceInline;
    if (inlineProcess) {
        dm.getStats().incNumSerialThreads(1);
        try {
            scheduleAction(dm);
        } finally {
            dm.getStats().incNumSerialThreads(-1);
        }
    } else {
        // not inline
        try {
            getExecutor(dm).execute(new SizeableRunnable(this.getBytesRead()) {

                public void run() {
                    scheduleAction(dm);
                }

                @Override
                public String toString() {
                    return "Processing {" + DistributionMessage.this.toString() + "}";
                }
            });
        } catch (RejectedExecutionException ex) {
            if (!dm.shutdownInProgress()) {
                // fix for bug 32395
                logger.warn(LocalizedMessage.create(LocalizedStrings.DistributionMessage_0__SCHEDULE_REJECTED, this.toString()), ex);
            }
        } catch (VirtualMachineError err) {
            SystemFailure.initiateFailure(err);
            // now, so don't let this thread continue.
            throw err;
        } catch (Throwable t) {
            // Whenever you catch Error or Throwable, you must also
            // catch VirtualMachineError (see above). However, there is
            // _still_ a possibility that you are dealing with a cascading
            // error condition, so you also need to check to see if the JVM
            // is still usable:
            SystemFailure.checkFailure();
            logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionMessage_UNCAUGHT_EXCEPTION_PROCESSING__0, this), t);
            // I don't believe this ever happens (DJP May 2007)
            throw new InternalGemFireException(LocalizedStrings.DistributionMessage_UNEXPECTED_ERROR_SCHEDULING_MESSAGE.toLocalizedString(), t);
        }
    }
// not inline
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 92 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project apex-core by apache.

the class Server method handleSubscriberRequest.

/**
   *
   * @param request
   * @param key
   */
private void handleSubscriberRequest(final SubscribeRequestTuple request, final SelectionKey key) {
    try {
        serverHelperExecutor.submit(new Runnable() {

            @Override
            public void run() {
                final String upstream_identifier = request.getUpstreamIdentifier();
                /*
           * if there is already a datalist registered for the type in which this client is interested,
           * then get a iterator on the data items of that data list. If the datalist is not registered,
           * then create one and register it. Hopefully this one would be used by future upstream nodes.
           */
                DataList dl = publisherBuffers.get(upstream_identifier);
                if (dl == null) {
                    dl = Tuple.FAST_VERSION.equals(request.getVersion()) ? new FastDataList(upstream_identifier, blockSize, numberOfCacheBlocks, BACK_PRESSURE_ENABLED) : new DataList(upstream_identifier, blockSize, numberOfCacheBlocks, BACK_PRESSURE_ENABLED);
                    DataList odl = publisherBuffers.putIfAbsent(upstream_identifier, dl);
                    if (odl != null) {
                        dl = odl;
                    }
                }
                final String identifier = request.getIdentifier();
                final String type = request.getStreamType();
                final long skipWindowId = (long) request.getBaseSeconds() << 32 | request.getWindowId();
                final LogicalNode ln = new LogicalNode(identifier, upstream_identifier, type, dl.newIterator(skipWindowId), skipWindowId, eventloop);
                int mask = request.getMask();
                if (mask != 0) {
                    for (Integer bs : request.getPartitions()) {
                        ln.addPartition(bs, mask);
                    }
                }
                final LogicalNode oln = subscriberGroups.put(type, ln);
                if (oln != null) {
                    oln.boot();
                }
                final Subscriber subscriber = new Subscriber(ln, request.getBufferSize());
                eventloop.submit(new Runnable() {

                    @Override
                    public void run() {
                        key.attach(subscriber);
                        subscriber.registered(key);
                        subscriber.connected();
                    }
                });
            }
        });
    } catch (RejectedExecutionException e) {
        logger.error("Received subscriber request {} after server {} termination. Disconnecting {}.", request, this, key.channel(), e);
        if (key.isValid()) {
            try {
                key.channel().close();
            } catch (IOException ioe) {
                logger.error("Failed to close channel {}", key.channel(), ioe);
            }
        }
    }
}
Also used : FastDataList(com.datatorrent.bufferserver.internal.FastDataList) DataList(com.datatorrent.bufferserver.internal.DataList) FastDataList(com.datatorrent.bufferserver.internal.FastDataList) IOException(java.io.IOException) LogicalNode(com.datatorrent.bufferserver.internal.LogicalNode) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 93 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project spring-data-document-examples by spring-projects.

the class NavigationManager method startActivity.

public static boolean startActivity(Context context, Class<?> activity) {
    try {
        Intent intent = new Intent();
        intent.setClass(context, activity);
        context.startActivity(intent);
    } catch (RejectedExecutionException ex) {
    }
    return true;
}
Also used : Intent(android.content.Intent) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 94 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project spring-framework by spring-projects.

the class TaskExecutorAdapter method submitListenable.

@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
    try {
        ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
        doExecute(this.concurrentExecutor, this.taskDecorator, future);
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 95 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project spring-framework by spring-projects.

the class TaskExecutorAdapter method submit.

@Override
public <T> Future<T> submit(Callable<T> task) {
    try {
        if (this.taskDecorator == null && this.concurrentExecutor instanceof ExecutorService) {
            return ((ExecutorService) this.concurrentExecutor).submit(task);
        } else {
            FutureTask<T> future = new FutureTask<>(task);
            doExecute(this.concurrentExecutor, this.taskDecorator, future);
            return future;
        }
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) FutureTask(java.util.concurrent.FutureTask) ExecutorService(java.util.concurrent.ExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Aggregations

RejectedExecutionException (java.util.concurrent.RejectedExecutionException)246 ExecutorService (java.util.concurrent.ExecutorService)42 IOException (java.io.IOException)34 Test (org.junit.Test)34 Future (java.util.concurrent.Future)19 ArrayList (java.util.ArrayList)18 Executor (java.util.concurrent.Executor)18 ExecutionException (java.util.concurrent.ExecutionException)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)15 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)14 List (java.util.List)11 TaskRejectedException (org.springframework.core.task.TaskRejectedException)11 BitmapDrawable (android.graphics.drawable.BitmapDrawable)10 Animation (android.view.animation.Animation)10 Map (java.util.Map)10 CancellationException (java.util.concurrent.CancellationException)10 CacheableBitmapDrawable (uk.co.senab.bitmapcache.CacheableBitmapDrawable)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9