use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class TxnMapNearCacheInvalidationTest method testTxnInvalidatesNearCache.
private void testTxnInvalidatesNearCache(InvalidatorTxnOp invalidatorTxnTask) {
final String mapName = "test";
final int numberOfEntries = 1000;
NearCacheConfig nearCacheConfig = createNearCacheConfig(mapName).setInvalidateOnChange(true);
Config config = smallInstanceConfig();
config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Integer, Integer> map = hz.getMap(mapName);
// 1. populate Near Cache
invalidatorTxnTask.doPopulateNearCache(map, numberOfEntries);
// 2. run a txn task which causes invalidation
hz.executeTransaction(invalidatorTxnTask.createTxnTask(mapName, numberOfEntries));
// 3. assert
invalidatorTxnTask.doAssertion(map, numberOfEntries);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class InMemoryFormatTest method testNativeNearCache_throwsException.
@Test(expected = InvalidConfigurationException.class)
public void testNativeNearCache_throwsException() throws Exception {
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setInMemoryFormat(InMemoryFormat.NATIVE);
Config config = getConfig();
config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
HazelcastInstance member = createHazelcastInstance(config);
member.getMap("default");
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class IssuesTest method testIssue174NearCacheContainsKeySingleNode.
@Test
public void testIssue174NearCacheContainsKeySingleNode() {
int n = 1;
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n);
Config config = getConfig();
config.setClusterName("testIssue174NearCacheContainsKeySingleNode");
NearCacheConfig nearCacheConfig = new NearCacheConfig();
config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
HazelcastInstance h = factory.newHazelcastInstance(config);
IMap<String, String> map = h.getMap("testIssue174NearCacheContainsKeySingleNode");
map.put("key", "value");
assertTrue(map.containsKey("key"));
h.shutdown();
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class EvictionTest method testIssue585ZeroTTLShouldPreventEvictionWithSet.
@Test
public void testIssue585ZeroTTLShouldPreventEvictionWithSet() {
MapConfig mapConfig = newMapConfig("testIssue585ZeroTTLShouldPreventEvictionWithSet").setNearCacheConfig(new NearCacheConfig());
Config config = getConfig().setClusterName("testIssue585ZeroTTLShouldPreventEvictionWithSet").addMapConfig(mapConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
HazelcastInstance h = factory.newHazelcastInstance(config);
IMap<String, String> map = h.getMap("testIssue585ZeroTTLShouldPreventEvictionWithSet");
map.set("key", "value", 1, SECONDS);
map.set("key", "value2", 0, SECONDS);
sleepAtLeastSeconds(2);
assertEquals("value2", map.get("key"));
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class HazelcastConnectorTest method beforeClass.
@BeforeClass
public static void beforeClass() {
Config config = smallInstanceConfig();
config.getCacheConfig("*").getEventJournalConfig().setEnabled(true);
config.getMapConfig("stream*").getEventJournalConfig().setEnabled(true);
config.getMapConfig("nearCache*").setNearCacheConfig(new NearCacheConfig());
initialize(2, config);
}
Aggregations