use of org.agrona.MutableDirectBuffer in project Aeron by real-logic.
the class EventLogger method logFrameIn.
public void logFrameIn(final DirectBuffer buffer, final int offset, final int length, final InetSocketAddress dstAddress) {
if (IS_FRAME_IN_ENABLED) {
final MutableDirectBuffer encodedBuffer = ENCODING_BUFFER.get();
final int encodedLength = EventEncoder.encode(encodedBuffer, buffer, offset, length, dstAddress);
ringBuffer.write(EventCode.FRAME_IN.id(), encodedBuffer, 0, encodedLength);
}
}
use of org.agrona.MutableDirectBuffer in project Aeron by real-logic.
the class EventLogger method log.
public void log(final EventCode code, final DirectBuffer buffer, final int offset, final int length) {
if (EventCode.isEnabled(code, ENABLED_EVENT_CODES)) {
final MutableDirectBuffer encodedBuffer = ENCODING_BUFFER.get();
final int encodedLength = EventEncoder.encode(encodedBuffer, buffer, offset, length);
ringBuffer.write(code.id(), encodedBuffer, 0, encodedLength);
}
}
use of org.agrona.MutableDirectBuffer in project zeebe by zeebe-io.
the class ClientApiMessageHandler method handleControlMessageRequest.
private boolean handleControlMessageRequest(final BrokerEventMetadata eventMetadata, final DirectBuffer buffer, final int messageOffset, final int messageLength) {
boolean isHandled = false;
long publishPosition;
do {
publishPosition = controlMessageDispatcher.claim(claimedControlMessageFragment, ControlMessageRequestHeaderDescriptor.framedLength(messageLength));
} while (publishPosition == -2);
if (publishPosition >= 0) {
final MutableDirectBuffer writeBuffer = claimedControlMessageFragment.getBuffer();
int writeBufferOffset = claimedControlMessageFragment.getOffset();
controlMessageRequestHeaderDescriptor.wrap(writeBuffer, writeBufferOffset).streamId(eventMetadata.getRequestStreamId()).requestId(eventMetadata.getRequestId());
writeBufferOffset += ControlMessageRequestHeaderDescriptor.headerLength();
writeBuffer.putBytes(writeBufferOffset, buffer, messageOffset, messageLength);
claimedControlMessageFragment.commit();
isHandled = true;
}
return isHandled;
}
use of org.agrona.MutableDirectBuffer in project zeebe by zeebe-io.
the class POJOMappingBenchmark method performMappingCycleReverseEncodedOrder.
@Benchmark
@Threads(1)
public void performMappingCycleReverseEncodedOrder(POJOMappingContext ctx) throws Exception {
final TaskEvent taskEvent = ctx.getTaskEvent();
final DirectBuffer encodedTaskEvent = ctx.getReverseOrderEncodedTaskEvent();
final MutableDirectBuffer writeBuffer = ctx.getWriteBuffer();
taskEvent.reset();
taskEvent.wrap(encodedTaskEvent, 0, encodedTaskEvent.capacity());
taskEvent.write(writeBuffer, 0);
}
use of org.agrona.MutableDirectBuffer in project zeebe by zeebe-io.
the class POJOMappingBenchmark method performMappingCycleOptimalEncodedOrder.
@Benchmark
@Threads(1)
public void performMappingCycleOptimalEncodedOrder(POJOMappingContext ctx) throws Exception {
final TaskEvent taskEvent = ctx.getTaskEvent();
final DirectBuffer encodedTaskEvent = ctx.getOptimalOrderEncodedTaskEvent();
final MutableDirectBuffer writeBuffer = ctx.getWriteBuffer();
taskEvent.reset();
taskEvent.wrap(encodedTaskEvent, 0, encodedTaskEvent.capacity());
taskEvent.write(writeBuffer, 0);
}
Aggregations