Skip to content

Commit

Permalink
others(operate-importer): add more logs during the import of process …
Browse files Browse the repository at this point in the history
…definitions (#3512)

* others(operate-importer): add more logs during the import of process definitions

* others(logs): format files

* others(logs): format files 2 and remove trace logs
  • Loading branch information
mathias-vandaele committed Oct 28, 2024
1 parent 332e943 commit 3ec930d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void handleImportedDefinitions(List<ProcessDefinition> definitions) {
if (definitions.isEmpty()) {
return;
}
LOG.debug("Handle of the imported process definitions starts...");
try {
meter(definitions.size());
var result =
Expand All @@ -78,6 +79,7 @@ public void handleImportedDefinitions(List<ProcessDefinition> definitions) {
definition ->
new ProcessDefinitionVersion(
definition.getKey(), definition.getVersion().intValue()))));
LOG.info("Updating the store with retrieved process definitions");
stateStore.update(result);
} catch (Exception e) {
LOG.error("Failed to handle imported definitions", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ public List<ProcessDefinition> query() {
}
List<Object> newPaginationIdx = processDefinitionResult.getSortValues();

LOG.debug("A page of process definitions has been fetched, continuing...");

if (!CollectionUtils.isEmpty(newPaginationIdx)) {
paginationIndex = newPaginationIdx;
}

// result is sorted by key in descending order, so we will always encounter the latest
// version first

LOG.debug("Sorting process definition results by descending order");
var items =
Optional.ofNullable(processDefinitionResult.getItems()).orElse(List.of()).stream()
.filter(
Expand All @@ -93,7 +96,7 @@ public List<ProcessDefinition> query() {

} while (processDefinitionResult.getItems() != null
&& !processDefinitionResult.getItems().isEmpty());

LOG.debug("Fetching from Operate has been correctly executed.");
return processDefinitions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ public class ProcessStateStoreImpl implements ProcessStateStore {
private final ProcessDefinitionInspector processDefinitionInspector;
private final InboundExecutableRegistry executableRegistry;

private record ProcessState(
int version,
long processDefinitionKey,
String tenantId,
List<InboundConnectorElement> connectorElements) {}

public ProcessStateStoreImpl(
ProcessDefinitionInspector processDefinitionInspector,
InboundExecutableRegistry executableRegistry) {
Expand All @@ -54,11 +48,13 @@ public ProcessStateStoreImpl(
public void update(ProcessImportResult processDefinitions) {
var entries = processDefinitions.processDefinitionVersions().entrySet();

LOG.debug("Filtering only new process definitions...");
var newlyDeployed =
entries.stream()
.filter(entry -> !processStates.containsKey(entry.getKey().bpmnProcessId()))
.toList();

LOG.debug("Filtering only updated process definitions...");
var replacedWithDifferentVersion =
entries.stream()
.filter(
Expand All @@ -68,6 +64,7 @@ public void update(ProcessImportResult processDefinitions) {
})
.toList();

LOG.debug("Filtering only old process definitions)");
var deletedProcessIds =
processStates.keySet().stream()
.filter(
Expand All @@ -85,6 +82,7 @@ public void update(ProcessImportResult processDefinitions) {

private void newlyDeployed(
Map.Entry<ProcessDefinitionIdentifier, ProcessDefinitionVersion> entry) {
LOG.info("Activating newly deployed process definition: {}", entry.getKey().bpmnProcessId());
try {
processStates.compute(
entry.getKey().bpmnProcessId(),
Expand All @@ -110,6 +108,9 @@ private void newlyDeployed(
private void replacedWithDifferentVersion(
Map.Entry<ProcessDefinitionIdentifier, ProcessDefinitionVersion> entry) {
try {
LOG.info(
"Activating newest deployed version process definition: {}",
entry.getKey().bpmnProcessId());
processStates.computeIfPresent(
entry.getKey().bpmnProcessId(),
(key, state) -> {
Expand All @@ -133,6 +134,7 @@ private void replacedWithDifferentVersion(

private void deleted(String processId) {
try {
LOG.info("Deactivating newly deployed process definition: {}", processId);
processStates.computeIfPresent(
processId,
(key1, state) -> {
Expand Down Expand Up @@ -204,4 +206,10 @@ private void logResult(
LOG.info(". . Process {}", key);
}
}

private record ProcessState(
int version,
long processDefinitionKey,
String tenantId,
List<InboundConnectorElement> connectorElements) {}
}

0 comments on commit 3ec930d

Please sign in to comment.