Java 8 RejectedExecutionException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RejectedExecutionException class.

This code example shows how to use the following methods:
                request.abort(new RejectedExecutionException("Max requests per destination " + client.getMaxRequestsQueuedPerDestination() + " exceeded for " + this));
            } 
        } 
        else 
        { 
            request.abort(new RejectedExecutionException(client + " is stopped"));
        } 
    } 
 
    protected abstract void send(); 
 
    public void newConnection(Promise<Connection> promise)
    { 
        createConnection(promise);
    } 
 
    protected void createConnection(Promise<Connection> promise)
    { 
        client.newConnection(this, promise);
    } 
6
CodeRank
This code example shows how to use the following methods:
                exchange.setException(e);
            } 
 
            LOG.trace("{} executing task {}", callerRuns ? "CallerRuns" : "Aborted", call);
            if (shutdown.get()) {
                exchange.setException(new RejectedExecutionException());
            } 
            callback.done(true);
            return true; 
        } 
    } 
 
    public boolean isCallerRunsWhenRejected() { 
        return callerRunsWhenRejected;
    } 
 
    public void setCallerRunsWhenRejected(boolean callerRunsWhenRejected) {
        this.callerRunsWhenRejected = callerRunsWhenRejected;
    } 
 
6
CodeRank
This code example shows how to use the following methods:
	 */ 
	@Override 
	public void rejectedExecution( 
		Runnable runnable, ThreadPoolExecutor threadPoolExecutor) { 
 
		throw new RejectedExecutionException(); 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:
        try { 
            // block until there's room 
            executor.getQueue().put(r);
        } 
        catch (InterruptedException e) {
            throw new RejectedExecutionException("Unexpected InterruptedException", e);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
 
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
         try { 
            boolean successful = executor.getQueue().offer(r, waitTime, TimeUnit.MILLISECONDS);
            if (!successful)
               throw new RejectedExecutionException("Rejected execution after waiting " + waitTime + " ms for task ["
                     + r.getClass() + "] to be executed.");
         } catch (InterruptedException e) {
            throw new RejectedExecutionException(e);
         } 
      } 
   } 
} 
5
CodeRank
This code example shows how to use the following methods:
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
         try { 
            executor.getQueue().put(r);
         } catch (InterruptedException e) {
            // should never happen since we never wait 
            throw new RejectedExecutionException(e);
         } 
      } 
   } 
 
   /** 
    * A handler for rejected tasks that inserts the specified element into this queue, waiting if necessary up to the 
    * specified wait time for space to become available. 
    */ 
   static class TimedBlockingPolicy implements RejectedExecutionHandler {
      private final long waitTime;
 
      /** 
       * @param waitTime 
       *           wait time in milliseconds for space to become available. 
5
CodeRank
This code example shows how to use the following methods:addSuppressed
                    { 
                        ((Rejectable)task).reject();
                    } 
                    catch (Throwable x)
                    { 
                        e.addSuppressed(x);
                        LOG.warn(e);
                    } 
                } 
            } 
        } 
    } 
 
    @Override 
    public void dispatch() 
    { 
        execute(); 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Override 
    public void execute(Runnable command) {
        if (!taskQ.offer(command)) {
            throw new RejectedExecutionException("Executor[" + name + "] is overloaded!");
        } 
        addNewWorkerIfRequired(); 
    } 
 
    @Override 
    public <T> Future<T> submit(Callable<T> task) {
        final RunnableFuture<T> rf = new CompletableFutureTask<T>(task, getAsyncExecutor());
        execute(rf);
        return rf;
    } 
 
    @Override 
    public <T> Future<T> submit(Runnable task, T result) {
        final RunnableFuture<T> rf = new CompletableFutureTask<T>(task, result, getAsyncExecutor());
5
CodeRank
This code example shows how to use the following methods:
        if (command == null) {
            throw new NullPointerException("command can't be null");
        } 
 
        if (!live) {
            throw new RejectedExecutionException("Executor is terminated!");
        } 
 
        Worker worker = getWorker(command);
        worker.schedule(command);
    } 
 
    private Worker getWorker(Runnable command) {
        final int key;
        if (command instanceof StripedRunnable) {
            key = ((StripedRunnable) command).getKey();
        } else { 
            key = rand.nextInt();
        } 
 
5
CodeRank
This code example shows how to use the following methods:
                " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!" , 
                threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
                e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
                url.getProtocol(), url.getIp(), url.getPort());
        logger.warn(msg);
        throw new RejectedExecutionException(msg);
    } 
 
} 
5
CodeRank

Related Java 8 RejectedExecutionException Questions & Answers:

See Code Examples for Java 8 RejectedExecutionException Methods: