use of org.apache.ignite.configuration.AddressResolver in project ignite by apache.
the class GridAddressResolverSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
cfg.setAddressResolver(new AddressResolver() {
@Override
public Collection<InetSocketAddress> getExternalAddresses(InetSocketAddress addr) throws IgniteCheckedException {
Set<InetSocketAddress> set = new HashSet<>();
set.add(addr);
set.add(igniteInstanceName.contains("0") ? addr0 : addr1);
return set;
}
});
return cfg;
}
use of org.apache.ignite.configuration.AddressResolver in project ignite by apache.
the class TcpCommunicationSpiMultiJvmTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpCommunicationSpi commSpi = new TestCommunicationSpi(replacingAttrSpi);
commSpi.setLocalPort(45010);
if (localAddrStr != null)
commSpi.setLocalAddress(localAddrStr);
if (externalAddr != null) {
commSpi.setAddressResolver(new AddressResolver() {
@Override
public Collection<InetSocketAddress> getExternalAddresses(InetSocketAddress addr) throws IgniteCheckedException {
return Collections.singletonList(externalAddr);
}
});
} else
commSpi.setLocalAddress(InetAddress.getLocalHost().getHostName());
cfg.setCommunicationSpi(commSpi);
return cfg;
}
use of org.apache.ignite.configuration.AddressResolver in project ignite by apache.
the class GridTcpSpiForwardingSelfTest method testCustomResolver.
/**
* @throws Exception If any error occurs.
*/
@Test
public void testCustomResolver() throws Exception {
final Map<InetSocketAddress, Collection<InetSocketAddress>> map = new HashMap<>();
map.put(new InetSocketAddress("127.0.0.1", locPort1), F.asList(new InetSocketAddress("127.0.0.1", extPort1)));
map.put(new InetSocketAddress("127.0.0.1", commLocPort1), F.asList(new InetSocketAddress("127.0.0.1", commExtPort1)));
map.put(new InetSocketAddress("127.0.0.1", locPort2), F.asList(new InetSocketAddress("127.0.0.1", extPort2)));
map.put(new InetSocketAddress("127.0.0.1", commLocPort2), F.asList(new InetSocketAddress("127.0.0.1", commExtPort2)));
rslvr = new AddressResolver() {
@Override
public Collection<InetSocketAddress> getExternalAddresses(InetSocketAddress addr) {
return map.get(addr);
}
};
doTestForward();
}
Aggregations