Search in sources :

Example 26 with MutableDirectBuffer

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);
    }
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer)

Example 27 with MutableDirectBuffer

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);
    }
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer)

Example 28 with MutableDirectBuffer

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;
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer)

Example 29 with MutableDirectBuffer

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);
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) TaskEvent(io.zeebe.broker.taskqueue.data.TaskEvent) MutableDirectBuffer(org.agrona.MutableDirectBuffer) Threads(org.openjdk.jmh.annotations.Threads) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 30 with MutableDirectBuffer

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);
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) TaskEvent(io.zeebe.broker.taskqueue.data.TaskEvent) MutableDirectBuffer(org.agrona.MutableDirectBuffer) Threads(org.openjdk.jmh.annotations.Threads) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

MutableDirectBuffer (org.agrona.MutableDirectBuffer)42 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)18 BeforeEach (org.junit.jupiter.api.BeforeEach)12 Test (org.junit.jupiter.api.Test)12 DirectBuffer (org.agrona.DirectBuffer)11 MediaDriver (io.aeron.driver.MediaDriver)10 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)10 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)10 RegistrationException (io.aeron.exceptions.RegistrationException)8 FragmentHandler (io.aeron.logbuffer.FragmentHandler)8 InterruptAfter (io.aeron.test.InterruptAfter)8 InterruptingTestCallback (io.aeron.test.InterruptingTestCallback)8 SystemTestWatcher (io.aeron.test.SystemTestWatcher)8 Tests (io.aeron.test.Tests)8 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)8 Objects.requireNonNull (java.util.Objects.requireNonNull)8 MutableLong (org.agrona.collections.MutableLong)8 Assertions.assertNotEquals (org.junit.jupiter.api.Assertions.assertNotEquals)8 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)8 Assumptions.assumeTrue (org.junit.jupiter.api.Assumptions.assumeTrue)8