Search in sources :

Example 1 with TcpDiscoveryIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.

the class OptimizedMarshallerTest method testNonSerializable1.

/**
 * Tests ability to marshal non-serializable objects.
 *
 * @throws IgniteCheckedException If marshalling failed.
 */
@Test
public void testNonSerializable1() throws IgniteCheckedException {
    OptimizedMarshaller marsh = marshaller();
    marsh.setRequireSerializable(false);
    byte[] bytes = marsh.marshal(new TcpDiscoveryVmIpFinder());
    TcpDiscoveryIpFinder ipFinder = marsh.unmarshal(bytes, null);
    assertFalse(ipFinder.isShared());
    ipFinder = marsh.unmarshal(marsh.marshal(new TcpDiscoveryVmIpFinder(true)), null);
    assertTrue(ipFinder.isShared());
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with TcpDiscoveryIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.

the class OptimizedMarshallerTest method testNonSerializable3.

/**
 * Tests ability to marshal non-serializable objects.
 *
 * @throws IgniteCheckedException If marshalling failed.
 */
@Test
public void testNonSerializable3() throws IgniteCheckedException {
    OptimizedMarshaller marsh = marshaller();
    marsh.setRequireSerializable(false);
    byte[] bytes = marsh.marshal(new TestTcpDiscoveryIpFinderAdapter());
    TcpDiscoveryIpFinder ipFinder = marsh.unmarshal(bytes, null);
    assertFalse(ipFinder.isShared());
}
Also used : TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with TcpDiscoveryIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.

the class IgniteExchangeLatchManagerDiscoHistoryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoveryIpFinder ipFinder = ((TcpDiscoverySpi) cfg.getDiscoverySpi()).getIpFinder();
    int topHistSize = victim ? TOPOLOGY_HISTORY_SIZE : TcpDiscoverySpi.DFLT_TOP_HISTORY_SIZE;
    CustomTcpDiscoverySpi discoSpi = new CustomTcpDiscoverySpi(topHistSize, ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    if (victim) {
        cfg.setFailureHandler(new AbstractFailureHandler() {

            /**
             * {@inheritDoc}
             */
            @Override
            protected boolean handle(Ignite ignite, FailureContext failureCtx) {
                cpFailureCtx.compareAndSet(null, failureCtx);
                // Invalidate kernel context.
                return true;
            }
        });
        cfg.setLifecycleBeans(lifecycleBean);
        disco = discoSpi;
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) TestTcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 4 with TcpDiscoveryIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.

the class BasicWarmupClosure method apply.

/**
 * {@inheritDoc}
 */
@Override
public void apply(IgniteConfiguration gridCfg) {
    // Remove cache duplicates, clean up the rest, etc.
    IgniteConfiguration cfg = prepareConfiguration(gridCfg);
    // Do nothing if no caches found.
    if (cfg == null)
        return;
    out("Starting grids to warmup caches [gridCnt=" + gridCnt + ", caches=" + cfg.getCacheConfiguration().length + ']');
    Collection<Ignite> ignites = new LinkedList<>();
    String old = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);
    try {
        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
        TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
        for (int i = 0; i < gridCnt; i++) {
            IgniteConfiguration cfg0 = new IgniteConfiguration(cfg);
            TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
            discoSpi.setIpFinder(ipFinder);
            discoSpi.setLocalPort(discoveryPort);
            cfg0.setDiscoverySpi(discoSpi);
            cfg0.setGridLogger(new NullLogger());
            cfg0.setIgniteInstanceName("ignite-warmup-grid-" + i);
            ignites.add(Ignition.start(cfg0));
        }
        doWarmup(ignites);
    } catch (Exception e) {
        throw new IgniteException(e);
    } finally {
        for (Ignite ignite : ignites) Ignition.stop(ignite.name(), false);
        out("Stopped warmup grids.");
        if (old == null)
            old = "false";
        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, old);
    }
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) LinkedList(java.util.LinkedList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 5 with TcpDiscoveryIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder in project ignite by apache.

the class TcpDiscoveryNodeAttributesUpdateOnReconnectTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    if (gridName.contains("client")) {
        Map<String, String> attrs = new HashMap<>();
        attrs.put("test", "1");
        cfg.setUserAttributes(attrs);
    }
    IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi spi = new IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi();
    TcpDiscoveryIpFinder finder = ((TcpDiscoverySpi) cfg.getDiscoverySpi()).getIpFinder();
    spi.setIpFinder(finder);
    cfg.setDiscoverySpi(spi);
    cfg.setPluginProviders(new TestReconnectSecurityPluginProvider());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) IgniteClientReconnectAbstractTest(org.apache.ignite.internal.IgniteClientReconnectAbstractTest) TcpDiscoveryIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder) TestReconnectSecurityPluginProvider(org.apache.ignite.spi.discovery.TestReconnectSecurityPluginProvider)

Aggregations

TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)10 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)5 Ignite (org.apache.ignite.Ignite)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 TcpDiscoveryMulticastIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder)2 Method (java.lang.reflect.Method)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 AbstractFailureHandler (org.apache.ignite.failure.AbstractFailureHandler)1 FailureContext (org.apache.ignite.failure.FailureContext)1 IgniteClientReconnectAbstractTest (org.apache.ignite.internal.IgniteClientReconnectAbstractTest)1 IgniteProductVersion.fromString (org.apache.ignite.lang.IgniteProductVersion.fromString)1 NullLogger (org.apache.ignite.logger.NullLogger)1