Reputation: 319
My remote (Linux) and local (windows) node both use the same jdk version 1.7.0_45 and gridgain 6.0.3 and peer-class loading is enabled. But I get the folowing:
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)
Local node console has log:
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]
Code
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);
}
}
}
}
The file related code is only called by the master node.
Upvotes: 0
Views: 595
Reputation: 2292
Also, if you are keeping FileDescriptor in one of the classes you are sending across, you can declare it as transient
and re-initialize it remote node whenever it gets accessed.
Upvotes: 1
Reputation: 406
Looks like you are trying (intentionally or not) to send java.io.FileDescriptor
over the network. I cannot confirm this right now, but I believe this class may be platform-specific, thus the checksum mismatch.
On the other hand, deserialized file descriptor will not be valid on remote computer anyway because it contains operating system file descriptors/handles. I think the solution here is just to make sure that instances of java.io.FileDescriptor
are not sent to remote nodes.
If you are sending an anonymous compute closure, try to make it static and pass all required arguments as a constructor parameters. This way you will make sure that no extra local variables are captured by the java compiler to your class.
Upvotes: 1