use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class IgfsOneClientNodeTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME));
cfg.setClientMode(true);
cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(new TcpDiscoveryVmIpFinder(true)));
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName("igfs");
igfsCfg.setMetaCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));
igfsCfg.setDataCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));
cfg.setFileSystemConfiguration(igfsCfg);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method clientMessageWorkerStart.
/**
* @param srvs Number of server nodes.
* @param connectTo What server connect to.
* @throws Exception If failed.
*/
private void clientMessageWorkerStart(int srvs, int connectTo) throws Exception {
startServerNodes(srvs);
Ignite srv = G.ignite("server-" + (connectTo - 1));
final TcpDiscoveryNode srvNode = (TcpDiscoveryNode) srv.cluster().localNode();
assertEquals((long) connectTo, srvNode.order());
TestTcpDiscoverySpi srvSpi = ((TestTcpDiscoverySpi) srv.configuration().getDiscoverySpi());
final String client0 = "client-" + clientIdx.getAndIncrement();
srvSpi.delayJoinAckFor = client0;
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
clientIpFinder = new TcpDiscoveryVmIpFinder();
clientIpFinder.setAddresses(Collections.singleton("localhost:" + srvNode.discoveryPort()));
Ignite client = startGrid(client0);
clientIpFinder = null;
clientNodeIds.add(client.cluster().localNode().id());
TestTcpDiscoverySpi clientSpi = ((TestTcpDiscoverySpi) client.configuration().getDiscoverySpi());
assertFalse(clientSpi.invalidResponse());
TcpDiscoveryNode clientNode = (TcpDiscoveryNode) client.cluster().localNode();
assertEquals(srvNode.id(), clientNode.clientRouterNodeId());
return null;
}
});
final String client1 = "client-" + clientIdx.getAndIncrement();
while (!fut.isDone()) {
startGrid(client1);
stopGrid(client1);
}
fut.get();
checkNodes(srvs, 1);
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method testClientReconnectHistoryMissingOnRouter.
/**
* @throws Exception if failed.
*/
public void testClientReconnectHistoryMissingOnRouter() throws Exception {
clientFailureDetectionTimeout = 60000;
netTimeout = 60000;
startServerNodes(2);
Ignite srv0 = grid("server-0");
TcpDiscoveryNode srv0Node = (TcpDiscoveryNode) srv0.cluster().localNode();
clientIpFinder = new TcpDiscoveryVmIpFinder();
clientIpFinder.setAddresses(Collections.singleton("localhost:" + srv0Node.discoveryPort()));
startClientNodes(1);
attachListeners(0, 1);
Ignite client = grid("client-0");
TcpDiscoveryNode clientNode = (TcpDiscoveryNode) client.cluster().localNode();
TestTcpDiscoverySpi clientSpi = (TestTcpDiscoverySpi) client.configuration().getDiscoverySpi();
UUID clientNodeId = clientNode.id();
checkNodes(2, 1);
clientSpi.pauseAll(true);
stopGrid(srv0.name());
startServerNodes(1);
Ignite srv2 = grid("server-2");
TcpDiscoveryNode srv2Node = (TcpDiscoveryNode) srv2.cluster().localNode();
clientIpFinder.setAddresses(Collections.singleton("localhost:" + srv2Node.discoveryPort()));
clientSpi.resumeAll();
awaitPartitionMapExchange();
assertEquals("connected", clientSpi.getSpiState());
assertEquals(clientNodeId, clientNode.id());
assertEquals(srv2Node.id(), clientNode.clientRouterNodeId());
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method testJoinTimeout.
/**
* @throws Exception If failed.
*/
public void testJoinTimeout() throws Exception {
clientIpFinder = new TcpDiscoveryVmIpFinder();
joinTimeout = 1000;
try {
startClientNodes(1);
fail("Client cannot be start because no server nodes run");
} catch (IgniteCheckedException e) {
IgniteSpiException spiEx = e.getCause(IgniteSpiException.class);
assert spiEx != null : e;
assert spiEx.getMessage().contains("Join process timed out") : spiEx.getMessage();
}
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method setClientRouter.
/**
* @param clientIdx Client index.
* @param srvIdx Server index.
* @throws Exception In case of error.
*/
private void setClientRouter(int clientIdx, int srvIdx) throws Exception {
TcpDiscoverySpi disco = (TcpDiscoverySpi) G.ignite("client-" + clientIdx).configuration().getDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = (TcpDiscoveryVmIpFinder) disco.getIpFinder();
String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get(srvIdx).toString();
if (addr.startsWith("/"))
addr = addr.substring(1);
ipFinder.setAddresses(Collections.singletonList(addr));
}
Aggregations