Search in sources :

Example 1 with NodeRemoteProcessGroupStatusSnapshotDTO

use of org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO in project nifi by apache.

the class StatusMerger method merge.

public static void merge(final RemoteProcessGroupStatusDTO target, final boolean targetReadablePermission, final RemoteProcessGroupStatusDTO 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.setTargetUri(toMerge.getTargetUri());
    }
    merge(target.getAggregateSnapshot(), targetReadablePermission, toMerge.getAggregateSnapshot(), toMergeReadablePermission);
    if (target.getNodeSnapshots() != null) {
        final NodeRemoteProcessGroupStatusSnapshotDTO nodeSnapshot = new NodeRemoteProcessGroupStatusSnapshotDTO();
        nodeSnapshot.setStatusSnapshot(toMerge.getAggregateSnapshot());
        nodeSnapshot.setAddress(nodeAddress);
        nodeSnapshot.setApiPort(nodeApiPort);
        nodeSnapshot.setNodeId(nodeId);
        target.getNodeSnapshots().add(nodeSnapshot);
    }
}
Also used : NodeRemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO)

Example 2 with NodeRemoteProcessGroupStatusSnapshotDTO

use of org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO in project nifi by apache.

the class RemoteProcessGroupStatusEndpointMerger method mergeResponses.

@Override
protected void mergeResponses(RemoteProcessGroupStatusEntity clientEntity, Map<NodeIdentifier, RemoteProcessGroupStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
    final RemoteProcessGroupStatusDTO mergedRemoteProcessGroupStatus = clientEntity.getRemoteProcessGroupStatus();
    mergedRemoteProcessGroupStatus.setNodeSnapshots(new ArrayList<>());
    final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
    final NodeRemoteProcessGroupStatusSnapshotDTO selectedNodeSnapshot = new NodeRemoteProcessGroupStatusSnapshotDTO();
    selectedNodeSnapshot.setStatusSnapshot(mergedRemoteProcessGroupStatus.getAggregateSnapshot().clone());
    selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
    selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
    selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
    mergedRemoteProcessGroupStatus.getNodeSnapshots().add(selectedNodeSnapshot);
    // merge the other nodes
    for (final Map.Entry<NodeIdentifier, RemoteProcessGroupStatusEntity> entry : entityMap.entrySet()) {
        final NodeIdentifier nodeId = entry.getKey();
        final RemoteProcessGroupStatusEntity nodeRemoteProcessGroupStatusEntity = entry.getValue();
        final RemoteProcessGroupStatusDTO nodeRemoteProcessGroupStatus = nodeRemoteProcessGroupStatusEntity.getRemoteProcessGroupStatus();
        if (nodeRemoteProcessGroupStatus == mergedRemoteProcessGroupStatus) {
            continue;
        }
        mergeStatus(mergedRemoteProcessGroupStatus, clientEntity.getCanRead(), nodeRemoteProcessGroupStatus, nodeRemoteProcessGroupStatusEntity.getCanRead(), nodeId);
    }
}
Also used : NodeRemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) RemoteProcessGroupStatusEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity) 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) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) ArrayList(java.util.ArrayList) NodeRemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) RemoteProcessGroupStatusEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Map(java.util.Map)

Aggregations

NodeRemoteProcessGroupStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.NodeRemoteProcessGroupStatusSnapshotDTO)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 RemoteProcessGroupStatusDTO (org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO)1 RemoteProcessGroupStatusEntity (org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity)1