[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Messages posted by: anil2012  XML
Profile for anil2012 -> Messages posted by anil2012 [4]
Author Message
Hi,

I am trying to fire events using JCache with Ehcache as backend cache provider.

I tried this simple example using programmatic cache creation approach.But none of the events are fired.

Below program runs with following exception :

Listenr added : true
Exception in thread "main" java.lang.IllegalArgumentException: null source
at java.util.EventObject.<init>(Unknown Source)
at javax.cache.event.CacheEntryEvent.<init>(CacheEntryEvent.java:26)
at net.sf.ehcache.jcache.JCacheEntryEventAdapter.<init>(JCacheEntryEventAdapter.java:38)
at net.sf.ehcache.jcache.JCacheListenerAdapter.notifyElementPut(JCacheListenerAdapter.java:121)
at net.sf.ehcache.event.RegisteredEventListeners.notifyListener(RegisteredEventListeners.java:294)
at net.sf.ehcache.event.RegisteredEventListeners.invokeListener(RegisteredEventListeners.java:284)
at net.sf.ehcache.event.RegisteredEventListeners.internalNotifyElementPut(RegisteredEventListeners.java:144)
at net.sf.ehcache.event.RegisteredEventListeners.notifyElementPut(RegisteredEventListeners.java:122)
at net.sf.ehcache.Cache.notifyPutInternalListeners(Cache.java:1485)
at net.sf.ehcache.Cache.putInternal(Cache.java:1460)
at net.sf.ehcache.Cache.put(Cache.java:1387)
at net.sf.ehcache.Cache.put(Cache.java:1352)
at net.sf.ehcache.constructs.EhcacheDecoratorAdapter.put(EhcacheDecoratorAdapter.java:119)
at net.sf.ehcache.jcache.JCacheEhcacheDecorator.put(JCacheEhcacheDecorator.java:84)
at net.sf.ehcache.jcache.JCache.put(JCache.java:245)
at com.tibco.events.other.TestCacheEvents.testEvents(TestCacheEvents.java:28)
at com.tibco.events.other.TestCacheEvents.<init>(TestCacheEvents.java:19)
at com.tibco.events.other.TestCacheEvents.main(TestCacheEvents.java:31)


Why events are not getting fired? As per my knowledge ehcache wrapper implementation provides complete implementation of JSR 107(except transaction) or Am I missing something?

I will be thankful if you provide a sample example which can demonstrate JCache Events using ehcache as backend cache?
Code Details are:
JSR 107 JCache Api - 0.5 version
Ehcache-Jcache api - ehcache-jcache-1.5.0-0.5.jar
JDK version 1.6
I included all other dependencies

Here is the code :
Code:
 public class TestCacheEvents {
 
 	CacheManager cacheManager;
 	Cache<Object,Object> cache;
 	private String cacheName = "inventory";
 	private CacheEntryListener cacheEntryListener;
 	
 	public TestCacheEvents()
 	{	
 		cache = Caching.getCacheManager().createCacheBuilder(cacheName).build();
 		cacheEntryListener = new MyListener();
 		registerListener();
 		testEvents();
 	}
 	public void registerListener()
 	{
 		boolean isRegistered = cache.registerCacheEntryListener(cacheEntryListener);
 		System.out.println("Listenr added : "+isRegistered);
 	}
 	public void testEvents()
 	{
 		cache.put("abc", "xyz");
                cache.get("abc");
 		cache.remove("abc");
 	}
 	public static void main(String[] args) {
 		new TestCacheEvents();
 	}
 }
 public class MyListener  implements CacheEntryCreatedListener<Object,Object>,CacheEntryRemovedListener<Object, Object>, CacheEntryReadListener<Object, Object> {
 	@Override
 	public void entryRead(
 			CacheEntryEvent<? extends Object, ? extends Object> event)
 			throws CacheEntryListenerException {
 		System.out.println("Entry Read Event Fired : "+event.getValue());
 	}
 	@Override
 	public void entryCreated(
 			CacheEntryEvent<? extends Object, ? extends Object> event)
 			throws CacheEntryListenerException {
 		System.out.println("Entry Created Event Fired : "+event.getValue());
 	}
 	@Override
 	public void entryRemoved(
 			CacheEntryEvent<? extends Object, ? extends Object> event)
 			throws CacheEntryListenerException {
 		System.out.println("Entry Removed Event Fired :"+event.getValue());
 	}
 }
 
 

Hi,
I am doing performance analysis of standalone ehcache. I am analyzing it for 10,000 put operations.
I created cache of size maxElementsInMemory = 50000, with default LRU policy with eternal set to true and no disk persistence. Program runs normally and I found average time for 10 test as 130 ms

Later I changed the setting as follows and performed the same,
Cache Manager maxBytesLocalHeap="100m" under it created single cache with maxBytesLocalHeap = "30m"
I found average time as 340 ms.
For this case program runs with this message

Dec 17, 2012 10:12:26 PM net.sf.ehcache.pool.sizeof.filter.AnnotationSizeOfFilter <clinit>
INFO: Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
Dec 17, 2012 10:12:26 PM net.sf.ehcache.pool.sizeof.AgentLoader <clinit>
INFO: Unavailable or unrecognised attach API : java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
Dec 17, 2012 10:12:26 PM net.sf.ehcache.pool.sizeof.JvmInformation <clinit>
INFO: Detected JVM data model settings of: 64-Bit HotSpot JVM with Compressed OOPs
Dec 17, 2012 10:12:26 PM net.sf.ehcache.pool.impl.DefaultSizeOfEngine <init>
INFO: using Unsafe sizeof engine


Why this happens? Is there any way to remove this message? What should i do to get same results as maxElementsInMemory case.

I want to use this both features in my project. Please Reply.
Thanks.
Thanks for reply,
Your reply doesn't answer my question. I am not looking for enterprise level application. I want to use this distributed cache for my masters level project, so i want to create a cluster with partitioned topology with support for linear scalability. I am interested in upto which point it supports linear scalability, High availability, and the questions which i asked in my post. Would you please answer my question?
I am looking for terracotta ehcache,

I want to know the limitations of opensource distributed ehcache specially for developement envirnment.
Does opensource distributed ehcache version has any limitations on number of Terracotta servers in partitioned topology?
Are there any limitations on
1)number of objects in cluster
2) max size of object
3)max number of active terracotta servers
4) max number of passive nodes under one active server
5) Does opensource supports infinite linear scalability?
6) Are there any limitations on High availability, Reliability, Consistency, Cache patterns like write through\write back ?

If there are any other limitations of opensource version please tell me.
 
Profile for anil2012 -> Messages posted by anil2012 [4]
Go to:   
Powered by JForum 2.1.7 © JForum Team