use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class ContainsValueOperationTest method setUp.
@Before
public void setUp() throws Exception {
Config config = getConfig();
member1 = factory.newHazelcastInstance(config);
member2 = factory.newHazelcastInstance(config);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheTest method testAfterLoadAllNearCacheIsInvalidated.
@Test
public void testAfterLoadAllNearCacheIsInvalidated() {
int mapSize = 1000;
String mapName = randomMapName();
Config config = createNearCachedMapConfigWithMapStoreConfig(mapName);
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, Integer> map = instance.getMap(mapName);
populateMap(map, mapSize);
populateNearCache(map, mapSize);
map.loadAll(true);
assertEquals(0, getNearCacheStats(map).getOwnedEntryCount());
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheTest method testNearCacheInvalidationByUsingMapPutAll.
@Test
public void testNearCacheInvalidationByUsingMapPutAll() {
int clusterSize = 3;
int mapSize = 5000;
String mapName = randomMapName();
Config config = getConfig();
config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig().setInvalidateOnChange(true));
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(clusterSize);
HazelcastInstance[] instances = factory.newInstances(config);
final IMap<Integer, Integer> map = instances[0].getMap(mapName);
populateMap(map, mapSize);
populateNearCache(map, mapSize);
// more-or-less (count / no_of_nodes) should be in the Near Cache now
assertTrue(getNearCacheSize(map) > (mapSize / clusterSize - mapSize * 0.1));
Map<Integer, Integer> invalidationMap = new HashMap<Integer, Integer>(mapSize);
populateMap(invalidationMap, mapSize);
// this should invalidate the Near Cache
map.putAll(invalidationMap);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals("Invalidation is not working on putAll()", 0, getNearCacheSize(map));
}
});
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheTest method testGetAsync.
@Test
public void testGetAsync() {
int mapSize = 1000;
int expectedHits = 400;
String mapName = "testGetAsyncWithNearCache";
Config config = getConfig();
config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig().setInvalidateOnChange(false));
TestHazelcastInstanceFactory hazelcastInstanceFactory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = hazelcastInstanceFactory.newHazelcastInstance(config);
hazelcastInstanceFactory.newHazelcastInstance(config);
IMap<Integer, Integer> map = instance1.getMap(mapName);
populateMap(map, mapSize);
populateNearCache(map, mapSize);
for (int i = 0; i < mapSize; i++) {
map.getAsync(i);
}
long hits = getNearCacheStats(map).getHits();
assertTrue(format("Near Cache hits should be > %d but were %d", expectedHits, hits), hits > expectedHits);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheTest method testAfterExecuteOnEntriesNearCacheIsInvalidated.
@Test
public void testAfterExecuteOnEntriesNearCacheIsInvalidated() {
int mapSize = 10;
String mapName = randomMapName();
Config config = createNearCachedMapConfig(mapName);
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, Employee> map = instance.getMap(mapName);
for (int i = 0; i < mapSize; i++) {
map.put(i, new Employee(i, "", 0, true, 0D));
}
populateNearCache(map, mapSize);
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("salary").equal(0);
map.executeOnEntries(new AbstractEntryProcessor<Integer, Employee>() {
@Override
public Object process(Map.Entry<Integer, Employee> entry) {
Employee employee = entry.getValue();
double currentSalary = employee.getSalary();
double newSalary = currentSalary + 10;
employee.setSalary(newSalary);
return newSalary;
}
}, predicate);
assertEquals(0, getNearCacheStats(map).getOwnedEntryCount());
}
Aggregations