This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 22f700f476 NIFI-13031 Changed PG StatusSnapshotDTO to use cloned copy 
for accurate status
22f700f476 is described below

commit 22f700f4767288ee1d32451b35e6d70116419496
Author: Nissim Shiman <nshi...@yahoo.com>
AuthorDate: Fri May 31 17:49:22 2024 +0000

    NIFI-13031 Changed PG StatusSnapshotDTO to use cloned copy for accurate 
status
    
    This closes #8946
    
    Signed-off-by: David Handermann <exceptionfact...@apache.org>
---
 .../dto/status/ConnectionStatusSnapshotDTO.java    |  1 +
 .../dto/status/ProcessGroupStatusSnapshotDTO.java  | 43 +++++++++++++++++-----
 .../entity/ConnectionStatisticsSnapshotEntity.java |  1 +
 .../api/entity/ConnectionStatusSnapshotEntity.java |  1 +
 .../web/api/entity/PortStatusSnapshotEntity.java   |  1 +
 .../entity/ProcessGroupStatusSnapshotEntity.java   |  1 +
 .../api/entity/ProcessorStatusSnapshotEntity.java  |  1 +
 .../RemoteProcessGroupStatusSnapshotEntity.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<ConnectionStatusSnapshotEntity> 
collectionStatusSnapshotEntities = new ArrayList<>();
+            for (final ConnectionStatusSnapshotEntity 
connectionStatusSnapshotEntity : connectionStatusSnapshots) {
+                
collectionStatusSnapshotEntities.add(connectionStatusSnapshotEntity.clone());
+            }
+            
other.setConnectionStatusSnapshots(collectionStatusSnapshotEntities);
+        }
+
+        if (processorStatusSnapshots != null) {
+            final List<ProcessorStatusSnapshotEntity> 
processorStatusSnapshotEntities = new ArrayList<>();
+            for (final ProcessorStatusSnapshotEntity 
processorStatusSnapshotEntity : processorStatusSnapshots) {
+                
processorStatusSnapshotEntities.add(processorStatusSnapshotEntity.clone());
+            }
+            other.setProcessorStatusSnapshots(processorStatusSnapshotEntities);
+        }
+
+        if (remoteProcessGroupStatusSnapshots != null) {
+            final List<RemoteProcessGroupStatusSnapshotEntity> 
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<ProcessGroupStatusSnapshotEntity> childGroups = new 
ArrayList<>();
@@ -580,11 +601,15 @@ public class ProcessGroupStatusSnapshotDTO implements 
Cloneable {
         return other;
     }
 
-    private <T> Collection<T> copy(final Collection<T> original) {
-        if (original == null) {
-            return null;
+    private Collection<PortStatusSnapshotEntity> 
copyPortStatusSnapshots(Collection<PortStatusSnapshotEntity> 
portStatusSnapshots) {
+        if (portStatusSnapshots != null) {
+            final List<PortStatusSnapshotEntity> portStatusSnapshotEntities = 
new ArrayList<>();
+            for (final PortStatusSnapshotEntity portStatusSnapshotEntity : 
portStatusSnapshots) {
+               
portStatusSnapshotEntities.add(portStatusSnapshotEntity.clone());
+            }
+            return portStatusSnapshotEntities;
         }
 
-        return new ArrayList<T>(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());
 

Reply via email to