com.lmax.disruptor.EventTranslatorVararg Java Examples
The following examples show how to use
com.lmax.disruptor.EventTranslatorVararg.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. * @return true if the value was published, false if there was insufficient capacity. */ public boolean tryPublishEvent(EventTranslatorVararg<E> translator, Object... args) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
Example #2
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param batchStartsAt The first element of the array which is within the batch. * @param batchSize The actual size of the batch. * @param args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, int batchStartsAt, int batchSize, Object[]... args) { checkBounds(args, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, batchStartsAt, batchSize, finalSequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
Example #3
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
private void translateAndPublish(EventTranslatorVararg<E> translator, long sequence, Object... args) { try { translator.translateTo(get(sequence), sequence, args); } finally { sequencer.publish(sequence); } }
Example #4
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
private void translateAndPublishBatch(final EventTranslatorVararg<E> translator, int batchStartsAt, final int batchSize, final long finalSequence, final Object[][] args) { final long initialSequence = finalSequence - (batchSize - 1); try { long sequence = initialSequence; final int batchEndsAt = batchStartsAt + batchSize; for (int i = batchStartsAt; i < batchEndsAt; i++) { translator.translateTo(get(sequence), sequence++, args[i]); } } finally { sequencer.publish(initialSequence, finalSequence); } }
Example #5
Source File: AsyncLoggerDisruptor.java From logging-log4j2 with Apache License 2.0 | 5 votes |
void enqueueLogMessageWhenQueueFull( final EventTranslatorVararg<RingBufferLogEvent> translator, final AsyncLogger asyncLogger, final StackTraceElement location, final String fqcn, final Level level, final Marker marker, final Message msg, final Throwable thrown) { try { // Note: we deliberately access the volatile disruptor field afresh here. // Avoiding this and using an older reference could result in adding a log event to the disruptor after it // was shut down, which could cause the publishEvent method to hang and never return. if (synchronizeEnqueueWhenQueueFull()) { synchronized (queueFullEnqueueLock) { disruptor.getRingBuffer().publishEvent(translator, asyncLogger, // asyncLogger: 0 location, // location: 1 fqcn, // 2 level, // 3 marker, // 4 msg, // 5 thrown); // 6 } } else { disruptor.getRingBuffer().publishEvent(translator, asyncLogger, // asyncLogger: 0 location, // location: 1 fqcn, // 2 level, // 3 marker, // 4 msg, // 5 thrown); // 6 } } catch (final NullPointerException npe) { // LOG4J2-639: catch NPE if disruptor field was set to null in stop() logWarningOnNpeFromDisruptorPublish(level, fqcn, msg, thrown); } }
Example #6
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public void publishEvent(EventTranslatorVararg<ResponseEvent> translator, Object... args) { throw new UnsupportedOperationException(); }
Example #7
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public boolean tryPublishEvent(EventTranslatorVararg<ResponseEvent> translator, Object... args) { throw new UnsupportedOperationException(); }
Example #8
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public void publishEvents(EventTranslatorVararg<ResponseEvent> translator, Object[]... args) { throw new UnsupportedOperationException(); }
Example #9
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public void publishEvents(EventTranslatorVararg<ResponseEvent> translator, int batchStartsAt, int batchSize, Object[]... args) { throw new UnsupportedOperationException(); }
Example #10
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public boolean tryPublishEvents(EventTranslatorVararg<ResponseEvent> translator, Object[]... args) { throw new UnsupportedOperationException(); }
Example #11
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public boolean tryPublishEvents(EventTranslatorVararg<ResponseEvent> translator, int batchStartsAt, int batchSize, Object[]... args) { throw new UnsupportedOperationException(); }
Example #12
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. */ public void publishEvent(EventTranslatorVararg<E> translator, Object... args) { final long sequence = sequencer.next(); translateAndPublish(translator, sequence, args); }
Example #13
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public void publishEvents(EventTranslatorVararg<E> translator, Object[]... args) { publishEvents(translator, 0, args.length, args); }
Example #14
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param batchStartsAt The first element of the array which is within the batch. * @param batchSize The actual size of the batch * @param args User supplied arguments, one Object[] per event. * @see #publishEvents(EventTranslator[]) */ public void publishEvents(EventTranslatorVararg<E> translator, int batchStartsAt, int batchSize, Object[]... args) { checkBounds(batchStartsAt, batchSize, args); final long finalSequence = sequencer.next(batchSize); translateAndPublishBatch(translator, batchStartsAt, batchSize, finalSequence, args); }
Example #15
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, Object[]... args) { return tryPublishEvents(translator, 0, args.length, args); }