[jboss-user] [JBossCache] - Re: Exceptio in startService with PojoCache

yudivian do-not-reply at jboss.com
Tue Sep 5 18:56:58 EDT 2006


Hi, thanks for your post in the forum. Let me describe you a little more my problem and maybe you can help me. I'm developing an application where I need to replicate some data, to do this I'm using two instance of TreeCache for simple data and I'm using PojoCache to replicate an Array List. In a first version of the application I was usin only the two instance of TreeCache and it was working fine but when start to use PojoCache it works if I run the application in only one PC (or only one JVM) but when I run it in more than one PC I got the exceptions I wrote in the forum and I don't know why. I really don't know why a transaction is holding a lock for that long, (this must be inside JBCache because I'm not using transactions). Do you have any suggestion of how can I solve this problem or how to release the lock in the node. 

This is the code of the class that use PojoCache, maybe you can see an error using PojoCache in this code. (I use the method getMessageBusy() very often and from many different threads)


  | public class JBCacheDMS {
  | 	
  | 	private static final Logger log = Logger.getLogger(JBCacheDMS.class);
  | 
  | 	protected boolean inited;
  | 
  | 	protected PojoCache queues;
  | 
  | 	protected HashMap<String, List> proxyQueues;
  | 
  | 	public void init(String DMSUrl, String[] DMSnodesUrls) {
  | 		try {
  | 			queues = new PojoCache();
  | 			PropertyConfigurator config = new PropertyConfigurator(); // configure tree cache.
  | 			   config.configure(queues, "config/replSync-service.xml");
  | 			String platformName = System.getProperty("platformName");
  | 			queues.setClusterName("DMS-" + platformName);
  | 			queues.setCacheMode(PojoCache.REPL_SYNC);
  | //			queues.createService();
  | 			queues.startService();
  | //			addTreeCacheListener();
  | 			proxyQueues = new HashMap<String, List>();
  | 			inited = true;
  | 		} catch (Exception e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 
  | 	}
  | 
  | 	/**
  | 	 * To add a TreeCacheListener
  | 	 * 
  | 	 * @param listener
  | 	 *            The listener to add
  | 	 */
  | 	public void addTreeCacheListener(TreeCacheListener listener) {
  | 		queues.addTreeCacheListener(listener);
  | 	}
  | 
  | 	/**
  | 	 * To remove a TreeCacheListener
  | 	 * 
  | 	 * @param listener
  | 	 *            The listener to remove
  | 	 */
  | 	public void removeTreeCacheListener(TreeCacheListener listener) {
  | 		queues.removeTreeCacheListener(listener);
  | 	}
  | 
  | 	/**
  | 	 * Return an instance of DMStorage(the class itself) if the class was
  | 	 * inited, if not returns null
  | 	 * 
  | 	 * @return an instance of DMS
  | 	 */
  | 	public DMS getDMS() {
  | 		if (inited)
  | 			return this;
  | 		return null;
  | 	}
  | 
  | 	public void stop() {
  | 		// TODO Auto-generated method stub
  | 
  | 	}
  | 
  | 	public void createQueue(String name) {
  | 		try {
  | 			queues.putObject(name, new ArrayList<AbstractMessage>());
  | 			List<AbstractMessage> proxyList = (List) queues.getObject(name);
  | 			proxyQueues.put(name, proxyList);
  | 			// System.out.println(getAgent(name).getName().getName());
  | 		} catch (CacheException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 
  | 	}
  | 
  | 	public void deleteQueue(String name) {
  | 		try {
  | 			proxyQueues.remove(name);
  | 			queues.removeObject(name);
  | 			queues.remove(name);
  | 		} catch (CacheException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 
  | 	}
  | 
  | 	public void putMessage(String name, AbstractMessage message) {
  | 		if (!queues.exists(name)){
  | 			createQueue(name);
  | 		}
  | 		List<AbstractMessage> proxyList = proxyQueues.get(name);
  | 		proxyList.add(message);
  | 	}
  | 
  | 	public AbstractMessage getMessageBusy(String name) {
  | 		if (!queues.exists(name)){
  | 			createQueue(name);
  | 		}
  | 		List<AbstractMessage> proxyList = proxyQueues.get(name);
  | 		AbstractMessage message = proxyList.remove(0);
  | 		while(message == null){
  | 			message = proxyList.remove(0);
  | 			try {
  | 				Thread.sleep(10);
  | 			} catch (InterruptedException e) {
  | 				// TODO Auto-generated catch block
  | 				e.printStackTrace();
  | 			}
  | 		}
  | 		return message;
  | 	}
  | }
  | 
>You have a transaction on the existing cache instance that's holding a write >lock on a node for 15 seconds. That's preventing the acquisition of the read >lock that's necessary to prepare the state transfer. So a question is why a >tx is holding the lock for that long.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969599#3969599

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969599



More information about the jboss-user mailing list