use of org.apache.nifi.web.api.dto.status.NodeProcessorStatusSnapshotDTO in project nifi by apache.
the class StatusMerger method merge.
public static void merge(final ProcessorStatusDTO target, final boolean targetReadablePermission, final ProcessorStatusDTO 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.setType(toMerge.getType());
}
merge(target.getAggregateSnapshot(), targetReadablePermission, toMerge.getAggregateSnapshot(), toMergeReadablePermission);
// ensure the aggregate snapshot was specified before promoting the runStatus to the status dto
if (target.getAggregateSnapshot() != null) {
target.setRunStatus(target.getAggregateSnapshot().getRunStatus());
}
if (target.getNodeSnapshots() != null) {
final NodeProcessorStatusSnapshotDTO nodeSnapshot = new NodeProcessorStatusSnapshotDTO();
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.NodeProcessorStatusSnapshotDTO in project nifi by apache.
the class ProcessorStatusEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(ProcessorStatusEntity clientEntity, Map<NodeIdentifier, ProcessorStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final ProcessorStatusDTO mergedProcessorStatus = clientEntity.getProcessorStatus();
mergedProcessorStatus.setNodeSnapshots(new ArrayList<>());
final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
final NodeProcessorStatusSnapshotDTO selectedNodeSnapshot = new NodeProcessorStatusSnapshotDTO();
selectedNodeSnapshot.setStatusSnapshot(mergedProcessorStatus.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedProcessorStatus.getNodeSnapshots().add(selectedNodeSnapshot);
// merge the other nodes
for (final Map.Entry<NodeIdentifier, ProcessorStatusEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final ProcessorStatusEntity nodeProcessorStatusEntity = entry.getValue();
final ProcessorStatusDTO nodeProcessorStatus = nodeProcessorStatusEntity.getProcessorStatus();
if (nodeProcessorStatus == mergedProcessorStatus) {
continue;
}
mergeStatus(mergedProcessorStatus, clientEntity.getCanRead(), nodeProcessorStatus, nodeProcessorStatusEntity.getCanRead(), nodeId);
}
}
Aggregations