Search in sources :

Example 11 with PortStatusDTO

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

the class PortStatusEndpointMerger method mergeResponses.

@Override
protected void mergeResponses(PortStatusEntity clientEntity, Map<NodeIdentifier, PortStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
    final PortStatusDTO mergedPortStatus = clientEntity.getPortStatus();
    mergedPortStatus.setNodeSnapshots(new ArrayList<>());
    final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
    if (selectedNodeId == null) {
        throw new IllegalArgumentException("Attempted to merge Status request but could not find the appropriate Node Identifier");
    }
    final NodePortStatusSnapshotDTO selectedNodeSnapshot = new NodePortStatusSnapshotDTO();
    selectedNodeSnapshot.setStatusSnapshot(mergedPortStatus.getAggregateSnapshot().clone());
    selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
    selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
    selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
    mergedPortStatus.getNodeSnapshots().add(selectedNodeSnapshot);
    // merge the other nodes
    for (final Map.Entry<NodeIdentifier, PortStatusEntity> entry : entityMap.entrySet()) {
        final NodeIdentifier nodeId = entry.getKey();
        final PortStatusEntity nodePortStatusEntity = entry.getValue();
        final PortStatusDTO nodePortStatus = nodePortStatusEntity.getPortStatus();
        if (nodePortStatus == mergedPortStatus) {
            continue;
        }
        mergeStatus(mergedPortStatus, clientEntity.getCanRead(), nodePortStatus, nodePortStatusEntity.getCanRead(), nodeId);
    }
}
Also used : PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) PortStatusEntity(org.apache.nifi.web.api.entity.PortStatusEntity) Map(java.util.Map) Set(java.util.Set) StatusMerger(org.apache.nifi.cluster.manager.StatusMerger) NodePortStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodePortStatusSnapshotDTO) 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) NodePortStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodePortStatusSnapshotDTO) PortStatusEntity(org.apache.nifi.web.api.entity.PortStatusEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) Map(java.util.Map)

Example 12 with PortStatusDTO

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

the class DtoFactory method createPortStatusDto.

/**
 * Creates a PortStatusDTO for the specified PortStatus.
 *
 * @param portStatus status
 * @return dto
 */
public PortStatusDTO createPortStatusDto(final PortStatus portStatus) {
    final PortStatusDTO dto = new PortStatusDTO();
    dto.setId(portStatus.getId());
    dto.setGroupId(portStatus.getGroupId());
    dto.setName(portStatus.getName());
    dto.setRunStatus(portStatus.getRunStatus().toString());
    dto.setTransmitting(portStatus.isTransmitting());
    dto.setStatsLastRefreshed(new Date());
    final PortStatusSnapshotDTO snapshot = new PortStatusSnapshotDTO();
    dto.setAggregateSnapshot(snapshot);
    snapshot.setId(portStatus.getId());
    snapshot.setGroupId(portStatus.getGroupId());
    snapshot.setName(portStatus.getName());
    snapshot.setRunStatus(portStatus.getRunStatus().toString());
    snapshot.setActiveThreadCount(portStatus.getActiveThreadCount());
    snapshot.setFlowFilesOut(portStatus.getOutputCount());
    snapshot.setBytesOut(portStatus.getOutputBytes());
    snapshot.setFlowFilesIn(portStatus.getInputCount());
    snapshot.setBytesIn(portStatus.getInputBytes());
    StatusMerger.updatePrettyPrintedFields(snapshot);
    return dto;
}
Also used : PortStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.PortStatusSnapshotDTO) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) Date(java.util.Date)

Example 13 with PortStatusDTO

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

the class DtoFactory method createProcessGroupStatusDto.

