[infinispan-issues] [JBoss JIRA] (ISPN-4973) DataRehashed an CacheEntryInvalidated events are not fired on cache
William Burns (JIRA)
issues at jboss.org
Mon Dec 8 10:28:39 EST 2014
[ https://issues.jboss.org/browse/ISPN-4973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13025938#comment-13025938 ]
William Burns commented on ISPN-4973:
-------------------------------------
Can you confirm [~vchepeli] ?
> DataRehashed an CacheEntryInvalidated events are not fired on cache
> -------------------------------------------------------------------
>
> Key: ISPN-4973
> URL: https://issues.jboss.org/browse/ISPN-4973
> Project: Infinispan
> Issue Type: Bug
> Components: Core
> Affects Versions: 7.0.0.CR1, 7.0.0.CR2, 7.0.0.Final
> Reporter: Vitalii Chepeliuk
> Assignee: William Burns
>
> Two async listeners created {InvalidationListener, DistributionListener} and check if async events are fired on cache
> * InvalidationListener
> {code}
> /**
> * Custom listener for handling notification events.
> */
> @Listener(sync=false)
> public class InvalidationListener {
> public AtomicInteger keyId = new AtomicInteger();
> public String nodeName;
> public Thread threadRunningNotif;
> public volatile boolean isInvalidated = false;
> public InvalidationListener(final String nodeName) {
> this.nodeName = nodeName;
> }
> /**
> * Handles the entry created event.
> * @param event
> */
> @CacheEntryCreated
> public void handleCreationAndModification(Event event) {
> if(event.isPre()) {
> threadRunningNotif = Thread.currentThread();
> keyId.getAndIncrement();
> }
> }
> /**
> * Handles the entry invalidated event.
> * @param event
> */
> @CacheEntryInvalidated
> public void handleInvalidation(CacheEntryInvalidatedEvent event) {
> if (event.isPre()) {
> System.out.println("Data is invalidated.");
> isInvalidated = true;
> threadRunningNotif = Thread.currentThread();
> keyId.getAndIncrement();
> }
> }
> {code}
> * DistributionListener
> {code}
> /**
> * Custom listener for verifying all notificaitions.
> */
> @Listener(sync=false)
> public class DistributionListener {
> public AtomicInteger keyId = new AtomicInteger();
> public String nodeName;
> public Thread topologyThreadRunningNotif = null;
> public Thread threadRunningNotif;
> public volatile boolean isRehashed= false;
> public volatile boolean isTopologyChanged = false;
> public DistributionListener(final String nodeName) {
> this.nodeName = nodeName;
> }
> /**
> * Handling data creation event.
> * @param event
> */
> @CacheEntryCreated
> public void handleCreationAndModification(Event event) {
> if(event.isPre()) {
> threadRunningNotif = Thread.currentThread();
> keyId.getAndIncrement();
> }
> }
> /**
> * Handles data rehashed event.
> * @param evn
> */
> @DataRehashed
> public void handleDataRehash(Event evn) {
> if(evn.isPre()) {
> System.out.println("Data Rehashed on " + nodeName);
> isRehashed = true;
> threadRunningNotif = Thread.currentThread();
> }
> }
> /**
> * Handles cluster topology changed event.
> * @param event
> */
> @TopologyChanged
> public void handleTopologyChange(TopologyChangedEvent event) {
> if(!event.isPre()) {
> System.out.println("Topology changed." + nodeName);
> isTopologyChanged = true;
> topologyThreadRunningNotif = Thread.currentThread();
> }
> }
> }
> {code}
> no CacheEntryInvalidated event is fired
> {code}
> /**
> * Checks that the cache on node1 is invalidated and the CacheInvalidated event is fired and the notification went
> * asynchronously.
> *
> * @throws Exception
> */
> @Test
> @OperateOnDeployment("node1")
> @InSequence(3)
> public void testNode1Invalidation() throws Exception {
> eventually("The elements should be invalidated.", new Condition() {
> @Override
> public boolean isSatisfied() throws Exception {
> return listenerNode1.isInvalidated;
> }
> }, 15000, 15);
> assertTrue("The invalidation should be done asynchronously", listenerNode1.threadRunningNotif != Thread.currentThread());
> assertTrue("The number of called invalidation method should be <= 50, but is " + listenerNode1.keyId.get(), listenerNode1.keyId.get() <= 50);
> }
> {code}
> No DataRehashed event is fired
> {code}
> /**
> * Verifying that the data has been rehashed on node1, the event DataRehashed was fired and the notification was
> * asynchronous.
> * @throws Exception
> */
> @Test
> @OperateOnDeployment("node1")
> @InSequence(3)
> public void testDataRehashEventNode1Verifying() throws Exception {
> eventually("The rehash should happen.", new Condition() {
> @Override
> public boolean isSatisfied() throws Exception {
> return listenerNode1.isRehashed;
> }
> }, 15000, 15);
> assertTrue("The rehash listener thread should be different rather than the current.", Thread.currentThread() != listenerNode1.threadRunningNotif);
> assertTrue("The topology should be changed so far on node1.", listenerNode1.isTopologyChanged);
> assertTrue("The topology should be changed with different thread rather than this one on node1.", listenerNode1.topologyThreadRunningNotif != Thread.currentThread());
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
More information about the infinispan-issues
mailing list