Search in sources :

Example 56 with NearCacheConfig

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 57 with NearCacheConfig

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());
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest) URL(java.net.URL) Test(org.junit.Test) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest)

Example 58 with NearCacheConfig

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();
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.internal.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ICacheDataStructureAdapter(com.hazelcast.internal.adapter.ICacheDataStructureAdapter) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Example 59 with NearCacheConfig

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Example 60 with NearCacheConfig

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) EvictionConfig(com.hazelcast.config.EvictionConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) CacheManager(javax.cache.CacheManager) ClientConfig(com.hazelcast.client.config.ClientConfig) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) Before(org.junit.Before)

Aggregations

NearCacheConfig (com.hazelcast.config.NearCacheConfig)212 Test (org.junit.Test)89 QuickTest (com.hazelcast.test.annotation.QuickTest)82 Config (com.hazelcast.config.Config)66 HazelcastInstance (com.hazelcast.core.HazelcastInstance)65 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)62 ClientConfig (com.hazelcast.client.config.ClientConfig)51 MapConfig (com.hazelcast.config.MapConfig)37 EvictionConfig (com.hazelcast.config.EvictionConfig)24 Before (org.junit.Before)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)16 CacheConfig (com.hazelcast.config.CacheConfig)15 ParallelTest (com.hazelcast.test.annotation.ParallelTest)15 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)14 AssertTask (com.hazelcast.test.AssertTask)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 MapStoreConfig (com.hazelcast.config.MapStoreConfig)11 Data (com.hazelcast.nio.serialization.Data)11 MatchingPointConfigPatternMatcher (com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher)10 CachingProvider (javax.cache.spi.CachingProvider)10