public ProcessGroupStatusDTO createProcessGroupStatusDto(final ProcessGroup processGroup, final ProcessGroupStatus processGroupStatus) {
    final ProcessGroupStatusDTO processGroupStatusDto = createConciseProcessGroupStatusDto(processGroupStatus);
    final ProcessGroupStatusSnapshotDTO snapshot = processGroupStatusDto.getAggregateSnapshot();
    // processor status
    final Collection<ProcessorStatusSnapshotEntity> processorStatusSnapshotEntities = new ArrayList<>();
    snapshot.setProcessorStatusSnapshots(processorStatusSnapshotEntities);
    final Collection<ProcessorStatus> processorStatusCollection = processGroupStatus.getProcessorStatus();
    if (processorStatusCollection != null) {
        for (final ProcessorStatus processorStatus : processorStatusCollection) {
            final ProcessorStatusDTO processorStatusDto = createProcessorStatusDto(processorStatus);
            final ProcessorNode processor = processGroup.findProcessor(processorStatusDto.getId());
            final PermissionsDTO processorPermissions = createPermissionsDto(processor);
            processorStatusSnapshotEntities.add(entityFactory.createProcessorStatusSnapshotEntity(processorStatusDto.getAggregateSnapshot(), processorPermissions));
        }
    }
    // connection status
    final Collection<ConnectionStatusSnapshotEntity> connectionStatusDtoCollection = new ArrayList<>();
    snapshot.setConnectionStatusSnapshots(connectionStatusDtoCollection);
    final Collection<ConnectionStatus> connectionStatusCollection = processGroupStatus.getConnectionStatus();
    if (connectionStatusCollection != null) {
        for (final ConnectionStatus connectionStatus : connectionStatusCollection) {
            final ConnectionStatusDTO connectionStatusDto = createConnectionStatusDto(connectionStatus);
            final Connection connection = processGroup.findConnection(connectionStatusDto.getId());
            final PermissionsDTO connectionPermissions = createPermissionsDto(connection);
            connectionStatusDtoCollection.add(entityFactory.createConnectionStatusSnapshotEntity(connectionStatusDto.getAggregateSnapshot(), connectionPermissions));
        }
    }
    // local child process groups
    final Collection<ProcessGroupStatusSnapshotEntity> childProcessGroupStatusDtoCollection = new ArrayList<>();
    snapshot.setProcessGroupStatusSnapshots(childProcessGroupStatusDtoCollection);
    final Collection<ProcessGroupStatus> childProcessGroupStatusCollection = processGroupStatus.getProcessGroupStatus();
    if (childProcessGroupStatusCollection != null) {
        for (final ProcessGroupStatus childProcessGroupStatus : childProcessGroupStatusCollection) {
            final ProcessGroupStatusDTO childProcessGroupStatusDto = createProcessGroupStatusDto(processGroup, childProcessGroupStatus);
            final ProcessGroup childProcessGroup = processGroup.findProcessGroup(childProcessGroupStatusDto.getId());
            final PermissionsDTO childProcessGroupPermissions = createPermissionsDto(childProcessGroup);
            childProcessGroupStatusDtoCollection.add(entityFactory.createProcessGroupStatusSnapshotEntity(childProcessGroupStatusDto.getAggregateSnapshot(), childProcessGroupPermissions));
        }
    }
    // remote child process groups
    final Collection<RemoteProcessGroupStatusSnapshotEntity> childRemoteProcessGroupStatusDtoCollection = new ArrayList<>();
    snapshot.setRemoteProcessGroupStatusSnapshots(childRemoteProcessGroupStatusDtoCollection);
    final Collection<RemoteProcessGroupStatus> childRemoteProcessGroupStatusCollection = processGroupStatus.getRemoteProcessGroupStatus();
    if (childRemoteProcessGroupStatusCollection != null) {
        for (final RemoteProcessGroupStatus childRemoteProcessGroupStatus : childRemoteProcessGroupStatusCollection) {
            final RemoteProcessGroupStatusDTO childRemoteProcessGroupStatusDto = createRemoteProcessGroupStatusDto(childRemoteProcessGroupStatus);
            final RemoteProcessGroup remoteProcessGroup = processGroup.findRemoteProcessGroup(childRemoteProcessGroupStatusDto.getId());
            final PermissionsDTO remoteProcessGroupPermissions = createPermissionsDto(remoteProcessGroup);
            childRemoteProcessGroupStatusDtoCollection.add(entityFactory.createRemoteProcessGroupStatusSnapshotEntity(childRemoteProcessGroupStatusDto.getAggregateSnapshot(), remoteProcessGroupPermissions));
        }
    }
    // input ports
    final Collection<PortStatusSnapshotEntity> inputPortStatusDtoCollection = new ArrayList<>();
    snapshot.setInputPortStatusSnapshots(inputPortStatusDtoCollection);
    final Collection<PortStatus> inputPortStatusCollection = processGroupStatus.getInputPortStatus();
    if (inputPortStatusCollection != null) {
        for (final PortStatus portStatus : inputPortStatusCollection) {
            final PortStatusDTO portStatusDto = createPortStatusDto(portStatus);
            final Port inputPort = processGroup.findInputPort(portStatus.getId());
            final PermissionsDTO inputPortPermissions = createPermissionsDto(inputPort);
            inputPortStatusDtoCollection.add(entityFactory.createPortStatusSnapshotEntity(portStatusDto.getAggregateSnapshot(), inputPortPermissions));
        }
    }
    // output ports
    final Collection<PortStatusSnapshotEntity> outputPortStatusDtoCollection = new ArrayList<>();
    snapshot.setOutputPortStatusSnapshots(outputPortStatusDtoCollection);
    final Collection<PortStatus> outputPortStatusCollection = processGroupStatus.getOutputPortStatus();
    if (outputPortStatusCollection != null) {
        for (final PortStatus portStatus : outputPortStatusCollection) {
            final PortStatusDTO portStatusDto = createPortStatusDto(portStatus);
            final Port outputPort = processGroup.findOutputPort(portStatus.getId());
            final PermissionsDTO outputPortPermissions = createPermissionsDto(outputPort);
            outputPortStatusDtoCollection.add(entityFactory.createPortStatusSnapshotEntity(portStatusDto.getAggregateSnapshot(), outputPortPermissions));
        }
    }
    return processGroupStatusDto;
}
Also used : InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) ArrayList(java.util.ArrayList) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity) ProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity) PortStatusSnapshotEntity(org.apache.nifi.web.api.entity.PortStatusSnapshotEntity) ConnectionStatusSnapshotEntity(org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) PortStatus(org.apache.nifi.controller.status.PortStatus) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Connection(org.apache.nifi.connectable.Connection) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) ProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusSnapshotDTO) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) ProcessorStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessorStatusSnapshotEntity) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity)

Aggregations

PortStatusDTO (org.apache.nifi.web.api.dto.status.PortStatusDTO)13 Port (org.apache.nifi.connectable.Port)11 InstantiatedVersionedRemoteGroupPort (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort)11 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)11 RootGroupPort (org.apache.nifi.remote.RootGroupPort)11 ArrayList (java.util.ArrayList)10 Date (java.util.Date)9 Map (java.util.Map)9 Set (java.util.Set)9 NodeConnectionStatus (org.apache.nifi.cluster.coordination.node.NodeConnectionStatus)9 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)9 Arrays (java.util.Arrays)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8 Comparator (java.util.Comparator)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 LinkedHashMap (java.util.LinkedHashMap)8 LinkedHashSet (java.util.LinkedHashSet)8 List (java.util.List)8