Search in sources :

Example 1 with TestHazelcastFactory

use of com.hazelcast.client.test.TestHazelcastFactory in project hazelcast by hazelcast.

the class ClientAggregatorsSpecTest method getMapWithNodeCount.

@Override
protected <K, V> IMap<K, V> getMapWithNodeCount(int nodeCount, boolean parallelAccumulation) {
    if (nodeCount < 1) {
        throw new IllegalArgumentException("node count < 1");
    }
    MapConfig mapConfig = new MapConfig().setName("aggr").setInMemoryFormat(inMemoryFormat);
    Config config = new Config().setProperty(PARTITION_COUNT.getName(), String.valueOf(nodeCount)).setProperty(AGGREGATION_ACCUMULATION_PARALLEL_EVALUATION.getName(), String.valueOf(parallelAccumulation)).addMapConfig(mapConfig);
    factory = new TestHazelcastFactory();
    for (int i = 0; i < nodeCount; i++) {
        factory.newHazelcastInstance(config);
    }
    HazelcastInstance instance = factory.newHazelcastClient();
    return instance.getMap("aggr");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) MapConfig(com.hazelcast.config.MapConfig)

Example 2 with TestHazelcastFactory

use of com.hazelcast.client.test.TestHazelcastFactory in project hazelcast by hazelcast.

the class ClientCacheNearCacheStaleReadTest method setUp.

@Before
public void setUp() throws Exception {
    TestHazelcastFactory factory = new TestHazelcastFactory();
    valuePut = new AtomicInteger(0);
    stop = new AtomicBoolean(false);
    failed = new AtomicBoolean(false);
    assertionViolationCount = new AtomicInteger(0);
    Config config = new Config();
    config.setProperty(GroupProperty.CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), "2");
    member = factory.newHazelcastInstance(config);
    ClientConfig clientConfig = getClientConfig(CACHE_NAME);
    clientConfig.setProperty("hazelcast.invalidation.max.tolerated.miss.count", "0");
    client = factory.newHazelcastClient(clientConfig);
    CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    cache = cacheManager.createCache(CACHE_NAME, createCacheConfig(inMemoryFormat));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) ClientConfig(com.hazelcast.client.config.ClientConfig) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager) Before(org.junit.Before)

Example 3 with TestHazelcastFactory

use of com.hazelcast.client.test.TestHazelcastFactory in project hazelcast by hazelcast.

the class ClientCacheRecordStateStressTest method setUp.

@Before
public void setUp() throws Exception {
    factory = new TestHazelcastFactory();
    stop.set(false);
}
Also used : TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) Before(org.junit.Before)

Example 4 with TestHazelcastFactory

use of com.hazelcast.client.test.TestHazelcastFactory in project hazelcast by hazelcast.

the class ClientNearCacheInvalidationTest method setup.

@Before
public void setup() {
    hazelcastFactory = new TestHazelcastFactory();
    member = hazelcastFactory.newHazelcastInstance(getConfig());
    if (MEMBER_COUNT > 1) {
        HazelcastInstance[] allMembers = new HazelcastInstance[MEMBER_COUNT];
        allMembers[0] = member;
        for (int i = 1; i < MEMBER_COUNT; i++) {
            allMembers[i] = hazelcastFactory.newHazelcastInstance(getConfig());
        }
        waitAllForSafeState(allMembers);
    }
    ClientConfig clientConfig = createClientConfig();
    clientConfig.addNearCacheConfig(createNearCacheConfig(inMemoryFormat));
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    NearCacheManager nearCacheManager = client.client.getNearCacheManager();
    CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) HazelcastServerCachingProvider.createCachingProvider(member).getCacheManager();
    ICache<Object, String> cache = cacheManager.createCache(DEFAULT_CACHE_NAME, createCacheConfig(inMemoryFormat));
    ICache<Object, String> memberCache = member.getCacheManager().getCache(CacheUtil.getPrefixedCacheName(DEFAULT_CACHE_NAME, null, null));
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(DEFAULT_CACHE_NAME));
    testContext = new NearCacheTestContext(client, member, cacheManager, memberCacheManager, nearCacheManager, cache, memberCache, nearCache);
    // make sure several partitions are populated with data
    for (int i = 0; i < 1000; i++) {
        testContext.memberCache.put(Integer.toString(i), Integer.toString(i));
    }
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.nio.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager) Before(org.junit.Before)

Example 5 with TestHazelcastFactory

use of com.hazelcast.client.test.TestHazelcastFactory in project hazelcast by hazelcast.

the class ClientCacheThroughHazelcastInstanceTest method createInstance.

@Override
protected HazelcastInstance createInstance(Config config) {
    if (instanceFactory != null) {
        throw new IllegalStateException("There should not be multiple creation of TestHazelcastFactory!");
    }
    instanceFactory = new TestHazelcastFactory();
    ownerInstance = instanceFactory.newHazelcastInstance(config);
    if (config.getClassLoader() != null) {
        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        try {
            ClientConfig clientConfig = new ClientConfig();
            clientConfig.setClassLoader(config.getClassLoader());
            Thread.currentThread().setContextClassLoader(config.getClassLoader());
            return instanceFactory.newHazelcastClient(clientConfig);
        } finally {
            Thread.currentThread().setContextClassLoader(tccl);
        }
    } else {
        return instanceFactory.newHazelcastClient();
    }
}
Also used : TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) ClientConfig(com.hazelcast.client.config.ClientConfig)

Aggregations

TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)48 Before (org.junit.Before)30 Config (com.hazelcast.config.Config)24 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ClientConfig (com.hazelcast.client.config.ClientConfig)12 MapConfig (com.hazelcast.config.MapConfig)9 QuorumConfig (com.hazelcast.config.QuorumConfig)7 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)7 BeforeClass (org.junit.BeforeClass)7 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)3 NearCacheConfig (com.hazelcast.config.NearCacheConfig)3 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)2 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)2 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 CachingProvider (javax.cache.spi.CachingProvider)2 HazelcastServerCacheManager (com.hazelcast.cache.impl.HazelcastServerCacheManager)1