use of org.apache.nifi.web.api.dto.status.NodeConnectionStatusSnapshotDTO in project nifi by apache.
the class StatusMerger method merge.
public static void merge(final ConnectionStatusDTO target, final boolean targetReadablePermission, final ConnectionStatusDTO toMerge, final boolean toMergeReadablePermission, final String nodeId, final String nodeAddress, final Integer nodeApiPort) {
if (targetReadablePermission && !toMergeReadablePermission) {
target.setGroupId(toMerge.getGroupId());
target.setId(toMerge.getId());
target.setName(toMerge.getName());
target.setSourceId(toMerge.getSourceId());
target.setSourceName(toMerge.getSourceName());
target.setDestinationId(toMerge.getDestinationId());
target.setDestinationName(toMerge.getDestinationName());
}
merge(target.getAggregateSnapshot(), targetReadablePermission, toMerge.getAggregateSnapshot(), toMergeReadablePermission);
if (target.getNodeSnapshots() != null) {
final NodeConnectionStatusSnapshotDTO nodeSnapshot = new NodeConnectionStatusSnapshotDTO();
nodeSnapshot.setStatusSnapshot(toMerge.getAggregateSnapshot());
nodeSnapshot.setAddress(nodeAddress);
nodeSnapshot.setApiPort(nodeApiPort);
nodeSnapshot.setNodeId(nodeId);
target.getNodeSnapshots().add(nodeSnapshot);
}
}
use of org.apache.nifi.web.api.dto.status.NodeConnectionStatusSnapshotDTO in project nifi by apache.
the class ConnectionStatusEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(ConnectionStatusEntity clientEntity, Map<NodeIdentifier, ConnectionStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final ConnectionStatusDTO mergedConnectionStatus = clientEntity.getConnectionStatus();
mergedConnectionStatus.setNodeSnapshots(new ArrayList<>());
final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
final NodeConnectionStatusSnapshotDTO selectedNodeSnapshot = new NodeConnectionStatusSnapshotDTO();
selectedNodeSnapshot.setStatusSnapshot(mergedConnectionStatus.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedConnectionStatus.getNodeSnapshots().add(selectedNodeSnapshot);
// merge the other nodes
for (final Map.Entry<NodeIdentifier, ConnectionStatusEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final ConnectionStatusEntity nodeConnectionStatusEntity = entry.getValue();
final ConnectionStatusDTO nodeConnectionStatus = nodeConnectionStatusEntity.getConnectionStatus();
if (nodeConnectionStatus == mergedConnectionStatus) {
continue;
}
mergeStatus(mergedConnectionStatus, clientEntity.getCanRead(), nodeConnectionStatus, nodeConnectionStatusEntity.getCanRead(), nodeId);
}
}
Aggregations