[infinispan-issues] [JBoss JIRA] (ISPN-4973) DataRehashed an CacheEntryInvalidated events are not fired on cache
Vitalii Chepeliuk (JIRA)
issues at jboss.org
Wed Nov 12 09:28:29 EST 2014
[ https://issues.jboss.org/browse/ISPN-4973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vitalii Chepeliuk updated ISPN-4973:
------------------------------------
Description:
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 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 boolean isRehashed= false;
public 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}
was:
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 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 boolean isRehashed= false;
public 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}
> 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 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 boolean isRehashed= false;
> public 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