use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class NearCacheRecordStoreTestSupport method clearRecordsOrDestroyStore.
protected void clearRecordsOrDestroyStore(InMemoryFormat inMemoryFormat, boolean destroy) {
NearCacheConfig nearCacheConfig = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME, inMemoryFormat);
NearCacheRecordStore<Integer, String> nearCacheRecordStore = createNearCacheRecordStore(nearCacheConfig, inMemoryFormat);
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
nearCacheRecordStore.put(i, "Record-" + i);
// ensure that they are stored
assertNotNull(nearCacheRecordStore.get(i));
}
if (destroy) {
nearCacheRecordStore.destroy();
} else {
nearCacheRecordStore.clear();
}
assertEquals(0, nearCacheRecordStore.size());
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class NearCacheTestSupport method doConfigureInvalidateOnChangeForNearCache.
protected void doConfigureInvalidateOnChangeForNearCache() {
NearCacheConfig config1 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-1", DEFAULT_MEMORY_FORMAT);
NearCacheConfig config2 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-2", DEFAULT_MEMORY_FORMAT);
config1.setInvalidateOnChange(false);
config2.setInvalidateOnChange(true);
NearCache nearCache1 = createNearCache(config1.getName(), config1, createManagedNearCacheRecordStore());
NearCache nearCache2 = createNearCache(config2.getName(), config2, createManagedNearCacheRecordStore());
// show that NearCache gets "isInvalidateOnChange" configuration from specified NearCacheConfig
assertFalse(nearCache1.isInvalidatedOnChange());
assertTrue(nearCache2.isInvalidatedOnChange());
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class NearCacheTestSupport method doConfigureInMemoryFormatForNearCache.
protected void doConfigureInMemoryFormatForNearCache() {
NearCacheConfig config1 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-1", DEFAULT_MEMORY_FORMAT);
NearCacheConfig config2 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-2", DEFAULT_MEMORY_FORMAT);
config1.setInMemoryFormat(InMemoryFormat.OBJECT);
config2.setInMemoryFormat(InMemoryFormat.BINARY);
NearCache nearCache1 = createNearCache(config1.getName(), config1, createManagedNearCacheRecordStore());
NearCache nearCache2 = createNearCache(config2.getName(), config2, createManagedNearCacheRecordStore());
// show that NearCache gets "inMemoryFormat" configuration from specified NearCacheConfig
assertEquals(InMemoryFormat.OBJECT, nearCache1.getInMemoryFormat());
assertEquals(InMemoryFormat.BINARY, nearCache2.getInMemoryFormat());
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class MetaDataGeneratorTest method destroying_map_removes_related_metadata.
@Test
public void destroying_map_removes_related_metadata() throws Exception {
final String mapName = "test";
Config config = new Config();
NearCacheConfig nearCacheConfig = new NearCacheConfig();
config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
HazelcastInstance member = createHazelcastInstance(config);
IMap map = member.getMap(mapName);
map.put(1, 1);
final MetaDataGenerator metaDataGenerator = getMetaDataGenerator(member);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNotNull(metaDataGenerator.sequenceGenerators.get(mapName));
}
});
map.destroy();
assertNull(metaDataGenerator.sequenceGenerators.get(mapName));
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientReplicatedMapNearCacheBasicTest method testSerializeKeys_notSupported.
@Test(expected = InvalidConfigurationException.class)
public void testSerializeKeys_notSupported() {
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setSerializeKeys(true).setInMemoryFormat(inMemoryFormat);
nearCacheConfig.setName("test");
clientConfig.addNearCacheConfig(nearCacheConfig);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
client.getReplicatedMap("test");
}
Aggregations