Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clients can't submit HazelcastInstanceAware callables #6570

Closed
jerrinot opened this issue Oct 26, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@jerrinot
Copy link
Contributor

commented Oct 26, 2015

PartitionTargetCallableRequest deserialize the callable -> deserialiation set the HazelcastInstance -> Hazelcast instance is not serializable -> https://github.com/jerrinot/hazelcast/blob/5e4741568079cbde4c244a0aba40b434c38c0ffb/hazelcast/src/main/java/com/hazelcast/executor/impl/client/PartitionTargetCallableRequest.java#L79-79 throws exception.

Reproducer:

public class ClientMapCallableTest extends HazelcastTestSupport {

    private final TestHazelcastFactory hazelcastFactory = new TestHazelcastFactory();
    private HazelcastInstance client;
    private HazelcastInstance server;

    @Before
    public void setup() {
        server = hazelcastFactory.newHazelcastInstance();
        client = hazelcastFactory.newHazelcastClient();
    }

    @After
    public void tearDown() {
        hazelcastFactory.terminateAll();
    }

    @Test
    public void submitToAllMembers_whenTaskIsHazelcastInstanceAware_thenDoNotThrowException() throws ExecutionException, InterruptedException {
        IExecutorService executorService = client.getExecutorService(randomName());
        Map<Member, Future> memberFutureMap = executorService.submitToAllMembers(new MyCallable());
        FutureUtil.allDone(memberFutureMap.values());
    }

    private static class MyCallable implements Callable, HazelcastInstanceAware, Serializable {
        private HazelcastInstance instance;

        @Override
        public String call() throws Exception {
            return "foo";
        }

        @Override
        public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
            this.instance = hazelcastInstance;
        }
    }

}

@jerrinot jerrinot added this to the 3.6 milestone Oct 26, 2015

@jerrinot

This comment has been minimized.

Copy link
Contributor Author

commented Oct 26, 2015

The PartitionTargetCallableRequest (and all other requests?) should work with serialized tasks only. Unnecessary (de-)serialization wastes CPU cycles and it's a cause of this issue.

@pveentjer

This comment has been minimized.

Copy link
Member

commented Oct 26, 2015

The 'instance' field should be made transient.

@jerrinot

This comment has been minimized.

Copy link
Contributor Author

commented Oct 26, 2015

right. that makes the error to go away. but we are still doing unnecessary (de-)serialization?

@pveentjer

This comment has been minimized.

Copy link
Member

commented Oct 26, 2015

Probably yes. So imho this is a bug.

Can you try with member 2 member? And new client?

@jerrinot

This comment has been minimized.

Copy link
Contributor Author

commented Oct 26, 2015

I'm closing this in favour of #6571.

I'm using master which dues use the new client by default.

@jerrinot jerrinot closed this Oct 26, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.