/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_CANCEL_ALL: services.cancelAll(); return TRUE; } return super.processInLongOutLong(type, val); }
/** * @throws Exception If failed. */ @Test public void testCancelAllClashingNames() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES); CountDownLatch latch = new CountDownLatch(NUM_SERVICES); subscribeExeLatch(cfgs, latch); client.services().deployAll(cfgs); latch.await(30, TimeUnit.SECONDS); List<String> names = new ArrayList<>(); for (ServiceConfiguration cfg : cfgs) names.add(cfg.getName()); int batchSize = 5; int from = 0; while (from < NUM_SERVICES) { int to = Math.min(NUM_SERVICES, from + batchSize); List<String> toCancel = new ArrayList<>(names.subList(from, to)); toCancel.add(toCancel.get(0)); client.services().cancelAll(toCancel); from = to; } assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList()); }
/** * @throws Exception In case of an error. */ @Test public void testThrowingExceptionOnUndeployUsingPuplicApiWhileClientDisconnected() throws Exception { runTaskWhenDisconnected(() -> { GridTestUtils.assertThrowsWithCause(() -> client().services().cancelAll(), IgniteClientDisconnectedException.class); }); }
/** * @throws Exception If failed. */ @Test public void testCancelAll() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES); CountDownLatch latch = new CountDownLatch(NUM_SERVICES); subscribeExeLatch(cfgs, latch); client.services().deployAll(cfgs); latch.await(30, TimeUnit.SECONDS); client.services().cancelAll(); assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList()); }
/** * @throws Exception If failed. */ @Test public void testDefaultService() throws Exception { UUID clientNodeId = grid(CLIENT_IDX).cluster().localNode().id(); for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); final Ignite ignite = grid(i); ignite.services().deployNodeSingleton(SINGLETON_NAME, new TestService()); final ClusterGroup grp = ignite.cluster(); assertEquals(NODES_CNT, grp.nodes().size()); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000); Collection<ServiceDescriptor> srvDscs = ignite.services(grp).serviceDescriptors(); assertEquals(1, srvDscs.size()); Map<UUID, Integer> nodesMap = F.first(srvDscs).topologySnapshot(); assertEquals(NODES_CNT - 1, nodesMap.size()); for (Map.Entry<UUID, Integer> nodeInfo : nodesMap.entrySet()) { assertFalse(clientNodeId.equals(nodeInfo.getKey())); assertEquals(1, nodeInfo.getValue().intValue()); } ignite.services().cancelAll(); } }
/** * @throws Exception If failed. */ @Test public void testClientService() throws Exception { UUID clientNodeId = grid(CLIENT_IDX).cluster().localNode().id(); for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); final Ignite ignite = grid(i); ignite.services(ignite.cluster().forClients()).deployNodeSingleton(SINGLETON_NAME, new TestService()); final ClusterGroup grp = ignite.cluster(); assertEquals(NODES_CNT, grp.nodes().size()); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000); Collection<ServiceDescriptor> srvDscs = ignite.services(grp).serviceDescriptors(); assertEquals(1, srvDscs.size()); Map<UUID, Integer> nodesMap = F.first(srvDscs).topologySnapshot(); assertEquals(1, nodesMap.size()); for (Map.Entry<UUID, Integer> nodeInfo : nodesMap.entrySet()) { assertEquals(clientNodeId, nodeInfo.getKey()); assertEquals(1, nodeInfo.getValue().intValue()); } ignite.services().cancelAll(); } }
services.cancelAll(); else services.cancel(SERVICE_NAME);
ig.services().cancelAll();
ig.services().cancelAll();
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_CANCEL_ALL: services.cancelAll(); return TRUE; } return super.processInLongOutLong(type, val); }