/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setPeerClassLoadingEnabled(false); return cfg; }
IgniteClientReconnectAbstractTest.reconnectClientNode(log, cliNode, srvNode, new Runnable() { @Override public void run() { if (restart) {
/** * @param fut Future. * @throws Exception If failed. */ protected void assertNotDone(IgniteInternalFuture<?> fut) throws Exception { assertNotNull(fut); if (fut.isDone()) fail("Future completed with result: " + fut.get()); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true"); int srvs = serverCount(); if (srvs > 0) startGrids(srvs); int clients = clientCount(); if (clients > 0) { clientMode = true; startGridsMultiThreaded(srvs, clients); clientMode = false; } }
/** * @param client Client. * @return Server node client connected to. */ protected Ignite clientRouter(Ignite client) { if (tcpDiscovery()) { TcpDiscoveryNode node = (TcpDiscoveryNode)client.cluster().localNode(); assertTrue(node.isClient()); assertNotNull(node.clientRouterNodeId()); Ignite srv = G.ignite(node.clientRouterNodeId()); assertNotNull(srv); return srv; } else { for (Ignite node : G.allGrids()) { if (!node.cluster().localNode().isClient()) return node; } fail(); return null; } }
/** * @param e Client disconnected exception. * @return Reconnect future. */ protected IgniteFuture<?> check(CacheException e) { log.info("Expected exception: " + e); if (!(e.getCause() instanceof IgniteClientDisconnectedException)) log.error("Unexpected cause: " + e.getCause(), e); assertTrue("Unexpected cause: " + e.getCause(), e.getCause() instanceof IgniteClientDisconnectedException); IgniteClientDisconnectedException e0 = (IgniteClientDisconnectedException)e.getCause(); assertNotNull(e0.reconnectFuture()); return e0.reconnectFuture(); }
/** * Reconnect client node. * * @param client Client. * @param srv Server. * @param disconnectedC Closure which will be run when client node disconnected. * @throws Exception If failed. */ protected void reconnectClientNode(Ignite client, Ignite srv, @Nullable Runnable disconnectedC) throws Exception { reconnectClientNodes(log, Collections.singletonList(client), srv, disconnectedC); }
/** * @param e Client disconnected exception. */ protected void checkAndWait(CacheException e) { check(e).get(); }
/** * @param log Logger. * @param latch Latch. * @throws Exception If failed. */ protected static void waitReconnectEvent(IgniteLogger log, CountDownLatch latch) throws Exception { if (!latch.await(RECONNECT_TIMEOUT, MILLISECONDS)) { log.error("Failed to wait for reconnect event, will dump threads, latch count: " + latch.getCount()); U.dumpThreads(log); fail("Failed to wait for disconnect/reconnect event."); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); grid(0).getOrCreateCache(QUERY_CACHE).removeAll(); }
/** * @param e Client disconnected exception. */ protected void checkAndWait(IgniteClientDisconnectedException e) { log.info("Expected exception: " + e); assertNotNull(e.reconnectFuture()); e.reconnectFuture().get(); }
/** * Reconnect client node. * * @param log Logger. * @param client Client. * @param srv Server. * @param disconnectedC Closure which will be run when client node disconnected. * @throws Exception If failed. */ public static void reconnectClientNode(IgniteLogger log, Ignite client, Ignite srv, @Nullable Runnable disconnectedC) throws Exception { reconnectClientNodes(log, Collections.singletonList(client), srv, disconnectedC); }
IgniteClientReconnectAbstractTest.reconnectClientNode(log, cliNode, srvNode, new Runnable() { @Override public void run() { if (restart) {
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME)); return cfg; }
Thread.sleep(ThreadLocalRandom.current().nextLong(200, 1000)); IgniteClientReconnectAbstractTest.reconnectClientNode(log, cli, srv, new Runnable() { @Override public void run() {
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<Integer, Integer>(CACHE_NAME) .setAtomicityMode(ATOMIC) .setCacheMode(PARTITIONED); cfg.setCacheConfiguration(ccfg); return cfg; }
/** * @throws Exception If failed. */ @Test public void testReconnect() throws Exception { Ignite srv = startGrid("server"); IgniteEvents evts = srv.events(); evts.enableLocal(EventType.EVTS_DISCOVERY_ALL); evts.localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { ClusterNode node = ((DiscoveryEvent)evt).eventNode(); rejoinAttr = node.attribute("test"); return true; } }, EventType.EVT_NODE_JOINED); Ignite client = startGrid("client"); reconnectClientNode(log, client, srv, null); assertEquals("2", rejoinAttr); } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi(); cfg.setCommunicationSpi(spi); cfg.setCacheConfiguration(new CacheConfiguration("preconfigured-cache")); return cfg; }
IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, srv, () -> { if (transition) { blockExchangeSingleMessage(spi1, STATE_CHANGE_TOP_VER);
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); ccfg.setAtomicityMode(atomicMode()); ccfg.setWriteSynchronizationMode(FULL_SYNC); cfg.setCacheConfiguration(ccfg); return cfg; }