From 22f700f4767288ee1d32451b35e6d70116419496 Mon Sep 17 00:00:00 2001 From: Nissim Shiman Date: Fri, 31 May 2024 17:49:22 +0000 Subject: [PATCH] NIFI-13031 Changed PG StatusSnapshotDTO to use cloned copy for accurate status This closes #8946 Signed-off-by: David Handermann --- .../status/ConnectionStatusSnapshotDTO.java | 1 + .../status/ProcessGroupStatusSnapshotDTO.java | 43 +++++++++++++++---- .../ConnectionStatisticsSnapshotEntity.java | 1 + .../ConnectionStatusSnapshotEntity.java | 1 + .../api/entity/PortStatusSnapshotEntity.java | 1 + .../ProcessGroupStatusSnapshotEntity.java | 1 + .../entity/ProcessorStatusSnapshotEntity.java | 1 + ...emoteProcessGroupStatusSnapshotEntity.java | 1 + 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java index e876974cee..fc186adb46 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java @@ -321,6 +321,7 @@ public class ConnectionStatusSnapshotDTO implements Cloneable { other.setQueuedSize(getQueuedSize()); other.setPercentUseBytes(getPercentUseBytes()); other.setPercentUseCount(getPercentUseCount()); + other.setFlowFileAvailability(getFlowFileAvailability()); return other; } diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java index 5c17989649..39593473c5 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java @@ -563,11 +563,32 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable { other.setProcessingNanos(getProcessingNanos()); - other.setConnectionStatusSnapshots(copy(getConnectionStatusSnapshots())); - other.setProcessorStatusSnapshots(copy(getProcessorStatusSnapshots())); - other.setRemoteProcessGroupStatusSnapshots(copy(getRemoteProcessGroupStatusSnapshots())); - other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots())); - other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots())); + if (connectionStatusSnapshots != null) { + final List collectionStatusSnapshotEntities = new ArrayList<>(); + for (final ConnectionStatusSnapshotEntity connectionStatusSnapshotEntity : connectionStatusSnapshots) { + collectionStatusSnapshotEntities.add(connectionStatusSnapshotEntity.clone()); + } + other.setConnectionStatusSnapshots(collectionStatusSnapshotEntities); + } + + if (processorStatusSnapshots != null) { + final List processorStatusSnapshotEntities = new ArrayList<>(); + for (final ProcessorStatusSnapshotEntity processorStatusSnapshotEntity : processorStatusSnapshots) { + processorStatusSnapshotEntities.add(processorStatusSnapshotEntity.clone()); + } + other.setProcessorStatusSnapshots(processorStatusSnapshotEntities); + } + + if (remoteProcessGroupStatusSnapshots != null) { + final List remoteProcessGroupStatusSnapshotEntities = new ArrayList<>(); + for (final RemoteProcessGroupStatusSnapshotEntity remoteProcessGroupStatusSnapshotEntity : remoteProcessGroupStatusSnapshots) { + remoteProcessGroupStatusSnapshotEntities.add(remoteProcessGroupStatusSnapshotEntity.clone()); + } + other.setRemoteProcessGroupStatusSnapshots(remoteProcessGroupStatusSnapshotEntities); + } + + other.setInputPortStatusSnapshots(copyPortStatusSnapshots(inputPortStatusSnapshots)); + other.setOutputPortStatusSnapshots(copyPortStatusSnapshots(outputPortStatusSnapshots)); if (processGroupStatusSnapshots != null) { final List childGroups = new ArrayList<>(); @@ -580,11 +601,15 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable { return other; } - private Collection copy(final Collection original) { - if (original == null) { - return null; + private Collection copyPortStatusSnapshots(Collection portStatusSnapshots) { + if (portStatusSnapshots != null) { + final List portStatusSnapshotEntities = new ArrayList<>(); + for (final PortStatusSnapshotEntity portStatusSnapshotEntity : portStatusSnapshots) { + portStatusSnapshotEntities.add(portStatusSnapshotEntity.clone()); + } + return portStatusSnapshotEntities; } - return new ArrayList(original); + return null; } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatisticsSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatisticsSnapshotEntity.java index 5c94067665..fdc6f5cdd6 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatisticsSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatisticsSnapshotEntity.java @@ -67,6 +67,7 @@ public class ConnectionStatisticsSnapshotEntity extends Entity implements Readab @Override public ConnectionStatisticsSnapshotEntity clone() { final ConnectionStatisticsSnapshotEntity other = new ConnectionStatisticsSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setConnectionStatisticsSnapshot(this.getConnectionStatisticsSnapshot().clone()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatusSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatusSnapshotEntity.java index 5b86e85567..882d656bac 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatusSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConnectionStatusSnapshotEntity.java @@ -66,6 +66,7 @@ public class ConnectionStatusSnapshotEntity extends Entity implements ReadablePe @Override public ConnectionStatusSnapshotEntity clone() { final ConnectionStatusSnapshotEntity other = new ConnectionStatusSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setConnectionStatusSnapshot(this.getConnectionStatusSnapshot().clone()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PortStatusSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PortStatusSnapshotEntity.java index 7d4676c9e0..6a94a97cfa 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PortStatusSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/PortStatusSnapshotEntity.java @@ -67,6 +67,7 @@ public class PortStatusSnapshotEntity extends Entity implements ReadablePermissi @Override public PortStatusSnapshotEntity clone() { final PortStatusSnapshotEntity other = new PortStatusSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setPortStatusSnapshot(this.getPortStatusSnapshot().clone()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusSnapshotEntity.java index adc657cc43..c492c80465 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupStatusSnapshotEntity.java @@ -66,6 +66,7 @@ public class ProcessGroupStatusSnapshotEntity extends Entity implements Readable @Override public ProcessGroupStatusSnapshotEntity clone() { final ProcessGroupStatusSnapshotEntity other = new ProcessGroupStatusSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setProcessGroupStatusSnapshot(this.getProcessGroupStatusSnapshot().clone()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorStatusSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorStatusSnapshotEntity.java index 7ba765d4d3..a0bf3d4835 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorStatusSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessorStatusSnapshotEntity.java @@ -66,6 +66,7 @@ public class ProcessorStatusSnapshotEntity extends Entity implements ReadablePer @Override public ProcessorStatusSnapshotEntity clone() { final ProcessorStatusSnapshotEntity other = new ProcessorStatusSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setProcessorStatusSnapshot(this.getProcessorStatusSnapshot().clone()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupStatusSnapshotEntity.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupStatusSnapshotEntity.java index a0dec9157b..f46e31bb39 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupStatusSnapshotEntity.java +++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RemoteProcessGroupStatusSnapshotEntity.java @@ -67,6 +67,7 @@ public class RemoteProcessGroupStatusSnapshotEntity extends Entity implements Re @Override public RemoteProcessGroupStatusSnapshotEntity clone() { final RemoteProcessGroupStatusSnapshotEntity other = new RemoteProcessGroupStatusSnapshotEntity(); + other.setId(this.getId()); other.setCanRead(this.getCanRead()); other.setRemoteProcessGroupStatusSnapshot(this.getRemoteProcessGroupStatusSnapshot().clone());