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

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

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

origin: zeebe-io/zeebe

@Override
public int getType() {
 return buffer.getShort(typeOffset(fragmentOffset), Protocol.ENDIANNESS);
}
origin: io.zeebe/zb-logstreams

@Override
public int getType() {
 return buffer.getShort(typeOffset(fragmentOffset), Protocol.ENDIANNESS);
}
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

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: 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: io.zeebe/zb-dispatcher

/**
 * Add a new fragment to the batch.
 *
 * @param length the length of the fragment
 * @param streamId the stream id of the fragment
 * @return the position of the fragment
 * @throws IllegalArgumentException if the given length is greater than the remaining capacity. In
 *     this case, you should try with smaller length, or abort the whole batch.
 */
@SuppressWarnings("restriction")
public long nextFragment(int length, int streamId) {
 currentOffset = nextOffset;
 final int framedLength = framedLength(length);
 nextOffset += alignedLength(framedLength);
 // ensure that there is enough capacity for padding message, or less than frame alignment which
 // omits the padding message
 final int remainingCapacity = buffer.capacity() - nextOffset;
 if (remainingCapacity < 0
   || (FRAME_ALIGNMENT <= remainingCapacity && remainingCapacity < HEADER_LENGTH)) {
  throw new IllegalArgumentException(
    String.format(ERROR_MESSAGE, currentOffset, length, buffer.capacity()));
 }
 // set negative length => uncommitted fragment
 buffer.putIntOrdered(lengthOffset(currentOffset), -framedLength);
 UNSAFE.storeFence();
 buffer.putShort(typeOffset(currentOffset), TYPE_MESSAGE);
 buffer.putInt(streamIdOffset(currentOffset), streamId);
 return position(partitionId, partitionOffset + nextOffset);
}
origin: zeebe-io/zeebe

/**
 * Add a new fragment to the batch.
 *
 * @param length the length of the fragment
 * @param streamId the stream id of the fragment
 * @return the position of the fragment
 * @throws IllegalArgumentException if the given length is greater than the remaining capacity. In
 *     this case, you should try with smaller length, or abort the whole batch.
 */
@SuppressWarnings("restriction")
public long nextFragment(int length, int streamId) {
 currentOffset = nextOffset;
 final int framedLength = framedLength(length);
 nextOffset += alignedLength(framedLength);
 // ensure that there is enough capacity for padding message, or less than frame alignment which
 // omits the padding message
 final int remainingCapacity = buffer.capacity() - nextOffset;
 if (remainingCapacity < 0
   || (FRAME_ALIGNMENT <= remainingCapacity && remainingCapacity < HEADER_LENGTH)) {
  throw new IllegalArgumentException(
    String.format(ERROR_MESSAGE, currentOffset, length, buffer.capacity()));
 }
 // set negative length => uncommitted fragment
 buffer.putIntOrdered(lengthOffset(currentOffset), -framedLength);
 UNSAFE.storeFence();
 buffer.putShort(typeOffset(currentOffset), TYPE_MESSAGE);
 buffer.putInt(streamIdOffset(currentOffset), streamId);
 return position(partitionId, partitionOffset + nextOffset);
}
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: 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

@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;
}
origin: io.zeebe/zb-dispatcher

@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;
}
origin: io.zeebe/zb-dispatcher

@SuppressWarnings("restriction")
public int appendFrame(
  final LogBufferPartition partition,
  final int activePartitionId,
  final DirectBuffer msg,
  final int start,
  final int length,
  final int streamId) {
 final int partitionSize = partition.getPartitionSize();
 final int framedLength = framedLength(length);
 final int alignedFrameLength = alignedLength(framedLength);
 // 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), -framedLength);
  UNSAFE.storeFence();
  buffer.putShort(typeOffset(frameOffset), TYPE_MESSAGE);
  buffer.putInt(streamIdOffset(frameOffset), streamId);
  buffer.putBytes(messageOffset(frameOffset), msg, start, length);
  // commit the message
  buffer.putIntOrdered(lengthOffset(frameOffset), framedLength);
 } else {
  newTail = onEndOfPartition(partition, frameOffset);
 }
 return newTail;
}
origin: zeebe-io/zeebe

@SuppressWarnings("restriction")
public int appendFrame(
  final LogBufferPartition partition,
  final int activePartitionId,
  final DirectBuffer msg,
  final int start,
  final int length,
  final int streamId) {
 final int partitionSize = partition.getPartitionSize();
 final int framedLength = framedLength(length);
 final int alignedFrameLength = alignedLength(framedLength);
 // 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), -framedLength);
  UNSAFE.storeFence();
  buffer.putShort(typeOffset(frameOffset), TYPE_MESSAGE);
  buffer.putInt(streamIdOffset(frameOffset), streamId);
  buffer.putBytes(messageOffset(frameOffset), msg, start, length);
  // commit the message
  buffer.putIntOrdered(lengthOffset(frameOffset), framedLength);
 } else {
  newTail = onEndOfPartition(partition, frameOffset);
 }
 return newTail;
}
origin: zeebe-io/zeebe

final short type = buffer.getShort(typeOffset(fragmentOffset));
if (type == TYPE_PADDING) {
 fragmentOffset += alignedLength(framedLength);
origin: io.zeebe/zb-dispatcher

final short type = buffer.getShort(typeOffset(fragmentOffset));
if (type == TYPE_PADDING) {
 fragmentOffset += alignedLength(framedLength);
origin: zeebe-io/zeebe

final short type = buffer.getShort(typeOffset(partitionOffset));
if (type == TYPE_PADDING) {
 partitionOffset += alignedLength(framedLength);
origin: io.zeebe/zb-dispatcher

final short type = buffer.getShort(typeOffset(partitionOffset));
if (type == TYPE_PADDING) {
 partitionOffset += alignedLength(framedLength);
io.zeebe.dispatcher.impl.logDataFrameDescriptortypeOffset

Popular methods of DataFrameDescriptor

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

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JCheckBox (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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