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;
}
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);
}
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);
}
Aggregations