当前位置: 首页>>代码示例>>Java>>正文


Java RejectedExecutionException类代码示例

本文整理汇总了Java中java.util.concurrent.RejectedExecutionException的典型用法代码示例。如果您正苦于以下问题:Java RejectedExecutionException类的具体用法?Java RejectedExecutionException怎么用?Java RejectedExecutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RejectedExecutionException类属于java.util.concurrent包,在下文中一共展示了RejectedExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submitListenable

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@Override
public ListenableFuture<?> submitListenable (Runnable task)
{
   ExecutorService executor = getThreadPoolExecutor ();
   try
   {
      ListenableFutureTask<Object> future =
         new ListenableFutureTask<Object> (task, null);
      executor.execute (future);
      return future;
   }
   catch (RejectedExecutionException ex)
   {
      throw new TaskRejectedException ("Executor [" + executor +
         "] did not accept task: " + task, ex);
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:18,代码来源:FairThreadPoolTaskExecutor.java

示例2: processRpcRequest

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
/**处理客户端请求**/
private void processRpcRequest(final ChannelHandlerContext context, final DefaultRequest request) {
    final long processStartTime = System.currentTimeMillis();
    try {
        this.pool.execute(new Runnable() {
            @Override
            public void run() {

                try {
                    RpcContext.init(request);
                    processRpcRequest(context, request, processStartTime);
                } finally {
                    RpcContext.destroy();
                }

            }
        });
    } catch (RejectedExecutionException e) {
        DefaultResponse response = new DefaultResponse();
        response.setRequestId(request.getRequestId());
        response.setException(new RpcFrameworkException("process thread pool is full, reject"));
        response.setProcessTime(System.currentTimeMillis() - processStartTime);
        context.channel().write(response);
    }

}
 
开发者ID:TFdream,项目名称:mango,代码行数:27,代码来源:NettyServerImpl.java

示例3: execute

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
/**
 * Submit a task to be executed in the future.
 * @param runnable The task to be executed.
 */
@Override
public void execute(Runnable runnable) {
  if (runnable == null) {
    throw new NullPointerException("runnable parameter is null");
  }

  if (!mWorkQueue.offer(runnable)) {
    throw new RejectedExecutionException(
        mName + " queue is full, size=" + mWorkQueue.size());
  }

  final int queueSize = mWorkQueue.size();
  final int maxSize = mMaxQueueSize.get();
  if ((queueSize > maxSize) && mMaxQueueSize.compareAndSet(maxSize, queueSize)) {
    FLog.v(TAG, "%s: max pending work in queue = %d", mName, queueSize);
  } // else, there was a race and another thread updated and logged the max queue size

  startWorkerIfNeeded();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ConstrainedExecutorService.java

示例4: execute

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
public void execute(ReceivablePacket<L2GameClient> rp)
{
	try
	{
		if (rp.getClient().getState() == GameClientState.IN_GAME)
		{
			ThreadPoolManager.getInstance().executePacket(rp);
		}
		else
		{
			ThreadPoolManager.getInstance().executeIOPacket(rp);
		}
	}
	catch (RejectedExecutionException e)
	{
		// if the server is shutdown we ignore
		if (!ThreadPoolManager.getInstance().isShutdown())
		{
			_log.severe("Failed executing: "+rp.getClass().getSimpleName()+" for Client: "+rp.getClient().toString());
		}
	}
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:23,代码来源:L2GamePacketHandler.java

示例5: endpointNowInUse

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@Override
public void endpointNowInUse(Endpoint endpoint) {
  int count = endpointCount.incrementAndGet();
  final boolean isDebugEnabled = logger.isDebugEnabled();
  if (isDebugEnabled) {
    logger.debug("InstantiatorRecoveryTask - EndpointNowInUse. Now have {} endpoints", count);
  }
  if (count == 1) {
    synchronized (recoveryScheduledLock) {
      if (!recoveryScheduled) {
        try {
          recoveryScheduled = true;
          background.execute(new RecoveryTask());
          if (isDebugEnabled) {
            logger.debug("InstantiatorRecoveryTask - Scheduled Recovery Task");
          }
        } catch (RejectedExecutionException e) {
          // ignore, the timer has been cancelled, which means we're shutting down.
        }
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:InstantiatorRecoveryListener.java

示例6: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
	if (!stopped && outstandingTask == null) {
		AutoFocusTask newTask = new AutoFocusTask();
		try {
			// Unnecessary, our app's min sdk is higher than 11.
			// if (Build.VERSION.SDK_INT >= 11) {
			// 	newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			// } else {
			//
			// }
			newTask.execute();
			outstandingTask = newTask;
		} catch (RejectedExecutionException ree) {
			Log.w(TAG, "Could not request auto focus", ree);
		}
	}
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:19,代码来源:AutoFocusManager.java

示例7: basicProcess

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
/** Return true if a reply should be sent */
@Override
protected void basicProcess(final DistributionManager dm, final LocalRegion lclRgn) {
  Assert.assertTrue(this.serialNum != DistributionAdvisor.ILLEGAL_SERIAL);
  try {
    this.lockRoot = null;
    // may set lockRoot to the root region where destroyLock is acquired

    final boolean sendReply = true;

    // Part of fix for bug 34450 which was caused by a PR destroy region op
    // dead-locked with
    // a PR create region op. The create region op required an entry update
    // to release a
    // DLock needed by the PR destroy.. by moving the destroy to the waiting
    // pool, the entry
    // update is allowed to complete.
    dm.getWaitingThreadPool().execute(destroyOp(dm, lclRgn, sendReply));
  } catch (RejectedExecutionException e) {
    // rejected while trying to execute destroy thread
    // must be shutting down, just quit
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:DestroyRegionOperation.java

示例8: submit

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@Override
public RExecutorBatchFuture submit(Callable<?> ...tasks) {
    if (tasks.length == 0) {
        throw new NullPointerException("Tasks are not defined");
    }

    List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
    TasksBatchService executorRemoteService = createBatchService();
    RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
    for (Callable<?> task : tasks) {
        check(task);
        byte[] classBody = getClassBody(task);
        byte[] state = encode(task);
        RemotePromise<?> promise = (RemotePromise<?>)asyncService.executeCallable(task.getClass().getName(), classBody, state);
        RedissonExecutorFuture<?> executorFuture = new RedissonExecutorFuture(promise, promise.getRequestId());
        result.add(executorFuture);
    }
    
    List<Boolean> addResult = (List<Boolean>) executorRemoteService.executeAdd();
    if (!addResult.get(0)) {
        throw new RejectedExecutionException("Tasks have been rejected. ExecutorService is in shutdown state");
    }
    
    return new RedissonExecutorBatchFuture(result);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:RedissonExecutorService.java

示例9: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@SuppressLint("NewApi")
synchronized void autoFocusAgainLater() {
	if (!stopped && outstandingTask == null) {
		AutoFocusTask newTask = new AutoFocusTask();
		try {
			if (Build.VERSION.SDK_INT >= 11) {
				newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				newTask.execute();
			}
			outstandingTask = newTask;
		} catch (RejectedExecutionException ree) {
			Log.w(TAG, "Could not request auto focus", ree);
		}
	}
}
 
开发者ID:AnyRTC,项目名称:anyRTC-RTCP-Android,代码行数:17,代码来源:AutoFocusManager.java

示例10: growArray

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:ForkJoinPool.java

示例11: growArray

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
/**
 * 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 {
            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;
}
 
开发者ID:monix,项目名称:monix-forkjoin,代码行数:28,代码来源:ForkJoinPool.java

示例12: addFailure

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
public void addFailure() {
  if (blacklist.contains(location)) {
    // A second failure must have happened before we added
    // this server to the blacklist. Don't count that failure.
    return;
  }
  long failures = consecutiveFailures.incrementAndGet();
  if (failures >= THRESHOLD) {
    if (logger.isDebugEnabled()) {
      logger.debug("Blacklisting server {} for {}ms because it had {} consecutive failures",
          location, pingInterval, failures);
    }
    blacklist.add(location);
    broadcaster.serverAdded(location);
    try {
      background.schedule(new ExpireBlackListTask(location), pingInterval,
          TimeUnit.MILLISECONDS);
    } catch (RejectedExecutionException e) {
      // ignore, the timer has been cancelled, which means we're shutting down.
    }

  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:ServerBlackList.java

示例13: schedule

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
public Subscription schedule(Action0 action) {
    if (isUnsubscribed()) {
        return Subscriptions.unsubscribed();
    }
    Subscription ea = new ScheduledAction(action, this.tasks);
    this.tasks.add(ea);
    this.queue.offer(ea);
    if (this.wip.getAndIncrement() != 0) {
        return ea;
    }
    try {
        this.executor.execute(this);
        return ea;
    } catch (RejectedExecutionException t) {
        this.tasks.remove(ea);
        this.wip.decrementAndGet();
        RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
        throw t;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:ExecutorScheduler.java

示例14: processSocket

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
public boolean processSocket(NioChannel socket, SocketStatus status, boolean dispatch) {
    try {
        KeyAttachment attachment = (KeyAttachment)socket.getAttachment();
        if (attachment == null) {
            return false;
        }
        attachment.setCometNotify(false); //will get reset upon next reg
        SocketProcessor sc = processorCache.poll();
        if ( sc == null ) sc = new SocketProcessor(socket,status);
        else sc.reset(socket,status);
        if ( dispatch && getExecutor()!=null ) getExecutor().execute(sc);
        else sc.run();
    } catch (RejectedExecutionException rx) {
        log.warn("Socket processing request was rejected for:"+socket,rx);
        return false;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        // This means we got an OOM or similar creating a thread, or that
        // the pool and its queue are full
        log.error(sm.getString("endpoint.process.fail"), t);
        return false;
    }
    return true;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:25,代码来源:NioEndpoint.java

示例15: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //导入依赖的package包/类
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
    if (!stopped && outstandingTask == null) {
        AutoFocusTask newTask = new AutoFocusTask();
        try {
            if (Build.VERSION.SDK_INT >= 11) {
                newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                newTask.execute();
            }
            outstandingTask = newTask;
        } catch (RejectedExecutionException ree) {
            Log.w(TAG, "Could not request auto focus", ree);
        }
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:17,代码来源:AutoFocusManager.java


注:本文中的java.util.concurrent.RejectedExecutionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。