gridgain / gridgain-old

267 stars 85 forks source link

Force serialized class reloading #81

Open quidproquo opened 10 years ago

quidproquo commented 10 years ago

Is there a way force reloading of serialized classes that are associated with GridClosures? I have an example program that has a closure which makes use of inner classes but when those inner classes are changed, I get an exception. When I change the serialVersionUID of the serialized classes, I get a different exception saying that I need to make sure the class is loaded on all nodes. Is there a way to force a reload if the serialized version changes?

dsetrakyan commented 10 years ago

Can you provide a sample code to reproduce?

quidproquo commented 10 years ago

Initial code:

public class CalculateStatisticsTask extends GridComputeTaskSplitAdapter<List<Map<String, String>>, List<Statistics>> {

    private static final long serialVersionUID = 1L;

    @Override
    protected Collection<? extends GridComputeJob> split(int gridSize, List<Map<String, String>> axeses) {
        Collection<GridComputeJob> jobs = new LinkedList<>();

        for (final Map<String, String> axes : axeses) {
            jobs.add(new GridComputeJobAdapter() {

                private static final long serialVersionUID = 1L;

                @Nullable
                @Override
                public Object execute() {
                    System.out.println("Axes: xyz");
                }

            });
        }

        return jobs;
    }
    // ...
}

I run this task from a client node and have an remote node running in a terminal window. It prints out the "Axes: xyz" which is fine. However, if I change the code to print out something else ("Axes: abc"), the remote node still prints out the old String. If i change the serialVersionUID to a new value, I get the following exception:

Caused by: java.lang.ClassNotFoundException: Optimized stream class checksum mismatch (is same version of marshalled class present on all nodes?)

From reading the documentation on "Zero Deployment," it says:

Moreover, GridGain supports redeployment, so, you don’t have to restart the nodes every time you change the task or closure code - again, just modify the code, compile, and run, and all your changes will be picked up on the grid automatically.

However, it doesn't seem to pickup the new code at all. I was testing if changing the serialVersionUID would do that. Is there a way to pickup the new code without restarting the remote node?