Search in sources :

Example 76 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class PendingDeployments method markResolved.

public void markResolved(long deploymentKey) {
    final DirectBuffer currentValue = map.get(deploymentKey);
    buffer.putBytes(0, currentValue, 0, VALUE_LENGTH);
    buffer.putInt(STATE_OFFSET, STATE_RESOLVED, BYTE_ORDER);
    map.put(deploymentKey, buffer);
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Example 77 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class ClusterManager method open.

private void open() {
    final List<SocketAddress> collect = Arrays.stream(transportComponentCfg.gossip.initialContactPoints).map(SocketAddress::from).collect(Collectors.toList());
    if (!collect.isEmpty()) {
        context.getGossip().join(collect);
    }
    clusterMemberListManager.publishNodeAPIAddresses();
    final LogStreamsManager logStreamManager = context.getLogStreamsManager();
    final File storageDirectory = new File(transportComponentCfg.management.directory);
    if (!storageDirectory.exists()) {
        try {
            storageDirectory.getParentFile().mkdirs();
            Files.createDirectory(storageDirectory.toPath());
        } catch (final IOException e) {
            LOG.error("Unable to create directory {}", storageDirectory, e);
        }
    }
    final SocketBindingCfg replicationApi = transportComponentCfg.replicationApi;
    final SocketAddress socketAddress = new SocketAddress(replicationApi.getHost(transportComponentCfg.host), replicationApi.port);
    final File[] storageFiles = storageDirectory.listFiles();
    if (storageFiles != null && storageFiles.length > 0) {
        for (int i = 0; i < storageFiles.length; i++) {
            final File storageFile = storageFiles[i];
            final RaftPersistentFileStorage storage = new RaftPersistentFileStorage(storageFile.getAbsolutePath());
            final DirectBuffer topicName = storage.getTopicName();
            final int partitionId = storage.getPartitionId();
            LogStream logStream = logStreamManager.getLogStream(partitionId);
            if (logStream == null) {
                final String directory = storage.getLogDirectory();
                logStream = logStreamManager.createLogStream(topicName, partitionId, directory);
            }
            storage.setLogStream(logStream);
            createRaft(socketAddress, logStream, storage.getMembers(), storage);
        }
    } else {
        if (transportComponentCfg.gossip.initialContactPoints.length == 0) {
            LOG.debug("Broker bootstraps the system topic");
            createPartition(Protocol.SYSTEM_TOPIC_BUF, Protocol.SYSTEM_PARTITION);
        }
    }
}
Also used : RaftPersistentFileStorage(io.zeebe.broker.clustering.raft.RaftPersistentFileStorage) DirectBuffer(org.agrona.DirectBuffer) IOException(java.io.IOException) SocketBindingCfg(io.zeebe.broker.transport.cfg.SocketBindingCfg) LogStream(io.zeebe.logstreams.log.LogStream) LogStreamsManager(io.zeebe.broker.logstreams.LogStreamsManager) File(java.io.File)

Example 78 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class POJOMappingContext method setUp.

@Setup
public void setUp() {
    taskEvent.setEventType(TaskEventType.CREATE);
    taskEvent.setLockTime(System.currentTimeMillis());
    taskEvent.setType(BufferUtil.wrapString("someTaskType"));
    final DirectBuffer payload = write((w) -> {
        w.writeString(BufferUtil.wrapString("key1"));
        w.writeString(BufferUtil.wrapString("aValue"));
        w.writeString(BufferUtil.wrapString("key2"));
        w.writeString(BufferUtil.wrapString("alsoaValue"));
        w.writeString(BufferUtil.wrapString("key3"));
        w.writeString(BufferUtil.wrapString("anotherValue"));
        w.writeString(BufferUtil.wrapString("key4"));
        w.writeString(BufferUtil.wrapString("yetAnotherValue"));
    });
    taskEvent.setPayload(payload);
    final DirectBuffer headers = write((w) -> {
        w.writeMapHeader(2);
        w.writeString(BufferUtil.wrapString("key1"));
        w.writeString(BufferUtil.wrapString("value"));
        w.writeString(BufferUtil.wrapString("key2"));
        w.writeString(BufferUtil.wrapString("value"));
    });
    taskEvent.setHeaders(headers);
    optimalOrderMsgPack = new UnsafeBuffer(new byte[taskEvent.getLength()]);
    taskEvent.write(optimalOrderMsgPack, 0);
    this.reverseOrderMsgPack = revertMapProperties(optimalOrderMsgPack);
    this.writeBuffer = new UnsafeBuffer(new byte[optimalOrderMsgPack.capacity()]);
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Setup(org.openjdk.jmh.annotations.Setup)

Example 79 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class POJOMappingBenchmark method performReadingOptimalOrder.

@Benchmark
@Threads(1)
public void performReadingOptimalOrder(POJOMappingContext ctx) {
    final TaskEvent taskEvent = ctx.getTaskEvent();
    final DirectBuffer encodedTaskEvent = ctx.getOptimalOrderEncodedTaskEvent();
    taskEvent.reset();
    taskEvent.wrap(encodedTaskEvent, 0, encodedTaskEvent.capacity());
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) TaskEvent(io.zeebe.broker.taskqueue.data.TaskEvent) Threads(org.openjdk.jmh.annotations.Threads) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 80 with DirectBuffer

use of org.agrona.DirectBuffer 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)

Aggregations

DirectBuffer (org.agrona.DirectBuffer)116 Header (io.aeron.logbuffer.Header)21 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)21 MutableDirectBuffer (org.agrona.MutableDirectBuffer)20 File (java.io.File)19 MediaDriver (io.aeron.driver.MediaDriver)18 CountersReader (org.agrona.concurrent.status.CountersReader)15 ThreadingMode (io.aeron.driver.ThreadingMode)12 FragmentHandler (io.aeron.logbuffer.FragmentHandler)12 MappedByteBuffer (java.nio.MappedByteBuffer)12 ClusteredService (io.aeron.cluster.service.ClusteredService)10 InterruptAfter (io.aeron.test.InterruptAfter)10 Test (org.junit.jupiter.api.Test)10 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 Publication (io.aeron.Publication)9 ClientSession (io.aeron.cluster.service.ClientSession)9 ClusteredServiceContainer (io.aeron.cluster.service.ClusteredServiceContainer)8 Assertions (org.junit.jupiter.api.Assertions)8 Mockito.mock (org.mockito.Mockito.mock)8