Search in sources :

Example 1 with NodeProcessorStatusSnapshotDTO

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

Example 2 with NodeProcessorStatusSnapshotDTO

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);
    }
}
Also used : NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) NodeProcessorStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeProcessorStatusSnapshotDTO) ProcessorStatusEntity(org.apache.nifi.web.api.entity.ProcessorStatusEntity) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) Map(java.util.Map) Set(java.util.Set) StatusMerger(org.apache.nifi.cluster.manager.StatusMerger) URI(java.net.URI) Pattern(java.util.regex.Pattern) ComponentEntityStatusMerger(org.apache.nifi.cluster.manager.ComponentEntityStatusMerger) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) ArrayList(java.util.ArrayList) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) ProcessorStatusEntity(org.apache.nifi.web.api.entity.ProcessorStatusEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) Map(java.util.Map) NodeProcessorStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeProcessorStatusSnapshotDTO)

Aggregations

NodeProcessorStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.NodeProcessorStatusSnapshotDTO)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Set (java.util.Set)1 Pattern (java.util.regex.Pattern)1 ComponentEntityStatusMerger (org.apache.nifi.cluster.manager.ComponentEntityStatusMerger)1 NodeResponse (org.apache.nifi.cluster.manager.NodeResponse)1 StatusMerger (org.apache.nifi.cluster.manager.StatusMerger)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 ProcessorStatusDTO (org.apache.nifi.web.api.dto.status.ProcessorStatusDTO)1 ProcessorStatusEntity (org.apache.nifi.web.api.entity.ProcessorStatusEntity)1