Search in sources :

Example 1 with JaxbProtocolContext

use of org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext in project nifi by apache.

the class Node method createCoordinatorProtocolSender.

@SuppressWarnings("unchecked")
private ClusterCoordinationProtocolSender createCoordinatorProtocolSender() {
    final SocketConfiguration socketConfig = new SocketConfiguration();
    socketConfig.setSocketTimeout(3000);
    socketConfig.setReuseAddress(true);
    final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<>(JaxbProtocolUtils.JAXB_CONTEXT);
    return new StandardClusterCoordinationProtocolSender(socketConfig, protocolContext, 1);
}
Also used : StandardClusterCoordinationProtocolSender(org.apache.nifi.cluster.protocol.impl.StandardClusterCoordinationProtocolSender) SocketConfiguration(org.apache.nifi.io.socket.SocketConfiguration) ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) ProtocolMessage(org.apache.nifi.cluster.protocol.message.ProtocolMessage)

Example 2 with JaxbProtocolContext

use of org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext in project nifi by apache.

the class Node method createNodeProtocolSender.

@SuppressWarnings("unchecked")
private NodeProtocolSender createNodeProtocolSender() {
    final SocketConfiguration socketConfig = new SocketConfiguration();
    socketConfig.setSocketTimeout(3000);
    socketConfig.setReuseAddress(true);
    final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<>(JaxbProtocolUtils.JAXB_CONTEXT);
    final NodeProtocolSender protocolSender = new LeaderElectionNodeProtocolSender(socketConfig, protocolContext, electionManager);
    return protocolSender;
}
Also used : LeaderElectionNodeProtocolSender(org.apache.nifi.cluster.coordination.node.LeaderElectionNodeProtocolSender) NodeProtocolSender(org.apache.nifi.cluster.protocol.NodeProtocolSender) LeaderElectionNodeProtocolSender(org.apache.nifi.cluster.coordination.node.LeaderElectionNodeProtocolSender) SocketConfiguration(org.apache.nifi.io.socket.SocketConfiguration) ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) ProtocolMessage(org.apache.nifi.cluster.protocol.message.ProtocolMessage)

Example 3 with JaxbProtocolContext

use of org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext in project nifi by apache.

the class Node method createClusterCoordinator.

@SuppressWarnings("unchecked")
private NodeClusterCoordinator createClusterCoordinator() {
    final EventReporter eventReporter = new EventReporter() {

        @Override
        public void reportEvent(Severity severity, String category, String message) {
            reportedEvents.add(new ReportedEvent(nodeId, severity, message));
        }
    };
    final ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
    serverSocketConfiguration.setSocketTimeout(5000);
    final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<>(JaxbProtocolUtils.JAXB_CONTEXT);
    protocolListener = new SocketProtocolListener(3, Integer.parseInt(nodeProperties.getProperty(NiFiProperties.CLUSTER_NODE_PROTOCOL_PORT)), serverSocketConfiguration, protocolContext);
    try {
        protocolListener.start();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    final ClusterCoordinationProtocolSenderListener protocolSenderListener = new ClusterCoordinationProtocolSenderListener(createCoordinatorProtocolSender(), protocolListener);
    return new NodeClusterCoordinator(protocolSenderListener, eventReporter, electionManager, flowElection, null, revisionManager, nodeProperties, protocolSender);
}
Also used : SocketProtocolListener(org.apache.nifi.cluster.protocol.impl.SocketProtocolListener) NodeClusterCoordinator(org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator) Severity(org.apache.nifi.reporting.Severity) IOException(java.io.IOException) ProtocolMessage(org.apache.nifi.cluster.protocol.message.ProtocolMessage) ReportedEvent(org.apache.nifi.cluster.ReportedEvent) ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) ClusterCoordinationProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener) EventReporter(org.apache.nifi.events.EventReporter)

Example 4 with JaxbProtocolContext

use of org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext in project nifi by apache.

the class SocketProtocolListenerTest method setup.

@Before
public void setup() throws Exception {
    final ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
    marshaller = protocolContext.createMarshaller();
    unmarshaller = protocolContext.createUnmarshaller();
    ServerSocketConfiguration configuration = new ServerSocketConfiguration();
    configuration.setSocketTimeout(1000);
    listener = new SocketProtocolListener(5, 0, configuration, protocolContext);
    listener.start();
    int port = listener.getPort();
    SocketConfiguration config = new SocketConfiguration();
    config.setReuseAddress(true);
    config.setSocketTimeout(1000);
    socket = SocketUtils.createSocket(new InetSocketAddress("localhost", port), config);
}
Also used : ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) InetSocketAddress(java.net.InetSocketAddress) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) ProtocolContext(org.apache.nifi.cluster.protocol.ProtocolContext) SocketConfiguration(org.apache.nifi.io.socket.SocketConfiguration) ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) Before(org.junit.Before)

Aggregations

JaxbProtocolContext (org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext)4 ServerSocketConfiguration (org.apache.nifi.io.socket.ServerSocketConfiguration)4 ProtocolMessage (org.apache.nifi.cluster.protocol.message.ProtocolMessage)3 SocketConfiguration (org.apache.nifi.io.socket.SocketConfiguration)3 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ReportedEvent (org.apache.nifi.cluster.ReportedEvent)1 LeaderElectionNodeProtocolSender (org.apache.nifi.cluster.coordination.node.LeaderElectionNodeProtocolSender)1 NodeClusterCoordinator (org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator)1 NodeProtocolSender (org.apache.nifi.cluster.protocol.NodeProtocolSender)1 ProtocolContext (org.apache.nifi.cluster.protocol.ProtocolContext)1 ClusterCoordinationProtocolSenderListener (org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener)1 SocketProtocolListener (org.apache.nifi.cluster.protocol.impl.SocketProtocolListener)1 StandardClusterCoordinationProtocolSender (org.apache.nifi.cluster.protocol.impl.StandardClusterCoordinationProtocolSender)1 EventReporter (org.apache.nifi.events.EventReporter)1 Severity (org.apache.nifi.reporting.Severity)1 Before (org.junit.Before)1