use of org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder 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 isMcast = finder instanceof TcpDiscoveryMulticastIpFinder;
w.writeByte((byte) (isMcast ? 2 : 1));
Collection<InetSocketAddress> addrs = finder.getRegisteredAddresses();
w.writeInt(addrs.size());
for (InetSocketAddress a : addrs) w.writeString(a.toString());
if (isMcast) {
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.multicast.TcpDiscoveryMulticastIpFinder in project ignite by apache.
the class TcpDiscoverySelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
TcpDiscoverySpi spi = nodeSpi.get();
if (spi == null) {
spi = igniteInstanceName.contains("testPingInterruptedOnNodeFailedFailingNode") ? new TestTcpDiscoverySpi() : new TcpDiscoverySpi();
} else
nodeSpi.set(null);
discoMap.put(igniteInstanceName, spi);
spi.setIpFinder(ipFinder);
spi.setNetworkTimeout(2500);
spi.setIpFinderCleanFrequency(5000);
spi.setJoinTimeout(5000);
cfg.setDiscoverySpi(spi);
cfg.setFailureDetectionTimeout(7500);
if (ccfgs != null)
cfg.setCacheConfiguration(ccfgs);
else
cfg.setCacheConfiguration();
if (segPlc != null)
cfg.setSegmentationPolicy(segPlc);
cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
cfg.setIncludeProperties();
cfg.setMetricsUpdateFrequency(1000);
if (!igniteInstanceName.contains("LoopbackProblemTest"))
cfg.setLocalHost("127.0.0.1");
if (igniteInstanceName.contains("testFailureDetectionOnNodePing")) {
// To make test faster: on Windows 1 connect takes 1 second.
spi.setReconnectCount(1);
cfg.setMetricsUpdateFrequency(40000);
cfg.setClientFailureDetectionTimeout(41000);
}
cfg.setConnectorConfiguration(null);
if (nodeId != null)
cfg.setNodeId(nodeId);
if (igniteInstanceName.contains("NonSharedIpFinder")) {
TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
finder.setAddresses(Arrays.asList("127.0.0.1:47501"));
spi.setIpFinder(finder);
} else if (igniteInstanceName.contains("MulticastIpFinder")) {
TcpDiscoveryMulticastIpFinder finder = new TcpDiscoveryMulticastIpFinder();
finder.setAddressRequestAttempts(5);
finder.setMulticastGroup(GridTestUtils.getNextMulticastGroup(getClass()));
finder.setMulticastPort(GridTestUtils.getNextMulticastPort(getClass()));
spi.setIpFinder(finder);
// (possibly due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7122846).
if (U.isMacOs())
spi.setLocalAddress(F.first(U.allLocalIps()));
} else if (igniteInstanceName.contains("testPingInterruptedOnNodeFailedPingingNode"))
cfg.setFailureDetectionTimeout(30_000);
else if (igniteInstanceName.contains("testNoRingMessageWorkerAbnormalFailureNormalNode"))
cfg.setFailureDetectionTimeout(3_000);
else if (igniteInstanceName.contains("testNoRingMessageWorkerAbnormalFailureSegmentedNode")) {
cfg.setFailureDetectionTimeout(6_000);
cfg.setGridLogger(strLog = new GridStringLogger());
strLog.logLength(300_000);
} else if (igniteInstanceName.contains("testNodeShutdownOnRingMessageWorkerFailureFailedNode")) {
cfg.setGridLogger(strLog = new GridStringLogger());
strLog.logLength(300_000);
}
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder 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()));
}
}
}
}
Aggregations