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");
}
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));
}
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);
}
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));
}
}
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();
}
}
Aggregations