简体   繁体   English

Hazelcast杀死用户会话

[英]Hazelcast killing a user session

I'm looking into killing an user active session for my hazelcast cluster. 我正在考虑终止我的hazelcast群集的用户活动会话。

We have the session map and that appears to have two entries per session 我们有会话映射,每个会话似乎有两个条目

[SESSIONID] mapped to a boolean value and [SESSIONID]::hz::user mapped to our user object [SESSIONID]映射到一个布尔值,[SESSIONID] :: hz :: user映射到我们的用户对象

The way I see it to kill a session I have to loop through the map and find the user object, and once that's found remove that entry parse the key and look for the other sessionId mapped to boolean and kill that as well. 我看到它杀死会话的方式必须遍历地图并找到用户对象,一旦找到该对象,则删除该条目以解析键并查找映射到布尔值的另一个sessionId并杀死它。

Is there an easier way that I'm missing? 有没有更简单的方法让我丢失?

It is well described in Hazelcast Mastering book : http://hazelcast.org/mastering-hazelcast/ You need to register to read that book. Hazelcast Mastering手册对此进行了很好的描述: http ://hazelcast.org/mastering-hazelcast/您需要注册才能阅读该书。 You can use Predicate with : 您可以将Predicate用于:

  1. Criteria API 标准API
  2. Distributed SQL Query 分布式SQL查询
  3. RegexPredicate to search the sessionid in map RegexPredicate在地图中搜索sessionid

Imagine that we have a Hazelcast IMap where the key is some ID, the value is a Person object, and we want to retrieve all persons with a given name using the following (and naive) implementation: 假设我们有一个Hazelcast IMap,其中的键是一些ID,值是一个Person对象,并且我们想使用以下(和幼稚的)实现来检索具有给定名称的所有人员:

public Set<Person> getWithNameNaive(String name){
    Set<Person> result = new HashSet<Person>();
    for(Person person: personMap.values()){
        if(person.name.equals(name)){
            result.add(person);
        }
    }
    return result;

Hazelcast way to solve that problem : Hazelcast解决该问题的方法:

 public Set<Person> getWithName(String name) {
    Predicate namePredicate = equal("name", name);
    return (Set<Person>) personMap.values(namePredicate);
}

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

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