Search in sources :

Example 1 with NodeCountersSnapshotDTO

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);
}
Also used : NodeCountersSnapshotDTO(org.apache.nifi.web.api.dto.NodeCountersSnapshotDTO)

Example 2 with NodeCountersSnapshotDTO

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());
    }
}
Also used : NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) NodeCountersSnapshotDTO(org.apache.nifi.web.api.dto.NodeCountersSnapshotDTO) CountersDTO(org.apache.nifi.web.api.dto.CountersDTO) Map(java.util.Map)

Aggregations

NodeCountersSnapshotDTO (org.apache.nifi.web.api.dto.NodeCountersSnapshotDTO)2 Map (java.util.Map)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 CountersDTO (org.apache.nifi.web.api.dto.CountersDTO)1