public void wrap(final DirectBuffer buffer, final int offset) { this.fragmentOffset = offset; this.messageOffset = messageOffset(fragmentOffset); this.buffer = buffer; }
public int cleanPartitions() { int workCount = 0; for (int i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++) { final LogBufferPartition partition = partitions[i]; if (partition.getStatusVolatile() == PARTITION_NEEDS_CLEANING) { partition.clean(); ++workCount; } } return workCount; }
public static int getFramedRequestLength(int messageLength) { return DataFrameDescriptor.alignedLength(REQUEST_HEADER_LENGTH + messageLength); }
public static int alignedFramedLength(int msgLength) { return alignedLength(framedLength(msgLength)); }
public LogBuffer(AllocatedBuffer allocatedBuffer, int partitionSize, int initialPartitionId) { this.partitionSize = partitionSize; rawBuffer = allocatedBuffer; partitions = new PartitionBuilder().slicePartitions(partitionSize, rawBuffer); metadataBuffer = new UnsafeBuffer( rawBuffer.getRawBuffer(), logMetadataOffset(partitionSize), LOG_META_DATA_LENGTH); metadataBuffer.putInt(LOG_INITIAL_PARTITION_ID_OFFSET, initialPartitionId); metadataBuffer.putIntVolatile(LOG_ACTIVE_PARTITION_ID_OFFSET, initialPartitionId); }
public void onActiveParitionFilled(int activePartitionId) { final int nextPartitionId = 1 + activePartitionId; final int nextNextPartitionId = 1 + nextPartitionId; final LogBufferPartition nextNextPartition = partitions[(nextNextPartitionId) % getPartitionCount()]; nextNextPartition.setStatusOrdered(PARTITION_NEEDS_CLEANING); metadataBuffer.putIntOrdered(LOG_ACTIVE_PARTITION_ID_OFFSET, nextPartitionId); }
public LogBufferPartition getPartition(int id) { return partitions[id % getPartitionCount()]; }
public boolean needsCleaning() { return getStatusVolatile() == PARTITION_NEEDS_CLEANING; }
protected long updatePublisherPosition(final int activePartitionId, int newOffset) { long newPosition = -1; if (newOffset > 0) { newPosition = position(activePartitionId, newOffset); } else if (newOffset == RESULT_PADDING_AT_END_OF_PARTITION) { logBuffer.onActiveParitionFilled(activePartitionId); newPosition = -2; } return newPosition; }
public void clean() { dataBuffer.setMemory(0, partitionSize, (byte) 0); metadataBuffer.putInt(PARTITION_TAIL_COUNTER_OFFSET, 0); setStatusOrdered(PARTITION_CLEAN); }
public static int getFramedMessageLength(int messageLength) { return DataFrameDescriptor.alignedLength(MESSAGE_HEADER_LENGTH + messageLength); }
public static int alignedFramedLength(int msgLength) { return alignedLength(framedLength(msgLength)); }
public void wrap(final DirectBuffer buffer, final int offset) { this.fragmentOffset = offset; this.messageOffset = messageOffset(fragmentOffset); this.buffer = buffer; }
public LogBuffer(AllocatedBuffer allocatedBuffer, int partitionSize, int initialPartitionId) { this.partitionSize = partitionSize; rawBuffer = allocatedBuffer; partitions = new PartitionBuilder().slicePartitions(partitionSize, rawBuffer); metadataBuffer = new UnsafeBuffer( rawBuffer.getRawBuffer(), logMetadataOffset(partitionSize), LOG_META_DATA_LENGTH); metadataBuffer.putInt(LOG_INITIAL_PARTITION_ID_OFFSET, initialPartitionId); metadataBuffer.putIntVolatile(LOG_ACTIVE_PARTITION_ID_OFFSET, initialPartitionId); }
public int cleanPartitions() { int workCount = 0; for (int i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++) { final LogBufferPartition partition = partitions[i]; if (partition.getStatusVolatile() == PARTITION_NEEDS_CLEANING) { partition.clean(); ++workCount; } } return workCount; }
public void onActiveParitionFilled(int activePartitionId) { final int nextPartitionId = 1 + activePartitionId; final int nextNextPartitionId = 1 + nextPartitionId; final LogBufferPartition nextNextPartition = partitions[(nextNextPartitionId) % getPartitionCount()]; nextNextPartition.setStatusOrdered(PARTITION_NEEDS_CLEANING); metadataBuffer.putIntOrdered(LOG_ACTIVE_PARTITION_ID_OFFSET, nextPartitionId); }
public LogBufferPartition getPartition(int id) { return partitions[id % getPartitionCount()]; }
public boolean needsCleaning() { return getStatusVolatile() == PARTITION_NEEDS_CLEANING; }
public static int getFramedRequestLength(int messageLength) { return DataFrameDescriptor.alignedLength(REQUEST_HEADER_LENGTH + messageLength); }
public static int getFramedMessageLength(int messageLength) { return DataFrameDescriptor.alignedLength(MESSAGE_HEADER_LENGTH + messageLength); }