use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class LazyEvictableEntryViewTest method test_hashCode.
@Test
public void test_hashCode() throws Exception {
EntryView entryView = createLazyEvictableEntryView();
assertEquals(entryView.hashCode(), view.hashCode());
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class EvictionTest method sleepAndAssertTtlExpirationCorrectness.
private void sleepAndAssertTtlExpirationCorrectness(IMap<Integer, String> map, long expected, long startRef, long endRef) {
sleepAtLeastSeconds(3);
EntryView view = map.getEntryView(1);
if (expected == Long.MAX_VALUE) {
assertEquals(expected, view.getExpirationTime());
} else {
long actual = MILLISECONDS.toSeconds(view.getExpirationTime() - startRef);
long delta = (1 + MILLISECONDS.toSeconds(endRef - startRef));
assertEquals(expected, actual, delta);
}
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class EvictionTest method testMaxIdle_readThroughIndex.
private void testMaxIdle_readThroughIndex(IndexType type) {
String mapName = randomMapName();
Config config = getConfig();
config.getMapConfig("default").setPerEntryStatsEnabled(true);
// "disable" the cleaner task
config.setProperty(PROP_TASK_PERIOD_SECONDS, Integer.toString(MAX_VALUE));
HazelcastInstance node = createHazelcastInstance(config);
IMap<Integer, Employee> map = node.getMap(mapName);
map.addIndex(type, "city");
int entryCount = 5;
Map<Integer, Long> lastAccessTimes = new HashMap<>();
for (int i = 0; i < entryCount; ++i) {
String cityName = i % 2 == 0 ? "cityname" : null;
Employee emp = new Employee(i, "name" + i, cityName, 0, true, i);
map.put(i, emp, 0L, SECONDS, 60L, SECONDS);
// we do get to set the last access time
map.get(i);
EntryView view = map.getEntryView(i);
long lastAccessTime = view.getLastAccessTime();
assertTrue(lastAccessTime > 0);
lastAccessTimes.put(i, lastAccessTime);
}
sleepAtLeastSeconds(1);
EntryObject entryObject = new PredicateBuilderImpl().getEntryObject();
Predicate predicateCityNull = entryObject.get("city").isNull();
Collection<Employee> valuesNullCity = map.values(predicateCityNull);
Collection<Employee> valuesNotNullCity = map.values(Predicates.equal("city", "cityname"));
assertEquals(entryCount, valuesNullCity.size() + valuesNotNullCity.size());
// check that evaluating the predicate didn't update the last access time of the returned records
for (int i = 0; i < entryCount; ++i) {
EntryView view = map.getEntryView(i);
assertNotNull(view);
long lastAccessTime = view.getLastAccessTime();
long prevLastAccessTime = lastAccessTimes.get(i);
assertTrue("lastAccessTime=" + lastAccessTime + ", prevLastAccessTime=" + prevLastAccessTime, lastAccessTime == prevLastAccessTime);
}
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class EvictionTest method assertTtlExpirationCorrectness.
private void assertTtlExpirationCorrectness(IMap<Integer, String> map, long expected) {
EntryView view = map.getEntryView(1);
assertEquals(expected, view.getExpirationTime());
assertTrue(map.containsKey(1));
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class EntryLoaderSimpleTest method assertExpiredEventually.
private void assertExpiredEventually(IMap map, String prefix, int from, int to) {
assertTrueEventually(() -> {
for (int i = from; i < to; i++) {
EntryView entryView = map.getEntryView(prefix + i);
assertNull("Current time: " + System.currentTimeMillis(), entryView);
}
});
}
Aggregations