简体   繁体   中英

Force put objects to Hazelcast local map

We are working on a distributed data processing system, and Hazelcast is one of the component we are using.

We have a streaming data input coming to the cluster and we have to process the data (update/accumulate etc). There is distributed request map, which has local entry listeners. We process a new request (update/accumulate in memory) and put to another distributed map, which is the actual datagrid.

Thus we can process each request concurrently without locking. However, the putting of data to the main datagrid might involve a network trip.

Is there a way I can force specify which node to be selected? Basically I would want to put it in the local map for datagrid. This should improve the overall throughput by avoiding the network trip.

By using a partition aware key, I can specify that all such keys go to the same partition, however, I am looking to actually 'specify' the partition. Is this possible?

You can create a key for a specific partition. We do this often for testing.

Once you have created such a key for every partition, you can use

map.put("yourkey@partitionkey", value)

Checkout out the git repo and look for HazelcastTestSupport.generateKeyOwnedBy(hz).

Important: it can be that a partition belongs to a member at some point in time, but a partition can move around in the system. Eg when member joins/leaves the cluster, so the solution could be fragile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM