use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.
the class GridSpiAbstractTest method configure.
/**
* @param spi SPI.
* @throws Exception If failed.
* @throws IllegalAccessException If failed.
* @throws InvocationTargetException If failed.
*/
private void configure(IgniteSpi spi) throws Exception {
// Inject Configuration.
for (Method m : getClass().getMethods()) {
GridSpiTestConfig cfg = m.getAnnotation(GridSpiTestConfig.class);
if (cfg != null) {
if (getTestData().isDiscoveryTest() || (cfg.type() != ConfigType.DISCOVERY && !(spi instanceof DiscoverySpi)) || (cfg.type() != ConfigType.SELF && spi instanceof DiscoverySpi)) {
assert m.getName().startsWith("get") : "Test configuration must be a getter [method=" + m.getName() + ']';
// Determine getter name.
String name = cfg.setterName();
if (name == null || name.isEmpty())
name = 's' + m.getName().substring(1);
Method setter = getMethod(spi.getClass(), name);
assert setter != null : "Spi does not have setter for configuration property [spi=" + spi.getClass().getName() + ", config-prop=" + name + ']';
// Inject configuration parameter into spi.
setter.invoke(spi, m.invoke(this));
}
}
}
// will find each other.
if (spi instanceof TcpCommunicationSpi)
((TcpCommunicationSpi) spi).setLocalPort(GridTestUtils.getNextCommPort(getClass()));
if (spi instanceof TcpDiscoverySpi) {
TcpDiscoveryIpFinder ipFinder = ((TcpDiscoverySpi) spi).getIpFinder();
if (ipFinder instanceof TcpDiscoveryMulticastIpFinder) {
String mcastAddr = GridTestUtils.getNextMulticastGroup(getClass());
if (mcastAddr != null && !mcastAddr.isEmpty()) {
((TcpDiscoveryMulticastIpFinder) ipFinder).setMulticastGroup(mcastAddr);
((TcpDiscoveryMulticastIpFinder) ipFinder).setMulticastPort(GridTestUtils.getNextMulticastPort(getClass()));
}
}
}
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.
the class PlatformConfigurationUtils method writeDiscoveryConfiguration.
/**
* Writes discovery configuration.
*
* @param w Writer.
* @param spi Disco.
*/
private static void writeDiscoveryConfiguration(BinaryRawWriter w, DiscoverySpi spi) {
assert w != null;
assert spi != null;
if (!(spi instanceof TcpDiscoverySpi)) {
w.writeBoolean(false);
return;
}
w.writeBoolean(true);
TcpDiscoverySpi tcp = (TcpDiscoverySpi) spi;
TcpDiscoveryIpFinder finder = tcp.getIpFinder();
if (finder instanceof TcpDiscoveryVmIpFinder) {
w.writeBoolean(true);
boolean isMulticast = finder instanceof TcpDiscoveryMulticastIpFinder;
w.writeByte((byte) (isMulticast ? 2 : 1));
Collection<InetSocketAddress> addrs = finder.getRegisteredAddresses();
w.writeInt(addrs.size());
for (InetSocketAddress a : addrs) w.writeString(a.toString());
if (isMulticast) {
TcpDiscoveryMulticastIpFinder multiFinder = (TcpDiscoveryMulticastIpFinder) finder;
w.writeString(multiFinder.getLocalAddress());
w.writeString(multiFinder.getMulticastGroup());
w.writeInt(multiFinder.getMulticastPort());
w.writeInt(multiFinder.getAddressRequestAttempts());
w.writeInt(multiFinder.getResponseWaitTime());
int ttl = multiFinder.getTimeToLive();
w.writeBoolean(ttl != -1);
if (ttl != -1)
w.writeInt(ttl);
}
} else
w.writeBoolean(false);
w.writeLong(tcp.getSocketTimeout());
w.writeLong(tcp.getAckTimeout());
w.writeLong(tcp.getMaxAckTimeout());
w.writeLong(tcp.getNetworkTimeout());
w.writeLong(tcp.getJoinTimeout());
w.writeBoolean(tcp.isForceServerMode());
w.writeBoolean(tcp.isClientReconnectDisabled());
w.writeString(tcp.getLocalAddress());
w.writeInt(tcp.getReconnectCount());
w.writeInt(tcp.getLocalPort());
w.writeInt(tcp.getLocalPortRange());
w.writeLong(tcp.getStatisticsPrintFrequency());
w.writeLong(tcp.getIpFinderCleanFrequency());
w.writeInt(tcp.getThreadPriority());
w.writeInt((int) tcp.getTopHistorySize());
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.
the class GridCacheNearReaderPreloadSelfTest method startUp.
/**
* Startup routine.
*
* @throws Exception If failed.
*/
private void startUp() throws Exception {
TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
Ignite node1 = G.start(dataNode(ipFinder, "node1"));
Ignite node2 = G.start(dataNode(ipFinder, "node2"));
Ignite node3 = G.start(dataNode(ipFinder, "node3"));
info("Node 1: " + node1.cluster().localNode().id());
info("Node 2: " + node2.cluster().localNode().id());
info("Node 3: " + node3.cluster().localNode().id());
cache1 = node1.cache(CACHE_NAME);
cache2 = node2.cache(CACHE_NAME);
cache3 = node3.cache(CACHE_NAME);
}
Aggregations