use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method sequences_migrated_whenNewlyJoinedNodesShutdown.
@Test
public void sequences_migrated_whenNewlyJoinedNodesShutdown() throws Exception {
String mapName = "test";
Config config = newConfig(mapName);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
IMap<Object, Object> map = instance1.getMap(mapName);
for (int i = 0; i < 10000; i++) {
map.put(i, i);
}
Map<Integer, Long> source = getPartitionToSequenceMap(mapName, instance1);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
waitAllForSafeState(instance2);
instance1.shutdown();
HazelcastInstance instance3 = factory.newHazelcastInstance(config);
waitAllForSafeState(instance3);
instance2.shutdown();
waitAllForSafeState(instance3);
Map<Integer, Long> destination = getPartitionToSequenceMap(mapName, instance3);
for (Map.Entry<Integer, Long> entry : source.entrySet()) {
Integer key = entry.getKey();
Long first = entry.getValue();
Long last = destination.get(key);
assertEquals(first, last);
}
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MemberMapRecordStateStressTest method all_records_are_readable_state_in_the_end.
@Test
public void all_records_are_readable_state_in_the_end() throws Exception {
HazelcastInstance member1 = factory.newHazelcastInstance();
HazelcastInstance member2 = factory.newHazelcastInstance();
Config config = new Config();
config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig());
HazelcastInstance nearCachedMember = factory.newHazelcastInstance(config);
IMap memberMap = member1.getMap(mapName);
// initial population of imap from member
for (int i = 0; i < KEY_SPACE; i++) {
memberMap.put(i, i);
}
List<Thread> threads = new ArrayList<Thread>();
// member
for (int i = 0; i < PUT_THREAD_COUNT; i++) {
Put put = new Put(memberMap);
threads.add(put);
}
// nearCachedMap
IMap nearCachedMap = nearCachedMember.getMap(mapName);
// member
for (int i = 0; i < PUT_LOCAL_THREAD_COUNT; i++) {
Put put = new Put(nearCachedMap);
threads.add(put);
}
for (int i = 0; i < GET_ALL_THREAD_COUNT; i++) {
GetAll getAll = new GetAll(nearCachedMap);
threads.add(getAll);
}
for (int i = 0; i < GET_THREAD_COUNT; i++) {
Get get = new Get(nearCachedMap);
threads.add(get);
}
for (int i = 0; i < REMOVE_THREAD_COUNT; i++) {
Remove remove = new Remove(nearCachedMap);
threads.add(remove);
}
for (int i = 0; i < CLEAR_THREAD_COUNT; i++) {
Clear clear = new Clear(nearCachedMap);
threads.add(clear);
}
// start threads
for (Thread thread : threads) {
thread.start();
}
// stress for a while
sleepSeconds(TEST_RUN_SECONDS);
// stop threads
stop.set(true);
for (Thread thread : threads) {
thread.join();
}
assertFinalRecordStateIsReadPermitted(member1, ((NearCachedMapProxyImpl) nearCachedMap).getNearCache());
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheBatchInvalidationTest method testBatchInvalidationRemovesEntries.
@Test
public void testBatchInvalidationRemovesEntries() throws Exception {
String mapName = randomMapName();
Config config = newConfig(mapName);
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
configureBatching(config, true, 12, 1);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
final IMap<Integer, Integer> map1 = node1.getMap(mapName);
final IMap<Integer, Integer> map2 = node2.getMap(mapName);
int size = 1000;
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(i);
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(i);
}
// generate invalidation data
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MapQueryEngineImpl_queryLocalPartitions_resultSizeLimitTest method setup.
@Before
public void setup() {
Config config = new Config();
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "" + PARTITION_COUNT);
config.setProperty(GroupProperty.QUERY_RESULT_SIZE_LIMIT.getName(), "" + RESULT_SIZE_LIMIT);
HazelcastInstance hz = createHazelcastInstance(config);
map = hz.getMap(randomName());
MapService mapService = getNodeEngineImpl(hz).getService(MapService.SERVICE_NAME);
queryEngine = new MapQueryEngineImpl(mapService.getMapServiceContext());
// we fill all partitions, so we get the NodeResultLimit for all partitions as well
QueryResultSizeLimiter resultSizeLimiter = queryEngine.getQueryResultSizeLimiter();
limit = (int) resultSizeLimiter.getNodeResultLimit(PARTITION_COUNT);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class NearCacheLiteMemberTest method createConfig.
public static Config createConfig(String mapName, boolean liteMember) {
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setInvalidateOnChange(true);
Config config = new Config();
config.setLiteMember(liteMember);
config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
return config;
}
Aggregations