Search in sources :

Example 11 with TcpDiscoveryMulticastIpFinder

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());
}
Also used : TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) InetSocketAddress(java.net.InetSocketAddress) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 12 with TcpDiscoveryMulticastIpFinder

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Example 13 with TcpDiscoveryMulticastIpFinder

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()));
            }
        }
    }
}
Also used : TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) Method(java.lang.reflect.Method) IgniteProductVersion.fromString(org.apache.ignite.lang.IgniteProductVersion.fromString) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

TcpDiscoveryMulticastIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder)13 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)5 InetSocketAddress (java.net.InetSocketAddress)4 Socket (java.net.Socket)3 ArrayList (java.util.ArrayList)3 Ignite (org.apache.ignite.Ignite)3 T2 (org.apache.ignite.internal.util.typedef.T2)3 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)3 Nullable (org.jetbrains.annotations.Nullable)3 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)2 TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)2 Test (org.junit.jupiter.api.Test)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 SSLContext (javax.net.ssl.SSLContext)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 GridPortRecord (org.apache.ignite.internal.processors.port.GridPortRecord)1