Skip to content

Commit

Permalink
merge: #9556
Browse files Browse the repository at this point in the history
9556: Start instructions in compact logger r=pihme a=pihme

## Description

- add information about start instructions to interface layer
- use this information in compact logger to summarize start instructions

## Related issues

closes #9555 



Co-authored-by: pihme <pihme@users.noreply.github.com>
  • Loading branch information
zeebe-bors-camunda[bot] and pihme committed Jun 23, 2022
2 parents a6202e6 + f94f26e commit dfbcbff
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.camunda.zeebe.util.buffer.BufferUtil;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.agrona.DirectBuffer;

public final class ProcessInstanceCreationRecord extends UnifiedRecordValue
Expand Down Expand Up @@ -70,6 +71,11 @@ public ProcessInstanceCreationRecord setProcessDefinitionKey(final long key) {
return this;
}

@Override
public List<ProcessInstanceCreationStartInstructionValue> getStartInstructions() {
return startInstructionsProperty.stream().collect(Collectors.toList());
}

public ProcessInstanceCreationRecord setVersion(final int version) {
versionProperty.setValue(version);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
package io.camunda.zeebe.protocol.impl.record.value.processinstance;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.camunda.zeebe.msgpack.property.StringProperty;
import io.camunda.zeebe.msgpack.value.ObjectValue;
import io.camunda.zeebe.protocol.record.value.ProcessInstanceCreationRecordValue.ProcessInstanceCreationStartInstructionValue;
import io.camunda.zeebe.util.buffer.BufferUtil;
import org.agrona.DirectBuffer;

public class ProcessInstanceCreationStartInstruction extends ObjectValue {
@JsonIgnoreProperties({
/* 'encodedLength' is a technical field needed for MsgPack and inherited from ObjectValue; it has
no purpose in exported JSON records*/
"encodedLength"
})
public final class ProcessInstanceCreationStartInstruction extends ObjectValue
implements ProcessInstanceCreationStartInstructionValue {

private final StringProperty elementIdProp = new StringProperty("elementId");

Expand All @@ -26,6 +34,7 @@ public DirectBuffer getElementIdBuffer() {
return elementIdProp.getValue();
}

@Override
public String getElementId() {
return BufferUtil.bufferAsString(elementIdProp.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.camunda.zeebe.protocol.impl.record.value.message.MessageSubscriptionRecord;
import io.camunda.zeebe.protocol.impl.record.value.message.ProcessMessageSubscriptionRecord;
import io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord;
import io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationStartInstruction;
import io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord;
import io.camunda.zeebe.protocol.impl.record.value.timer.TimerRecord;
import io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord;
Expand Down Expand Up @@ -723,9 +724,11 @@ final var record = new DeploymentDistributionRecord();
.setVariables(
new UnsafeBuffer(
MsgPackConverter.convertToMsgPack("{'foo':'bar','baz':'boz'}")))
.addStartInstruction(
new ProcessInstanceCreationStartInstruction().setElementId("element"))
.setProcessInstanceKey(instanceKey);
},
"{'variables':{'foo':'bar','baz':'boz'},'bpmnProcessId':'process','processDefinitionKey':1,'version':1,'processInstanceKey':2}"
"{'variables':{'foo':'bar','baz':'boz'},'bpmnProcessId':'process','processDefinitionKey':1,'version':1,'processInstanceKey':2,'startInstructions':[{'elementId':'element'}]}"
},

/////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -734,7 +737,7 @@ final var record = new DeploymentDistributionRecord();
{
"Empty ProcessInstanceCreationRecord",
(Supplier<UnifiedRecordValue>) ProcessInstanceCreationRecord::new,
"{'variables':{},'bpmnProcessId':'','processDefinitionKey':-1,'version':-1,'processInstanceKey':-1}"
"{'variables':{},'bpmnProcessId':'','processDefinitionKey':-1,'version':-1,'processInstanceKey':-1, 'startInstructions':[]}"
},

/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.camunda.zeebe.protocol.record.ImmutableProtocol;
import io.camunda.zeebe.protocol.record.RecordValueWithVariables;
import java.util.List;
import org.immutables.value.Value;

@Value.Immutable
Expand All @@ -37,4 +38,15 @@ public interface ProcessInstanceCreationRecordValue
* @return the unique key of the BPMN process definition to create a process from
*/
long getProcessDefinitionKey();

/**
* @return list of start instructions (if available), or an empty list
*/
List<ProcessInstanceCreationStartInstructionValue> getStartInstructions();

@Value.Immutable
@ImmutableProtocol(builder = ImmutableProcessInstanceCreationStartInstructionValue.Builder.class)
interface ProcessInstanceCreationStartInstructionValue {
String getElementId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.camunda.zeebe.protocol.record.value.MessageSubscriptionRecordValue;
import io.camunda.zeebe.protocol.record.value.ProcessEventRecordValue;
import io.camunda.zeebe.protocol.record.value.ProcessInstanceCreationRecordValue;
import io.camunda.zeebe.protocol.record.value.ProcessInstanceCreationRecordValue.ProcessInstanceCreationStartInstructionValue;
import io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue;
import io.camunda.zeebe.protocol.record.value.ProcessMessageSubscriptionRecordValue;
import io.camunda.zeebe.protocol.record.value.TimerRecordValue;
Expand Down Expand Up @@ -471,10 +472,22 @@ private String summarizeProcessInstanceCreation(final Record<?> record) {
.append("new <process ")
.append(formatId(value.getBpmnProcessId()))
.append(">")
.append(summarizeStartInstructions(value.getStartInstructions()))
.append(summarizeVariables(value.getVariables()))
.toString();
}

private String summarizeStartInstructions(
final List<ProcessInstanceCreationStartInstructionValue> startInstructions) {
if (startInstructions.isEmpty()) {
return " (default start) ";
} else {
return startInstructions.stream()
.map(ProcessInstanceCreationStartInstructionValue::getElementId)
.collect(Collectors.joining(", ", " (starting before elements: ", ") "));
}
}

private String summarizeProcessInstanceSubscription(final Record<?> record) {
final var value = (ProcessMessageSubscriptionRecordValue) record.getValue();

Expand Down

0 comments on commit dfbcbff

Please sign in to comment.