/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> deployAll(ClusterGroup prj, Collection<ServiceConfiguration> cfgs) { if (prj == null) // Deploy to servers by default if no projection specified. return deployAll(cfgs, ctx.cluster().get().forServers().predicate()); else if (prj.predicate() == F.<ClusterNode>alwaysTrue()) return deployAll(cfgs, null); else // Deploy to predicate nodes by default. return deployAll(cfgs, prj.predicate()); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> deployAll(ClusterGroup prj, Collection<ServiceConfiguration> cfgs) { if (prj == null) // Deploy to servers by default if no projection specified. return deployAll(cfgs, ctx.cluster().get().forServers().predicate()); else if (prj.predicate() == F.<ClusterNode>alwaysTrue()) return deployAll(cfgs, null); else // Deploy to predicate nodes by default. return deployAll(cfgs, prj.predicate()); }
/** {@inheritDoc} */ @Override public boolean apply(ClusterNode node) { A.notNull(node, "node is null"); return grp.predicate().apply(node) && p.apply(node); }
if (prj.predicate() == F.<ClusterNode>alwaysTrue()) { int idx = ThreadLocalRandom.current().nextInt(snapshot.size());
/** {@inheritDoc} */ @Override public ClusterGroup forOthers(ClusterGroup grp) { A.notNull(grp, "grp"); if (ids != null) { guard(); try { Set<UUID> nodeIds = U.newHashSet(ids.size()); for (UUID id : ids) { ClusterNode n = node(id); if (n != null && !grp.predicate().apply(n)) nodeIds.add(id); } return new ClusterGroupAdapter(ctx, subjId, nodeIds); } finally { unguard(); } } else return forPredicate(F.not(grp.predicate())); }
/** * @param async If {@code true}, then asynchronous method of deployment will be performed. * @throws Exception If failed. */ private void deployAllFail(boolean async) throws Exception { Ignite client = grid(CLIENT_NODE_NAME); CountDownLatch latch = new CountDownLatch(NUM_SERVICES - 1); List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES); subscribeExeLatch(cfgs, latch); ServiceConfiguration failingCfg = cfgs.get(cfgs.size() - 1); failingCfg.setName(null); assertFailingDeploy(client, async, cfgs, failingCfg); assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs.subList(0, cfgs.size() - 1)); }
/** * @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 test failed. */ @Test public void testProjection() throws Exception { assert prj != null; assert prj.ignite() != null; assert prj.predicate() != null; int size = projectionSize(); assert prj.nodes().size() == size; Collection<UUID> nodeIds = projectionNodeIds(); for (ClusterNode node : prj.nodes()) assert nodeIds.contains(node.id()); }
/** * @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 testClashingNamesFail() 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); subscribeExeLatch(cfgs, latch); IgniteFuture<Void> fut = client.services().deployAllAsync(fstBatch); ServiceConfiguration failingCfg = cfgs.get(NUM_SERVICES - 1); failingCfg.setName(null); assertFailingDeploy(client, false, sndBatch, failingCfg); fut.get(); 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()); }
/** * @throws Exception If failed. */ @Test public void testDeployAllAsync() 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); IgniteFuture<Void> fut = client.services().deployAllAsync(cfgs); fut.get(); assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs); }
/** * @throws Exception If failed. */ @Test public void testClashingNames() 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); List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2); List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES); IgniteFuture<Void> fstFut = client.services().deployAllAsync(fstBatch); IgniteFuture<Void> sndFut = client.services().deployAllAsync(sndBatch); fstFut.get(); sndFut.get(); assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs); }
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), numServices);
@Override public void run(IgniteServices services, String svcName, TestService svc) throws Exception { services.deployClusterSingleton(svcName, (Service)svc); ServiceConfiguration cfg = new ServiceConfiguration(); cfg.setName(svcName); cfg.setService((Service)svc); cfg.setTotalCount(1); cfg.setMaxPerNodeCount(1); cfg.setNodeFilter(services.clusterGroup().predicate()); services.deploy(cfg); waitForServiceDeploymentIfNeeded(services, svcName); } }));
deployAll(Arrays.asList(cfgs), ctx.cluster().get().forServers().predicate()).get();
/** * @param prj Grid projection. * @param cfgs Service configurations. * @return Future for deployment. */ public IgniteInternalFuture<?> deployAll(ClusterGroup prj, Collection<ServiceConfiguration> cfgs) { if (prj == null) // Deploy to servers by default if no projection specified. return deployAll(cfgs, ctx.cluster().get().forServers().predicate()); else if (prj.predicate() == F.<ClusterNode>alwaysTrue()) return deployAll(cfgs, null); else // Deploy to predicate nodes by default. return deployAll(cfgs, prj.predicate()); }
/** {@inheritDoc} */ @Override public boolean apply(ClusterNode node) { A.notNull(node, "node is null"); return grp.predicate().apply(node) && p.apply(node); }