Java Code Examples for io.aeron.logbuffer.ControlledFragmentHandler#Action

The following examples show how to use io.aeron.logbuffer.ControlledFragmentHandler#Action . 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: StressSessionHandler.java    From artio with Apache License 2.0 6 votes vote down vote up
public ControlledFragmentHandler.Action onMessage(
    final DirectBuffer buffer,
    final int offset,
    final int length,
    final int libraryId,
    final Session session,
    final int sequenceIndex,
    final long messageType,
    final long timestampInNs,
    final long position,
    final OnMessageInfo messageInfo)
{
    if (StressConfiguration.PRINT_EXCHANGE)
    {
        string.wrap(buffer);
        System.out.printf("%d -> %s%n", session.id(), printer.toString(string, offset, length, messageType));
    }

    return CONTINUE;
}
 
Example 2
Source File: ReportFactory.java    From artio with Apache License 2.0 5 votes vote down vote up
public ControlledFragmentHandler.Action sendReport(final Session session, final Side side)
{
    encodedLength = encoder.putLongAscii(0, session.lastSentMsgSeqNum());

    executionReport.orderID(encodeBuffer, encodedLength)
        .execID(encodeBuffer, encodedLength);

    executionReport.execType(ExecType.FILL)
        .ordStatus(OrdStatus.FILLED)
        .side(side);

    executionReport.instrument().symbol(MSFT.getBytes(US_ASCII));

    return Pressure.apply(session.trySend(executionReport));
}
 
Example 3
Source File: InternalSession.java    From artio with Apache License 2.0 5 votes vote down vote up
public ControlledFragmentHandler.Action onInvalidMessage(
    final int refSeqNum,
    final int refTagId,
    final char[] refMsgType,
    final int refMsgTypeLength,
    final int rejectReason, final long position)
{
    return super.onInvalidMessage(refSeqNum, refTagId, refMsgType, refMsgTypeLength, rejectReason, position);
}
 
Example 4
Source File: StressSessionHandler.java    From artio with Apache License 2.0 5 votes vote down vote up
public ControlledFragmentHandler.Action onDisconnect(
    final int libraryId, final Session session, final DisconnectReason reason)
{
    if (StressConfiguration.PRINT_EXCHANGE)
    {
        System.out.printf("%d Disconnected: %s%n", session.id(), reason);
    }

    return CONTINUE;
}
 
Example 5
Source File: LiveRecordingMessageTransceiver.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
public ControlledFragmentHandler.Action onFragment(
    final DirectBuffer buffer, final int offset, final int length, final Header header)
{
    if (recordingPositionConsumed == recordingPosition)
    {
        return ABORT;
    }

    final long timestamp = buffer.getLong(offset, LITTLE_ENDIAN);
    final long checksum = buffer.getLong(offset + length - SIZE_OF_LONG, LITTLE_ENDIAN);
    onMessageReceived(timestamp, checksum);
    recordingPositionConsumed += align(length, FRAME_ALIGNMENT);

    return COMMIT;
}
 
Example 6
Source File: FixMessageTracker.java    From artio with Apache License 2.0 4 votes vote down vote up
public ControlledFragmentHandler.Action onFragment(
    final DirectBuffer buffer, final int offset, final int length, final Header header)
{
    messageHeaderDecoder.wrap(buffer, offset);

    if (messageHeaderDecoder.templateId() == FixMessageDecoder.TEMPLATE_ID)
    {
        final int messageOffset = offset + MessageHeaderDecoder.ENCODED_LENGTH;
        if (sessionId != UNK_SESSION)
        {
            messageDecoder.wrap(
                buffer,
                messageOffset,
                messageHeaderDecoder.blockLength(),
                messageHeaderDecoder.version()
            );

            if (messageDecoder.session() != sessionId)
            {
                return CONTINUE;
            }
        }

        if (DebugLogger.isEnabled(logTag))
        {
            messageDecoder.skipMetaData();
            final int bodyLength = messageDecoder.bodyLength();
            final int bodyOffset = messageDecoder.limit();
            final CharFormatter formatter = FOUND_REPLAY_MESSAGE.get();
            formatter.clear();
            DebugLogger.log(logTag, formatter, buffer, bodyOffset, bodyLength);
        }

        final ControlledFragmentHandler.Action action = messageHandler.onFragment(buffer, offset, length, header);
        if (action != ABORT)
        {
            count++;
        }
        return action;
    }

    return CONTINUE;
}
 
