java.util.concurrent.RejectedExecutionException Java Examples

The following examples show how to use java.util.concurrent.RejectedExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TThreadedSelectorServer.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
/**
 * Accept a new connection.
 */
private void handleAccept() {
  final TNonblockingTransport client = doAccept();
  if (client != null) {
    // Pass this connection to a selector thread
    final SelectorThread targetThread = threadChooser.nextThread();

    if (args.acceptPolicy == Args.AcceptPolicy.FAST_ACCEPT || invoker == null) {
      doAddAccept(targetThread, client);
    } else {
      // FAIR_ACCEPT
      try {
        invoker.submit(new Runnable() {
          public void run() {
            doAddAccept(targetThread, client);
          }
        });
      } catch (RejectedExecutionException rx) {
        LOGGER.warn("ExecutorService rejected accept registration!", rx);
        // close immediately
        client.close();
      }
    }
  }
}
 
Example #2
Source File: FluxInterval.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void subscribe(CoreSubscriber<? super Long> actual) {
	Worker w = timedScheduler.createWorker();

	IntervalRunnable r = new IntervalRunnable(actual, w);

	actual.onSubscribe(r);

	try {
		w.schedulePeriodically(r, initialDelay, period, unit);
	}
	catch (RejectedExecutionException ree) {
		if (!r.cancelled) {
			actual.onError(Operators.onRejectedExecution(ree, r, null, null,
					actual.currentContext()));
		}
	}
}
 
Example #3
Source File: ThreadPoolExecutorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * execute throws RejectedExecutionException if saturated.
 */
public void testSaturatedExecute() {
    final CountDownLatch done = new CountDownLatch(1);
    final ThreadPoolExecutor p =
        new ThreadPoolExecutor(1, 1,
                               LONG_DELAY_MS, MILLISECONDS,
                               new ArrayBlockingQueue<Runnable>(1));
    try (PoolCleaner cleaner = cleaner(p, done)) {
        Runnable task = new CheckedRunnable() {
            public void realRun() throws InterruptedException {
                await(done);
            }};
        for (int i = 0; i < 2; ++i)
            p.execute(task);
        for (int i = 0; i < 2; ++i) {
            try {
                p.execute(task);
                shouldThrow();
            } catch (RejectedExecutionException success) {}
            assertTrue(p.getTaskCount() <= 2);
        }
    }
}
 
Example #4
Source File: TThreadedSelectorServerWithFix.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
/**
 * Accept a new connection.
 */
private void handleAccept() {
  final TNonblockingTransport client = doAccept();
  if (client != null) {
    // Pass this connection to a selector thread
    final SelectorThread targetThread = threadChooser.nextThread();

    if (args.acceptPolicy == Args.AcceptPolicy.FAST_ACCEPT || invoker == null) {
      doAddAccept(targetThread, client);
    } else {
      // FAIR_ACCEPT
      try {
        invoker.submit(new Runnable() {
          public void run() {
            doAddAccept(targetThread, client);
          }
        });
      } catch (RejectedExecutionException rx) {
        LOGGER.warn("ExecutorService rejected accept registration!", rx);
        // close immediately
        client.close();
      }
    }
  }
}
 
Example #5
Source File: ConnectionOrderedChannelHandler.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        //fix, reject exception can not be sent to consumer because thread pool is full, resulting in consumers waiting till timeout. 修复,由于线程池已满,拒绝异常无法发送给使用者,导致使用者等待超时。
        if (message instanceof Request && t instanceof RejectedExecutionException) {
            Request request = (Request) message;
            if (request.isTwoWay()) {
                String msg = "Server side(" + url.getIp() + "," + url.getPort() + ") threadpool is exhausted ,detail msg:" + t.getMessage();
                Response response = new Response(request.getId(), request.getVersion());
                response.setStatus(Response.SERVER_THREADPOOL_EXHAUSTED_ERROR);
                response.setErrorMessage(msg);
                channel.send(response);
                return;
            }
        }
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #6
Source File: ForkJoinPool.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes or doubles the capacity of array. Call either
 * by owner or with lock held -- it is OK for base, but not
 * top, to move while resizings are in progress.
 */
