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.Logger
private final ProtocolMessageMarshaller
<ProtocolMessage> private final ProtocolContext
<ProtocolMessage> private final SocketConfiguration
private 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 Socket
createSocket
(InetSocketAddress socketAddress) protected abstract InetSocketAddress
heartbeat
(HeartbeatMessage msg, String address) Sends a heartbeat to the address givenrequestConnection
(ConnectionRequestMessage msg, boolean allowConnectToSelf) Sends a "connection request" message to the cluster manager.private ProtocolMessage
sendProtocolMessage
(ProtocolMessage msg, String hostname, int port, CommsTimingDetails timingDetails) private void
validateNotConnectingToSelf
(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:NodeProtocolSender
Sends a "connection request" message to the cluster manager.- Specified by:
requestConnection
in 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:NodeProtocolSender
Sends a heartbeat to the address given- Specified by:
heartbeat
in 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:NodeProtocolSender
Sends a "cluster workflow request" message to the Cluster Coordinator.- Specified by:
clusterWorkload
in interfaceNodeProtocolSender
- Parameters:
msg
- a request message- Returns:
- the response from the Cluster Coordinator
- Throws:
ProtocolException
- if communication failed
-
createSocket
-
getSocketConfiguration
-
sendProtocolMessage
private ProtocolMessage sendProtocolMessage(ProtocolMessage msg, String hostname, int port, CommsTimingDetails timingDetails) -
getServiceAddress
- Throws:
IOException
-