private void onFailure(String errMsg, ProducerJob job, ConcurrentLinkedDeque<ProducerJob> retries) { log.debug(String.format("OnFailure: will retry job %s.%sReason:%s", job, System.lineSeparator(), errMsg)); retries.add(job); }
} catch (IOException e) { log.debug(String.format("%s failed due to %s. Retrying...", jobString, e.getMessage())); nextRound.add(job); return; nextRound.add(Pair.of(prefix, FilterOperator.EQUALS)); for (String expanded : getUrlPartitions(prefix)) { nextRound.add(Pair.of(expanded, FilterOperator.CONTAINS));
@Override public void taggedConsumeLine(String tag, String line) { lines.add(line); } }
@Override public void onFailure(Throwable throwable) { callbackFailures.incrementAndGet(); callbackExceptions.add(throwable); } });
public void returnConnection(ClientConnectionHolder connection) { activeInvocationCount.decrementAndGet(); if (connection.getConnection().isOpen()) { connections.get(connection.sslContext == null ? NULL_SSL_CONTEXT : connection.sslContext).add(connection); } runPending(); }
/** * Add a rate sample for a rate metric. * @param name of the rate metric * @param elapsed time */ public void add(String name, long elapsed) { ConcurrentMap<String, ThreadSafeSampleStat> localStats = threadLocalMetricsMap.get(); if (localStats == null) { localStats = new ConcurrentHashMap<>(); threadLocalMetricsMap.set(localStats); weakReferenceQueue.add(new WeakReference<>(localStats)); } ThreadSafeSampleStat stat = localStats.get(name); if (stat == null) { stat = new ThreadSafeSampleStat(); localStats.put(name, stat); } stat.add(elapsed); }
public void getConnection(ConnectionListener connectionListener, ErrorListener errorListener, boolean ignoreConnectionLimits, SSLContext sslContext) { pendingConnectionRequests.add(new RequestHolder(connectionListener, errorListener, ignoreConnectionLimits, sslContext)); runPending(); }
/** * @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(); }
log.warn("Batch request failed. Jobs: " + Joiner.on(",").join(jobs)); for (ProducerJob job : jobs) { retries.add(job);
private void endBlock() throws IOException { Preconditions.checkState(waitingAckQueue.isEmpty(), "should call flush first before calling close"); if (state != State.STREAMING) { throw new IOException("stream already broken"); } state = State.CLOSING; long finalizedLength = ackedBlockLength; PacketHeader header = new PacketHeader(4, finalizedLength, nextPacketSeqno, true, 0, false); buf.release(); buf = null; int headerLen = header.getSerializedSize(); ByteBuf headerBuf = alloc.directBuffer(headerLen); header.putInBuffer(headerBuf.nioBuffer(0, headerLen)); headerBuf.writerIndex(headerLen); CompletableFuture<Long> future = new CompletableFuture<>(); waitingAckQueue.add(new Callback(future, finalizedLength, datanodeList)); datanodeList.forEach(ch -> ch.writeAndFlush(headerBuf.retainedDuplicate())); headerBuf.release(); try { future.get(); } catch (InterruptedException e) { throw (IOException) new InterruptedIOException().initCause(e); } catch (ExecutionException e) { Throwable cause = e.getCause(); Throwables.propagateIfPossible(cause, IOException.class); throw new IOException(cause); } }
@Test public void sendNoContext() throws Exception { int size = 1000; ConcurrentLinkedDeque<Integer> expected = new ConcurrentLinkedDeque<>(); ConcurrentLinkedDeque<Integer> obtained = new ConcurrentLinkedDeque<>(); startNodes(2); CountDownLatch latch = new CountDownLatch(1); vertices[1].eventBus().<Integer>consumer(ADDRESS1, msg -> { obtained.add(msg.body()); if (obtained.size() == expected.size()) { assertEquals(new ArrayList<>(expected), new ArrayList<>(obtained)); testComplete(); } }).completionHandler(ar -> { assertTrue(ar.succeeded()); latch.countDown(); }); latch.await(); EventBus bus = vertices[0].eventBus(); for (int i = 0;i < size;i++) { expected.add(i); bus.send(ADDRESS1, i); } await(); }
@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; } });
dataToRemap.add(r);
public void submit(WorkItem item) { workItems.add(item); }
/** * @throws Exception If failed. */ @Test public void testConcurrentCompletion() throws Exception { GridCompoundFuture<Boolean, Boolean> fut = new GridCompoundFuture<>(CU.boolReducer()); final ConcurrentLinkedDeque<GridFutureAdapter<Boolean>> futs = new ConcurrentLinkedDeque<>(); for (int i = 0; i < 1000; i++) { GridFutureAdapter<Boolean> part = new GridFutureAdapter<>(); fut.add(part); futs.add(part); } fut.markInitialized(); IgniteInternalFuture<?> complete = multithreadedAsync(new Runnable() { @Override public void run() { GridFutureAdapter<Boolean> part; while ((part = futs.poll()) != null) part.onDone(true); } }, 20); complete.get(); assertTrue(fut.isDone()); }
futs.add(part);
currentData.add(data);
@Test public void sendNoContext() throws Exception { int size = 1000; ConcurrentLinkedDeque<Integer> expected = new ConcurrentLinkedDeque<>(); ConcurrentLinkedDeque<Integer> obtained = new ConcurrentLinkedDeque<>(); startNodes(2); CountDownLatch latch = new CountDownLatch(1); vertices[1].eventBus().<Integer>consumer(ADDRESS1, msg -> { obtained.add(msg.body()); if (obtained.size() == expected.size()) { assertEquals(new ArrayList<>(expected), new ArrayList<>(obtained)); testComplete(); } }).completionHandler(ar -> { assertTrue(ar.succeeded()); latch.countDown(); }); latch.await(); EventBus bus = vertices[0].eventBus(); for (int i = 0;i < size;i++) { expected.add(i); bus.send(ADDRESS1, i); } await(); }
/** * Request a redraw of a visualization. */ public void requestRedraw(VisualizationTask task, Visualization vis) { updateQueue.add(vis); synchronizedRedraw(); } }
public void add(TopicName topicName, Message message) { long counter = limiter.getAndIncrement(topicName); if (counter < previewSizePerTopic) { messages.add(new MessagePreviewSnapshot(topicName, messagePreviewFactory.create(message))); } }