Search in sources :

Example 1 with UnpackedObject

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;
}
Also used : ProcessInstanceRelated(io.camunda.zeebe.protocol.record.value.ProcessInstanceRelated) ProcessInstanceRelatedIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceRelatedIntent) Intent(io.camunda.zeebe.protocol.record.intent.Intent) UnpackedObject(io.camunda.zeebe.msgpack.UnpackedObject)

Example 2 with UnpackedObject

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");
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) UnpackedObject(io.camunda.zeebe.msgpack.UnpackedObject)

Example 3 with UnpackedObject

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;
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) UnpackedObject(io.camunda.zeebe.msgpack.UnpackedObject)

Example 4 with UnpackedObject

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());
}
Also used : LogStreamReader(io.camunda.zeebe.logstreams.log.LogStreamReader) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ValueType(io.camunda.zeebe.protocol.record.ValueType) UnpackedObject(io.camunda.zeebe.msgpack.UnpackedObject) EnumMap(java.util.EnumMap)

Example 5 with UnpackedObject

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;
}
Also used : ProcessInstanceRelated(io.camunda.zeebe.protocol.record.value.ProcessInstanceRelated) ProcessInstanceRelatedIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceRelatedIntent) Intent(io.camunda.zeebe.protocol.record.intent.Intent) UnpackedObject(io.camunda.zeebe.msgpack.UnpackedObject)

Aggregations

UnpackedObject (io.camunda.zeebe.msgpack.UnpackedObject)12 LogStreamReader (io.camunda.zeebe.logstreams.log.LogStreamReader)3 LoggedEvent (io.camunda.zeebe.logstreams.log.LoggedEvent)3 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)3 ValueType (io.camunda.zeebe.protocol.record.ValueType)3 Intent (io.camunda.zeebe.protocol.record.intent.Intent)3 ProcessInstanceRelatedIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceRelatedIntent)3 ProcessInstanceRelated (io.camunda.zeebe.protocol.record.value.ProcessInstanceRelated)3 EnumMap (java.util.EnumMap)3 MutableDirectBuffer (org.agrona.MutableDirectBuffer)3 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)3