我的远程 (Linux) 和本地 (Windows) 节点都使用相同的 jdk 版本 1.7.0_45 和 gridgain 6.0.3,并且启用了对等类加载。但我得到以下信息:
Caused by: java.lang.ClassNotFoundException: Optimized stream class checksum mismatch (is same version of marshalled class present on all nodes?) [expected=-3449, actual=7739, cls=class java.io.FileDescriptor]
at org.gridgain.grid.marshaller.optimized.GridOptimizedClassResolver.readClass(GridOptimizedClassResolver.java:345)
本地节点控制台有日志:
visor> [20:50:12] Local node's library list differs from remote node's
[20:50:12] <commons-lang-2.6.jar> vs. <not jar or zip file>
[20:50:12] <guava-14.0.1.jar> vs. <guava-15.0.jar>
[20:50:12] <javax.servlet-api-3.0.1.jar> vs. <servlet-api-2.4.jar>
[20:50:12] <jcommander-1.30.jar> vs. <jcommander-1.27.jar>
[20:50:12] <log4j-1.2.16.jar> vs. <log4j.jar>
[20:50:12]
代码
public final class GG_HelloWorld {
public static class GridCmd extends Command<GridEvt> {
@Override
protected void executeImpl() throws CommandException, InterruptedException {
final GridConfiguration config = getEvent().getConfig();
// task
GridComputeTask<String, Integer> task = new GridComputeTaskSplitAdapter<String, Integer>() {
@NotNull
@Override
protected Collection<? extends GridComputeJob> split(int gridSize,
@NotNull String arg) {
Collection<GridComputeJob> jobs = new LinkedList<>();
for (final String word : arg.split(" ")) {
jobs.add(new GridComputeJobAdapter() {
@Nullable
@Override
public Object execute() {
X.println(">>>");
X.println(">>> Printing '" + word
+ "' on this node from grid job.");
X.println(">>>");
// Return number of letters in the word.
return word.length();
}
});
}
return jobs;
}
@Nullable
@Override
public Integer reduce(@NotNull List<GridComputeJobResult> results) {
return results.size() - 1 + F.sumInt(F.<Integer>jobResults(results));
}
};
try (Grid g = G.start(config)) {
GridComputeTaskFuture<Integer> fut = g.compute().execute(task, "Hello Grid Enabled World!");
// Wait for task completion.
int phraseLen = fut.get();
X.println(">>>");
X.println(">>> Finished executing Grid \"Hello World\" example with custom task.");
X.println(">>> Total number of characters in the phrase is '" + phraseLen + "'.");
X.println(">>> Check all nodes for output (this node is also part of the grid).");
X.println(">>>");
} catch (GridException e) {
throw new CommandException(e);
}
}
}
}
文件相关代码仅由主节点调用。