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);
}
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);
}
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());
}
Aggregations