use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientCacheReadWriteThroughTest method getInstance.
@Override
protected HazelcastInstance getInstance() {
// Create server instance
HazelcastInstance serverInstance = factory.newHazelcastInstance(createConfig());
serverCachingProvider = createServerCachingProvider(serverInstance);
// Create client instance
ClientConfig clientConfig = new ClientConfig();
NearCacheConfig nearCacheConfig = new NearCacheConfig(CACHE_WITH_NEARCACHE);
nearCacheConfig.getEvictionConfig().setSize(NEARCACHE_SIZE);
clientConfig.addNearCacheConfig(nearCacheConfig);
return ((TestHazelcastFactory) factory).newHazelcastClient(clientConfig);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class AbstractClientConfigBuilderTest method testNearCacheConfig_withEvictionConfig_withPreloaderConfig.
@Test
public void testNearCacheConfig_withEvictionConfig_withPreloaderConfig() throws IOException {
URL schemaResource = XMLConfigBuilderTest.class.getClassLoader().getResource("hazelcast-client-test.xml");
ClientConfig clientConfig = new XmlClientConfigBuilder(schemaResource).build();
assertEquals("MyInstanceName", clientConfig.getInstanceName());
NearCacheConfig nearCacheConfig = clientConfig.getNearCacheConfig("nearCacheWithEvictionAndPreloader");
assertEquals(10000, nearCacheConfig.getTimeToLiveSeconds());
assertEquals(5000, nearCacheConfig.getMaxIdleSeconds());
assertFalse(nearCacheConfig.isInvalidateOnChange());
assertEquals(InMemoryFormat.OBJECT, nearCacheConfig.getInMemoryFormat());
assertFalse(nearCacheConfig.isCacheLocalEntries());
assertNotNull(nearCacheConfig.getEvictionConfig());
assertEquals(100, nearCacheConfig.getEvictionConfig().getSize());
assertEquals(MaxSizePolicy.ENTRY_COUNT, nearCacheConfig.getEvictionConfig().getMaxSizePolicy());
assertEquals(EvictionPolicy.LFU, nearCacheConfig.getEvictionConfig().getEvictionPolicy());
assertNotNull(nearCacheConfig.getPreloaderConfig());
assertTrue(nearCacheConfig.getPreloaderConfig().isEnabled());
assertEquals("/tmp/myNearCache", nearCacheConfig.getPreloaderConfig().getDirectory());
assertEquals(2342, nearCacheConfig.getPreloaderConfig().getStoreInitialDelaySeconds());
assertEquals(4223, nearCacheConfig.getPreloaderConfig().getStoreIntervalSeconds());
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientCacheNearCacheBasicTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext(boolean loaderEnabled) {
Config config = getConfig();
CacheConfig<K, V> cacheConfig = getCacheConfig(nearCacheConfig, loaderEnabled);
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
CachingProvider memberProvider = createServerCachingProvider(member);
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
ICacheDataStructureAdapter<K, V> dataAdapter = new ICacheDataStructureAdapter<K, V>(memberCache);
NearCacheTestContextBuilder<K, V, Data, String> builder = createNearCacheContextBuilder(cacheConfig);
return builder.setDataInstance(member).setDataAdapter(dataAdapter).setMemberCacheManager(memberCacheManager).build();
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientCacheInvalidationMetaDataFetcherTest method getRepairingTask.
@SuppressWarnings("unchecked")
private RepairingTask getRepairingTask(String cacheName, int partition, long givenSequence, UUID givenUuid) {
HazelcastInstance member = factory.newHazelcastInstance();
distortRandomPartitionSequence(getPrefixedName(cacheName), partition, givenSequence, member);
distortRandomPartitionUuid(partition, givenUuid, member);
ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(new NearCacheConfig(cacheName));
HazelcastClientProxy client = (HazelcastClientProxy) factory.newHazelcastClient(clientConfig);
CachingProvider clientCachingProvider = createClientCachingProvider(client);
Cache<Integer, Integer> clientCache = clientCachingProvider.getCacheManager().createCache(cacheName, newCacheConfig());
ClientContext clientContext = ((ClientProxy) clientCache).getContext();
return clientContext.getRepairingTask(SERVICE_NAME);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientCacheReconciliationTest method setUp.
@Before
public void setUp() {
EvictionConfig evictionConfig = new EvictionConfig().setMaxSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
cacheConfig = new CacheConfig<Integer, Integer>().setEvictionConfig(evictionConfig);
NearCacheConfig nearCacheConfig = new NearCacheConfig("*").setInvalidateOnChange(true);
clientConfig = new ClientConfig().setProperty(MAX_TOLERATED_MISS_COUNT.getName(), "0").setProperty(RECONCILIATION_INTERVAL_SECONDS.getName(), String.valueOf(RECONCILIATION_INTERVAL_SECS)).setProperty(MIN_RECONCILIATION_INTERVAL_SECONDS.getName(), String.valueOf(RECONCILIATION_INTERVAL_SECS)).addNearCacheConfig(nearCacheConfig);
Config config = getBaseConfig().setProperty(MAP_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), String.valueOf(Integer.MAX_VALUE)).setProperty(MAP_INVALIDATION_MESSAGE_BATCH_SIZE.getName(), String.valueOf(Integer.MAX_VALUE));
HazelcastInstance server = factory.newHazelcastInstance(config);
CachingProvider provider = createServerCachingProvider(server);
CacheManager serverCacheManager = provider.getCacheManager();
serverCache1 = serverCacheManager.createCache(CACHE_1_NAME, cacheConfig);
serverCache2 = serverCacheManager.createCache(CACHE_2_NAME, cacheConfig);
serverCache3 = serverCacheManager.createCache(CACHE_3_NAME, cacheConfig);
}
Aggregations