use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method missedAddFinishedMessage.
/**
* @param singleSrv If {@code true} starts one server node two otherwise.
* @throws Exception If failed.
*/
private void missedAddFinishedMessage(boolean singleSrv) throws Exception {
int srvs = singleSrv ? 1 : 2;
startServerNodes(srvs);
afterWrite = new CIX2<TcpDiscoveryAbstractMessage, Socket>() {
private boolean first = true;
@Override
public void applyx(TcpDiscoveryAbstractMessage msg, Socket sock) throws IgniteCheckedException {
if (first && (msg instanceof TcpDiscoveryJoinRequestMessage)) {
first = false;
log.info("Close socket after message write [msg=" + msg + "]");
try {
sock.close();
} catch (IOException e) {
throw new IgniteCheckedException(e);
}
log.info("Delay after message write [msg=" + msg + "]");
// Wait when server process join request.
U.sleep(5000);
}
}
};
Ignite srv = singleSrv ? G.ignite("server-0") : G.ignite("server-1");
TcpDiscoveryNode srvNode = (TcpDiscoveryNode) srv.cluster().localNode();
assertEquals(singleSrv ? 1 : 2, srvNode.order());
clientIpFinder = new TcpDiscoveryVmIpFinder();
clientIpFinder.setAddresses(Collections.singleton("localhost:" + srvNode.discoveryPort()));
startClientNodes(1);
TcpDiscoveryNode clientNode = (TcpDiscoveryNode) G.ignite("client-0").cluster().localNode();
assertEquals(srvNode.id(), clientNode.clientRouterNodeId());
checkNodes(srvs, 1);
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setClientFailureDetectionTimeout(clientFailureDetectionTimeout());
TcpDiscoverySpi disco = getDiscoverySpi();
if (igniteInstanceName.startsWith("server"))
disco.setIpFinder(IP_FINDER);
else if (igniteInstanceName.startsWith("client")) {
cfg.setClientMode(true);
TcpDiscoveryVmIpFinder ipFinder;
if (clientIpFinder != null)
ipFinder = clientIpFinder;
else {
ipFinder = new TcpDiscoveryVmIpFinder();
String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get((clientIdx.get() - 1) / clientsPerSrv).toString();
if (addr.startsWith("/"))
addr = addr.substring(1);
ipFinder.setAddresses(Collections.singletonList(addr));
}
disco.setIpFinder(ipFinder);
String nodeId = cfg.getNodeId().toString();
nodeId = "cc" + nodeId.substring(2);
cfg.setNodeId(UUID.fromString(nodeId));
} else
throw new IllegalArgumentException();
if (useFailureDetectionTimeout())
cfg.setFailureDetectionTimeout(failureDetectionTimeout());
else {
if (longSockTimeouts) {
disco.setAckTimeout(2000);
disco.setSocketTimeout(2000);
} else {
disco.setAckTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_ACK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_ACK_TIMEOUT);
disco.setSocketTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_SOCK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_SOCK_TIMEOUT);
}
}
disco.setJoinTimeout(joinTimeout);
disco.setNetworkTimeout(netTimeout);
disco.setClientReconnectDisabled(reconnectDisabled);
if (disco instanceof TestTcpDiscoverySpi)
((TestTcpDiscoverySpi) disco).afterWrite(afterWrite);
cfg.setDiscoverySpi(disco);
if (nodeId != null)
cfg.setNodeId(nodeId);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class Log4j2LoggerSelfTest method getConfiguration.
/**
* Creates grid configuration.
*
* @param igniteInstanceName Ignite instance name.
* @param logPath Logger configuration path.
* @return Grid configuration.
* @throws Exception If error occurred.
*/
private static IgniteConfiguration getConfiguration(String igniteInstanceName, String logPath) throws Exception {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {
{
setAddresses(Collections.singleton("127.0.0.1:47500..47509"));
}
});
return new IgniteConfiguration().setIgniteInstanceName(igniteInstanceName).setGridLogger(new Log4J2Logger(logPath)).setConnectorConfiguration(null).setDiscoverySpi(disco);
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class GridCacheTcpClientDiscoveryMultiThreadedTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
// Filling configuration for client nodes
if (client) {
TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
Collection<String> addrs = new ArrayList<>(ipFinder.getRegisteredAddresses().size());
for (InetSocketAddress sockAddr : ipFinder.getRegisteredAddresses()) addrs.add(sockAddr.getHostString() + ":" + sockAddr.getPort());
clientFinder.setAddresses(addrs);
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(clientFinder));
cfg.setClientMode(true);
}
cfg.setLocalHost("127.0.0.1");
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class GridSessionCancelSiblingsFromTaskSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
c.setDiscoverySpi(discoSpi);
c.setPublicThreadPoolSize(SPLIT_COUNT * EXEC_COUNT);
return c;
}
Aggregations