final ForkJoinTask<?>[] growArray() {
    ForkJoinTask<?>[] oldA = array;
    int size = oldA != null ? oldA.length << 1 : INITIAL_QUEUE_CAPACITY;
    if (size > MAXIMUM_QUEUE_CAPACITY)
        throw new RejectedExecutionException("Queue capacity exceeded");
    int oldMask, t, b;
    ForkJoinTask<?>[] a = array = new ForkJoinTask<?>[size];
    if (oldA != null && (oldMask = oldA.length - 1) >= 0 &&
        (t = top) - (b = base) > 0) {
        int mask = size - 1;
        do { // emulate poll from old array, push to new array
            ForkJoinTask<?> x;
            int oldj = ((b & oldMask) << ASHIFT) + ABASE;
            int j    = ((b &    mask) << ASHIFT) + ABASE;
            x = (ForkJoinTask<?>)U.getObjectVolatile(oldA, oldj);
            if (x != null &&
                U.compareAndSwapObject(oldA, oldj, x, null))
                U.putObjectVolatile(a, j, x);
        } while (++b != t);
    }
    return a;
}
 
Example #7
Source File: TaskExecutorAdapter.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Future<?> submit(Runnable task) {
	try {
		if (this.concurrentExecutor instanceof ExecutorService) {
			return ((ExecutorService) this.concurrentExecutor).submit(task);
		}
		else {
			FutureTask<Object> future = new FutureTask<Object>(task, null);
			this.concurrentExecutor.execute(future);
			return future;
		}
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException(
				"Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
	}
}
 
Example #8
Source File: DefaultExceptionHandler.java    From api-gateway-core with Apache License 2.0 6 votes vote down vote up
@Override
public ExceptionResponse getExceptionResponse(Exception exception) {
    ExceptionResponse exceptionResponse = new ExceptionResponse();
    if (exception instanceof GatewayException) {
        GatewayException gatewayException = (GatewayException) exception;
        exceptionResponse.setStatus(gatewayException.getStatus());
        exceptionResponse.setContentType("text/plain");
        exceptionResponse.setContent(gatewayException.getMessage());
    } else if (exception instanceof ConnectException) {
        exceptionResponse.setStatus(HttpResponseStatus.NOT_FOUND);
        exceptionResponse.setContentType("text/plain");
        exceptionResponse.setContent("connect server refused");
    } else if (exception instanceof RejectedExecutionException) {
        exceptionResponse.setStatus(HttpResponseStatus.TOO_MANY_REQUESTS);
        exceptionResponse.setContentType("text/plain");
        exceptionResponse.setContent("too many requests");
    } else {
        exceptionResponse.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
        exceptionResponse.setContentType("text/plain");
        exceptionResponse.setContent(exception.getMessage());
    }
    return exceptionResponse;
}
 
Example #9
Source File: DumpThreadRejectedHandler.java    From mpush with Apache License 2.0 6 votes vote down vote up
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    LOGGER.warn("one task rejected, poolConfig={}, poolInfo={}", poolConfig, Utils.getPoolInfo(e));
    if (!dumping) {
        dumping = true;
        dumpJVMInfo();
    }

    if (rejectedPolicy == REJECTED_POLICY_ABORT) {
        throw new RejectedExecutionException("one task rejected, pool=" + poolConfig.getName());
    } else if (rejectedPolicy == REJECTED_POLICY_CALLER_RUNS) {
        if (!e.isShutdown()) {
            r.run();
        }
    }
}
 
Example #10
Source File: TestSafeQueueingFuturePool.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
@Test
public void testRejectedFailure() throws Exception {
    TestFuturePool<Void> pool = new TestFuturePool<Void>();
    final AtomicBoolean result = new AtomicBoolean(false);
    pool.executor.shutdown();
    final CountDownLatch latch = new CountDownLatch(1);
    Future<Void> future = pool.wrapper.apply(new Function0<Void>() {
        public Void apply() {
            result.set(true);
            latch.countDown();
            return null;
        }
    });
    try {
        Await.result(future);
        fail("should have thrown");
    } catch (RejectedExecutionException ex) {
    }
    assertFalse(result.get());
    pool.wrapper.close();
    latch.await();
    assertTrue(result.get());
    pool.shutdown();
}
 
Example #11
Source File: MeanShiftTests.java    From clust4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testParallelLarger() {
	MeanShift wine_serial = new MeanShift(wine, 
		new MeanShiftParameters().setVerbose(true)).fit();
	System.out.println();
	
	MeanShift wine_paral = null; 
	try {
		wine_paral = new MeanShift(wine, 
				new MeanShiftParameters().setVerbose(true).setForceParallel(true)).fit();
	} catch(OutOfMemoryError | RejectedExecutionException e) {
		// don't propagate these...
		return;
	}
	System.out.println();
	
	assertTrue(Precision.equals(wine_serial.getBandwidth(), wine_paral.getBandwidth(), 1e-9));
	assertTrue(wine_serial.silhouetteScore() == wine_paral.silhouetteScore());
	assertTrue(VecUtils.equalsExactly(wine_serial.getLabels(), wine_paral.getLabels()));
}
 
