Search code examples
hazelcastgrid-computing

HazelcastGrid Computing EntryProcessor Executed on every Member


i have a problem with hazelcast using EntryProcessor or ExecutorService. If the key not exist in any member the Processor is still executed in each node and i don't understand why?

The processor receives key entry to null.

UPDATE with some code

    //example of IMap executeOnKeys
    Map<?, ?> map = getCache().executeOnKeys(keys, processor);

    //example using executor service
    Future<Object[]> result = executor.submitToKeyOwner(myCallable, key);

Processor

public class MyProcessor implements EntryProcessor<MyKey, MyValue>, Serializable {
...code
}

Callable

public class MyCallable implements Callable<Object[]>, Serializable {
...code
}

Two examples makes every node of the cluster receive the requests. If they haven't the key, the process is triggered and that's the problem.

I'm sending the request from a Lite member that is part of the cluster.

Thanks,


Solution

  • The EntryProccessor doesn't check if the key exists. It is something like a stored procedure and in theory can also create new key-value pairs. That said you can send an EntryProcessor to a key that doesn't exist yet and you would be able to store a new, just generated value.

    You can, however, check if there's a value in the entry and if not you can expect the key to not yet exist and skip processing (if that helps) :-)