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
}
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);
}
}
}
}
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;
}
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);
}
}
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);
}
}
Aggregations