com.lmax.disruptor.EventTranslatorThreeArg Java Examples

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