use of org.apache.ignite.network.StaticNodeFinder in project ignite-3 by apache.
the class ItMetaStorageRaftGroupTest method beforeTest.
/**
* Run {@code NODES} cluster nodes.
*/
@BeforeEach
public void beforeTest(TestInfo testInfo) {
List<NetworkAddress> localAddresses = findLocalAddresses(NODE_PORT_BASE, NODE_PORT_BASE + NODES);
var nodeFinder = new StaticNodeFinder(localAddresses);
localAddresses.stream().map(addr -> ClusterServiceTestUtils.clusterService(testInfo, addr.port(), nodeFinder, NETWORK_FACTORY)).forEach(clusterService -> {
clusterService.start();
cluster.add(clusterService);
});
for (ClusterService node : cluster) {
assertTrue(waitForTopology(node, NODES, 1000));
}
LOG.info("Cluster started.");
executor = new ScheduledThreadPoolExecutor(20, new NamedThreadFactory(Loza.CLIENT_POOL_NAME));
}
use of org.apache.ignite.network.StaticNodeFinder in project ignite-3 by apache.
the class ItNodeTest method createService.
/**
* @param groupId Group id.
* @param peerId Peer id.
* @param nodeOptions Node options.
* @return Raft group service.
*/
private RaftGroupService createService(String groupId, PeerId peerId, NodeOptions nodeOptions) {
Configuration initialConf = nodeOptions.getInitialConf();
nodeOptions.setStripes(1);
Stream<PeerId> peers = initialConf == null ? Stream.empty() : Stream.concat(initialConf.getPeers().stream(), initialConf.getLearners().stream());
List<NetworkAddress> addressList = peers.map(PeerId::getEndpoint).map(JRaftUtils::addressFromEndpoint).collect(toList());
var nodeManager = new NodeManager();
ClusterService clusterService = ClusterServiceTestUtils.clusterService(testInfo, peerId.getEndpoint().getPort(), new StaticNodeFinder(addressList), new TestScaleCubeClusterServiceFactory());
ExecutorService requestExecutor = JRaftUtils.createRequestExecutor(nodeOptions);
executors.add(requestExecutor);
IgniteRpcServer rpcServer = new TestIgniteRpcServer(clusterService, nodeManager, nodeOptions, requestExecutor);
nodeOptions.setRpcClient(new IgniteRpcClient(clusterService));
clusterService.start();
var service = new RaftGroupService(groupId, peerId, nodeOptions, rpcServer, nodeManager) {
@Override
public synchronized void shutdown() {
rpcServer.shutdown();
super.shutdown();
clusterService.stop();
}
};
services.add(service);
return service;
}
use of org.apache.ignite.network.StaticNodeFinder in project ignite-3 by apache.
the class RaftServerAbstractTest method clusterService.
/**
* Creates a client cluster view.
*
* @param port Local port.
* @param servers Server nodes of the cluster.
* @return The client cluster view.
*/
protected ClusterService clusterService(int port, List<NetworkAddress> servers, boolean start) {
var network = ClusterServiceTestUtils.clusterService(testInfo, port, new StaticNodeFinder(servers), NETWORK_FACTORY);
if (start) {
network.start();
}
clusterServices.add(network);
return network;
}
use of org.apache.ignite.network.StaticNodeFinder in project ignite-3 by apache.
the class ItLozaTest method clusterService.
/**
* Returns the client cluster view.
*
* @param testInfo Test info.
* @param port Local port.
* @param srvs Server nodes of the cluster.
* @return The client cluster view.
*/
private static ClusterService clusterService(TestInfo testInfo, int port, List<NetworkAddress> srvs) {
var network = ClusterServiceTestUtils.clusterService(testInfo, port, new StaticNodeFinder(srvs), NETWORK_FACTORY);
network.start();
return network;
}
use of org.apache.ignite.network.StaticNodeFinder in project ignite-3 by apache.
the class ItAbstractListenerSnapshotTest method clusterService.
/**
* Creates a cluster service.
*/
private ClusterService clusterService(TestInfo testInfo, int port, NetworkAddress otherPeer) {
var network = ClusterServiceTestUtils.clusterService(testInfo, port, new StaticNodeFinder(List.of(otherPeer)), NETWORK_FACTORY);
network.start();
cluster.add(network);
return network;
}
Aggregations