Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiry Policy can not working in gridgain 8.8.9 #2419

Open
zhouqian2015 opened this issue May 12, 2022 · 0 comments
Open

Expiry Policy can not working in gridgain 8.8.9 #2419

zhouqian2015 opened this issue May 12, 2022 · 0 comments

Comments

@zhouqian2015
Copy link

zhouqian2015 commented May 12, 2022

I have a question while using gridgain 8.8.9. I have CityKey and City objects,when i specified the CityKey.COUNTRYCODE as a affinity key, The Expiry Policy didn't work. I put one thousand pieces of data to the cache,the key is CityKey object and the value is City object ,and the expiry time is one minute.one minute later,only two pieces of data were removed, then i used cache -scan command in visor ,all the data were removed ,but if i used cache command , the data would always exist. IF I removed the @AffinityKeyMapped annotation on CityKey.COUNTRYCODE,the expiry policy could work. I did the same test with gridgain 8.8.18,and the expiry policy worked all the time. So I wonder to know if this is a bug in gridgain 8.8.9, If it’s not a bug, what’s the reason and how to solve it.

CityKey

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);
    }
}

City

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

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();
    }
}

Here is the gridgain visor output.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant