/** {@inheritDoc} */ @Override public IgniteServices services() { checkIgnite(); return g.services(); }
@Override public Void call() throws Exception { IgniteServices srvs = ig.services(); return null; } }, IgniteException.class, "Can not perform the operation because the cluster is inactive.");
/** * Stops Apache Ignite services that represent distributed inference infrastructure. */ private void stopService() { ignite.services().cancel(String.format(INFERENCE_SERVICE_NAME_PATTERN, suffix)); }
/** {@inheritDoc} */ @Override public IgniteServices services(ClusterGroup grp) { checkIgnite(); return g.services(grp); }
/** * Stops TensorFlow cluster. * * @param clusterId Cluster identifier. */ public void stopClusterIfExists(UUID clusterId) { ignite.services().cancel(String.format(SERVICE_NAME_TEMPLATE, clusterId)); log.info("Cluster maintained cancelled as a service [clusterId=" + clusterId + "]"); }
@Override public Object call() throws Exception { System.out.println("Undeploy " + SERVICE_NAME); ignite.services().cancel(SERVICE_NAME); return null; } });
/** {@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); } } }
/** * @param node Node. * @return Service proxy. */ private static MyService serviceProxy(Ignite node) { return node.services().serviceProxy("DummyService", MyService.class, true); }
/** * @throws Exception If failed. */ private CounterService proxy(Ignite g) throws Exception { return g.services().serviceProxy(SERVICE_NAME, CounterService.class, false); }
@Override public boolean apply() { return ignite.services(grp).serviceDescriptors().size() == 1; } }, 5000);
@Override public boolean apply() { TestService srvc = grid(srvcNode).services().service(srvcName); if (srvc == null) return false; assertEquals(srvcNode, srvc.serviceNode()); return true; } }, 5000);
/** {@inheritDoc} */ @Override public void inject(GridResourceField field, Object target, Class<?> depCls, GridDeployment dep) throws IgniteCheckedException { ServiceResource ann = (ServiceResource)field.getAnnotation(); Class svcItf = ann.proxyInterface(); Object svc; if (svcItf == Void.class) svc = ignite.services().service(ann.serviceName()); else svc = ignite.services().serviceProxy(ann.serviceName(), svcItf, ann.proxySticky()); if (svc != null) GridResourceUtils.inject(field.getField(), target, svc); }
/** {@inheritDoc} */ @Override public Object execute() throws IgniteException { ignite.services().deployNodeSingleton(serviceName, new PlatformTestService()); return null; } }
/** * @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); }
/** * @throws Exception If failed. */ @Test public void testExecution() throws Exception { startGrid(0); // Server. Ignition.setClientMode(true); Ignite ignite = startGrid(); // Client. ignite.services().deployClusterSingleton("my-service", new MyServiceImpl()); MyService svc = ignite.services().serviceProxy("my-service", MyService.class, false); svc.hello(); }
/** * @param client Client node. * @param svcName Service name. * @throws Exception If failed. */ private void checkDeploy(Ignite client, String svcName) throws Exception { assertTrue(client.configuration().isClientMode()); CountDownLatch latch = new CountDownLatch(1); DummyService.exeLatch(svcName, latch); client.services().deployClusterSingleton(svcName, new DummyService()); assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); } }
/** * @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 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(); }
/** * @param ignite Ignite. */ private void deployService(final Ignite ignite) { ServiceConfiguration svcCfg = new ServiceConfiguration(); svcCfg.setService(new ManagementService()); svcCfg.setName(SERVICE_NAME); svcCfg.setTotalCount(1); svcCfg.setMaxPerNodeCount(1); svcCfg.setNodeFilter((IgnitePredicate<ClusterNode>)node -> !node.isClient()); ignite.services().deploy(svcCfg); }
/** * @throws Exception If failed. */ @Test public void testServiceDeployment3() throws Exception { startGrid(0).services().deploy(serviceConfig(true)); startGrid(1); startGrid(2); stopGrid(0); awaitPartitionMapExchange(); ignite(1).services().deploy(serviceConfig(false)); startGrid(0); }