Search in sources :

Example 1 with ServerSocketConfiguration

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

the class ServerSocketConfigurationFactoryBean method getObject.

@Override
public ServerSocketConfiguration getObject() throws Exception {
    if (configuration == null) {
        configuration = new ServerSocketConfiguration();
        configuration.setNeedClientAuth(properties.getNeedClientAuth());
        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 : ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) SSLContextFactory(org.apache.nifi.io.socket.SSLContextFactory)

Example 2 with ServerSocketConfiguration

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

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

ServerSocketConfiguration (org.apache.nifi.io.socket.ServerSocketConfiguration)3 JaxbProtocolContext (org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ReportedEvent (org.apache.nifi.cluster.ReportedEvent)1 NodeClusterCoordinator (org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator)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 ProtocolMessage (org.apache.nifi.cluster.protocol.message.ProtocolMessage)1 EventReporter (org.apache.nifi.events.EventReporter)1 SSLContextFactory (org.apache.nifi.io.socket.SSLContextFactory)1 SocketConfiguration (org.apache.nifi.io.socket.SocketConfiguration)1 Severity (org.apache.nifi.reporting.Severity)1 Before (org.junit.Before)1