Tabnine Logo
DataFrameDescriptor.lengthOffset
Code IndexAdd Tabnine to your IDE (free)

How to use
lengthOffset
method
in
io.zeebe.dispatcher.impl.log.DataFrameDescriptor

Best Java code snippets using io.zeebe.dispatcher.impl.log.DataFrameDescriptor.lengthOffset (Showing top 20 results out of 315)

origin: io.zeebe/zb-logstreams

@Override
public int getMessageLength() {
 return messageLength(buffer.getInt(lengthOffset(fragmentOffset), Protocol.ENDIANNESS));
}
origin: zeebe-io/zeebe

@Override
public int getMessageLength() {
 return messageLength(buffer.getInt(lengthOffset(fragmentOffset), Protocol.ENDIANNESS));
}
origin: io.zeebe/zb-logstreams

public static int getFragmentLength(final DirectBuffer buffer, final int offset) {
 return alignedLength(buffer.getInt(lengthOffset(offset), Protocol.ENDIANNESS));
}
origin: zeebe-io/zeebe

/** Commit the fragment so that it can be read by subscriptions. */
public void commit() {
 // commit the message by writing the positive framed length
 buffer.putIntOrdered(lengthOffset(0), buffer.capacity());
 onCompleteHandler.run();
 reset();
}
origin: zeebe-io/zeebe

public static int getFragmentLength(final DirectBuffer buffer, final int offset) {
 return alignedLength(buffer.getInt(lengthOffset(offset), Protocol.ENDIANNESS));
}
origin: io.zeebe/zb-dispatcher

/** Commit the fragment so that it can be read by subscriptions. */
public void commit() {
 // commit the message by writing the positive framed length
 buffer.putIntOrdered(lengthOffset(0), buffer.capacity());
 onCompleteHandler.run();
 reset();
}
origin: zeebe-io/zeebe

/**
 * Commit all fragments of the batch and mark them as failed. They will be ignored by
 * subscriptions.
 */
public void abort() {
 // discard all fragments by set the type to padding
 int fragmentOffset = 0;
 while (fragmentOffset < nextOffset) {
  final int fragmentLength = -buffer.getInt(lengthOffset(fragmentOffset));
  buffer.putInt(typeOffset(fragmentOffset), TYPE_PADDING);
  buffer.putIntOrdered(lengthOffset(fragmentOffset), fragmentLength);
  fragmentOffset += DataFrameDescriptor.alignedLength(fragmentLength);
 }
 fillRemainingBatchSize();
 onCompleteHandler.run();
 reset();
}
origin: zeebe-io/zeebe

/** Commit the fragment and mark it as failed. It will be ignored by subscriptions. */
public void abort() {
 // abort the message by setting type to padding and writing the positive framed length
 buffer.putInt(typeOffset(0), TYPE_PADDING);
 buffer.putIntOrdered(lengthOffset(0), buffer.capacity());
 onCompleteHandler.run();
 reset();
}
origin: io.zeebe/zb-dispatcher

/** Commit the fragment and mark it as failed. It will be ignored by subscriptions. */
public void abort() {
 // abort the message by setting type to padding and writing the positive framed length
 buffer.putInt(typeOffset(0), TYPE_PADDING);
 buffer.putIntOrdered(lengthOffset(0), buffer.capacity());
 onCompleteHandler.run();
 reset();
}
origin: zeebe-io/zeebe

private void fillRemainingBatchSize() {
 // since the claimed batch size can be longer than the written fragment
 // size, we need to fill the rest with a padding fragment
 final int remainingLength = buffer.capacity() - nextOffset;
 if (remainingLength >= HEADER_LENGTH) {
  buffer.putInt(lengthOffset(nextOffset), remainingLength);
  buffer.putShort(typeOffset(nextOffset), TYPE_PADDING);
 }
}
origin: io.zeebe/zb-dispatcher

/**
 * Commit all fragments of the batch and mark them as failed. They will be ignored by
 * subscriptions.
 */
