public long getRemainingCapacity() { return ringBuffer.remainingCapacity(); }
public long getUsage() { if (ringBuffer == null) { return 0; } return (long) ringBuffer.getBufferSize() - ringBuffer.remainingCapacity(); }
@Override public long getUsage() { return ringBuffer.getBufferSize() - ringBuffer.remainingCapacity(); }
@Override public void onEvent(final TestEvent event, final long sequence, final boolean endOfBatch) throws Exception { remainingCapacity[0] = disruptor.getRingBuffer().remainingCapacity(); } };
public void publishDirect(List<Object> batch, boolean block) throws InsufficientCapacityException { int size = 0; if (batch != null) { size = batch.size(); if (block) { int left = size; int batchIndex = 0; while (left > 0) { int availableCapacity = (int) _buffer.remainingCapacity(); if (availableCapacity > 0) { int n = availableCapacity >= left ? left : availableCapacity; final long end = _buffer.next(n); publishBuffer(batch, batchIndex, end - n + 1, end); left -= n; batchIndex += n; } else { JStormUtils.sleepMs(1); } } } else { final long end = _buffer.tryNext(size); publishBuffer(batch, 0, end - size + 1, end); } } }
static long asyncRemainingCapacity(Logger logger) { if (logger instanceof AsyncLogger) { try { Field f = field(AsyncLogger.class, "loggerDisruptor"); return ((AsyncLoggerDisruptor) f.get(logger)).getDisruptor().getRingBuffer().remainingCapacity(); } catch (Exception ex) { throw new RuntimeException(ex); } } else { LoggerConfig loggerConfig = ((org.apache.logging.log4j.core.Logger) logger).get(); if (loggerConfig instanceof AsyncLoggerConfig) { try { Object delegate = field(AsyncLoggerConfig.class, "delegate").get(loggerConfig); return ((Disruptor) field(AsyncLoggerConfigDisruptor.class, "disruptor").get(delegate)).getRingBuffer().remainingCapacity(); } catch (Exception ex) { throw new RuntimeException(ex); } } else { Appender async = loggerConfig.getAppenders().get("async"); if (async instanceof AsyncAppender) { return ((AsyncAppender) async).getQueueCapacity(); } } } throw new IllegalStateException("Neither Async Loggers nor AsyncAppender are configured"); } private static Field field(Class<?> c, String name) throws NoSuchFieldException {
@Test(timeout = 1000) public void shouldTrackRemainingCapacity() throws Exception { final long[] remainingCapacity = {-1}; //Given final EventHandler<TestEvent> eventHandler = new EventHandler<TestEvent>() { @Override public void onEvent(final TestEvent event, final long sequence, final boolean endOfBatch) throws Exception { remainingCapacity[0] = disruptor.getRingBuffer().remainingCapacity(); } }; disruptor.handleEventsWith(eventHandler); //When publishEvent(); //Then while (remainingCapacity[0] == -1) { Thread.sleep(100); } assertThat(remainingCapacity[0], is(ringBuffer.getBufferSize() - 1L)); assertThat(disruptor.getRingBuffer().remainingCapacity(), is(ringBuffer.getBufferSize() - 0L)); }
@Override public Integer getValue() { return (int) disruptor.getRingBuffer().remainingCapacity(); } });
/** * @return */ public long getAvailableCapacity() { return m_ringBuffer.remainingCapacity(); }
@Override public String toString() { return "RingBufferProcessor{" + "barrier=" + barrier + ", remaining=" + ringBuffer.remainingCapacity() + '}'; }
@Override public long getAvailableCapacity() { return ringBuffer.remainingCapacity(); }
@Override public long remainingSlots() { return ringBuffer.remainingCapacity(); }
@Override public long remainingSlots() { return ringBuffer.remainingCapacity(); }
@Scheduled(initialDelay = _1_MINUTE, fixedDelay = _1_MINUTE) public void healthCheck() { logger.info("Tapir Salto is running... Remaining capacity: '{}'", ringBuffer.remainingCapacity()); } }
@Scheduled(initialDelay = _1_MINUTE, fixedDelay = _1_MINUTE) public void healthCheck() { logger.info("Tapir Captain is running... Remaining capacity: '{}'", ringBuffer.remainingCapacity()); } }
public long getUsage() { if (ringBuffer == null) { return 0; } return (long) ringBuffer.getBufferSize() - ringBuffer.remainingCapacity(); }
/** * @return */ public long getPendingRequests() { return m_ringBuffer.getBufferSize() - m_ringBuffer.remainingCapacity(); }
private int remainingDisruptorCapacity() { final Disruptor<RingBufferLogEvent> temp = disruptor; if (hasLog4jBeenShutDown(temp)) { return -1; } return (int) temp.getRingBuffer().remainingCapacity(); } /**
private int remainingDisruptorCapacity() { final Disruptor<Log4jEventWrapper> temp = disruptor; if (hasLog4jBeenShutDown(temp)) { return -1; } return (int) temp.getRingBuffer().remainingCapacity(); }
@Override public long getBufferedEvents() { if (disruptor != null) { return disruptor.getBufferSize() - disruptor.getRingBuffer().remainingCapacity(); } return 0L; }