use of org.apache.nifi.web.api.dto.NodeCountersSnapshotDTO in project nifi by apache.
the class StatusMerger method merge.
public static void merge(final CountersDTO target, final CountersDTO toMerge, final String nodeId, final String nodeAddress, final Integer nodeApiPort) {
merge(target.getAggregateSnapshot(), toMerge.getAggregateSnapshot());
List<NodeCountersSnapshotDTO> nodeSnapshots = target.getNodeSnapshots();
if (nodeSnapshots == null) {
nodeSnapshots = new ArrayList<>();
}
final NodeCountersSnapshotDTO nodeCountersSnapshot = new NodeCountersSnapshotDTO();
nodeCountersSnapshot.setNodeId(nodeId);
nodeCountersSnapshot.setAddress(nodeAddress);
nodeCountersSnapshot.setApiPort(nodeApiPort);
nodeCountersSnapshot.setSnapshot(toMerge.getAggregateSnapshot());
nodeSnapshots.add(nodeCountersSnapshot);
target.setNodeSnapshots(nodeSnapshots);
}
use of org.apache.nifi.web.api.dto.NodeCountersSnapshotDTO in project nifi by apache.
the class CountersEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(CountersDTO clientDto, Map<NodeIdentifier, CountersDTO> dtoMap, NodeIdentifier selectedNodeId) {
final CountersDTO mergedCounters = clientDto;
mergedCounters.setNodeSnapshots(new ArrayList<NodeCountersSnapshotDTO>());
final NodeCountersSnapshotDTO selectedNodeSnapshot = new NodeCountersSnapshotDTO();
selectedNodeSnapshot.setSnapshot(clientDto.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedCounters.getNodeSnapshots().add(selectedNodeSnapshot);
for (final Map.Entry<NodeIdentifier, CountersDTO> entry : dtoMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final CountersDTO toMerge = entry.getValue();
if (toMerge == clientDto) {
continue;
}
StatusMerger.merge(mergedCounters, toMerge, nodeId.getId(), nodeId.getApiAddress(), nodeId.getApiPort());
}
}
Aggregations