Package org.apache.nifi.cluster.protocol
Class AbstractNodeProtocolSender
java.lang.Object
org.apache.nifi.cluster.protocol.AbstractNodeProtocolSender
- All Implemented Interfaces:
NodeProtocolSender
- Direct Known Subclasses:
LeaderElectionNodeProtocolSender
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate final ProtocolMessageMarshaller<ProtocolMessage> private final ProtocolContext<ProtocolMessage> private final SocketConfigurationprivate final ProtocolMessageUnmarshaller<ProtocolMessage> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractNodeProtocolSender(SocketConfiguration socketConfiguration, ProtocolContext<ProtocolMessage> protocolContext) -
Method Summary
Modifier and TypeMethodDescriptionSends a "cluster workflow request" message to the Cluster Coordinator.private SocketcreateSocket(InetSocketAddress socketAddress) protected abstract InetSocketAddressheartbeat(HeartbeatMessage msg, String address) Sends a heartbeat to the address givenSends a "node statuses" request message to the Cluster Coordinator.requestConnection(ConnectionRequestMessage msg, boolean allowConnectToSelf) Sends a "connection request" message to the cluster manager.private ProtocolMessagesendProtocolMessage(ProtocolMessage msg, String hostname, int port, CommsTimingDetails timingDetails) private voidvalidateNotConnectingToSelf(ConnectionRequestMessage msg, InetSocketAddress socketAddress)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
socketConfiguration
-
protocolContext
-
marshaller
-
unmarshaller
-
-
Constructor Details
-
AbstractNodeProtocolSender
public AbstractNodeProtocolSender(SocketConfiguration socketConfiguration, ProtocolContext<ProtocolMessage> protocolContext)
-
-
Method Details
-
requestConnection
public ConnectionResponseMessage requestConnection(ConnectionRequestMessage msg, boolean allowConnectToSelf) throws ProtocolException, UnknownServiceAddressException Description copied from interface:NodeProtocolSenderSends a "connection request" message to the cluster manager.- Specified by:
requestConnectionin interfaceNodeProtocolSender- Parameters:
msg- a messageallowConnectToSelf- whether or not the node should be allowed to connect to the cluster if the Cluster Coordinator is this node- Returns:
- the response
- Throws:
ProtocolException- if communication failedUnknownServiceAddressException- if the cluster manager's address is not known
-
validateNotConnectingToSelf
private void validateNotConnectingToSelf(ConnectionRequestMessage msg, InetSocketAddress socketAddress) -
heartbeat
public HeartbeatResponseMessage heartbeat(HeartbeatMessage msg, String address) throws ProtocolException Description copied from interface:NodeProtocolSenderSends a heartbeat to the address given- Specified by:
heartbeatin interfaceNodeProtocolSender- Parameters:
msg- the heartbeat message to sendaddress- the address of the Cluster Coordinator in <hostname>:<port> format- Returns:
- the response from the Cluster Coordinator
- Throws:
ProtocolException- if unable to send the heartbeat
-
clusterWorkload
public ClusterWorkloadResponseMessage clusterWorkload(ClusterWorkloadRequestMessage msg) throws ProtocolException Description copied from interface:NodeProtocolSenderSends a "cluster workflow request" message to the Cluster Coordinator.- Specified by:
clusterWorkloadin interfaceNodeProtocolSender- Parameters:
msg- a request message- Returns:
- the response from the Cluster Coordinator
- Throws:
ProtocolException- if communication failed
-
nodeStatuses
public NodeStatusesResponseMessage nodeStatuses(NodeStatusesRequestMessage msg) throws ProtocolException Description copied from interface:NodeProtocolSenderSends a "node statuses" request message to the Cluster Coordinator.- Specified by:
nodeStatusesin interfaceNodeProtocolSender- Parameters:
msg- a request message- Returns:
- the response from the Cluster Coordinator containing the statuses of all nodes in the cluster
- Throws:
ProtocolException- if communication failed
-
createSocket
-
getSocketConfiguration
-
sendProtocolMessage
private ProtocolMessage sendProtocolMessage(ProtocolMessage msg, String hostname, int port, CommsTimingDetails timingDetails) -
getServiceAddress
- Throws:
IOException
-