首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >到期保险单不能在Grid增益8.8.9中起作用

到期保险单不能在Grid增益8.8.9中起作用
EN

Stack Overflow用户
提问于 2022-05-12 08:29:18
回答 1查看 35关注 0票数 0

我有一个问题,而使用网格增益8.8.9。我有CityKey和City对象,当我将CityKey.COUNTRYCODE指定为关联键时,过期策略无效。我把一千条数据放到缓存中,键是CityKey对象,值是CityKey,过期时间是一分钟后,只有两条数据被删除,然后我在监控程序中使用了缓存-scan命令,所有数据都被删除了,但是如果我使用缓存命令,数据将始终存在。如果我删除了CityKey.COUNTRYCODE上的@AffinityKeyMapped注释,过期策略就可以工作了。我对grid增益8.8.18做了同样的测试,到期政策一直有效。所以,我想知道这是否是gridgain 8.8.9中的一个bug,如果不是bug,原因是什么,以及如何解决它。

CityKey

代码语言:javascript
复制
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
public class CityKey {
    /** */
    private int ID;
    /** */
   @AffinityKeyMapped
    private String COUNTRYCODE;
    public CityKey(int ID, String COUNTRYCODE) {
        this.ID = ID;
        this.COUNTRYCODE = COUNTRYCODE;
    }
    public CityKey() {
    }
    public int getID() {
        return ID;
    }
    public void setID(int ID) {
        this.ID = ID;
    }
    @Override
    public String toString() {
        return "CityKey{" +
                "ID=" + ID +
                ", COUNTRYCODE='" + COUNTRYCODE + '\'' +
                '}';
    }
    public String getCOUNTRYCODE() {
        return COUNTRYCODE;
    }
    public void setCOUNTRYCODE(String COUNTRYCODE) {
        this.COUNTRYCODE = COUNTRYCODE;
    }
    public void assssssss(String sssss){
        System.out.println(sssss);
    }
}

城市

代码语言:javascript
复制
public class City {
    private String NAME;
    private String DISTRICT;
    private int POPULATION;
    public City(String NAME, String DISTRICT, int POPULATION) {
        this.NAME = NAME;
        this.DISTRICT = DISTRICT;
        this.POPULATION = POPULATION;
    }
    public String getNAME() {
        return NAME;
    }
    public void setNAME(String NAME) {
        this.NAME = NAME;
    }
    public String getDISTRICT() {
        return DISTRICT;
    }
    public void setDISTRICT(String DISTRICT) {
        this.DISTRICT = DISTRICT;
    }
    public int getPOPULATION() {
        return POPULATION;
    }
    public void setPOPULATION(int POPULATION) {
        this.POPULATION = POPULATION;
    }
    @Override
    public String toString() {
        return "City{" +
                "NAME='" + NAME + '\'' +
                ", DISTRICT='" + DISTRICT + '\'' +
                ", POPULATION=" + POPULATION +
                '}';
    }
}

GridGainTest

代码语言:javascript
复制
public class GridGainTest {
    public static void main(String[] args) throws Exception {
        ClientConfiguration clientConfiguration = new ClientConfiguration().setAddresses("127.0.0.1:10800");
        IgniteClient client = Ignition.startClient(clientConfiguration);
    // client.destroyCache("testcity");

        ClientCacheConfiguration cacheConfiguration = new ClientCacheConfiguration().setName("testcity");
        cacheConfiguration.setExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.MINUTES, 1)));
        ClientCache<CityKey, City> city = client.getOrCreateCache(cacheConfiguration);

        for (int i = 1000000; i < 1001000; ++i) {
            City value = new City("henan", "a place", 1000000);
            CityKey key = new CityKey(i, "hn" + i);
            city.put(key, value);
            System.out.println(i);
        }
        client.close();
    }
}

以下是网格增益管理程序输出。

代码语言:javascript
复制
visor> cache



Time of the snapshot: 2022-05-12 15:24:33

|    Name(@)    |    Mode     | Nodes | Total entries (Heap / Off-heap) | Primar

y entries (Heap / Off-heap) |   Hits    |  Misses   |   Reads   |  Writes   |

| testcity(@c0) | PARTITIONED | 1     | 1000 (0 / 1000)                 | min: 1

000 (0 / 1000)              | min: 0    | min: 0    | min: 0    | min: 0    |

|               |             |       |                                 | avg: 1

000.00 (0.00 / 1000.00)     | avg: 0.00 | avg: 0.00 | avg: 0.00 | avg: 0.00 |

|               |             |       |                                 | max: 1

000 (0 / 1000)              | max: 0    | max: 0    | max: 0    | max: 0    |

+-------------------------------------------------------------------------------

----------------------------------------------------------------------------+

Use "-a" flag to see detailed statistics.

visor> cache

Time of the snapshot: 2022-05-12 15:26:50

|    Name(@)    |    Mode     | Nodes | Total entries (Heap / Off-heap) | Primar

y entries (Heap / Off-heap) |   Hits    |  Misses   |   Reads   |  Writes   |

| testcity(@c0) | PARTITIONED | 1     | 998 (0 / 998)                   | min: 9

98 (0 / 998)                | min: 0    | min: 0    | min: 0    | min: 0    |

|               |             |       |                                 | avg: 9

98.00 (0.00 / 998.00)       | avg: 0.00 | avg: 0.00 | avg: 0.00 | avg: 0.00 |

|               |             |       |                                 | max: 9

98 (0 / 998)                | max: 0    | max: 0    | max: 0    | max: 0    |

+-------------------------------------------------------------------------------

----------------------------------------------------------------------------+

Use "-a" flag to see detailed statistics.

visor> cache -scan

Time of the snapshot: 2022-05-12 15:28:42

+===============================================================+

| # |    Name(@)    |    Mode     |   Size (Heap / Off-heap)    |

+===============================================================+

| 0 | testcity(@c0) | PARTITIONED | min: 998 (0 / 998)          |

|   |               |             | avg: 998.00 (0.00 / 998.00) |

|   |               |             | max: 998 (0 / 998)          |

+---------------------------------------------------------------+

 

Choose cache number ('c' to cancel) [c]: 0

Cache: testcity is empty
EN

回答 1

Stack Overflow用户

发布于 2022-05-12 09:13:43

很可能这是个已知的问题。这可能与不正确地处理墓碑有关,因为一个角落的情况下,亲和力和分配都有问题。试试最新的GridGain 8.8.18。该问题是GG-34306 -修复了一个问题与清理墓碑

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72212342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档