/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }
/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }
/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }
public Map<String, Number> getStatistics() { HashMap<String, Number> statistics = new HashMap<>(); statistics.put("queue", queue.size()); statistics.put("sentButUnacknowledgedSubContainer", sentButUnacknowledgedSubContainer.size()); statistics.put("correlationToParentContainer", correlationToParentContainer.size()); statistics.put("containerCorrelationIdMap", containerCorrelationIdMap.size()); statistics.put("responsesToBeDelivered", responsesToBeDelivered.size()); statistics.put("correlationIdGenerator", correlationIdGenerator.get()); statistics.put("deliveredItems", deliveredItems.get()); statistics.put("erroredItems", erroredItems.get()); statistics.put("deliveredContainers", deliveredContainers.get()); statistics.put("erroredContainers", erroredContainers.get()); return statistics; }
/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }
@SuppressWarnings("unchecked") protected synchronized void trySendingMessages(ChannelHandlerContext ctx) { while (queue.size() > 0) { // Get the RequestItem that is up next in the queue. PlcRequestContainer currentItem = (PlcRequestContainer) queue.current(); InternalPlcRequest request = currentItem.getRequest(); // Send the TPDU. try { ChannelFuture channelFuture = queue.removeAndWrite(); ctx.flush(); if (channelFuture == null) { break; } } catch (Exception e) { LOGGER.error("Error sending more queues messages", e); ctx.fireExceptionCaught(e); } if (request instanceof CorrelatedPlcRequest) { CorrelatedPlcRequest correlatedPlcRequest = (CorrelatedPlcRequest) request; // Add it to the list of sentButUnacknowledgedSubContainer. sentButUnacknowledgedSubContainer.put(correlatedPlcRequest.getTdpu(), currentItem); LOGGER.debug("container with id {} sent: ", correlatedPlcRequest.getTdpu(), currentItem); } } ctx.flush(); }
/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }
/** * Add the given {@code msg} and {@link ChannelPromise}. */ public void add(Object msg, ChannelPromise promise) { assert ctx.executor().inEventLoop(); if (msg == null) { throw new NullPointerException("msg"); } if (promise == null) { throw new NullPointerException("promise"); } // It is possible for writes to be triggered from removeAndFailAll(). To preserve ordering, // we should add them to the queue and let removeAndFailAll() fail them later. int messageSize = size(msg); PendingWrite write = PendingWrite.newInstance(msg, messageSize, promise); PendingWrite currentTail = tail; if (currentTail == null) { tail = head = write; } else { currentTail.next = write; tail = write; } size ++; bytes += messageSize; tracker.incrementPendingOutboundBytes(write.size); }