Search in sources :

Example 16 with GridDiscoveryManager

use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.

the class GridIoManagerSelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    ctx.config().setCommunicationSpi(new TcpCommunicationSpi());
    ctx.config().setMarshaller(new JdkMarshaller());
    // Turn off peer class loading to simplify mocking.
    ctx.config().setPeerClassLoadingEnabled(false);
    // Register local and remote nodes in discovery manager.
    GridDiscoveryManager mockedDiscoveryMgr = Mockito.mock(GridDiscoveryManager.class);
    when(mockedDiscoveryMgr.localNode()).thenReturn(locNode);
    when(mockedDiscoveryMgr.remoteNodes()).thenReturn(F.<ClusterNode>asList(rmtNode));
    ctx.add(mockedDiscoveryMgr);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Example 17 with GridDiscoveryManager

use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.

the class GridManagerStopSelfTest method testStopDiscoveryManager.

/**
     * @throws Exception If failed.
     */
public void testStopDiscoveryManager() throws Exception {
    DiscoverySpi spi = new TcpDiscoverySpi();
    injectLogger(spi);
    ctx.config().setDiscoverySpi(spi);
    GridDiscoveryManager mgr = new GridDiscoveryManager(ctx);
    mgr.stop(true);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 18 with GridDiscoveryManager

use of org.apache.ignite.internal.managers.discovery.GridDiscoveryManager in project ignite by apache.

the class IgniteCacheClientNodePartitionsExchangeTest method clientOnlyCacheStart.

/**
     * @param nearCache If {@code true} creates near cache on client.
     * @param srvNode If {@code true} creates client cache on server node.
     * @throws Exception If failed.
     */
private void clientOnlyCacheStart(boolean nearCache, boolean srvNode) throws Exception {
    Ignite ignite0 = startGrid(0);
    Ignite ignite1 = startGrid(1);
    boolean lateAff = ignite1.configuration().isLateAffinityAssignment();
    waitForTopologyUpdate(2, new AffinityTopologyVersion(2, lateAff ? 1 : 0));
    final String CACHE_NAME1 = "cache1";
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setName(CACHE_NAME1);
    if (srvNode)
        ccfg.setNodeFilter(new TestFilter(getTestIgniteInstanceName(2)));
    ignite0.createCache(ccfg);
    client = !srvNode;
    Ignite ignite2 = startGrid(2);
    int minorVer = !client && lateAff ? 1 : 0;
    waitForTopologyUpdate(3, new AffinityTopologyVersion(3, minorVer));
    TestCommunicationSpi spi0 = (TestCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    TestCommunicationSpi spi1 = (TestCommunicationSpi) ignite1.configuration().getCommunicationSpi();
    TestCommunicationSpi spi2 = (TestCommunicationSpi) ignite2.configuration().getCommunicationSpi();
    spi0.reset();
    spi1.reset();
    spi2.reset();
    assertNull(((IgniteKernal) ignite2).context().cache().context().cache().internalCache(CACHE_NAME1));
    if (nearCache)
        ignite2.getOrCreateNearCache(CACHE_NAME1, new NearCacheConfiguration<>());
    else
        ignite2.cache(CACHE_NAME1);
    waitForTopologyUpdate(3, new AffinityTopologyVersion(3, ++minorVer));
    GridCacheAdapter cache = ((IgniteKernal) ignite2).context().cache().context().cache().internalCache(CACHE_NAME1);
    assertNotNull(cache);
    assertEquals(nearCache, cache.context().isNear());
    assertEquals(0, spi0.partitionsSingleMessages());
    assertEquals(1, spi0.partitionsFullMessages());
    assertEquals(0, spi1.partitionsSingleMessages());
    assertEquals(0, spi1.partitionsFullMessages());
    assertEquals(1, spi2.partitionsSingleMessages());
    assertEquals(0, spi2.partitionsFullMessages());
    ClusterNode clientNode = ((IgniteKernal) ignite2).localNode();
    for (Ignite ignite : Ignition.allGrids()) {
        GridDiscoveryManager disco = ((IgniteKernal) ignite).context().discovery();
        assertTrue(disco.cacheNode(clientNode, CACHE_NAME1));
        assertFalse(disco.cacheAffinityNode(clientNode, CACHE_NAME1));
        assertEquals(nearCache, disco.cacheNearNode(clientNode, CACHE_NAME1));
    }
    spi0.reset();
    spi1.reset();
    spi2.reset();
    if (!srvNode) {
        log.info("Close client cache: " + CACHE_NAME1);
        ignite2.cache(CACHE_NAME1).close();
        assertNull(((IgniteKernal) ignite2).context().cache().context().cache().internalCache(CACHE_NAME1));
        waitForTopologyUpdate(3, new AffinityTopologyVersion(3, ++minorVer));
        assertEquals(0, spi0.partitionsSingleMessages());
        assertEquals(0, spi0.partitionsFullMessages());
        assertEquals(0, spi1.partitionsSingleMessages());
        assertEquals(0, spi1.partitionsFullMessages());
        assertEquals(0, spi2.partitionsSingleMessages());
        assertEquals(0, spi2.partitionsFullMessages());
    }
    final String CACHE_NAME2 = "cache2";
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setName(CACHE_NAME2);
    log.info("Create new cache: " + CACHE_NAME2);
    ignite2.createCache(ccfg);
    waitForTopologyUpdate(3, new AffinityTopologyVersion(3, ++minorVer));
    assertEquals(0, spi0.partitionsSingleMessages());
    assertEquals(2, spi0.partitionsFullMessages());
    assertEquals(1, spi1.partitionsSingleMessages());
    assertEquals(0, spi1.partitionsFullMessages());
    assertEquals(1, spi2.partitionsSingleMessages());
    assertEquals(0, spi2.partitionsFullMessages());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteKernal(org.apache.ignite.internal.IgniteKernal) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) Ignite(org.apache.ignite.Ignite) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)18 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 IgniteKernal (org.apache.ignite.internal.IgniteKernal)5 Ignite (org.apache.ignite.Ignite)4 IgniteException (org.apache.ignite.IgniteException)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)3 UUID (java.util.UUID)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)2 Event (org.apache.ignite.events.Event)2 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)2 GridLocalEventListener (org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener)2 NullLogger (org.apache.ignite.logger.NullLogger)2 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)2 IgniteSpiVersionCheckException (org.apache.ignite.spi.IgniteSpiVersionCheckException)2