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);
}
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);
}
}
}
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()]);
}
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());
}
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);
}
Aggregations