Example 7
Source File: RetryManagerTest.java    From artio with Apache License 2.0 4 votes vote down vote up
private void attemptResultsIn(final ControlledFragmentHandler.Action action)
{
    when(unitOfWork.attemptToAction()).thenReturn(action);
}
 
Example 8
Source File: RecordingSignalAdapter.java    From aeron with Apache License 2.0 4 votes vote down vote up
private ControlledFragmentHandler.Action onFragment(
    final DirectBuffer buffer, final int offset, final int length, final Header header)
{
    if (isDone)
    {
        return ABORT;
    }

    messageHeaderDecoder.wrap(buffer, offset);

    final int schemaId = messageHeaderDecoder.schemaId();
    if (schemaId != MessageHeaderDecoder.SCHEMA_ID)
    {
        throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId);
    }

    final int templateId = messageHeaderDecoder.templateId();
    switch (templateId)
    {
        case ControlResponseDecoder.TEMPLATE_ID:
            controlResponseDecoder.wrap(
                buffer,
                offset + MessageHeaderDecoder.ENCODED_LENGTH,
                messageHeaderDecoder.blockLength(),
                messageHeaderDecoder.version());

            if (controlResponseDecoder.controlSessionId() == controlSessionId)
            {
                controlEventListener.onResponse(
                    controlSessionId,
                    controlResponseDecoder.correlationId(),
                    controlResponseDecoder.relevantId(),
                    controlResponseDecoder.code(),
                    controlResponseDecoder.errorMessage());

                isDone = true;
                return BREAK;
            }
            break;

        case RecordingSignalEventDecoder.TEMPLATE_ID:
            recordingSignalEventDecoder.wrap(
                buffer,
                offset + MessageHeaderDecoder.ENCODED_LENGTH,
                messageHeaderDecoder.blockLength(),
                messageHeaderDecoder.version());

            if (recordingSignalEventDecoder.controlSessionId() == controlSessionId)
            {
                recordingSignalConsumer.onSignal(
                    recordingSignalEventDecoder.controlSessionId(),
                    recordingSignalEventDecoder.correlationId(),
                    recordingSignalEventDecoder.recordingId(),
                    recordingSignalEventDecoder.subscriptionId(),
                    recordingSignalEventDecoder.position(),
                    recordingSignalEventDecoder.signal());

                isDone = true;
                return BREAK;
            }
            break;
    }

    return CONTINUE;
}
 
Example 9
Source File: ControlledEgressListener.java    From aeron with Apache License 2.0 3 votes vote down vote up
/**
 * Message event returned from the clustered service.
 *
 * @param clusterSessionId to which the message belongs.
 * @param timestamp        at which the correlated ingress was sequenced in the cluster.
 * @param buffer           containing the message.
 * @param offset           at which the message begins.
 * @param length           of the message in bytes.
 * @param header           Aeron header associated with the message fragment.
 * @return what action should be taken regarding advancement of the stream.
 */
ControlledFragmentHandler.Action onMessage(
    long clusterSessionId,
    long timestamp,
    DirectBuffer buffer,
    int offset,
    int length,
    Header header);
 
Example 10
Source File: ReplayProtocolHandler.java    From artio with Apache License 2.0 votes vote down vote up
ControlledFragmentHandler.Action onReplayComplete(long connectionId);