Tabnine Logo
Encoder.offset
Code IndexAdd Tabnine to your IDE (free)

How to use
offset
method
in
uk.co.real_logic.artio.builder.Encoder

Best Java code snippets using uk.co.real_logic.artio.builder.Encoder.offset (Showing top 12 results out of 315)

origin: real-logic/artio

private long send(
  final long result,
  final int messageType,
  final int sequenceIndex,
  final Encoder encoder,
  final int msgSeqNo)
{
  if (!libraryConnected)
  {
    return LIBRARY_DISCONNECTED;
  }
  final int length = Encoder.length(result);
  final int offset = Encoder.offset(result);
  final long position = gatewayPublication.saveMessage(
    buffer, offset, length,
    libraryId, messageType, sessionId, sequenceIndex, connectionId, OK, msgSeqNo);
  encoder.resetMessage();
  return position;
}
origin: real-logic/artio

private void assertEncodesTo(final Encoder encoder, final String expectedValue)
{
  final long result = encoder.encode(buffer, 1);
  final int length = Encoder.length(result);
  final int offset = Encoder.offset(result);
  assertEquals(expectedValue, buffer.getAscii(offset, expectedValue.length()));
  assertEquals(expectedValue.length(), length);
}
origin: real-logic/artio

private void onMessageWithSession(
  final int messageType,
  final long result,
  final Action expectedAction,
  final long sessionId,
  final long connectionId)
{
  final int length = Encoder.length(result);
  final int offset = Encoder.offset(result);
  final Action action = replayer.onMessage(
    buffer, offset, length,
    LIBRARY_ID, connectionId, sessionId, SEQUENCE_INDEX, messageType, 0L, OK, 0, 0L);
  assertEquals(expectedAction, action);
}
origin: real-logic/artio

