Search in sources :

Example 1 with NodeEvent

use of org.apache.nifi.cluster.event.NodeEvent in project nifi by apache.

the class StandardNiFiServiceFacade method getNode.

private NodeDTO getNode(final NodeIdentifier nodeId) {
    final NodeConnectionStatus nodeStatus = clusterCoordinator.getConnectionStatus(nodeId);
    final List<NodeEvent> events = clusterCoordinator.getNodeEvents(nodeId);
    final Set<String> roles = getRoles(nodeId);
    final NodeHeartbeat heartbeat = heartbeatMonitor.getLatestHeartbeat(nodeId);
    return dtoFactory.createNodeDTO(nodeId, nodeStatus, heartbeat, events, roles);
}
Also used : NodeEvent(org.apache.nifi.cluster.event.NodeEvent) NodeHeartbeat(org.apache.nifi.cluster.coordination.heartbeat.NodeHeartbeat) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus)

Example 2 with NodeEvent

use of org.apache.nifi.cluster.event.NodeEvent in project nifi by apache.

the class NodeClusterCoordinator method addNodeEvent.

private void addNodeEvent(final NodeIdentifier nodeId, final Severity severity, final String message) {
    final NodeEvent event = new Event(nodeId.toString(), message, severity);
    final CircularFifoQueue<NodeEvent> eventQueue = nodeEvents.computeIfAbsent(nodeId, id -> new CircularFifoQueue<>());
    synchronized (eventQueue) {
        eventQueue.add(event);
    }
}
Also used : NodeEvent(org.apache.nifi.cluster.event.NodeEvent) NodeEvent(org.apache.nifi.cluster.event.NodeEvent) Event(org.apache.nifi.cluster.event.Event)

Example 3 with NodeEvent

use of org.apache.nifi.cluster.event.NodeEvent in project nifi by apache.

the class DtoFactory method createNodeDTO.

public NodeDTO createNodeDTO(final NodeIdentifier nodeId, final NodeConnectionStatus status, final NodeHeartbeat nodeHeartbeat, final List<NodeEvent> events, final Set<String> roles) {
    final NodeDTO nodeDto = new NodeDTO();
    // populate node dto
    nodeDto.setNodeId(nodeId.getId());
    nodeDto.setAddress(nodeId.getApiAddress());
    nodeDto.setApiPort(nodeId.getApiPort());
    nodeDto.setStatus(status.getState().name());
    nodeDto.setRoles(roles);
    if (status.getConnectionRequestTime() != null) {
        final Date connectionRequested = new Date(status.getConnectionRequestTime());
        nodeDto.setConnectionRequested(connectionRequested);
    }
    // only connected nodes have heartbeats
    if (nodeHeartbeat != null) {
        final Date heartbeat = new Date(nodeHeartbeat.getTimestamp());
        nodeDto.setHeartbeat(heartbeat);
        nodeDto.setNodeStartTime(new Date(nodeHeartbeat.getSystemStartTime()));
        nodeDto.setActiveThreadCount(nodeHeartbeat.getActiveThreadCount());
        nodeDto.setQueued(FormatUtils.formatCount(nodeHeartbeat.getFlowFileCount()) + " / " + FormatUtils.formatDataSize(nodeHeartbeat.getFlowFileBytes()));
    }
    // populate node events
    final List<NodeEvent> nodeEvents = new ArrayList<>(events);
    Collections.sort(nodeEvents, new Comparator<NodeEvent>() {

        @Override
        public int compare(final NodeEvent event1, final NodeEvent event2) {
            return new Date(event2.getTimestamp()).compareTo(new Date(event1.getTimestamp()));
        }
    });
    // create the node event dtos
    final List<NodeEventDTO> nodeEventDtos = new ArrayList<>();
    for (final NodeEvent event : nodeEvents) {
        // create node event dto
        final NodeEventDTO nodeEventDto = new NodeEventDTO();
        nodeEventDtos.add(nodeEventDto);
        // populate node event dto
        nodeEventDto.setMessage(event.getMessage());
        nodeEventDto.setCategory(event.getSeverity().name());
        nodeEventDto.setTimestamp(new Date(event.getTimestamp()));
    }
    nodeDto.setEvents(nodeEventDtos);
    return nodeDto;
}
Also used : NodeEvent(org.apache.nifi.cluster.event.NodeEvent) ArrayList(java.util.ArrayList) ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) Date(java.util.Date)

Aggregations

NodeEvent (org.apache.nifi.cluster.event.NodeEvent)3 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 NodeHeartbeat (org.apache.nifi.cluster.coordination.heartbeat.NodeHeartbeat)1 NodeConnectionStatus (org.apache.nifi.cluster.coordination.node.NodeConnectionStatus)1 Event (org.apache.nifi.cluster.event.Event)1 ProvenanceNodeDTO (org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO)1