use of com.hazelcast.config.MultiMapConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testMultimapConfig.
@Test
public void testMultimapConfig() {
MultiMapConfig testMultiMapConfig = config.getMultiMapConfig("testMultimap");
assertEquals(MultiMapConfig.ValueCollectionType.LIST, testMultiMapConfig.getValueCollectionType());
assertEquals(2, testMultiMapConfig.getEntryListenerConfigs().size());
assertFalse(testMultiMapConfig.isBinary());
assertFalse(testMultiMapConfig.isStatisticsEnabled());
for (EntryListenerConfig listener : testMultiMapConfig.getEntryListenerConfigs()) {
if (listener.getClassName() != null) {
assertNull(listener.getImplementation());
assertTrue(listener.isIncludeValue());
assertFalse(listener.isLocal());
} else {
assertNotNull(listener.getImplementation());
assertEquals(entryListener, listener.getImplementation());
assertTrue(listener.isLocal());
assertTrue(listener.isIncludeValue());
}
}
}
use of com.hazelcast.config.MultiMapConfig in project hazelcast by hazelcast.
the class MultiMapTestsFrom2X method testContains.
@Test
public void testContains() throws Exception {
final HazelcastInstance instance = createHazelcastInstance();
instance.getConfig().addMultiMapConfig(new MultiMapConfig().setName("testContains").setBinary(false));
MultiMap<String, ComplexValue> multiMap = instance.getMultiMap("testContains");
// MultiMap
assertTrue(multiMap.put("1", new ComplexValue("text", 1)));
assertFalse(multiMap.put("1", new ComplexValue("text", 1)));
assertFalse(multiMap.put("1", new ComplexValue("text", 2)));
assertTrue(multiMap.containsValue(new ComplexValue("text", 1)));
assertTrue(multiMap.containsValue(new ComplexValue("text", 2)));
assertTrue(multiMap.remove("1", new ComplexValue("text", 3)));
assertFalse(multiMap.remove("1", new ComplexValue("text", 1)));
assertTrue(multiMap.put("1", new ComplexValue("text", 1)));
assertTrue(multiMap.containsEntry("1", new ComplexValue("text", 1)));
assertTrue(multiMap.containsEntry("1", new ComplexValue("text", 2)));
assertTrue(multiMap.remove("1", new ComplexValue("text", 1)));
// MultiMap List
instance.getConfig().addMultiMapConfig(new MultiMapConfig().setName("testContains.list").setValueCollectionType("LIST").setBinary(false));
MultiMap<String, ComplexValue> mmList = instance.getMultiMap("testContains.list");
assertTrue(mmList.put("1", new ComplexValue("text", 1)));
assertTrue(mmList.put("1", new ComplexValue("text", 1)));
assertTrue(mmList.put("1", new ComplexValue("text", 2)));
assertEquals(3, mmList.size());
assertTrue(mmList.remove("1", new ComplexValue("text", 4)));
assertEquals(2, mmList.size());
}
use of com.hazelcast.config.MultiMapConfig in project hazelcast by hazelcast.
the class MultiMapTest method testIssue1882.
/**
* ConcurrentModificationExceptions
*/
@Test
public void testIssue1882() {
String mmName = "mm";
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final Config config = new Config();
final MultiMapConfig multiMapConfig = config.getMultiMapConfig(mmName);
multiMapConfig.setValueCollectionType(MultiMapConfig.ValueCollectionType.LIST);
final HazelcastInstance instance1 = factory.newHazelcastInstance(config);
final HazelcastInstance instance2 = factory.newHazelcastInstance(config);
final String key = generateKeyOwnedBy(instance1);
final MultiMap<Object, Object> mm1 = instance1.getMultiMap("mm");
mm1.put(key, 1);
mm1.put(key, 2);
final AtomicBoolean running = new AtomicBoolean(true);
new Thread() {
@Override
public void run() {
int count = 3;
while (running.get()) {
mm1.put(key, count++);
}
}
}.start();
for (int i = 0; i < 10; i++) {
mm1.get(key);
}
}
use of com.hazelcast.config.MultiMapConfig in project hazelcast by hazelcast.
the class MultiMapService method init.
@Override
public void init(final NodeEngine nodeEngine, Properties properties) {
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int partition = 0; partition < partitionCount; partition++) {
partitionContainers[partition] = new MultiMapPartitionContainer(this, partition);
}
final LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
if (lockService != null) {
lockService.registerLockStoreConstructor(SERVICE_NAME, new ConstructorFunction<ObjectNamespace, LockStoreInfo>() {
@Override
public LockStoreInfo createNew(final ObjectNamespace key) {
String name = key.getObjectName();
final MultiMapConfig multiMapConfig = nodeEngine.getConfig().findMultiMapConfig(name);
return new LockStoreInfo() {
@Override
public int getBackupCount() {
return multiMapConfig.getSyncBackupCount();
}
@Override
public int getAsyncBackupCount() {
return multiMapConfig.getAsyncBackupCount();
}
};
}
});
}
}
use of com.hazelcast.config.MultiMapConfig in project hazelcast by hazelcast.
the class MultiMapOperation method getValueCollectionType.
public final MultiMapConfig.ValueCollectionType getValueCollectionType(MultiMapContainer container) {
checkNotNull(container, "Argument container should not be null");
MultiMapConfig config = container.getConfig();
return config.getValueCollectionType();
}
Aggregations