/** * Finds a service descriptor by name. * * @param name Service name. * @return Descriptor or null. */ private ServiceDescriptor findDescriptor(String name) { for (ServiceDescriptor d : services.serviceDescriptors()) if (d.name().equals(name)) return d; return null; }
/** {@inheritDoc} */ @Override protected Collection<VisorServiceDescriptor> run(final Void arg) { Collection<VisorServiceDescriptor> res = new ArrayList<>(); if (ignite.cluster().active()) { Collection<ServiceDescriptor> services = ignite.services().serviceDescriptors(); for (ServiceDescriptor srvc : services) res.add(new VisorServiceDescriptor(srvc)); } return res; }
/** {@inheritDoc} */ @Override public Boolean call() throws Exception { try { return ignite.services().serviceDescriptors().iterator().hasNext(); } catch (Exception e) { e.printStackTrace(); return false; } finally { Thread.sleep(10); } } }
@Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000);
@Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000);
/** * @param client Client Ignite instance. * @param expCfgs Configurations of services that are expected to be deployed. */ private void assertDeployedServices(Ignite client, Collection<ServiceConfiguration> expCfgs) { Set<String> expNames = new HashSet<>(); Set<String> actNames = new HashSet<>(); for (ServiceConfiguration cfg : expCfgs) expNames.add(cfg.getName()); for (ServiceDescriptor desc : client.services().serviceDescriptors()) actNames.add(desc.name()); assertEquals(expNames, actNames); }
/** * @param ignite Ignite instance. * @param srvcName Affinity service name. */ protected void checkAffinityServiceDeployment(Ignite ignite, String srvcName) { ServiceDescriptor desc = null; for (ServiceDescriptor d : ignite.services().serviceDescriptors()) { if (d.name().equals(srvcName)) { desc = d; break; } } assertNotNull(desc); assertEquals(1, desc.topologySnapshot().size()); ClusterNode n = ignite.affinity(desc.cacheName()).mapKeyToNode(desc.affinityKey()); assertNotNull(n); assertTrue(desc.topologySnapshot().containsKey(n.id())); }
/** * @param svcName Service name. * @param ignite Ignite instance. * @param cnt Expected count. */ protected void checkCount(String svcName, IgniteEx ignite, int cnt) throws IgniteInterruptedCheckedException { AffinityTopologyVersion topVer = ignite.context().discovery().topologyVersionEx(); waitForServicesReadyTopology(ignite, topVer); assertEquals(cnt, actualCount(svcName, ignite.services().serviceDescriptors())); }
/** * @throws Exception If failed. */ @Test public void testServiceDeployment1() throws Exception { startGrid(SERVER_NODE); startGrid(SERVER_NODE_WITH_EXT_CLASS_LOADER).services().deploy(serviceConfig()); startGrid(CLIENT_NODE); startGrid(CLIENT_NODE_WITH_EXT_CLASS_LOADER).services().deploy(serviceConfig()); ignite(SERVER_NODE).services().serviceDescriptors(); ignite(SERVER_NODE_WITH_EXT_CLASS_LOADER).services().serviceDescriptors(); }
/** * @throws Exception If failed. */ @Test public void testAffinityDeploy() throws Exception { Ignite g = randomGrid(); final Integer affKey = 1; // Store a cache key. g.cache(CACHE_NAME).put(affKey, affKey.toString()); String name = "serviceAffinity"; IgniteFuture<?> fut = g.services().deployKeyAffinitySingletonAsync(name, new AffinityService(affKey), CACHE_NAME, affKey); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); checkCount(name, g.services().serviceDescriptors(), 1); }
/** * @throws Exception If failed. */ @Test public void testDeploySingleton() throws Exception { Ignite g = randomGrid(); String name = "serviceSingleton"; CountDownLatch latch = new CountDownLatch(1); DummyService.exeLatch(name, latch); IgniteFuture<?> fut = g.services().deployClusterSingletonAsync(name, new DummyService()); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, 1, DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), 1); }
/** * @throws Exception If failed. */ @Test public void testDeployMultiple2() throws Exception { Ignite g = randomGrid(); String name = "serviceMultiple2"; int cnt = nodeCount() * 2 + 1; CountDownLatch latch = new CountDownLatch(cnt); DummyService.exeLatch(name, latch); IgniteFuture<?> fut = g.services().deployMultipleAsync(name, new DummyService(), cnt, 3); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, cnt, DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), cnt); }
/** * @throws Exception If failed. */ @Test public void testDeploySingletonOld() throws Exception { Ignite g = randomGrid(); String name = "serviceSingletonOld"; CountDownLatch latch = new CountDownLatch(1); DummyService.exeLatch(name, latch); IgniteServices svcs = g.services().withAsync(); svcs.deployClusterSingleton(name, new DummyService()); IgniteFuture<?> fut = svcs.future(); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, 1, DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), 1); }
/** * @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 If failed. */ @Test public void testAffinityDeployOld() throws Exception { Ignite g = randomGrid(); final Integer affKey = 1; // Store a cache key. g.cache(CACHE_NAME).put(affKey, affKey.toString()); String name = "serviceAffinityOld"; IgniteServices svcs = g.services().withAsync(); svcs.deployKeyAffinitySingleton(name, new AffinityService(affKey), CACHE_NAME, affKey); IgniteFuture<?> fut = svcs.future(); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); checkCount(name, g.services().serviceDescriptors(), 1); }
/** * @throws Exception If failed. */ @Test public void testDeployMultiple1() throws Exception { Ignite g = randomGrid(); String name = "serviceMultiple1"; CountDownLatch latch = new CountDownLatch(nodeCount() * 2); DummyService.exeLatch(name, latch); IgniteFuture<?> fut = g.services().deployMultipleAsync(name, new DummyService(), nodeCount() * 2, 3); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, nodeCount() * 2, DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), nodeCount() * 2); }
/** * @throws Exception If failed. */ @Test public void testDeployMultiple1Old() throws Exception { Ignite g = randomGrid(); String name = "serviceMultiple1Old"; CountDownLatch latch = new CountDownLatch(nodeCount() * 2); DummyService.exeLatch(name, latch); IgniteServices svcs = g.services().withAsync(); svcs.deployMultiple(name, new DummyService(), nodeCount() * 2, 3); IgniteFuture<?> fut = svcs.future(); info("Deployed service: " + name); fut.get(); info("Finished waiting for service future: " + name); latch.await(); assertEquals(name, nodeCount() * 2, DummyService.started(name)); assertEquals(name, 0, DummyService.cancelled(name)); checkCount(name, g.services().serviceDescriptors(), nodeCount() * 2); }
@Override public boolean applyx() { return DummyService.started(CLUSTER_SINGLE) == 1 && DummyService.cancelled(CLUSTER_SINGLE) == 0 && DummyService.started(NODE_SINGLE) == nodeCount() && DummyService.cancelled(NODE_SINGLE) == 0 && DummyService.started(NODE_SINGLE_BUT_CLIENT) == nodeCount() && DummyService.cancelled(NODE_SINGLE_BUT_CLIENT) == 0 && DummyService.started(NODE_SINGLE_WITH_LIMIT) >= nodeCount() && DummyService.cancelled(NODE_SINGLE_WITH_LIMIT) == 0 && actualCount(AFFINITY, randomGrid().services().serviceDescriptors()) == 1; } },
/** * */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-6629") @Test public void testDeployService() throws Exception { Ignite ig1P = primary(0); Ignite ig1B = backUp(0); String serName = "service"; ServiceConfiguration serConf = new ServiceConfiguration(); serConf.setTotalCount(1); serConf.setName(serName); serConf.setService(new TestService()); ig1P.services().deploy(serConf); stopAllPrimary(); ig1B.active(true); U.sleep(3000); Collection<ServiceDescriptor> descs = ig1B.services().serviceDescriptors(); assertTrue(!F.isEmpty(descs)); TestService srv = ig1B.services().service(serName); assertTrue(srv != null); }
/** * @throws Exception If failed. */ @Test public void testServiceDeployment1() throws Exception { startGrid(0).services().deploy(serviceConfig(true)); startGrid(1).services().deploy(serviceConfig(false)); client = true; startGrid(2).services().deploy(serviceConfig(true)); startGrid(3).services().deploy(serviceConfig(false)); for (int i = 0; i < 4; i++) ignite(i).services().serviceDescriptors(); ignite(0).services().cancel("TestDeploymentService1"); ignite(1).services().cancel("TestDeploymentService2"); }