/** * Deploys a collection of dotnet services. * * @param reader Binary reader. * @param services Services. */ private void dotnetDeployAll(BinaryRawReaderEx reader, IgniteServices services) { Collection<ServiceConfiguration> cfgs = dotnetConfigurations(reader); services.deployAll(cfgs); }
/** * @param client Client. * @param async If {@code true}, then async version of deploy method will be used. * @param cfgs Service configurations. * @param failingCfg Configuration of the failing service. * @throws Exception If failed. */ private void assertFailingDeploy(Ignite client, boolean async, List<ServiceConfiguration> cfgs, ServiceConfiguration failingCfg) throws Exception { IgniteFuture<Void> fut = null; if (async) fut = client.services().deployAllAsync(cfgs); try { if (async) fut.get(); else client.services().deployAll(cfgs); fail("Should never reach here."); } catch (ServiceDeploymentException e) { info("Expected exception: " + e.getMessage()); Collection<ServiceConfiguration> expFails = Collections.singleton(failingCfg); Collection<ServiceConfiguration> actFails = e.getFailedConfigurations(); // Some cfgs may be lazy. Construct ServiceConfiguration from them for comparison. Collection<ServiceConfiguration> actFailsCp = new ArrayList<>(actFails.size()); for (ServiceConfiguration cfg : actFails) actFailsCp.add(copyService(cfg)); assertEqualsCollections(expFails, actFailsCp); } }
/** * @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 If failed. */ @Test public void testClashingNameDifferentConfig() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES); int numDepSvcs = NUM_SERVICES - 1; CountDownLatch latch = new CountDownLatch(numDepSvcs); List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2); List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES - 1); subscribeExeLatch(cfgs, latch); client.services().deployAll(fstBatch); ServiceConfiguration failingCfg = copyService(cfgs.get(NUM_SERVICES - 1)); // Same name, different config. failingCfg.setName(fstBatch.get(0).getName()); failingCfg.setTotalCount(fstBatch.get(0).getTotalCount() + 1); sndBatch.add(failingCfg); assertFailingDeploy(client, false, sndBatch, failingCfg); assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs.subList(0, numDepSvcs)); }
/** * @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 testDeployAll() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); CountDownLatch latch = new CountDownLatch(NUM_SERVICES); List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES); subscribeExeLatch(cfgs, latch); client.services().deployAll(cfgs); assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs); }
/** * @throws Exception If failed. */ @Test public void testCancelAllAsync() 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); IgniteFuture<Void> fut = client.services().cancelAllAsync(); fut.get(); assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList()); }
client.services().deployAll(cfgs);
/** * Deploys a collection of dotnet services. * * @param reader Binary reader. * @param services Services. */ private void dotnetDeployAll(BinaryRawReaderEx reader, IgniteServices services) { Collection<ServiceConfiguration> cfgs = dotnetConfigurations(reader); services.deployAll(cfgs); }