/** {@inheritDoc} */ @Override public PlatformTarget processInStreamOutObject(int type, BinaryRawReaderEx reader) throws IgniteCheckedException { switch (type) { case OP_SERVICE_PROXY: { String name = reader.readString(); boolean sticky = reader.readBoolean(); ServiceDescriptor d = findDescriptor(name); if (d == null) throw new IgniteException("Failed to find deployed service: " + name); Object proxy = PlatformService.class.isAssignableFrom(d.serviceClass()) ? services.serviceProxy(name, PlatformService.class, sticky) : new GridServiceProxy<>(services.clusterGroup(), name, Service.class, sticky, 0, platformCtx.kernalContext()); return new ServiceProxyHolder(proxy, d.serviceClass(), platformContext()); } } return super.processInStreamOutObject(type, reader); }
/** * @throws Exception If failed. */ @Test public void testServices() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); try (Ignite g1 = G.start(cfg)) { IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode())); services.deployNodeSingleton("test", new DummyService()); GridMarshallerTestBean inBean = newTestBean(services); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class); assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class); assert inBean != outBean; assert inBean.equals(outBean); ClusterGroup inPrj = services.clusterGroup(); ClusterGroup outPrj = ((IgniteServices)outBean.getObjectField()).clusterGroup(); assert inPrj.getClass().equals(outPrj.getClass()); assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes()); outBean.checkNullResources(); } }
@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); } }));
/** {@inheritDoc} */ @Override public PlatformTarget processInStreamOutObject(int type, BinaryRawReaderEx reader) throws IgniteCheckedException { switch (type) { case OP_SERVICE_PROXY: { String name = reader.readString(); boolean sticky = reader.readBoolean(); ServiceDescriptor d = findDescriptor(name); if (d == null) throw new IgniteException("Failed to find deployed service: " + name); Object proxy = PlatformService.class.isAssignableFrom(d.serviceClass()) ? services.serviceProxy(name, PlatformService.class, sticky) : new GridServiceProxy<>(services.clusterGroup(), name, Service.class, sticky, 0, platformCtx.kernalContext()); return new ServiceProxyHolder(proxy, d.serviceClass(), platformContext()); } } return super.processInStreamOutObject(type, reader); }