[jbosscache-commits] JBoss Cache SVN: r5075 - in cache-bench-fwk/trunk/cache-products: jbosscache-2.1.0cr2 and 4 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jan 8 14:13:03 EST 2008


Author: mircea.markus
Date: 2008-01-08 14:13:03 -0500 (Tue, 08 Jan 2008)
New Revision: 5075

Added:
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/conf/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/lib/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/cachewrappers/
   cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/cachewrappers/JBossCache210Cr2Wrapper.java
Log:


Added: cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/cachewrappers/JBossCache210Cr2Wrapper.java
===================================================================
--- cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/cachewrappers/JBossCache210Cr2Wrapper.java	                        (rev 0)
+++ cache-bench-fwk/trunk/cache-products/jbosscache-2.1.0cr2/src/org/cachebench/cachewrappers/JBossCache210Cr2Wrapper.java	2008-01-08 19:13:03 UTC (rev 5075)
@@ -0,0 +1,83 @@
+package org.cachebench.cachewrappers;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.marshall.NodeData;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.cachebench.CacheWrapper;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class JBossCache210Cr2Wrapper implements CacheWrapper
+{
+   private Cache cache;
+   private Log log = LogFactory.getLog(JBossCache210Cr2Wrapper.class);
+
+   public void init(Map parameters) throws Exception
+   {
+      log.info("Creating cache with the following configuration: " + parameters);
+      cache = DefaultCacheFactory.getInstance().createCache((String)parameters.get("config"));
+      log.info("Running cache with following config: " + cache.getConfiguration());
+      log.info("Running follwing JBossCacheVersion: " + org.jboss.cache.Version.version);
+      log.info("Running follwing JBossCacheCodeName: " + org.jboss.cache.Version.codename);
+   }
+
+   public void setUp() throws Exception
+   {
+   }
+
+   public void tearDown() throws Exception
+   {
+      cache.stop();
+   }
+
+   public void put(Object key, Object value) throws Exception
+   {
+      // make sure the threads don't conflict!
+      Fqn f = new Fqn("test", key);
+      cache.put(f, key, value);
+   }
+
+   public Object get(Object key) throws Exception
+   {
+      Fqn f = new Fqn("test", key);
+      return cache.get(f, key);
+   }
+
+   public void empty() throws Exception
+   {
+      //not removing root because there it fails with buddy replication: http://jira.jboss.com/jira/browse/JBCACHE-1241
+      cache.removeNode(new Fqn("test"));
+   }
+
+   public int getNumMembers()
+   {
+      return cache.getMembers().size();
+   }
+
+   public String getInfo()
+   {
+      return "Num direct children: " + cache.getRoot().getChildren().size();
+   }
+
+   public Object getReplicatedData(String key) throws Exception
+   {
+      CacheSPI cacheSpi = (CacheSPI) cache;
+      GravitateResult result = cacheSpi.gravitateData(new Fqn("test", key), true);
+      if (!result.isDataFound())
+      {
+         //totall replication?
+         return get(key);
+      }
+      NodeData nodeData = result.getNodeData().get(0);
+      return nodeData.getAttributes().get(key);
+   }
+}




More information about the jbosscache-commits mailing list