Search in sources :

Example 1 with NodeProcessGroupStatusSnapshotDTO

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

the class GroupStatusEndpointMerger method mergeResponses.

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

Example 2 with NodeProcessGroupStatusSnapshotDTO

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

the class StandardNiFiServiceFacade method getProcessGroupStatus.

@Override
public ProcessGroupStatusEntity getProcessGroupStatus(final String groupId, final boolean recursive) {
    final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
    final ProcessGroupStatusDTO dto = dtoFactory.createProcessGroupStatusDto(processGroup, controllerFacade.getProcessGroupStatus(groupId));
    // prune the response as necessary
    if (!recursive) {
        pruneChildGroups(dto.getAggregateSnapshot());
        if (dto.getNodeSnapshots() != null) {
            for (final NodeProcessGroupStatusSnapshotDTO nodeSnapshot : dto.getNodeSnapshots()) {
                pruneChildGroups(nodeSnapshot.getStatusSnapshot());
            }
        }
    }
    return entityFactory.createProcessGroupStatusEntity(dto, permissions);
}
Also used : ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) NodeProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeProcessGroupStatusSnapshotDTO)

Example 3 with NodeProcessGroupStatusSnapshotDTO

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

the class StatusMerger method merge.

public static void merge(final ProcessGroupStatusDTO target, final boolean targetReadablePermission, final ProcessGroupStatusDTO toMerge, final boolean toMergeReadablePermission, final String nodeId, final String nodeAddress, final Integer nodeApiPort) {
    if (targetReadablePermission && !toMergeReadablePermission) {
        target.setId(toMerge.getId());
        target.setName(toMerge.getName());
    }
    merge(target.getAggregateSnapshot(), targetReadablePermission, toMerge.getAggregateSnapshot(), toMergeReadablePermission);
    if (target.getNodeSnapshots() != null) {
        final NodeProcessGroupStatusSnapshotDTO nodeSnapshot = new NodeProcessGroupStatusSnapshotDTO();
        nodeSnapshot.setStatusSnapshot(toMerge.getAggregateSnapshot());
        nodeSnapshot.setAddress(nodeAddress);
        nodeSnapshot.setApiPort(nodeApiPort);
        nodeSnapshot.setNodeId(nodeId);
        target.getNodeSnapshots().add(nodeSnapshot);
    }
}
Also used : NodeProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeProcessGroupStatusSnapshotDTO)

Aggregations

NodeProcessGroupStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.NodeProcessGroupStatusSnapshotDTO)3 ProcessGroupStatusDTO (org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO)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 ProcessGroup (org.apache.nifi.groups.ProcessGroup)1 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)1 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)1 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)1 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)1 RemoteProcessGroupStatusDTO (org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO)1 ProcessGroupStatusEntity (org.apache.nifi.web.api.entity.ProcessGroupStatusEntity)1