use of io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue in project zeebe-process-test by camunda.
the class RecordStreamSourceImpl method updateWithNewRecords.
private void updateWithNewRecords() {
synchronized (logStreamReader) {
if (lastPosition < 0) {
logStreamReader.seekToFirstEvent();
} else {
logStreamReader.seekToNextEvent(lastPosition);
}
while (logStreamReader.hasNext()) {
final LoggedEvent event = logStreamReader.next();
final CopiedRecord<UnifiedRecordValue> record = mapToRecord(event);
records.add(record);
lastPosition = event.getPosition();
}
}
}
use of io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue in project zeebe by camunda.
the class SkipFailingEventsTest method shouldWriteErrorEventWithNoMessage.
@Test
public void shouldWriteErrorEventWithNoMessage() {
// given
streams.startStreamProcessor(STREAM_NAME, DefaultZeebeDbFactory.defaultFactory(), (processingContext) -> {
zeebeState = processingContext.getZeebeState();
return TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), processingContext.getWriters()).onCommand(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ACTIVATE_ELEMENT, new TypedRecordProcessor<>() {
@Override
public void processRecord(final TypedRecord<UnifiedRecordValue> record, final TypedResponseWriter responseWriter, final TypedStreamWriter streamWriter) {
throw new NullPointerException();
}
});
});
final long failingEventPosition = streams.newRecord(STREAM_NAME).event(PROCESS_INSTANCE_RECORD).recordType(RecordType.COMMAND).intent(ProcessInstanceIntent.ACTIVATE_ELEMENT).key(keyGenerator.nextKey()).write();
// when
waitForRecordWhichSatisfies(e -> Records.isEvent(e, ValueType.ERROR, ErrorIntent.CREATED));
// then
final ErrorRecord errorRecord = new RecordStream(streams.events(STREAM_NAME)).onlyErrorRecords().getFirst().getValue();
assertThat(errorRecord.getErrorEventPosition()).isEqualTo(failingEventPosition);
assertThat(BufferUtil.bufferAsString(errorRecord.getExceptionMessageBuffer())).isEqualTo("Without exception message.");
assertThat(errorRecord.getProcessInstanceKey()).isEqualTo(1);
}
use of io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue in project zeebe by camunda.
the class CopiedRecords method createCopiedRecord.
public static CopiedRecord createCopiedRecord(final int partitionId, final LoggedEvent rawEvent) {
// we have to access the underlying buffer and copy the metadata and value bytes
// otherwise next event will overwrite the event before, since UnpackedObject
// and RecordMetadata has properties (buffers, StringProperty etc.) which only wraps the given
// buffer instead of copying it
final DirectBuffer contentBuffer = rawEvent.getValueBuffer();
final byte[] metadataBytes = new byte[rawEvent.getMetadataLength()];
contentBuffer.getBytes(rawEvent.getMetadataOffset(), metadataBytes);
final DirectBuffer metadataBuffer = new UnsafeBuffer(metadataBytes);
final RecordMetadata metadata = new RecordMetadata();
metadata.wrap(metadataBuffer, 0, metadataBuffer.capacity());
final byte[] valueBytes = new byte[rawEvent.getValueLength()];
contentBuffer.getBytes(rawEvent.getValueOffset(), valueBytes);
final DirectBuffer valueBuffer = new UnsafeBuffer(valueBytes);
final UnifiedRecordValue recordValue = ReflectUtil.newInstance(EVENT_REGISTRY.get(metadata.getValueType()));
recordValue.wrap(valueBuffer);
return new CopiedRecord<>(recordValue, metadata, rawEvent.getKey(), partitionId, rawEvent.getPosition(), rawEvent.getSourceEventPosition(), rawEvent.getTimestamp());
}
use of io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue in project zeebe by camunda.
the class RecordValues method readRecordValue.
public UnifiedRecordValue readRecordValue(final LoggedEvent event, final ValueType valueType) {
final UnifiedRecordValue value = eventCache.get(valueType);
if (value != null) {
value.reset();
event.readValue(value);
}
return value;
}
use of io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue in project zeebe by camunda.
the class ReplayStateMachine method readRecordValue.
private TypedRecord<?> readRecordValue(final LoggedEvent currentEvent) {
final UnifiedRecordValue value = recordValues.readRecordValue(currentEvent, metadata.getValueType());
typedEvent.wrap(currentEvent, metadata, value);
return typedEvent;
}
Aggregations