Search in sources :

Example 6 with ConnectionStatusDTO

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

the class ConnectionStatusEndpointMerger method mergeResponses.

@Override
protected void mergeResponses(ConnectionStatusEntity clientEntity, Map<NodeIdentifier, ConnectionStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
    final ConnectionStatusDTO mergedConnectionStatus = clientEntity.getConnectionStatus();
    mergedConnectionStatus.setNodeSnapshots(new ArrayList<>());
    final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
    final NodeConnectionStatusSnapshotDTO selectedNodeSnapshot = new NodeConnectionStatusSnapshotDTO();
    selectedNodeSnapshot.setStatusSnapshot(mergedConnectionStatus.getAggregateSnapshot().clone());
    selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
    selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
    selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
    mergedConnectionStatus.getNodeSnapshots().add(selectedNodeSnapshot);
    // merge the other nodes
    for (final Map.Entry<NodeIdentifier, ConnectionStatusEntity> entry : entityMap.entrySet()) {
        final NodeIdentifier nodeId = entry.getKey();
        final ConnectionStatusEntity nodeConnectionStatusEntity = entry.getValue();
        final ConnectionStatusDTO nodeConnectionStatus = nodeConnectionStatusEntity.getConnectionStatus();
        if (nodeConnectionStatus == mergedConnectionStatus) {
            continue;
        }
        mergeStatus(mergedConnectionStatus, clientEntity.getCanRead(), nodeConnectionStatus, nodeConnectionStatusEntity.getCanRead(), nodeId);
    }
}
Also used : NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) ConnectionStatusEntity(org.apache.nifi.web.api.entity.ConnectionStatusEntity) Map(java.util.Map) Set(java.util.Set) StatusMerger(org.apache.nifi.cluster.manager.StatusMerger) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) URI(java.net.URI) Pattern(java.util.regex.Pattern) NodeConnectionStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeConnectionStatusSnapshotDTO) ComponentEntityStatusMerger(org.apache.nifi.cluster.manager.ComponentEntityStatusMerger) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) ArrayList(java.util.ArrayList) NodeConnectionStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.NodeConnectionStatusSnapshotDTO) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) ConnectionStatusEntity(org.apache.nifi.web.api.entity.ConnectionStatusEntity) Map(java.util.Map)

Example 7 with ConnectionStatusDTO

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

the class StandardNiFiServiceFacade method createConnection.

@Override
public ConnectionEntity createConnection(final Revision revision, final String groupId, final ConnectionDTO connectionDTO) {
    final RevisionUpdate<ConnectionDTO> snapshot = createComponent(revision, connectionDTO, () -> connectionDAO.createConnection(groupId, connectionDTO), connection -> dtoFactory.createConnectionDto(connection));
    final Connection connection = connectionDAO.getConnection(connectionDTO.getId());
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(connection);
    final ConnectionStatusDTO status = dtoFactory.createConnectionStatusDto(controllerFacade.getConnectionStatus(connectionDTO.getId()));
    return entityFactory.createConnectionEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status);
}
Also used : ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) Connection(org.apache.nifi.connectable.Connection) VersionedConnection(org.apache.nifi.registry.flow.VersionedConnection)

Example 8 with ConnectionStatusDTO

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

the class StandardNiFiServiceFacade method updateConnection.

@Override
public ConnectionEntity updateConnection(final Revision revision, final ConnectionDTO connectionDTO) {
    final Connection connectionNode = connectionDAO.getConnection(connectionDTO.getId());
    final RevisionUpdate<ConnectionDTO> snapshot = updateComponent(revision, connectionNode, () -> connectionDAO.updateConnection(connectionDTO), connection -> dtoFactory.createConnectionDto(connection));
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(connectionNode);
    final ConnectionStatusDTO status = dtoFactory.createConnectionStatusDto(controllerFacade.getConnectionStatus(connectionNode.getIdentifier()));
    return entityFactory.createConnectionEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status);
}
Also used : ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) Connection(org.apache.nifi.connectable.Connection) VersionedConnection(org.apache.nifi.registry.flow.VersionedConnection)

Example 9 with ConnectionStatusDTO

use of org.apache.nifi.web.api.dto.status.ConnectionStatusDTO 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

ConnectionStatusDTO (org.apache.nifi.web.api.dto.status.ConnectionStatusDTO)9 Connection (org.apache.nifi.connectable.Connection)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 Map (java.util.Map)3 Set (java.util.Set)3 StatusMerger (org.apache.nifi.cluster.manager.StatusMerger)3 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)3 ConnectionStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO)3 Collator (java.text.Collator)2 NumberFormat (java.text.NumberFormat)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2