Example #12
Source File: TaskQueue.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean offer(Runnable runnable) {
    if (executor == null) {
        throw new RejectedExecutionException("The task queue does not have executor!");
    }

    int currentPoolThreadSize = executor.getPoolSize();
    // have free worker. put task into queue to let the worker deal with task.有自由工作者。将任务放入队列,让工人处理任务。
    if (executor.getSubmittedTaskCount() < currentPoolThreadSize) {
        return super.offer(runnable);
    }

    // return false to let executor create new worker.提交的任务数大于当前线程数,小于最大线程数,直接创建worker执行任务
    if (currentPoolThreadSize < executor.getMaximumPoolSize()) {
        return false;
    }

    // currentPoolThreadSize >= max 当前线程数大于最大线程数,放入队列
    return super.offer(runnable);
}
 
Example #13
Source File: TaskExecutorAdapter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public Future<?> submit(Runnable task) {
	try {
		if (this.taskDecorator == null && this.concurrentExecutor instanceof ExecutorService) {
			return ((ExecutorService) this.concurrentExecutor).submit(task);
		}
		else {
			FutureTask<Object> future = new FutureTask<>(task, null);
			doExecute(this.concurrentExecutor, this.taskDecorator, future);
			return future;
		}
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException(
				"Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
	}
}
 
Example #14
Source File: Executor.java    From meghanada-server with GNU General Public License v3.0 6 votes vote down vote up
private Executor() {
  this.executorService = getExecutorService();
  this.eventBus =
      new AsyncEventBus(
          executorService,
          (throwable, subscriberExceptionContext) -> {
            if (!(throwable instanceof RejectedExecutionException)) {
              log.catching(throwable);
            }
          });
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread(
              () -> {
                try {
                  shutdown(1);
                } catch (Throwable t) {
                  // log.catching(t);
                }
              }));
}
 
Example #15
Source File: IntervalMulti.java    From smallrye-mutiny with Apache License 2.0 6 votes vote down vote up
@Override
public void subscribe(MultiSubscriber<? super Long> actual) {
    IntervalRunnable runnable = new IntervalRunnable(actual);

    actual.onSubscribe(runnable);

    try {
        if (initialDelay != null) {
            executor.scheduleAtFixedRate(runnable, initialDelay.toMillis(), period.toMillis(),
                    TimeUnit.MILLISECONDS);
        } else {
            executor.scheduleAtFixedRate(runnable, 0, period.toMillis(),
                    TimeUnit.MILLISECONDS);
        }
    } catch (RejectedExecutionException ree) {
        if (!runnable.cancelled.get()) {
            actual.onFailure(new RejectedExecutionException(ree));
        }
    }
}
 
Example #16
Source File: DefaultChannelPipeline.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
void execute() {
    EventExecutor executor = ctx.executor();
    if (executor.inEventLoop()) {
        callHandlerRemoved0(ctx);
    } else {
        try {
            executor.execute(this);
        } catch (RejectedExecutionException e) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Can't invoke handlerRemoved() as the EventExecutor {} rejected it," +
                                " removing handler {}.", executor, ctx.name(), e);
            }
            // remove0(...) was call before so just call AbstractChannelHandlerContext.setRemoved().
            ctx.setRemoved();
        }
    }
}
 
Example #17
Source File: InstantiatorRecoveryListener.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
public void endpointNowInUse(Endpoint endpoint) {
  int count  = endpointCount.incrementAndGet();
  if(pool.getLoggerI18n().fineEnabled()) {
    pool.getLoggerI18n().fine("InstantiatorRecoveryTask - EndpointNowInUse. Now have " + count  + " endpoints");
  }
  if(count == 1) {
    synchronized(recoveryScheduledLock) {
      if(!recoveryScheduled) {
        try {
          recoveryScheduled = true;
          background.execute(new RecoveryTask());
          pool.getLoggerI18n().fine("InstantiatorRecoveryTask - Scheduled Recovery Task");
        } catch(RejectedExecutionException e) {
          //ignore, the timer has been cancelled, which means we're shutting down.
        }
      }
    }
  }
}
 