final int encodedOffset = Encoder.offset(result);
gapFiller.onMessage(
  buffer, encodedOffset, encodedLength,
origin: real-logic/artio

void send(final Encoder encoder)
{
  try
  {
    final long result = encoder.encode(writeAsciiBuffer, OFFSET);
    final int offset = Encoder.offset(result);
    final int length = Encoder.length(result);
    encoder.reset();
    writeBuffer.position(offset).limit(offset + length);
    final int written = socket.write(writeBuffer);
    assertEquals(length, written);
    DebugLogger.log(FIX_TEST, "> [" + writeAsciiBuffer.getAscii(offset, length) + "]");
    writeBuffer.clear();
  }
  catch (final IOException ex)
  {
    LangUtil.rethrowUnchecked(ex);
  }
}
origin: real-logic/artio

private void initiateConnection() throws IOException
{
  socket = SocketChannel.open(new InetSocketAddress("localhost", port));
  final UtcTimestampEncoder timestamp = new UtcTimestampEncoder();
  timestamp.encode(System.currentTimeMillis());
  logon
    .heartBtInt(10)
    .encryptMethod(0)
    .header()
    .sendingTime(timestamp.buffer())
    .msgSeqNum(1)
    .senderCompID(INITIATOR_ID)
    .targetCompID(ACCEPTOR_ID);
  final long result = logon.encode(buffer, 0);
  final int offset = Encoder.offset(result);
  final int length = Encoder.length(result);
  byteBuffer.position(offset);
  byteBuffer.limit(offset + length);
  assertEquals(length, socket.write(byteBuffer));
}
origin: real-logic/artio

final long result = encoder.encode(gapFillMsgSeqNum, newSeqNo);
final int encodedLength = Encoder.length(result);
final int encodedOffset = Encoder.offset(result);
final long sentPosition = publication.saveMessage(
  encoder.buffer(), encodedOffset, encodedLength,
origin: real-logic/artio

/**
 * Send a message on this session.
 *
 * @param encoder the encoder of the message to be sent
 * @return the position in the stream that corresponds to the end of this message or a negative
 * number indicating an error status.
 * @throws IndexOutOfBoundsException if the encoded message is too large, if this happens consider
 *                                   increasing {@link CommonConfiguration#sessionBufferSize(int)}
 */
public long send(final Encoder encoder)
{
  validateCanSendMessage();
  final int sentSeqNum = newSentSeqNum();
  final HeaderEncoder header = (HeaderEncoder)encoder.header();
  header
    .msgSeqNum(sentSeqNum)
    .sendingTime(timestampEncoder.buffer(), timestampEncoder.encode(time()));
  if (enableLastMsgSeqNumProcessed)
  {
    header.lastMsgSeqNumProcessed(lastMsgSeqNumProcessed);
  }
  if (!header.hasSenderCompID())
  {
    sessionIdStrategy.setupSession(sessionKey, header);
  }
  final long result = encoder.encode(asciiBuffer, 0);
  final int length = Encoder.length(result);
  final int offset = Encoder.offset(result);
  return send(asciiBuffer, offset, length, sentSeqNum, encoder.messageType());
}
origin: real-logic/artio

private Action sendGapFill(final int msgSeqNo, final int newSeqNo)
{
  final long result = gapFillEncoder.encode(msgSeqNo, newSeqNo);
  final int gapFillLength = Encoder.length(result);
  final int gapFillOffset = Encoder.offset(result);
  if (claimBuffer(MESSAGE_FRAME_BLOCK_LENGTH + gapFillLength))
  {
    final int destOffset = bufferClaim.offset();
    final MutableDirectBuffer destBuffer = bufferClaim.buffer();
    FIX_MESSAGE_ENCODER
      .wrapAndApplyHeader(destBuffer, destOffset, MESSAGE_HEADER_ENCODER)
      .libraryId(ENGINE_LIBRARY_ID)
      .messageType(SequenceResetDecoder.MESSAGE_TYPE)
      .session(this.sessionId)
      .sequenceIndex(this.sequenceIndex)
      .connection(this.connectionId)
      .timestamp(0)
      .status(MessageStatus.OK)
      .putBody(gapFillEncoder.buffer(), gapFillOffset, gapFillLength);
    bufferClaim.commit();
    this.beginGapFillSeqNum = NONE;
    return CONTINUE;
  }
  else
  {
    return ABORT;
  }
}
origin: real-logic/artio

@Test
public void doesNotReuseExistingSessionIdsForDistinctCompositeKeys()
{
  final SessionContext aContext = sessionContexts.onLogon(aSession);
  final SessionContext bContext = sessionContexts.onLogon(bSession); // bump counter
  final long result = logonWithSenderAndTarget(aSession.localCompId(), aSession.remoteCompId());
  sessionContexts.onSentFollowerMessage(
    aContext.sessionId(), aContext.sequenceIndex(), LogonDecoder.MESSAGE_TYPE, asciiBuffer,
    Encoder.offset(result), Encoder.length(result));
  final SessionContext cContext = sessionContexts.onLogon(cSession);
  assertNotEquals(DUPLICATE_SESSION, cContext);
  assertEquals(3, cContext.sessionId());
}
origin: real-logic/artio

private void bufferContainsMessage(
  final long sessionId,
  final int sequenceNumber,
  final int sequenceIndex,
  final Encoder exampleMessage,
  final HeaderEncoder header,
  final int messageType)
{
  final UtcTimestampEncoder timestampEncoder = new UtcTimestampEncoder();
  final int timestampLength = timestampEncoder.encode(ORIGINAL_SENDING_EPOCH_MS);
  MutableAsciiBuffer asciiBuffer = new MutableAsciiBuffer(new byte[BIG_BUFFER_LENGTH]);
  header
    .sendingTime(timestampEncoder.buffer(), timestampLength)
    .senderCompID(BUFFER_SENDER)
    .targetCompID(BUFFER_TARGET)
    .msgSeqNum(sequenceNumber);
  final long result = exampleMessage.encode(asciiBuffer, 0);
  logEntryLength = Encoder.length(result);
  final int encodedOffset = Encoder.offset(result);
  asciiBuffer = new MutableAsciiBuffer(asciiBuffer, encodedOffset, logEntryLength);
  bufferContainsMessage(sessionId, sequenceIndex, asciiBuffer, messageType);
}
origin: real-logic/artio

final int encodedOffset = Encoder.offset(result);
final boolean sent = inboundPublication.saveMessage(
  encodeBuffer, encodedOffset, encodedLength,
uk.co.real_logic.artio.builderEncoderoffset

Popular methods of Encoder

  • encode
    Encode the message onto a buffer in FIX tag=value\001 format.
  • length
  • reset
    Resets the encoder. Sets all the fields back to their uninitialized state.
  • header
  • messageType
  • resetMessage

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JOptionPane (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now