use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MultiMapListenerTest method testListeners.
@Test
public void testListeners() throws Exception {
int count = 4;
String name = randomMapName();
Config config = new Config();
config.getMultiMapConfig(name).setValueCollectionType(MultiMapConfig.ValueCollectionType.LIST);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(count);
HazelcastInstance[] instances = factory.newInstances(config);
final Set<String> keys = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
EntryListener<String, String> listener = new EntryAdapter<String, String>() {
public void entryAdded(EntryEvent<String, String> event) {
keys.add(event.getKey());
}
public void entryRemoved(EntryEvent<String, String> event) {
keys.remove(event.getKey());
}
@Override
public void mapCleared(MapEvent event) {
keys.clear();
}
};
final MultiMap<String, String> multiMap = instances[0].getMultiMap(name);
final String id = multiMap.addLocalEntryListener(listener);
multiMap.put("key1", "val1");
multiMap.put("key2", "val2");
multiMap.put("key3", "val3");
multiMap.put("key4", "val4");
multiMap.put("key5", "val5");
multiMap.put("key6", "val6");
multiMap.put("key7", "val7");
multiMap.put("key8", "val8");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContainsAll(multiMap.localKeySet(), keys);
}
});
if (keys.size() != 0) {
multiMap.remove(keys.iterator().next());
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContainsAll(multiMap.localKeySet(), keys);
}
});
multiMap.removeEntryListener(id);
getMultiMap(instances, name).clear();
keys.clear();
final String id2 = multiMap.addEntryListener(listener, true);
getMultiMap(instances, name).put("key3", "val3");
getMultiMap(instances, name).put("key3", "val33");
getMultiMap(instances, name).put("key4", "val4");
getMultiMap(instances, name).remove("key3", "val33");
assertSizeEventually(1, keys);
getMultiMap(instances, name).clear();
assertSizeEventually(0, keys);
multiMap.removeEntryListener(id2);
multiMap.addEntryListener(listener, "key7", true);
getMultiMap(instances, name).put("key2", "val2");
getMultiMap(instances, name).put("key3", "val3");
getMultiMap(instances, name).put("key7", "val7");
assertSizeEventually(1, keys);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MultiMapTransactionStressTest method createConfigWithDummyTxService.
private Config createConfigWithDummyTxService() {
Config config = new Config();
ServicesConfig servicesConfig = config.getServicesConfig();
servicesConfig.addServiceConfig(new ServiceConfig().setName(DUMMY_TX_SERVICE).setEnabled(true).setImplementation(new MapTransactionStressTest.DummyTransactionalService(DUMMY_TX_SERVICE)));
return config;
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MultiMapReturnedCollectionTest method createMultiMapWithCollectionType.
private MultiMap<Integer, Integer> createMultiMapWithCollectionType(MultiMapConfig.ValueCollectionType collectionType, int nodeCount) {
String multiMapName = randomMapName();
Config config = new Config();
config.getMultiMapConfig(multiMapName).setValueCollectionType(collectionType);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
final HazelcastInstance[] instances = factory.newInstances(config);
return instances[0].getMultiMap(multiMapName);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class LocalOperationStatsImplTest method testNodeConstructor.
@Test
public void testNodeConstructor() {
Config config = new Config();
config.setProperty(GroupProperty.MC_MAX_VISIBLE_SLOW_OPERATION_COUNT.getName(), "139");
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
Node node = getNode(hazelcastInstance);
LocalOperationStatsImpl localOperationStats = new LocalOperationStatsImpl(node);
assertEquals(139, localOperationStats.getMaxVisibleSlowOperationCount());
assertEquals(0, localOperationStats.getSlowOperations().size());
assertTrue(localOperationStats.getCreationTime() > 0);
assertNotNull(localOperationStats.toString());
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method groupNameIsSetToSpecifiedGroupNameWhenGroupingIsNotDisabled.
@Test
public void groupNameIsSetToSpecifiedGroupNameWhenGroupingIsNotDisabled() {
final String GROUP_NAME = "my-osgi-group";
HazelcastInternalOSGiService service = getService();
Config config = new Config();
config.getGroupConfig().setName(GROUP_NAME);
HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance(config);
assertEquals(GROUP_NAME, osgiInstance.getConfig().getGroupConfig().getName());
HazelcastInstance instance = osgiInstance.getDelegatedInstance();
assertEquals(GROUP_NAME, instance.getConfig().getGroupConfig().getName());
}
Aggregations