/** * @throws Exception In case of an error. */ @Test public void testThrowingExceptionOnDeployUsingPuplicApiWhileClientDisconnected() throws Exception { runTaskWhenDisconnected(() -> { GridTestUtils.assertThrowsWithCause( () -> client().services().deployNodeSingletonAsync("testService", MyServiceFactory.create()), IgniteClientDisconnectedException.class); }); }
/** * @param from If {@code true}, then added node will be an initiator of deployment. * Otherwise deployment <b>to</b> this node will be tested. * @param staticDeploy If {@code true}, then static deployment will be used instead of a dynamic one. * @throws Exception If failed. */ private void checkDeployFromNodeRemovedFromBlt(boolean from, boolean staticDeploy) throws Exception { persistence = true; Ignite insideNode = startGrid(0); startGrid(1); IgniteCluster cluster = insideNode.cluster(); cluster.active(true); stopGrid(1); cluster.setBaselineTopology(cluster.topologyVersion()); CountDownLatch exeLatch = new CountDownLatch(from ? 1 : 2); DummyService.exeLatch(SERVICE_NAME, exeLatch); if (from) deployServiceFromNewNode(staticDeploy); else { startGrid(1); IgniteFuture<Void> depFut = insideNode.services().deployNodeSingletonAsync(SERVICE_NAME, new DummyService()); depFut.get(10, TimeUnit.SECONDS); } assertTrue(exeLatch.await(10, TimeUnit.SECONDS)); }
/** * @param from If {@code true}, then added node will be an initiator of deployment. * Otherwise deployment <b>to</b> this node will be tested. * @throws Exception If failed. */ private void checkDeployWithNodeAddedToBlt(boolean from) throws Exception { persistence = true; Ignite insideNode = startGrid(0); IgniteCluster cluster = insideNode.cluster(); cluster.active(true); Ignite outsideNode = startGrid(1); cluster.setBaselineTopology(cluster.topologyVersion()); CountDownLatch exeLatch = new CountDownLatch(from ? 1 : 2); DummyService.exeLatch(SERVICE_NAME, exeLatch); if (from) { IgniteFuture<Void> depFut = outsideNode.services().deployClusterSingletonAsync(SERVICE_NAME, new DummyService()); depFut.get(10, TimeUnit.SECONDS); } else { IgniteFuture<Void> depFut = outsideNode.services().deployNodeSingletonAsync(SERVICE_NAME, new DummyService()); depFut.get(10, TimeUnit.SECONDS); } assertTrue(exeLatch.await(10, TimeUnit.SECONDS)); }
/** * @throws Exception If failed. */ @Test public void testDeployOnEachNode() throws Exception { Ignite g = randomGrid(); String name = "serviceOnEachNode"; CountDownLatch latch = new CountDownLatch(nodeCount()); DummyService.exeLatch(name, latch); IgniteFuture<?> fut = g.services().deployNodeSingletonAsync(name, new DummyService()); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, nodeCount(), DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), nodeCount()); }
/** * @throws Exception In case of an error. */ @Test public void testDeploymentProcessingOnCoordinatorLeaveTopology() throws Exception { try { IgniteEx ignite0 = (IgniteEx)startGrids(4); ((BlockingTcpDiscoverySpi)ignite0.context().discovery().getInjectedDiscoverySpi()).block(); IgniteEx ignite2 = grid(2); IgniteFuture fut = ignite2.services().deployNodeSingletonAsync("testService", new LongInitializedTestService(5000L)); IgniteFuture fut2 = ignite2.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(5000L)); IgniteFuture fut3 = ignite2.services().deployNodeSingletonAsync("testService3", new LongInitializedTestService(5000L)); assertEquals(ignite0.localNode(), U.oldest(ignite2.cluster().nodes(), null)); stopNode(ignite0); fut.get(TEST_FUTURE_WAIT_TIMEOUT); fut2.get(TEST_FUTURE_WAIT_TIMEOUT); fut3.get(TEST_FUTURE_WAIT_TIMEOUT); IgniteEx ignite3 = grid(3); assertNotNull(ignite3.services().service("testService")); assertNotNull(ignite3.services().service("testService2")); assertNotNull(ignite3.services().service("testService3")); } finally { stopAllGrids(); } }
IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
/** * @throws Exception If failed. */ @Test public void testDifferentConfiguration() throws Exception { String name = "dupService"; IgniteServices svcs1 = randomGrid().services(); IgniteServices svcs2 = randomGrid().services(); IgniteFuture<?> fut1 = svcs1.deployClusterSingletonAsync(name, new DummyService()); IgniteFuture<?> fut2 = svcs2.deployNodeSingletonAsync(name, new DummyService()); info("Deployed service: " + name); try { fut1.get(); info("Finished waiting for service future: " + name); fut2.get(); fail("Failed to receive mismatching configuration exception."); } catch (IgniteException e) { info("Received mismatching configuration exception: " + e.getMessage()); } }
/** * @throws Exception In case of an error. */ @Test public void testDeploymentProcessingOnServersLeaveTopology() throws Exception { try { startGrids(4); IgniteEx client = startGrid(getConfiguration("client").setClientMode(true)); IgniteEx ignite1 = grid(1); IgniteEx ignite2 = grid(2); ((BlockingTcpCommunicationSpi)ignite1.configuration().getCommunicationSpi()).block(); ((BlockingTcpCommunicationSpi)ignite2.configuration().getCommunicationSpi()).block(); IgniteFuture fut = client.services().deployNodeSingletonAsync("testService", new LongInitializedTestService(5000L)); IgniteFuture fut2 = client.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(5000L)); stopNode(ignite1); stopNode(ignite2); fut.get(TEST_FUTURE_WAIT_TIMEOUT); fut2.get(TEST_FUTURE_WAIT_TIMEOUT); IgniteEx ignite3 = grid(3); assertNotNull(ignite3.services().service("testService")); assertNotNull(ignite3.services().service("testService2")); } finally { stopAllGrids(); } }
IgniteFuture depFut = ignite4.services().deployNodeSingletonAsync("testService", new LongInitializedTestService(5000L)); IgniteFuture depFut2 = ignite4.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(5000L));