我创建了Ignite服务,它实现了Service和虚拟测试接口。我试图通过下面的代码
调用Test接口方法IgniteServiceTestInterface cntrSvc = ignite.services()
.serviceProxy("IgniteServiceTestInterface", IgniteServiceTestInterface.class, false);
System.out.println(cntrSvc.invokeNext(1));
方法已在Service中实现,并在调用时返回下一个计数器。但相反,我收到如下错误
Exception in thread "main" class org.apache.ignite.IgniteException: Failed to find deployed service: IgniteServiceTestInterface
at org.apache.ignite.internal.processors.service.GridServiceProxy$ProxyInvocationHandler.invoke(GridServiceProxy.java:167)
at com.sun.proxy.$Proxy30.invokeNext(Unknown Source)
at IgniteClient.main(IgniteClient.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
有谁可以告诉我,我错过了哪些文字
答案 0 :(得分:0)
它工作正常,服务名称与注册服务不匹配。一旦我纠正了它,我就可以调用服务名称。
答案 1 :(得分:0)
这可能有助于想要快速部署点火服务的人:
Config config = ConfigFactory.load();
String configFile = "ignite.xml";
Ignite ignite = Ignition.start(configFile);
// Deployment the service
IgniteServices services = ignite.services(ignite.cluster().forServers());
services.deployClusterSingleton("IgniteServiceTestInterface", new IgniteServiceTestImpl());
// Accessing the deployed service
IgniteServiceTestInterface cntrSvc = ignite.services()
.serviceProxy("IgniteServiceTestInterface", IgniteServiceTestInterface.class, false);
System.out.println(cntrSvc.invokeNext(1));