2017-03-02 195 views
0

在我的測試環境中,我在intellij-project中獲得了1個點火節點,並且在運行二進制程序的Docker容器中的另一個節點點燃(通過ignite.sh)。分佈式緩存工作正常... 但我也想從我的點燃「主」節點控制點火節點。 首先,我只想打印「Hello World」,如下例所示: https://dzone.com/articles/getting-started-with-apache-ignite 但是,只有當我在同一個JVM中啓動另一個ignite-instance時,它纔會起作用。 如果我通過點燃二進制運行它,它不起作用。但它應該(如入門指南中所述...)Apache Ignite計算羣集

爲什麼節點搜索DockerExampleTest類?當然,它找不到,因爲ignite-binary的代碼和我的intellij-project的代碼是不同的...我只想要在節點上執行lambda表達式。

我的代碼:

Ignite ignite = Ignition.getOrStart(cfg); 
    ClusterGroup remoteGroup = ignite.cluster().forRemotes(); 
    IgniteCompute compute = ignite.compute(remoteGroup); 

    compute.broadcast(() -> { System.out.println("Hello World"); }); 

錯誤:

SCHWERWIEGEND: Failed to obtain remote job result policy for result from ComputeTask.result(..) method (will fail the whole task): GridJobResultImpl [job=C4V2 [r=DockerExampleTest$$Lambda$10/[email protected]], sib=GridJobSiblingImpl [sesId=2834a6f8a51-ac1fe4d3-41bf-4693-8426-55e2be877df9, jobId=3834a6f8a51-ac1fe4d3-41bf-4693-8426-55e2be877df9, nodeId=2ceb6df9-fbe1-4f04-b660-26b1aaaed177, isJobDone=false], jobCtx=GridJobContextImpl [jobId=3834a6f8a51-ac1fe4d3-41bf-4693-8426-55e2be877df9, timeoutObj=null, attrs={}], node=TcpDiscoveryNode [id=2ceb6df9-fbe1-4f04-b660-26b1aaaed177, addrs=[0:0:0:0:0:0:0:1%lo, 127.0.0.1, 172.16.0.2], sockAddrs=[/0:0:0:0:0:0:0:1%lo:47500, /127.0.0.1:47500, /172.16.0.2:47500], discPort=47500, order=2, intOrder=2, lastExchangeTime=1488464796286, loc=false, ver=1.8.0#20161205-sha1:9ca40dbe, isClient=false], ex=class o.a.i.IgniteException: DockerExampleTest, hasRes=true, isCancelled=false, isOccupied=true] 
class org.apache.ignite.IgniteException: Remote job threw user exception (override or implement ComputeTask.result(..) method if you would like to have automatic failover for this exception). 
    at org.apache.ignite.compute.ComputeTaskAdapter.result(ComputeTaskAdapter.java:101) 
    at org.apache.ignite.internal.processors.task.GridTaskWorker$5.apply(GridTaskWorker.java:1030) 
    at org.apache.ignite.internal.processors.task.GridTaskWorker$5.apply(GridTaskWorker.java:1023) 
    at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6596) 
    at org.apache.ignite.internal.processors.task.GridTaskWorker.result(GridTaskWorker.java:1023) 
    at org.apache.ignite.internal.processors.task.GridTaskWorker.onResponse(GridTaskWorker.java:841) 
    at org.apache.ignite.internal.processors.task.GridTaskProcessor.processJobExecuteResponse(GridTaskProcessor.java:996) 
    at org.apache.ignite.internal.processors.task.GridTaskProcessor$JobMessageListener.onMessage(GridTaskProcessor.java:1221) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1082) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:710) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:102) 
    at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:673) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: class org.apache.ignite.IgniteException: DockerExampleTest 
    at org.apache.ignite.internal.processors.job.GridJobWorker.initialize(GridJobWorker.java:447) 
    at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1108) 
    at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1894) 
    ... 7 more 
Caused by: class org.apache.ignite.IgniteCheckedException: DockerExampleTest 
    at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9785) 
    at org.apache.ignite.internal.processors.job.GridJobWorker.initialize(GridJobWorker.java:428) 
    ... 9 more 
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: DockerExampleTest 
    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:689) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1480) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1418) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.readClass(BinaryReaderExImpl.java:370) 
    at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.readFixedType(BinaryFieldAccessor.java:828) 
    at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.read(BinaryFieldAccessor.java:639) 
    at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:829) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadObject(BinaryUtils.java:1634) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.readObject(BinaryReaderExImpl.java:1124) 
    at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.readBinary(GridClosureProcessor.java:2230) 
    at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:819) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450) 
    at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:298) 
    at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal0(BinaryMarshaller.java:100) 
    at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82) 
    at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9779) 
    ... 10 more 
Caused by: java.lang.ClassNotFoundException: DockerExampleTest 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:348) 
    at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8393) 
    at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185) 
    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:680) 
    ... 28 more 


class org.apache.ignite.binary.BinaryInvalidTypeException: DockerExampleTest 

    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:689) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1480) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1418) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.readClass(BinaryReaderExImpl.java:370) 
    at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.readFixedType(BinaryFieldAccessor.java:828) 
    at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.read(BinaryFieldAccessor.java:639) 
    at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:829) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450) 
    at org.apache.ignite.internal.binary.BinaryUtils.doReadObject(BinaryUtils.java:1634) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.readObject(BinaryReaderExImpl.java:1124) 
    at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.readBinary(GridClosureProcessor.java:2230) 
    at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:819) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498) 
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450) 
    at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:298) 
    at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal0(BinaryMarshaller.java:100) 
    at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82) 
    at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9779) 
    at org.apache.ignite.internal.processors.job.GridJobWorker.initialize(GridJobWorker.java:428) 
    at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1108) 
    at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1894) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1082) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:710) 
    at org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:102) 
    at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:673) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.ClassNotFoundException: DockerExampleTest 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:348) 
    at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8393) 
    at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185) 
    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:680) 
    ... 28 more 

回答

0

我想我找到了答案:我在配置PeerClassLoadingEnable設置爲true。明天我會試試。

1

Java中的lambda實際上是聲明它的類的靜態方法(在您的案例中爲DockerExampleTest)。要執行此方法,必須首先加載類,但您沒有在服務器類路徑中加載它。

爲了解決這個問題,您可以:

  • 創建與DockerExampleTest類的JAR文件,並把它放入到節點開始前的IGNITE_HOME/libs文件夾。
  • 啓用對等體類加載。

更多細節在這裏:https://apacheignite.readme.io/docs/zero-deployment