use of io.camunda.zeebe.msgpack.UnpackedObject in project zeebe by camunda.
the class DbBlackListState method tryToBlacklist.
@Override
public boolean tryToBlacklist(final TypedRecord<?> typedRecord, final Consumer<Long> onBlacklistingInstance) {
final Intent intent = typedRecord.getIntent();
if (shouldBeBlacklisted(intent)) {
final UnpackedObject value = typedRecord.getValue();
if (value instanceof ProcessInstanceRelated) {
final long processInstanceKey = ((ProcessInstanceRelated) value).getProcessInstanceKey();
blacklist(processInstanceKey);
onBlacklistingInstance.accept(processInstanceKey);
}
}
return false;
}
use of io.camunda.zeebe.msgpack.UnpackedObject in project zeebe by camunda.
the class LogStreamPrinter method writeRecord.
private static void writeRecord(final Map<ValueType, UnpackedObject> eventCache, final LoggedEvent event, final StringBuilder sb) {
sb.append(HEADER_INDENTATION);
writeRecordHeader(event, sb);
sb.append("\n");
final RecordMetadata metadata = new RecordMetadata();
event.readMetadata(metadata);
sb.append(ENTRY_INDENTATION);
writeMetadata(metadata, sb);
sb.append("\n");
final UnpackedObject unpackedObject = eventCache.get(metadata.getValueType());
event.readValue(unpackedObject);
sb.append(ENTRY_INDENTATION).append("Value:\n");
unpackedObject.writeJSON(sb);
sb.append("\n");
}
use of io.camunda.zeebe.msgpack.UnpackedObject in project zeebe by camunda.
the class Records method cloneValue.
public static <T extends UnpackedObject & RecordValue> T cloneValue(final RecordValue value) {
final UnpackedObject unpackedValue = (UnpackedObject) value;
final MutableDirectBuffer buffer = new UnsafeBuffer(ByteBuffer.allocate(unpackedValue.getLength()));
final T cloned = (T) ReflectUtil.newInstance(value.getClass());
unpackedValue.write(buffer, 0);
cloned.wrap(buffer, 0, unpackedValue.getLength());
return cloned;
}
use of io.camunda.zeebe.msgpack.UnpackedObject in project zeebe by zeebe-io.
the class LogStreamPrinter method printRecords.
public static void printRecords(final SynchronousLogStream logStream) {
final StringBuilder sb = new StringBuilder();
sb.append("Records on partition ");
sb.append(logStream.getPartitionId());
sb.append(":\n");
final EnumMap<ValueType, UnpackedObject> eventCache = new EnumMap<>(ValueType.class);
EVENT_REGISTRY.forEach((t, c) -> eventCache.put(t, ReflectUtil.newInstance(c)));
try (final LogStreamReader streamReader = logStream.newLogStreamReader()) {
streamReader.seekToFirstEvent();
while (streamReader.hasNext()) {
final LoggedEvent event = streamReader.next();
writeRecord(eventCache, event, sb);
}
}
LOGGER.info(sb.toString());
}
use of io.camunda.zeebe.msgpack.UnpackedObject in project zeebe by camunda-cloud.
the class DbBlackListState method tryToBlacklist.
@Override
public boolean tryToBlacklist(final TypedRecord<?> typedRecord, final Consumer<Long> onBlacklistingInstance) {
final Intent intent = typedRecord.getIntent();
if (shouldBeBlacklisted(intent)) {
final UnpackedObject value = typedRecord.getValue();
if (value instanceof ProcessInstanceRelated) {
final long processInstanceKey = ((ProcessInstanceRelated) value).getProcessInstanceKey();
blacklist(processInstanceKey);
onBlacklistingInstance.accept(processInstanceKey);
}
}
return false;
}
Aggregations