/** * retry offer task * * @param o task * @return offer success or not * @throws RejectedExecutionException if executor is terminated. */ public boolean retryOffer(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { if (executor.isShutdown()) { throw new RejectedExecutionException("Executor is shutdown!"); } return super.offer(o, timeout, unit); } }
/** * retry offer task * * @param o task * @return offer success or not * @throws RejectedExecutionException if executor is terminated. */ public boolean retryOffer(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { if (executor.isShutdown()) { throw new RejectedExecutionException("Executor is shutdown!"); } return super.offer(o, timeout, unit); } }
public boolean offer(ObjectContainer<T> item) { final long itemLength = item.getSize(); if (currentMemory.addAndGet(itemLength) <= memoryBound) { if (queue.offer(item)) { return true; } } currentMemory.addAndGet(-itemLength); return false; }
private void enqueueInternal( Job job ) { queue.offer( job ); notifyEnqueued( job ); }
public boolean force(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { if (parent.isShutdown()) { throw new RejectedExecutionException("Executor not running, can't force a command into the queue"); } return super.offer(o, timeout, unit); // forces the item onto the queue, to be used if the task is rejected }
@Override public void onMessage(Message msg) { try { LOG.trace("Queuing msg [" + msg.getJMSMessageID() + "]"); } catch (JMSException e) { // Nothing here, could not get message id } this.queue.offer(msg); }
public boolean force(Runnable o) { if (parent.isShutdown()) { throw new RejectedExecutionException("Executor not running, can't force a command into the queue"); } return super.offer(o); // forces the item onto the queue, to be used if the task is rejected }
public boolean force(Runnable o) { if (parent.isShutdown()) { throw new RejectedExecutionException("Executor not running, can't force a command into the queue"); } return super.offer(o); // forces the item onto the queue, to be used if the task is rejected }
public boolean force(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { if (parent.isShutdown()) { throw new RejectedExecutionException("Executor not running, can't force a command into the queue"); } return super.offer(o, timeout, unit); // forces the item onto the queue, to be used if the task is rejected }
@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. if (currentPoolThreadSize < executor.getMaximumPoolSize()) { return false; } // currentPoolThreadSize >= max return super.offer(runnable); }
@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. if (currentPoolThreadSize < executor.getMaximumPoolSize()) { return false; } // currentPoolThreadSize >= max return super.offer(runnable); }
private void enqueue(final IFileDownloadMessenger messenger) { synchronized (queueLock) { waitingQueue.offer(messenger); } push(); }
/** * {@inheritDoc} */ @Override protected void process(Tuple input) { if (!queue.offer(input)) { LOG.info(logPrefix() + "The message queue is full, preparing batch statement..."); prepareAndExecuteStatement(); queue.add(input); } }
private void sendNotifications() { for (QuorumServer server : self.getView().values()) { ToSend notmsg = new ToSend(ToSend.mType.notification, AuthFastLeaderElection.sequencer++, proposedLeader, proposedZxid, logicalclock.get(), QuorumPeer.ServerState.LOOKING, self.getView().get(server.id).electionAddr); sendqueue.offer(notmsg); } }
protected void forward(BatchSpoutMsgId msgId) { BatchStatus status = msgId.getBatchStatus(); BatchStatus newStatus = status.forward(); if (newStatus == null) { // create new status mkMsgId(msgId); LOG.info("Finish old batch " + msgId); } else { msgId.setBatchStatus(newStatus); batchQueue.offer(msgId); LOG.info("Forward batch " + msgId); } }
protected void handleFail(BatchSpoutMsgId msgId) { LOG.info("Failed batch " + msgId); BatchStatus status = msgId.getBatchStatus(); BatchStatus newStatus = status.error(); if (newStatus == BatchStatus.ERROR) { // create new status mkMsgId(msgId); } else { msgId.setBatchStatus(newStatus); batchQueue.offer(msgId); } }