public void abort() {
 // discard all fragments by set the type to padding
 int fragmentOffset = 0;
 while (fragmentOffset < nextOffset) {
  final int fragmentLength = -buffer.getInt(lengthOffset(fragmentOffset));
  buffer.putInt(typeOffset(fragmentOffset), TYPE_PADDING);
  buffer.putIntOrdered(lengthOffset(fragmentOffset), fragmentLength);
  fragmentOffset += DataFrameDescriptor.alignedLength(fragmentLength);
 }
 fillRemainingBatchSize();
 onCompleteHandler.run();
 reset();
}
origin: io.zeebe/zb-dispatcher

 @SuppressWarnings("restriction")
 protected int onEndOfPartition(final LogBufferPartition partition, final int partitionOffset) {
  int newTail = RESULT_END_OF_PARTITION;

  final int padLength = partition.getPartitionSize() - partitionOffset;

  if (padLength >= HEADER_LENGTH) {
   // this message tripped the end of the partition, fill buffer with padding
   final UnsafeBuffer buffer = partition.getDataBuffer();
   buffer.putIntOrdered(lengthOffset(partitionOffset), -padLength);
   UNSAFE.storeFence();
   buffer.putShort(typeOffset(partitionOffset), TYPE_PADDING);
   buffer.putIntOrdered(lengthOffset(partitionOffset), padLength);

   newTail = RESULT_PADDING_AT_END_OF_PARTITION;
  }

  return newTail;
 }
}
origin: io.zeebe/zb-dispatcher

private void fillRemainingBatchSize() {
 // since the claimed batch size can be longer than the written fragment
 // size, we need to fill the rest with a padding fragment
 final int remainingLength = buffer.capacity() - nextOffset;
 if (remainingLength >= HEADER_LENGTH) {
  buffer.putInt(lengthOffset(nextOffset), remainingLength);
  buffer.putShort(typeOffset(nextOffset), TYPE_PADDING);
 }
}
origin: zeebe-io/zeebe

 @SuppressWarnings("restriction")
 protected int onEndOfPartition(final LogBufferPartition partition, final int partitionOffset) {
  int newTail = RESULT_END_OF_PARTITION;

  final int padLength = partition.getPartitionSize() - partitionOffset;

  if (padLength >= HEADER_LENGTH) {
   // this message tripped the end of the partition, fill buffer with padding
   final UnsafeBuffer buffer = partition.getDataBuffer();
   buffer.putIntOrdered(lengthOffset(partitionOffset), -padLength);
   UNSAFE.storeFence();
   buffer.putShort(typeOffset(partitionOffset), TYPE_PADDING);
   buffer.putIntOrdered(lengthOffset(partitionOffset), padLength);

   newTail = RESULT_PADDING_AT_END_OF_PARTITION;
  }

  return newTail;
 }
}
origin: zeebe-io/zeebe

 @Override
 public DirectBuffer next() {
  final int framedFragmentLength =
    bufferView.getInt(DataFrameDescriptor.lengthOffset(iterationOffset));
  final int fragmentLength = DataFrameDescriptor.messageLength(framedFragmentLength);
  final int messageOffset = DataFrameDescriptor.messageOffset(iterationOffset);
  buffer.wrap(bufferView, messageOffset, fragmentLength);
  iterationOffset += DataFrameDescriptor.alignedLength(framedFragmentLength);
  return buffer;
 }
}
origin: io.zeebe/zb-dispatcher

 @Override
 public DirectBuffer next() {
  final int framedFragmentLength =
    bufferView.getInt(DataFrameDescriptor.lengthOffset(iterationOffset));
  final int fragmentLength = DataFrameDescriptor.messageLength(framedFragmentLength);
  final int messageOffset = DataFrameDescriptor.messageOffset(iterationOffset);
  buffer.wrap(bufferView, messageOffset, fragmentLength);
  iterationOffset += DataFrameDescriptor.alignedLength(framedFragmentLength);
  return buffer;
 }
}
origin: zeebe-io/zeebe

/** Commit all fragments of the batch so that it can be read by subscriptions. */
public void commit() {
 final int firstFragmentFramedLength = -buffer.getInt(lengthOffset(FIRST_FRAGMENT_OFFSET));
 // do not set batch flags if only one fragment in the batch
 if (currentOffset > 0) {
  // set batch begin flag
  final byte firstFragmentFlags = buffer.getByte(flagsOffset(FIRST_FRAGMENT_OFFSET));
  buffer.putByte(flagsOffset(FIRST_FRAGMENT_OFFSET), enableFlagBatchBegin(firstFragmentFlags));
  // set positive length => commit fragment
  int fragmentOffset = DataFrameDescriptor.alignedLength(firstFragmentFramedLength);
  while (fragmentOffset < nextOffset) {
   final int fragmentFramedLength = -buffer.getInt(lengthOffset(fragmentOffset));
   buffer.putInt(lengthOffset(fragmentOffset), fragmentFramedLength);
   fragmentOffset += DataFrameDescriptor.alignedLength(fragmentFramedLength);
  }
  // set batch end flag
  final byte lastFragmentFlags = buffer.getByte(flagsOffset(currentOffset));
  buffer.putByte(flagsOffset(currentOffset), enableFlagBatchEnd(lastFragmentFlags));
 }
 fillRemainingBatchSize();
 // commit the first fragment at the end so that the batch can be read at
 // once
 buffer.putIntOrdered(lengthOffset(FIRST_FRAGMENT_OFFSET), firstFragmentFramedLength);
 onCompleteHandler.run();
 reset();
}
origin: zeebe-io/zeebe

