[jboss-user] [JBoss Cache: Core Edition] - Re: ClusteredCacheLoader

lovelyliatroim do-not-reply at jboss.com
Wed May 21 12:35:08 EDT 2008


Ok found the problem area!!!

It is something to do with my custom MBean, why it causes this behaviour i dont know.


To replicate, just take the following. (Sorry i didnt get a chance to put in test case but it should be easy to copy and paste this into one).


  | {
  | 	CacheFactory factory = DefaultCacheFactory.getInstance();
  |         Cache cache = factory.createCache(configPath);
  |         CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(cache);
  |         wrapper.create();
  |         wrapper.start();
  |         System.out.println("Cache created");
  | 
  |         String quotePath = "/quotes/quoteA";
  |         String ricPath = "/ricIds/A/B/C";
  |         
  |         String key = "quote", value = "10;19";
  |     	Long future = new Long(System.currentTimeMillis() + 604800000);
  |         
  |         cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  |         cache.put(quotePath, key, value);
  | 		cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  |         cache.put(quotePath,CacheConstants.EXPIRATION_KEY, future);
  | 
  |     	
  |         cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  |         cache.put(ricPath, key, value);
  |         cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  |         cache.put(ricPath,CacheConstants.EXPIRATION_KEY, future);
  |         
  |         cache.getRoot().getChild("quotes").setResident(true);
  |         
  |       
  |         //Remove this block and works as normal
  |         StringBuilder b = new StringBuilder();
  |         Node n = cache.getRoot();
  |         Node node = n.getChild(Fqn.fromString("/"));
  | 		Iterator i = node.getChildren().iterator();
  | 		while(i.hasNext()){
  | 			Object child = i.next();
  | 			if(child instanceof NodeInvocationDelegate){
  | 				getLastNode((NodeInvocationDelegate)child,b);
  | 			}
  | 		}
  |         
  |         System.out.println(b.toString());
  |         
  |         
  |         Object quoteObj = cache.get(quotePath, key);
  |         Object ricObj = cache.get(ricPath, key);
  |         
  |         System.out.println("quoteObj= " +quoteObj);
  |         System.out.println("ricObj =" +ricObj);
  |         
  |         cache.stop();
  |         cache.destroy();
  |         }
  | 
  | private void getLastNode(NodeInvocationDelegate parent,StringBuilder nodeList){
  | 		if(parent.getChildren().size() == 0){
  | 			//reached the end node
  | 			nodeList.append(parent.getFqn().toString()+"("+parent.dataSize() +")\n");
  | 			return;
  | 		}
  | 		Iterator<Object> i = parent.getChildren().iterator();
  | 		while(i.hasNext()){
  | 			Object child = i.next();
  | 			if(child instanceof NodeInvocationDelegate){
  | 				NodeInvocationDelegate subNode = (NodeInvocationDelegate)child;
  | 				getLastNode(subNode,nodeList);
  | 			}
  | 		}
  | 	}
  | 
  | 


I have taken snippets of all code and mashed it all together to reproduce whats happening.Its not exactly happening in the above snippet as i explained earlier.

What i see as output for the above running is 

anonymous wrote : 
  | Cache created
  | 
  | quoteObj= null
  | ricObj =null
  | 
  | 

I would have expected to see 
quotes/quoteA(2)
/ricIds/A/B/C(2)


Maybe i shouldnt be doing what im doing to see whats in the tree, i wanted to create something similar to whats in the jmx-console so i can have a nice tree path view of whats paths and how many elements in the tree.

Wont be around till monday but if you dont call the mbean code, it works as normal!! Strange though!!




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

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



More information about the jboss-user mailing list