public static boolean hasIntent(final LoggedEvent event, final Intent intent) { if (event == null) { return false; } final RecordMetadata metadata = getMetadata(event); return metadata.getIntent() == intent; }
public static boolean hasIntent(final LoggedEvent event, final Intent intent) { if (event == null) { return false; } final RecordMetadata metadata = getMetadata(event); return metadata.getIntent() == intent; }
public MetadataFilter buildTypeFilter() { return m -> recordProcessors.containsKey(m.getRecordType(), m.getValueType(), m.getIntent().value()); }
public void storeRecord( long scopeKey, TypedRecord<WorkflowInstanceRecord> record, Purpose purpose) { final WorkflowInstanceIntent intent = (WorkflowInstanceIntent) record.getMetadata().getIntent(); storeRecord(record.getKey(), scopeKey, record.getValue(), intent, purpose); }
public long deferEvent(final TypedRecord<WorkflowInstanceRecord> event) { final WorkflowInstanceRecord value = event.getValue(); final WorkflowInstanceIntent intent = (WorkflowInstanceIntent) event.getMetadata().getIntent(); return deferRecord(value.getFlowScopeKey(), value, intent); }
@Override public void writeRejectionOnCommand(TypedRecord<?> command, RejectionType type, String reason) { final byte[] bytes = reason.getBytes(StandardCharsets.UTF_8); stringWrapper.wrap(bytes); stage( RecordType.COMMAND_REJECTION, command.getMetadata().getIntent(), command.getKey(), type, stringWrapper, command.getMetadata(), command.getValue()); }
@Override public void writeRejectionOnCommand( TypedRecord<?> command, RejectionType type, DirectBuffer reason) { stage( RecordType.COMMAND_REJECTION, command.getMetadata().getIntent(), command.getKey(), type, reason, command.getMetadata(), command.getValue()); }
@Override public void writeRejectionOnCommand( TypedRecord<?> command, RejectionType type, DirectBuffer reason) { stage( RecordType.COMMAND_REJECTION, command.getMetadata().getIntent(), command.getKey(), type, reason, command.getMetadata(), command.getValue()); }
@Override public void writeEvent(TypedRecord<?> event) { stringWrapper.wrap(0, 0); stage( RecordType.EVENT, event.getMetadata().getIntent(), event.getKey(), RejectionType.NULL_VAL, stringWrapper, event.getMetadata(), event.getValue()); }
@Override public void writeEvent(TypedRecord<?> event) { stringWrapper.wrap(0, 0); stage( RecordType.EVENT, event.getMetadata().getIntent(), event.getKey(), RejectionType.NULL_VAL, stringWrapper, event.getMetadata(), event.getValue()); }
public void storeRecord( long scopeKey, TypedRecord<WorkflowInstanceRecord> record, Purpose purpose) { final long key = record.getKey(); final WorkflowInstanceIntent intent = (WorkflowInstanceIntent) record.getMetadata().getIntent(); final WorkflowInstanceRecord value = record.getValue(); final IndexedRecord indexedRecord = new IndexedRecord(key, intent, value); final StoredRecord storedRecord = new StoredRecord(indexedRecord, purpose); setRecordKeys(scopeKey, key, purpose); recordColumnFamily.put(recordKey, storedRecord); recordParentChildColumnFamily.put(recordParentStateRecordKey, DbNil.INSTANCE); }
@Override public void writeRejection(TypedRecord<?> rejection) { final RecordMetadata metadata = rejection.getMetadata(); stage( RecordType.COMMAND_REJECTION, metadata.getIntent(), rejection.getKey(), rejection.getMetadata().getRejectionType(), rejection.getMetadata().getRejectionReason(), rejection.getMetadata(), rejection.getValue()); }
@Override public void writeRejection(TypedRecord<?> rejection) { final RecordMetadata metadata = rejection.getMetadata(); stage( RecordType.COMMAND_REJECTION, metadata.getIntent(), rejection.getKey(), rejection.getMetadata().getRejectionType(), rejection.getMetadata().getRejectionReason(), rejection.getMetadata(), rejection.getValue()); }
@Test public void shouldRejectCancelCommand() { // when final TypedRecord<TimerRecord> timerRecord = timerRecordForActivity("timer"); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); envRule.writeCommand(timerRecord.getKey(), TimerIntent.CANCEL, timerRecord.getValue()); streamProcessor.unblock(); // then final TypedRecord<TimerRecord> rejection = findTimerCommandRejection(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(TimerIntent.CANCEL); assertThat(rejection.getMetadata().getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); }
@Test public void shouldRejectTriggerCommand() { // when final TypedRecord<TimerRecord> timerRecord = timerRecordForActivity("timer"); envRule.writeCommand(timerRecord.getKey(), TimerIntent.CANCEL, timerRecord.getValue()); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); streamProcessor.unblock(); // then final TypedRecord<TimerRecord> rejection = findTimerCommandRejection(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(TimerIntent.TRIGGER); assertThat(rejection.getMetadata().getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); }
@Test public void shouldRejectDuplicatedTriggerCommand() { // when final TypedRecord<TimerRecord> timerRecord = timerRecordForActivity("timer"); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); streamProcessor.unblock(); // then final TypedRecord<TimerRecord> rejection = findTimerCommandRejection(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(TimerIntent.TRIGGER); assertThat(rejection.getMetadata().getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); }
@Test public void shouldRejectDuplicatedTriggerCommand() { // when final TypedRecord<TimerRecord> timerRecord = timerRecordForActivity("timer"); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); streamProcessor.unblock(); // then final TypedRecord<TimerRecord> rejection = findTimerCommandRejection(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(TimerIntent.TRIGGER); assertThat(rejection.getMetadata().getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); }
@Test public void shouldRejectCancelCommand() { // when final TypedRecord<TimerRecord> timerRecord = timerRecordForActivity("timer"); envRule.writeCommand(timerRecord.getKey(), TimerIntent.TRIGGER, timerRecord.getValue()); envRule.writeCommand(timerRecord.getKey(), TimerIntent.CANCEL, timerRecord.getValue()); streamProcessor.unblock(); // then final TypedRecord<TimerRecord> rejection = findTimerCommandRejection(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(TimerIntent.CANCEL); assertThat(rejection.getMetadata().getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); }
/** * This method makes only sense when the stream contains only entries of one workflow instance and * the element is only instantiated once within that instance. */ public Stream<WorkflowInstanceIntent> onlyStatesOf(final String elementId) { final DirectBuffer elementIdBuffer = BufferUtil.wrapString(elementId); return onlyWorkflowInstanceRecords() .onlyEvents() .filter(r -> elementIdBuffer.equals(r.getValue().getElementId())) .map(r -> (WorkflowInstanceIntent) r.getMetadata().getIntent()); } }
/** * This method makes only sense when the stream contains only entries of one workflow instance and * the element is only instantiated once within that instance. */ public Stream<WorkflowInstanceIntent> onlyStatesOf(final String elementId) { final DirectBuffer elementIdBuffer = BufferUtil.wrapString(elementId); return onlyWorkflowInstanceRecords() .onlyEvents() .filter(r -> elementIdBuffer.equals(r.getValue().getElementId())) .map(r -> (WorkflowInstanceIntent) r.getMetadata().getIntent()); } }