use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class RemoveTopicSubscriptionHandlerTest method shouldWriteErrorOnFailure.
@Test
public void shouldWriteErrorOnFailure() {
// given
final RemoveTopicSubscriptionHandler handler = new RemoveTopicSubscriptionHandler(output, subscriptionService);
final BrokerEventMetadata metadata = new BrokerEventMetadata();
metadata.requestStreamId(14);
final DirectBuffer request = encode(new CloseSubscriptionRequest().setSubscriberKey(5L));
actorSchedulerRule.submitActor(new Handler((actor) -> handler.handle(actor, 0, request, metadata)));
actorSchedulerRule.workUntilDone();
// when
futurePool.at(0).completeExceptionally(new RuntimeException("foo"));
actorSchedulerRule.workUntilDone();
// then
assertThat(output.getSentResponses()).hasSize(1);
final ErrorResponseDecoder errorDecoder = output.getAsErrorResponse(0);
assertThat(errorDecoder.errorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
assertThat(errorDecoder.errorData()).isEqualTo("Cannot close topic subscription. foo");
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class BufferingServerOutput method getAs.
protected <T extends MessageDecoderFlyweight> T getAs(int index, T decoder) {
final DirectBuffer sentResponse = sentResponses.get(index);
final int offset = TransportHeaderDescriptor.HEADER_LENGTH + RequestResponseHeaderDescriptor.HEADER_LENGTH;
headerDecoder.wrap(sentResponse, offset);
decoder.wrap(sentResponse, offset + headerDecoder.encodedLength(), headerDecoder.blockLength(), headerDecoder.version());
return decoder;
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class POJODeserializationBenchmark method deserialize.
@Benchmark
@Threads(1)
public void deserialize(POJODeserializationContext ctx) throws Exception {
final MsgPackSerializer serializer = ctx.getSerializer();
final DirectBuffer encodedMsgPack = ctx.getMsgpackBuffer();
serializer.deserialize(ctx.getTargetClass(), encodedMsgPack, 0, encodedMsgPack.capacity());
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class PayloadCache method lookupPayload.
private DirectBuffer lookupPayload(long position) {
DirectBuffer payload = null;
final boolean found = logStreamReader.seek(position);
if (found && logStreamReader.hasNext()) {
final LoggedEvent event = logStreamReader.next();
workflowInstanceEvent.reset();
event.readValue(workflowInstanceEvent);
payload = workflowInstanceEvent.getPayload();
}
return payload;
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class WorkflowCreateProcessor method processEvent.
@Override
public void processEvent(TypedEvent<WorkflowEvent> event) {
partitionIds.clear();
final WorkflowEvent workflowEvent = event.getValue();
final PendingDeployment pendingDeployment = pendingDeployments.get(workflowEvent.getDeploymentKey());
ensureNotNull("pending deployment", pendingDeployment);
final DirectBuffer topicName = pendingDeployment.getTopicName();
final TopicPartitionIterator iterator = topicPartitions.iterator();
while (iterator.hasNext()) {
final TopicPartition topicPartition = iterator.next();
if (BufferUtil.equals(topicName, topicPartition.getTopicName())) {
partitionIds.add(topicPartition.getPartitionId());
}
}
ensureGreaterThan("partition ids", partitionIds.size(), 0);
}
Aggregations