/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeString(out, grid.name()); }
@Override public boolean apply() { return Ignition.state(slowClient.name()) == IgniteState.STOPPED_ON_SEGMENTATION; } }, getTestTimeout());
/** {@inheritDoc} */ @Override public void close(boolean force) { notifyListenersOnClose(); String gridName = igfs.context().kernalContext().grid().name(); synchronized (REF_CTR_MUX) { Integer cnt = REF_CTRS.get(gridName); if (cnt != null) { // The node was created by this HadoopIgfsWrapper. // The node must be stopped when there are not opened filesystems that are used one. if (cnt > 1) REF_CTRS.put(gridName, cnt - 1); else { REF_CTRS.remove(gridName); G.stop(gridName, false); } } } }
@Override public void run() { for (IgniteEx ig : grids()) { try { cls.apply(ig); } catch (AssertionError e) { System.out.println("Assertion on " + ig.name()); throw e; } } } };
/** * @param ignite Ignite. * @param keysCnt Keys count. */ private void checkData(IgniteEx ignite, int keysCnt, int multiplier) { log.info("Check data: " + ignite.name() + ", keys=" + keysCnt); IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME); for (int k = 0; k < keysCnt; k++) Assert.assertEquals("node = " + ignite.name() + ", key = " + k, (Integer) (k * multiplier), cache.get(k)); }
@Override public boolean apply(ClusterNode n) { return !F.eq(grid(n).name(), grid(nearIdx).name()); } });
/** * @return DHT cache for this test. */ protected IgniteCache<Object, Object> dhtCache() { for (int i = 0; i < gridCount(); i++) { if (!nearOnlyIgniteInstanceName.equals(grid(i).name())) return grid(i).cache(DEFAULT_CACHE_NAME); } assert false : "Cannot find DHT cache for this test."; return null; }
@Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED, timeout = 5_000L) @Test public void testStopClientTransactionalReplicated() throws Exception { startNodesInClientMode(true); customIpFinder = new TcpDiscoveryVmIpFinder(false) .setAddresses( Collections.singletonList("127.0.0.1:47502") ); for (int i = 0; i < 3; i++) clients.add(startGrid(UUID.randomUUID().toString())); customIpFinder = null; doTest( TcpDiscoveryNodeLeftMessage.class, () -> stopGrid(clients.remove(clients.size() - 1).name()) ); }
/** * @throws Exception If failed. */ @Params(baseline = 9, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testStopBaselineTransactionalReplicated() throws Exception { AtomicInteger cntDownCntr = new AtomicInteger(0); doTest( asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_LEFT), () -> { IgniteEx node = baseline.get(baseline.size() - cntDownCntr.get() - 1); TestRecordingCommunicationSpi.spi(node).stopBlock(); cntDownCntr.incrementAndGet(); for (int i = 0; i < cntDownCntr.get(); i++) cntFinishedReadOperations.countDown(); // This node and previously stopped nodes as well. stopGrid(node.name()); } ); }
/** * @throws Exception If failed. */ @Params(servers = 4, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testStopServerTransactionalReplicated() throws Exception { doTest( asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_LEFT), () -> stopGrid(srvs.remove(srvs.size() - 1).name()) ); }
/** * @throws Exception If failed. */ @Params(baseline = 4, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testRestartBaselineTransactionalReplicated() throws Exception { doTest( asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_JOINED), () -> { IgniteEx node = baseline.get(baseline.size() - 1); TestRecordingCommunicationSpi.spi(node).stopBlock(); stopGrid(node.name()); for (int i = 0; i < baselineServersCount() - 2; i++) cntFinishedReadOperations.countDown(); startGrid(node.name()); } ); }
/** Checks that a bean with the specified group and name is available and has the expected attribute */ private void checkBean(String grp, String name, String attributeName, Object expAttributeVal) throws Exception { ObjectName mBeanName = IgniteUtils.makeMBeanName(grid().name(), grp, name); Object attributeVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName); assertEquals(expAttributeVal, attributeVal); } }
/** Checks that a bean with the specified group and name is available and has the expected attribute */ private void checkBean(String grp, String name, String attributeName, Object expAttributeVal) throws Exception { ObjectName mBeanName = IgniteUtils.makeMBeanName(grid().name(), grp, name); Object attributeVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName); assertEquals(expAttributeVal, attributeVal); } }
/** * @param ig Ignite. * @param cacheNames Cache names. */ protected void checkDescriptors(IgniteEx ig, Set<String> cacheNames) { Collection<DynamicCacheDescriptor> descs = ig.context().cache().cacheDescriptors().values(); assertEquals("Node name: " + ig.name(), cacheNames.size() + 1, descs.size()); int systemCnt = 0; for (DynamicCacheDescriptor desc : descs) if (!CU.isSystemCache(desc.cacheName())) assertTrue(desc.cacheName(), cacheNames.contains(desc.cacheName())); else systemCnt++; assertEquals(1, systemCnt); }
/** Check that kernal bean is available */ @Test public void testKernalBeans() throws Exception { checkBean("Kernal", "IgniteKernal", "InstanceName", grid().name()); checkBean("Kernal", "ClusterMetricsMXBeanImpl", "TotalServerNodes", 1); checkBean("Kernal", "ClusterMetricsMXBeanImpl", "TotalServerNodes", 1); }
/** * @param cacheName Cache name. * @throws Exception If failed. */ private void createCacheWithAffinity(String cacheName) throws Exception { CacheConfiguration ccfg = cacheConfiguration(grid(0).name()); ccfg.setName(cacheName); ccfg.setAffinity(new DummyAffinity()); grid(0).createCache(ccfg); }
/** * */ private void checkUpdCounter(IgniteEx ignite, List<String> issues, HashMap<Integer, Long> partMap) { final CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(CU.cacheId(CACHE_NAME)); assertNotNull(grpCtx); GridDhtPartitionTopologyImpl top = (GridDhtPartitionTopologyImpl)grpCtx.topology(); List<GridDhtLocalPartition> locParts = top.localPartitions(); for (GridDhtLocalPartition part : locParts) { Long cnt = partMap.get(part.id()); if (cnt == null) partMap.put(part.id(), part.updateCounter()); if ((cnt != null && part.updateCounter() != cnt) || part.updateCounter() == 0) issues.add("Node name " + ignite.name() + "Part = " + part.id() + " updCounter " + part.updateCounter()); } } }
/** * @param backups Backups number. * @throws Exception If failed. */ private void doStartGrids(int backups) throws Exception { this.backups = backups; startGrids(GRID_CNT); awaitPartitionMapExchange(); log.info("Grids: "); for (int i = 0; i < GRID_CNT; i++) log.info(grid(i).name() + ": " + grid(i).localNode().id()); }
/** * @param cacheName Cache name. * @param mode Atomicity mode. * @throws Exception If failed. */ protected void createCache(String cacheName, CacheAtomicityMode mode) throws Exception { CacheConfiguration ccfg = cacheConfiguration(grid(0).name()); ccfg.setName(cacheName); ccfg.setAtomicityMode(mode); ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT)); grid(0).createCache(ccfg); }
/** * @throws Exception If failed. */ @Test public void testConsistentId() throws Exception { Object id0 = grid(0).localNode().consistentId(); Serializable id1 = grid(0).configuration().getConsistentId(); assertEquals(id0, id1); assertEquals(grid(0).name(), id0); assertEquals(id0, grid(1).cluster().forRemotes().node().consistentId()); for (int i = 0; i < 4; ++i) { stopAllGrids(); startGrids(2); assertEquals(id0, grid(0).localNode().consistentId()); } } }