Search code examples
javadistributed-computinghazelcast

DistributedTask on Hazelcast, Task implementation needed on Hazelcast or caller can implement it


I am struggling to understand the behavior of DistributedTask implementation in Hazelcast. To me - A distributed Task , by definition is "Some logic (mostly heavy execution) which a Caller wants to process , is handed over to distributed services across network ". In theory these distributed processors over network does not need to know Task Logic in advance. The caller should provide the logic to execute and data points reference to these distribute services and once task is done, the caller should get the result.

Now, from hazelcast perspective, It seems that hazlecast server nodes themselves need to know the logic ( DistributedTask) in advance. Is my understanding correct ?

I was under the assumption that Caller ( Plain vanilla hazlecast connection pointing to any hazlecast server instance ) should be able to pass the Distributed Function body with Serialized objects to the server and request remote execution of the function, without hazlecast nodes knowing anything about the function body ?


Solution

  • Simple answer - you need a class definition to deserialize a serialized byte array. In case of Hazelcast, a distributed executor task requires the execution code to be present and in classpath of server nodes because servers need class definition to deserialize the serialized byte array of task code that was invoked by the caller.

    It is same as when you are using OBJECT in-memory-format for servers to store data in the form of Java object. By default, data is stored in serialized form of byte arrays.