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
mapCleared is added to EntryListener #2790
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00026b5
mapCleared is added to EntryListener
8c0940e
test & checkstyle fix for mapCleared pr
5ac8322
clearAll & evictAll todo comments for replicated map
25db3c2
note for c++ client specific decision
50339ee
added two more test for evictAll
d3ba560
merge
ff14dc2
remove commented code
5445c7a
update on pr about adding clearAll after review
c037293
update comment on webfilter
3a1f958
merge
0bbafb8
clear and evictAll is not fired when number of affected entries are zero
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
hazelcast-client/src/test/java/com/hazelcast/client/map/ClientMapEvictAllTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.hazelcast.client.map; | ||
|
||
import com.hazelcast.client.HazelcastClient; | ||
import com.hazelcast.core.EntryAdapter; | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.core.IMap; | ||
import com.hazelcast.core.MapEvent; | ||
import com.hazelcast.test.HazelcastSerialClassRunner; | ||
import com.hazelcast.test.HazelcastTestSupport; | ||
import com.hazelcast.test.annotation.QuickTest; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
@RunWith(HazelcastSerialClassRunner.class) | ||
@Category(QuickTest.class) | ||
public class ClientMapEvictAllTest extends HazelcastTestSupport { | ||
|
||
@Test | ||
public void evictAll_firesEvent() throws Exception { | ||
final String mapName = randomMapName(); | ||
final HazelcastInstance server1 = Hazelcast.newHazelcastInstance(null); | ||
final HazelcastInstance server2 = Hazelcast.newHazelcastInstance(null); | ||
final HazelcastInstance client = HazelcastClient.newHazelcastClient(); | ||
final IMap<Object, Object> map = client.getMap(mapName); | ||
final CountDownLatch evictedEntryCount = new CountDownLatch(3); | ||
map.addEntryListener(new EntryAdapter<Object, Object>() { | ||
@Override | ||
public void mapEvicted(MapEvent event) { | ||
final int affected = event.getNumberOfEntriesAffected(); | ||
for (int i = 0; i < affected; i++) { | ||
evictedEntryCount.countDown(); | ||
} | ||
|
||
} | ||
}, true); | ||
|
||
map.put(1, 1); | ||
map.put(2, 1); | ||
map.put(3, 1); | ||
map.evictAll(); | ||
|
||
assertOpenEventually(evictedEntryCount); | ||
assertEquals(0, map.size()); | ||
closeResources(client, server1, server2); | ||
} | ||
|
||
@Test | ||
public void evictAll_firesOnlyOneEvent() throws Exception { | ||
final String mapName = randomMapName(); | ||
final HazelcastInstance server1 = Hazelcast.newHazelcastInstance(null); | ||
final HazelcastInstance client = HazelcastClient.newHazelcastClient(); | ||
final IMap<Object, Object> map = client.getMap(mapName); | ||
final CountDownLatch eventCount = new CountDownLatch(2); | ||
map.addEntryListener(new EntryAdapter<Object, Object>() { | ||
@Override | ||
public void mapEvicted(MapEvent event) { | ||
eventCount.countDown(); | ||
|
||
} | ||
}, true); | ||
|
||
map.put(1, 1); | ||
map.put(2, 1); | ||
map.put(3, 1); | ||
map.evictAll(); | ||
|
||
assertFalse(eventCount.await(10, TimeUnit.SECONDS)); | ||
assertEquals(1, eventCount.getCount()); | ||
closeResources(client, server1); | ||
} | ||
|
||
|
||
private static void closeResources(HazelcastInstance... instances) { | ||
if (instances == null) { | ||
return; | ||
} | ||
for (HazelcastInstance instance : instances) { | ||
instance.shutdown(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can decrease code duplication later.