/** * @param discoMsg Discovery message. * @param msg Message. */ protected void debugLog(@Nullable TcpDiscoveryAbstractMessage discoMsg, String msg) { assert debugMode; String msg0 = new SimpleDateFormat("[HH:mm:ss,SSS]").format(new Date(System.currentTimeMillis())) + '[' + Thread.currentThread().getName() + "][" + getLocalNodeId() + "-" + locNode.internalOrder() + "] " + msg; debugLogQ.add(msg0); int delta = debugLogQ.size() - debugMsgHist; for (int i = 0; i < delta && debugLogQ.size() > debugMsgHist; i++) debugLogQ.poll(); }
@Override public void run() { GridFutureAdapter<Boolean> part; while ((part = futs.poll()) != null) part.onDone(true); } }, 20);
@Override public void run() { GridFutureAdapter<Boolean> part; Random rnd = new Random(); while ((part = futs.poll()) != null) { int op = rnd.nextInt(10); if (op < 8) part.onDone(true); else if (op == 8) part.onDone(false); else part.onDone(new IgniteCheckedException("TestMessage")); } } }, 20);
@Override public Object call() throws Exception { Random rnd = new Random(); while (!done) { for (int j = 0; j < rnd.nextInt(10); j++) { GridFutureAdapter<Object> fut = new GridFutureAdapter<>(); futs.add(fut); for (int k = 1; k < rnd.nextInt(3); k++) { fut.listen(new IgniteInClosure<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> t) { try { t.get(); } catch (IgniteCheckedException e) { e.printStackTrace(); } cnt.increment(); } }); } } GridFutureAdapter<Object> fut; while ((fut = futs.poll()) != null) fut.onDone(); } return null; } });
public T poll() { return queue.poll(); }
private TransactionInfo getTransactionInfoAndDrainPermits() { TransactionInfo transactionInfo = transactionInfos.poll(); if ( transactionInfo == null ) return null; // if any more batches can be written for this transaction then transactionPermits // is greater than zero and this transaction is available int permits = transactionInfo.transactionPermits.getAndSet(0); if ( permits > 0 ) { return transactionInfo; } else { // otherwise return null return null; } }
void cleanUpPongQueue() { Future<Boolean> b; while ((b = pongQueue.poll()) != null) { try { b.cancel(true); } catch (CancellationException e) { processException(e); } } }
void cleanUpPongQueue() { Future<Boolean> b; while ((b = pongQueue.poll()) != null) { try { b.cancel(true); } catch (CancellationException e) { processException(e); } } }
private void queueNewConnection(Connection connection) { MonoSink<Connection> subscriber = waitingSubscribers.poll(); if (subscriber == null) { activeConnections.add(connection); } else { borrowedCount.incrementAndGet(); subscriber.success(connection); } }
@Override public T getTask() { if (shouldHandleNextTask()) { return tasks.poll(); } else { return null; } }
@Override public List<SourceRecord> poll() throws InterruptedException { List<SourceRecord> records = new ArrayList<>(256); while (records.isEmpty()) { int size = messageQueue.size(); for (int i = 0; i < size; i++) { SourceRecord record = this.messageQueue.poll(); if (null == record) { break; } records.add(record); } if (records.isEmpty()) { Thread.sleep(100); } } return records; }
void clearQueue(int streamId) { ConcurrentLinkedDeque<PendingData> queue = outgoingDataQueue.get(streamId); while (queue != null && !queue.isEmpty() && outgoingFlowControl.get(streamId).get() > 0) { PendingData pendingData = queue.poll(); log.info("sending data from the queue: " + pendingData.data); sendDataFrames(pendingData.data, pendingData.isComplete, pendingData.stream, true) .thenAccept(v -> pendingData.future.complete(null)); } }
/** * @param msg Message. */ private void debugLog(String msg) { assert debugMode; String msg0 = new SimpleDateFormat("[HH:mm:ss,SSS]").format(new Date(System.currentTimeMillis())) + '[' + Thread.currentThread().getName() + "][" + locNodeId + "-" + locNode.internalOrder() + "] " + msg; debugLog.add(msg0); int delta = debugLog.size() - debugMsgHist; for (int i = 0; i < delta && debugLog.size() > debugMsgHist; i++) debugLog.poll(); }
public LogEvent poll() { LogEvent event = logEventDeque.poll(); setChanged(); notifyObservers(); return event; }
private void fireToListeners() { // //ChannelRegistrationListener[] listeners = listenerList.getListeners(ChannelRegistrationListener.class); // for(int i = 0; i < listeners.length; i++) { // listenerList.remove(ChannelRegistrationListener.class, listeners[i]); // listeners[i].processRegistrations(); // } while(!listenerList.isEmpty()) { ChannelRegistrationListener l = listenerList.poll(); l.processRegistrations(); } }
/** * @param discoMsg Discovery message. * @param msg Message. */ protected void debugLog(@Nullable TcpDiscoveryAbstractMessage discoMsg, String msg) { assert debugMode; String msg0 = new SimpleDateFormat("[HH:mm:ss,SSS]").format(new Date(System.currentTimeMillis())) + '[' + Thread.currentThread().getName() + "][" + getLocalNodeId() + "-" + locNode.internalOrder() + "] " + msg; debugLogQ.add(msg0); int delta = debugLogQ.size() - debugMsgHist; for (int i = 0; i < delta && debugLogQ.size() > debugMsgHist; i++) debugLogQ.poll(); }
@Override public void call() { executorScheduled.set(false); while (!taskQueue.isEmpty()) { InvokerTask<?, ?> task = taskQueue.poll(); if (task.execute()) { metrics.incrementOutputSuccess(); } else { task.cancel(); metrics.incrementOutputFailure(); } queueSize.getAndDecrement(); metrics.setQueueSize(queueSize.get()); } } };
protected void shutdown() { worker.unsubscribe(); while (!taskQueue.isEmpty()) { taskQueue.poll().cancel(); } metrics.setQueueSize(0); }
private void executeWithQueueStrategy(FutureOperation operation) { if (!operationQueuePermits.tryAcquire()) { logger.warn("Can't execute operation {}, no connections available, and Operation Queue at Max Depth", System.identityHashCode(operation)); operation.setRetrier(this, 1); operation.setException(new NoNodesAvailableException("No Nodes Available, and Operation Queue at Max Depth")); return; } operationQueue.offer(operation); verifyQueueStatus(); // Get next queued operation FutureOperation operationNext = operationQueue.poll(); if (operationNext == null) { return; } executeWithRequeueOnNoConnection(operationNext); }