Search in sources :

Example 1 with SocketConfiguration

use of org.apache.nifi.io.socket.SocketConfiguration 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 SocketConfiguration

use of org.apache.nifi.io.socket.SocketConfiguration in project nifi by apache.

the class SocketConfigurationFactoryBean method getObject.

@Override
public SocketConfiguration getObject() throws Exception {
    if (configuration == null) {
        configuration = new SocketConfiguration();
        final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterNodeReadTimeout(), TimeUnit.MILLISECONDS);
        configuration.setSocketTimeout(timeout);
        configuration.setReuseAddress(true);
        if (Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) {
            configuration.setSSLContextFactory(new SSLContextFactory(properties));
        }
    }
    return configuration;
}
Also used : SocketConfiguration(org.apache.nifi.io.socket.SocketConfiguration) SSLContextFactory(org.apache.nifi.io.socket.SSLContextFactory)

Example 3 with SocketConfiguration

use of org.apache.nifi.io.socket.SocketConfiguration 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 4 with SocketConfiguration

use of org.apache.nifi.io.socket.SocketConfiguration 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

SocketConfiguration (org.apache.nifi.io.socket.SocketConfiguration)4 JaxbProtocolContext (org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext)3 ServerSocketConfiguration (org.apache.nifi.io.socket.ServerSocketConfiguration)3 ProtocolMessage (org.apache.nifi.cluster.protocol.message.ProtocolMessage)2 InetSocketAddress (java.net.InetSocketAddress)1 LeaderElectionNodeProtocolSender (org.apache.nifi.cluster.coordination.node.LeaderElectionNodeProtocolSender)1 NodeProtocolSender (org.apache.nifi.cluster.protocol.NodeProtocolSender)1 ProtocolContext (org.apache.nifi.cluster.protocol.ProtocolContext)1 StandardClusterCoordinationProtocolSender (org.apache.nifi.cluster.protocol.impl.StandardClusterCoordinationProtocolSender)1 SSLContextFactory (org.apache.nifi.io.socket.SSLContextFactory)1 Before (org.junit.Before)1