简体   繁体   English

Hazelcast IMap性能

[英]Hazelcast IMap performance

I use the hazelcast 3.8.6. 我使用hazelcast 3.8.6。 There is a IMAP{Key, Value} with next settings: 有一个具有以下设置的IMAP {Key,Value}:

mapConfig.setBackupCount(5);
mapConfig.setReadBackupData(true);

the Key is 关键是

long userId;
long contentId;

also there are 5 nodes where the data is. 数据也有5个节点。 As far as i understand according the setting each node will be have all data. 据我了解,根据设置每个节点将拥有所有数据。 Such way i turn a distributed map to a replicated map to increase speed of get operations and don't do networking calls. 这样,我将分布式映射转换为复制映射以提高获取操作的速度,并且不进行网络调用。

let's image i need get all data for user by id. 让我们想象我需要通过id获取用户的所有数据。 in usual mode i would write next code: 在通常模式下,我将编写下一个代码:

EntryObject eo = new PredicateBuilder().getEntryObject();
Predicate predicate = eo.key().get("this.userId").equal(userId);
map.values(predicate).stream().map(.....)

this code will be executed on all nodes and result will be returned to node which make the call. 该代码将在所有节点上执行,结果将返回给进行调用的节点。 Am i right understding that in case of the settings "setReadBackupData(true)" the request won't be send to other nodes and all data will be found on node wich make this request? 我是否正确地说,如果设置为“ setReadBackupData(true)”,该请求将不会发送到其他节点,并且所有数据都将在发出此请求的节点上找到? or in that case to avoid networking calls i just should use something like this: 或者在这种情况下,为了避免网络通话,我应该使用如下所示的内容:

map.entrySet().stream()
.filter(entry->entry.getKey().getUserId().equals(userId))
.map(.....)

thanks. 谢谢。

请记住,仅当您从Member内部执行查询时,readBackupData标志才起作用,因此,如果您使用的是HazelcastClient,则它将不会从备份中读取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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