Example #18
Source File: AppInfo.java    From island with Apache License 2.0 6 votes vote down vote up
@UiThread private void loadIcon(final @Nullable IconFilter filter, final IconConsumer consumer, final boolean need_badge) {
	if (mCachedIcon == null) try {
		new AsyncTask<Void, Void, Drawable>() {

			@Override protected Drawable doInBackground(final Void... params) {
				return need_badge ? loadIcon(context().getPackageManager()) : loadUnbadgedIconCompat(context().getPackageManager());
			}

			@Override protected void onPostExecute(final Drawable drawable) {
				if (drawable == null) return;        // Might be null if app is currently being removed.
				final Drawable icon = (filter != null ? filter.process(drawable) : drawable);
				mCachedIcon = icon;
				consumer.accept(icon);
			}
		}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	} catch (final RejectedExecutionException e) {
		Analytics.$().report(e);        // For statistics purpose
	} else consumer.accept(mCachedIcon);
}
 
Example #19
Source File: ConcurrentTaskScheduler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long period) {
	try {
		return this.scheduledExecutor.scheduleAtFixedRate(decorateTask(task, true), 0, period, TimeUnit.MILLISECONDS);
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
	}
}
 
Example #20
Source File: PingTcpHandler.java    From Chronicle-Network with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitialize(final WireOut outWire) throws RejectedExecutionException {
    System.out.printf("0x%s initialised%n", toHexString(identityHashCode(this)));
    if (nc().isAcceptor()) {
        @NotNull WriteMarshallable writeMarshallable = newPingHandler(csp(), cid());
        publish(writeMarshallable);

        nc().eventLoop().addHandler(new PingSender(this::nc, this::localIdentifier, this::remoteIdentifier, cid()));
    }
}
 
Example #21
Source File: ThreadPoolTaskScheduler.java    From audit4j-core with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.audit4j.core.schedule.TaskScheduler#scheduleWithFixedDelay(java.lang.Runnable, long)
 *
 */
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long delay) {
    ScheduledExecutorService executor = getScheduledExecutor();
    try {
        return executor.scheduleWithFixedDelay(errorHandlingTask(task, true), 0, delay, TimeUnit.MILLISECONDS);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}
 
Example #22
Source File: SingleTimedScheduler.java    From reactive-streams-commons with Apache License 2.0 5 votes vote down vote up
@Override
public Disposable schedule(Runnable task, long delay, TimeUnit unit) {
    try {
        Future<?> f = executor.schedule(task, delay, unit);
        return () -> f.cancel(true);
    } catch (RejectedExecutionException ex) {
        return REJECTED;
    }
}
 
Example #23
Source File: BoundedElasticSchedulerTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void taskCapIsOnExecutorAndNotWorker() {
	BoundedElasticScheduler
			boundedElasticScheduler = afterTest.autoDispose(new BoundedElasticScheduler(1, 9, Thread::new, 10));
	Worker worker1 = afterTest.autoDispose(boundedElasticScheduler.createWorker());
	Worker worker2 = afterTest.autoDispose(boundedElasticScheduler.createWorker());
	Worker worker3 = afterTest.autoDispose(boundedElasticScheduler.createWorker());

	//schedule tasks for second and third workers as well as directly on scheduler to show worker1 is still impacted
	worker2.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	worker2.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	worker2.schedulePeriodically(() -> {}, 1000, 100, TimeUnit.MILLISECONDS);

	//enqueue tasks in second deferred worker
	worker3.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	worker3.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	worker3.schedulePeriodically(() -> {}, 1000, 100, TimeUnit.MILLISECONDS);

	//enqueue tasks on scheduler directly
	boundedElasticScheduler.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	boundedElasticScheduler.schedule(() -> {}, 1000, TimeUnit.MILLISECONDS);
	boundedElasticScheduler.schedulePeriodically(() -> {}, 1000, 100, TimeUnit.MILLISECONDS);

	//any attempt at scheduling more task should result in rejection
	ScheduledThreadPoolExecutor threadPoolExecutor = (ScheduledThreadPoolExecutor) boundedElasticScheduler.boundedServices.busyQueue.peek().executor;
	assertThat(threadPoolExecutor.getQueue().size()).as("queue full").isEqualTo(9);
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker1 immediate").isThrownBy(() -> worker1.schedule(() -> {}));
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker1 delayed").isThrownBy(() -> worker1.schedule(() -> {}, 100, TimeUnit.MILLISECONDS));
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker1 periodic").isThrownBy(() -> worker1.schedulePeriodically(() -> {}, 100, 100, TimeUnit.MILLISECONDS));
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker2 immediate").isThrownBy(() -> worker2.schedule(() -> {}));
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker2 delayed").isThrownBy(() -> worker2.schedule(() -> {}, 100, TimeUnit.MILLISECONDS));
	assertThatExceptionOfType(RejectedExecutionException.class).as("worker2 periodic").isThrownBy(() -> worker2.schedulePeriodically(() -> {}, 100, 100, TimeUnit.MILLISECONDS));
	assertThatExceptionOfType(RejectedExecutionException.class).as("scheduler immediate").isThrownBy(() -> boundedElasticScheduler.schedule(() -> {}));
	assertThatExceptionOfType(RejectedExecutionException.class).as("scheduler delayed").isThrownBy(() -> boundedElasticScheduler.schedule(() -> {}, 100, TimeUnit.MILLISECONDS));
	assertThatExceptionOfType(RejectedExecutionException.class).as("scheduler periodic").isThrownBy(() -> boundedElasticScheduler.schedulePeriodically(() -> {}, 100, 100, TimeUnit.MILLISECONDS));
}
 
Example #24
Source File: DefaultExecutorTest.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
@Test
public void executeRejection() {
    assumeTrue("Ignoring executor: " + name + ", it has an unbounded thread pool.", size > 0);
    for (int i = 0; i < size; i++) {
        executor.execute(Task.newAwaitForeverTask());
    }
    Task reject = new Task();
    expected.expect(RejectedExecutionException.class);
    executor.execute(reject);
}
 
Example #25
Source File: ScheduledExecutorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * schedule throws RejectedExecutionException if shutdown
 */
public void testSchedule2_RejectedExecutionException() throws InterruptedException {
    final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
    try (PoolCleaner cleaner = cleaner(p)) {
        try {
            p.shutdown();
            p.schedule(new NoOpCallable(),
                       MEDIUM_DELAY_MS, MILLISECONDS);
            shouldThrow();
        } catch (RejectedExecutionException success) {
        } catch (SecurityException ok) {}
    }
}
 
Example #26
Source File: SingleTimedScheduler.java    From reactive-streams-commons with Apache License 2.0 5 votes vote down vote up
@Override
public Disposable schedule(Runnable task) {
    try {
        Future<?> f = executor.submit(task);
        return () -> f.cancel(true);
    } catch (RejectedExecutionException ex) {
        return REJECTED;
    }
}
 
Example #27
Source File: CombinedFuture.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
final void execute() {
  try {
    listenerExecutor.execute(this);
  } catch (RejectedExecutionException e) {
    if (thrownByExecute) {
      setException(e);
    }
  }
}
 
Example #28
Source File: TaskExecutorAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
	try {
		ListenableFutureTask<T> future = new ListenableFutureTask<T>(task);
		doExecute(this.concurrentExecutor, this.taskDecorator, future);
		return future;
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException(
				"Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
	}
}
 
Example #29
Source File: ThreadPoolTaskScheduler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
	ScheduledExecutorService executor = getScheduledExecutor();
	long initialDelay = startTime.getTime() - System.currentTimeMillis();
	try {
		return executor.schedule(errorHandlingTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
	}
	catch (RejectedExecutionException ex) {
		throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
	}
}
 
Example #30
Source File: ParallelGTSDecoderIteratorWrapper.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Attempt to schedule one of the runnables
 */  
private synchronized void schedule() {
  //
  // If we have already too many inflight requests
  // or if we don't have any left, return
  //
  
  if (this.inflight.get() >= MAX_INFLIGHT) {
    return;
  }
  
  if (0 == this.pending.get()) {
    return;
  }
  
  if (idx >= runnables.size()) {
    return;
  }
  
  GTSDecoderIteratorRunnable runnable = runnables.get(idx);
  
  try {
    executor.execute(runnable);
    idx++;
  } catch (RejectedExecutionException ree) {
    if (standalone) {
      Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_CLIENT_PARALLEL_SCANNERS_REJECTIONS, Sensision.EMPTY_LABELS, 1);
    } else {
      Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_HBASE_CLIENT_PARALLEL_SCANNERS_REJECTIONS, Sensision.EMPTY_LABELS, 1);
    }
  }
}