/**
 * Finish reading and consume the fragments (i.e. update the subscription position). Mark all
 * fragments as failed.
 */
public void markFailed() {
 int fragmentOffset = 0;
 while (fragmentOffset < blockLength) {
  int framedFragmentLength =
    bufferView.getInt(DataFrameDescriptor.lengthOffset(fragmentOffset));
  if (framedFragmentLength < 0) {
   framedFragmentLength = -framedFragmentLength;
  }
  final int frameLength = DataFrameDescriptor.alignedLength(framedFragmentLength);
  final int flagsOffset = DataFrameDescriptor.flagsOffset(fragmentOffset);
  final byte flags = bufferView.getByte(flagsOffset);
  bufferView.putByte(flagsOffset, DataFrameDescriptor.enableFlagFailed(flags));
  fragmentOffset += frameLength;
 }
 updatePosition();
}
origin: io.zeebe/zb-dispatcher

/**
 * Finish reading and consume the fragments (i.e. update the subscription position). Mark all
 * fragments as failed.
 */
public void markFailed() {
 int fragmentOffset = 0;
 while (fragmentOffset < blockLength) {
  int framedFragmentLength =
    bufferView.getInt(DataFrameDescriptor.lengthOffset(fragmentOffset));
  if (framedFragmentLength < 0) {
   framedFragmentLength = -framedFragmentLength;
  }
  final int frameLength = DataFrameDescriptor.alignedLength(framedFragmentLength);
  final int flagsOffset = DataFrameDescriptor.flagsOffset(fragmentOffset);
  final byte flags = bufferView.getByte(flagsOffset);
  bufferView.putByte(flagsOffset, DataFrameDescriptor.enableFlagFailed(flags));
  fragmentOffset += frameLength;
 }
 updatePosition();
}
origin: zeebe-io/zeebe

@SuppressWarnings("restriction")
public int claim(
  final LogBufferPartition partition,
  final int activePartitionId,
  final ClaimedFragment claim,
  final int length,
  final int streamId,
  Runnable onComplete) {
 final int partitionSize = partition.getPartitionSize();
 final int framedMessageLength = framedLength(length);
 final int alignedFrameLength = alignedLength(framedMessageLength);
 // move the tail of the partition
 final int frameOffset = partition.getAndAddTail(alignedFrameLength);
 int newTail = frameOffset + alignedFrameLength;
 if (newTail <= (partitionSize - HEADER_LENGTH)) {
  final UnsafeBuffer buffer = partition.getDataBuffer();
  // write negative length field
  buffer.putIntOrdered(lengthOffset(frameOffset), -framedMessageLength);
  UNSAFE.storeFence();
  buffer.putShort(typeOffset(frameOffset), TYPE_MESSAGE);
  buffer.putInt(streamIdOffset(frameOffset), streamId);
  claim.wrap(buffer, frameOffset, framedMessageLength, onComplete);
  // Do not commit the message
 } else {
  newTail = onEndOfPartition(partition, frameOffset);
 }
 return newTail;
}
io.zeebe.dispatcher.impl.logDataFrameDescriptorlengthOffset

Popular methods of DataFrameDescriptor

  • alignedLength
  • messageLength
  • messageOffset
  • alignedFramedLength
  • streamIdOffset
  • typeOffset
  • enableFlagBatchBegin
  • enableFlagBatchEnd
  • enableFlagFailed
  • flagBatchBegin
  • flagBatchEnd
  • flagFailed
  • flagBatchEnd,
  • flagFailed,
  • flagsOffset,
  • framedLength,
  • versionOffset

Popular in Java

  • Start an intent from android
  • compareTo (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • 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