com.lmax.disruptor.EventTranslatorTwoArg Java Examples
The following examples show how to use
com.lmax.disruptor.EventTranslatorTwoArg.
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 two user supplied arguments. * * @see #tryPublishEvent(EventTranslator) * @param translator The user specified translation for the event * @param arg0 A user supplied argument. * @param arg1 A user supplied argument. * @return true if the value was published, false if there was insufficient capacity. */ public <A, B> boolean tryPublishEvent(EventTranslatorTwoArg<E, A, B> translator, A arg0, B arg1) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, arg0, arg1); return true; } catch (InsufficientCapacityException e) { return false; } }
Example #2
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
private <A, B> void translateAndPublish(EventTranslatorTwoArg<E, A, B> translator, long sequence, A arg0, B arg1) { try { translator.translateTo(get(sequence), sequence, arg0, arg1); } finally { sequencer.publish(sequence); } }
Example #3
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 5 votes |
private <A, B> void translateAndPublishBatch(final EventTranslatorTwoArg<E, A, B> translator, final A[] arg0, final B[] arg1, int batchStartsAt, int batchSize, final long finalSequence) { 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++, arg0[i], arg1[i]); } } finally { sequencer.publish(initialSequence, finalSequence); } }
Example #4
Source File: DisruptorAutoConfiguration.java From disruptor-spring-boot-starter with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public EventTranslatorTwoArg<DisruptorEvent, String, String> twoArgEventTranslator() { return new DisruptorEventTwoArgTranslator(); }
Example #5
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> void publishEvent(EventTranslatorTwoArg<ResponseEvent, A, B> translator, A arg0, B arg1) { ResponseEvent ev = new ResponseEvent(); translator.translateTo(ev, 0, arg0, arg1); responseEvents.add(ev); }
Example #6
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> boolean tryPublishEvent(EventTranslatorTwoArg<ResponseEvent, A, B> translator, A arg0, B arg1) { throw new UnsupportedOperationException(); }
Example #7
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> void publishEvents(EventTranslatorTwoArg<ResponseEvent, A, B> translator, A[] arg0, B[] arg1) { throw new UnsupportedOperationException(); }
Example #8
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> void publishEvents(EventTranslatorTwoArg<ResponseEvent, A, B> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1) { throw new UnsupportedOperationException(); }
Example #9
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> boolean tryPublishEvents(EventTranslatorTwoArg<ResponseEvent, A, B> translator, A[] arg0, B[] arg1) { throw new UnsupportedOperationException(); }
Example #10
Source File: CollectingResponseEventSink.java From couchbase-jvm-core with Apache License 2.0 | 4 votes |
@Override public <A, B> boolean tryPublishEvents(EventTranslatorTwoArg<ResponseEvent, A, B> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1) { throw new UnsupportedOperationException(); }
Example #11
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 3 votes |
/** * Allows two 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 arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient capacity. * @see #tryPublishEvents(EventTranslator[]) */ public <A, B> boolean tryPublishEvents(EventTranslatorTwoArg<E, A, B> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1) { checkBounds(arg0, arg1, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, arg0, arg1, batchStartsAt, batchSize, finalSequence); return true; } catch (InsufficientCapacityException e) { return false; } }
Example #12
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows two user supplied arguments. * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param arg0 A user supplied argument. * @param arg1 A user supplied argument. */ public <A, B> void publishEvent(EventTranslatorTwoArg<E, A, B> translator, A arg0, B arg1) { final long sequence = sequencer.next(); translateAndPublish(translator, sequence, arg0, arg1); }
Example #13
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows two user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public <A, B> void publishEvents(EventTranslatorTwoArg<E, A, B> translator, A[] arg0, B[] arg1) { publishEvents(translator, 0, arg0.length, arg0, arg1); }
Example #14
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows two 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 arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @see #publishEvents(EventTranslator[]) */ public <A, B> void publishEvents(EventTranslatorTwoArg<E, A, B> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1) { checkBounds(arg0, arg1, batchStartsAt, batchSize); final long finalSequence = sequencer.next(batchSize); translateAndPublishBatch(translator, arg0, arg1, batchStartsAt, batchSize, finalSequence); }
Example #15
Source File: RingBuffer.java From jstorm with Apache License 2.0 | 2 votes |
/** * Allows two user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient capacity. * @see #tryPublishEvents(com.lmax.disruptor.EventTranslator[]) */ public <A, B> boolean tryPublishEvents(EventTranslatorTwoArg<E, A, B> translator, A[] arg0, B[] arg1) { return tryPublishEvents(translator, 0, arg0.length, arg0, arg1); }