final HeartbeatResponseMessage responseMessage = protocolSender.heartbeat(heartbeatMessage, heartbeatAddress); final byte[] payloadBytes = heartbeatMessage.getHeartbeat().getPayload(); final HeartbeatPayload payload = HeartbeatPayload.unmarshal(payloadBytes); final List<NodeConnectionStatus> nodeStatusList = payload.getClusterStatus(); dateFormatter.format(new Date(heartbeatMessage.getHeartbeat().getCreatedTimestamp())), heartbeatAddress, dateFormatter.format(new Date()),
public HeartbeatMessage createHeartbeatMessage() { return new HeartbeatMessage(); }
final HeartbeatMessage message = new HeartbeatMessage(); message.setHeartbeat(heartbeat);
public static StandardNodeHeartbeat fromHeartbeatMessage(final HeartbeatMessage message, final long timestamp) { final Heartbeat heartbeat = message.getHeartbeat(); final HeartbeatPayload payload = HeartbeatPayload.unmarshal(heartbeat.getPayload()); return new StandardNodeHeartbeat(heartbeat.getNodeIdentifier(), timestamp, heartbeat.getConnectionStatus(), (int) payload.getTotalFlowFileCount(), payload.getTotalFlowFileBytes(), payload.getActiveThreadCount(), payload.getSystemStartTime()); } }
public HeartbeatMessage createHeartbeatMessage() { return new HeartbeatMessage(); }
private NodeIdentifier getNodeIdentifier(final ProtocolMessage message) { if (message == null) { return null; } switch (message.getType()) { case CONNECTION_REQUEST: return ((ConnectionRequestMessage) message).getConnectionRequest().getProposedNodeIdentifier(); case HEARTBEAT: return ((HeartbeatMessage) message).getHeartbeat().getNodeIdentifier(); case OFFLOAD_REQUEST: return ((OffloadMessage) message).getNodeId(); case DISCONNECTION_REQUEST: return ((DisconnectMessage) message).getNodeId(); case FLOW_REQUEST: return ((FlowRequestMessage) message).getNodeId(); case RECONNECTION_REQUEST: return ((ReconnectionRequestMessage) message).getNodeId(); default: return null; } }
private ProtocolMessage handleHeartbeat(final HeartbeatMessage msg) { final HeartbeatMessage heartbeatMsg = msg; final Heartbeat heartbeat = heartbeatMsg.getHeartbeat(); final NodeIdentifier nodeId = heartbeat.getNodeIdentifier(); final NodeConnectionStatus connectionStatus = heartbeat.getConnectionStatus(); final byte[] payloadBytes = heartbeat.getPayload(); final HeartbeatPayload payload = HeartbeatPayload.unmarshal(payloadBytes); final int activeThreadCount = payload.getActiveThreadCount(); final int flowFileCount = (int) payload.getTotalFlowFileCount(); final long flowFileBytes = payload.getTotalFlowFileBytes(); final long systemStartTime = payload.getSystemStartTime(); final NodeHeartbeat nodeHeartbeat = new StandardNodeHeartbeat(nodeId, System.currentTimeMillis(), connectionStatus, flowFileCount, flowFileBytes, activeThreadCount, systemStartTime); heartbeatMessages.put(heartbeat.getNodeIdentifier(), nodeHeartbeat); logger.debug("Received new heartbeat from {}", nodeId); // Formulate a List of differences between our view of the cluster topology and the node's view // and send that back to the node so that it is in-sync with us List<NodeConnectionStatus> nodeStatusList = payload.getClusterStatus(); if (nodeStatusList == null) { nodeStatusList = Collections.emptyList(); } final List<NodeConnectionStatus> updatedStatuses = getUpdatedStatuses(nodeStatusList); final HeartbeatResponseMessage responseMessage = new HeartbeatResponseMessage(); responseMessage.setUpdatedNodeStatuses(updatedStatuses); if (!getClusterCoordinator().isFlowElectionComplete()) { responseMessage.setFlowElectionMessage(getClusterCoordinator().getFlowElectionStatus()); } return responseMessage; }
private NodeIdentifier getNodeIdentifier(final ProtocolMessage message) { if (message == null) { return null; } switch (message.getType()) { case CONNECTION_REQUEST: return ((ConnectionRequestMessage) message).getConnectionRequest().getProposedNodeIdentifier(); case HEARTBEAT: return ((HeartbeatMessage) message).getHeartbeat().getNodeIdentifier(); case OFFLOAD_REQUEST: return ((OffloadMessage) message).getNodeId(); case DISCONNECTION_REQUEST: return ((DisconnectMessage) message).getNodeId(); case FLOW_REQUEST: return ((FlowRequestMessage) message).getNodeId(); case RECONNECTION_REQUEST: return ((ReconnectionRequestMessage) message).getNodeId(); default: return null; } }