Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fire MERGE events when merging MultiMap entries #13703

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -16,7 +16,6 @@

package com.hazelcast.multimap.impl.operations;

import com.hazelcast.core.EntryEventType;
import com.hazelcast.multimap.impl.MultiMapContainer;
import com.hazelcast.multimap.impl.MultiMapDataSerializerHook;
import com.hazelcast.multimap.impl.MultiMapMergeContainer;
Expand Down Expand Up @@ -75,7 +74,6 @@ public void run() throws Exception {
MultiMapValue result = container.merge(mergeContainer, mergePolicy);
if (result != null) {
resultMap.put(key, result.getCollection(false));
publishEvent(EntryEventType.MERGED, key, result, null);
}
}
response = !resultMap.isEmpty();
Expand Down
Expand Up @@ -19,7 +19,10 @@
import com.hazelcast.config.Config;
import com.hazelcast.config.MergePolicyConfig;
import com.hazelcast.config.MultiMapConfig;
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.EntryListener;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MapEvent;
import com.hazelcast.core.MultiMap;
import com.hazelcast.spi.merge.DiscardMergePolicy;
import com.hazelcast.spi.merge.HigherHitsMergePolicy;
Expand Down Expand Up @@ -70,13 +73,19 @@ public class MultiMapSplitBrainTest extends SplitBrainTestSupport {
public static Collection<Object[]> parameters() {
return asList(new Object[][]{
{DiscardMergePolicy.class, true},
{DiscardMergePolicy.class, false},
{HigherHitsMergePolicy.class, true},
{HigherHitsMergePolicy.class, false},
{LatestAccessMergePolicy.class, true},
{LatestAccessMergePolicy.class, false},
{LatestUpdateMergePolicy.class, true},
{LatestUpdateMergePolicy.class, false},
{PassThroughMergePolicy.class, true},
{PassThroughMergePolicy.class, false},
{PutIfAbsentMergePolicy.class, true},
{PutIfAbsentMergePolicy.class, false},
{RemoveValuesMergePolicy.class, true},

{RemoveValuesMergePolicy.class, false},
{ReturnPiCollectionMergePolicy.class, true},
{ReturnPiCollectionMergePolicy.class, false},
{MergeCollectionOfIntegerValuesMergePolicy.class, true},
Expand Down Expand Up @@ -133,6 +142,11 @@ protected void onAfterSplitBrainCreated(HazelcastInstance[] firstBrain, Hazelcas
multiMapA2 = secondBrain[0].getMultiMap(multiMapNameA);
multiMapB2 = secondBrain[0].getMultiMap(multiMapNameB);

EntryListener<Object, Object> listener = new EmptyEntryListener<Object, Object>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the important bit for the test

multiMapA1.addEntryListener(listener, true);
multiMapA2.addEntryListener(listener, true);
multiMapB2.addEntryListener(listener, true);

if (mergePolicyClass == DiscardMergePolicy.class) {
afterSplitDiscardMergePolicy();
} else if (mergePolicyClass == HigherHitsMergePolicy.class) {
Expand Down Expand Up @@ -458,4 +472,36 @@ private static void assertMultiMapsSize(MultiMap<?, ?> multiMap1, MultiMap<?, ?>
}
assertEqualsStringFormat("backupMultiMap should have size %d, but was %d", expectedSize, actualBackupSize);
}

private static class EmptyEntryListener<K, V> implements EntryListener<K, V> {
@Override
public void mapEvicted(MapEvent event) {

}

@Override
public void mapCleared(MapEvent event) {

}

@Override
public void entryUpdated(EntryEvent<K, V> event) {

}

@Override
public void entryRemoved(EntryEvent<K, V> event) {

}

@Override
public void entryEvicted(EntryEvent<K, V> event) {

}

@Override
public void entryAdded(EntryEvent<K, V> event) {

}
}
}