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);
}
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);
}
}
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;
}
Aggregations