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