diff --git a/.gitignore b/.gitignore index 989ab5feca253aa4d8ab1d9d9f9abf78fd76aad4..ee88a7870b58ef6150e56b2f50e8244873e391d9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ output* .project .classpath .settings +.checkstyle + +.DS_Store diff --git a/bin/ycsb b/bin/ycsb index cb1b3cbc09bb070528c5c253c0646dccc8113b07..ea1f653011d2fd28750a2be77815d2b79b8cf60e 100755 --- a/bin/ycsb +++ b/bin/ycsb @@ -42,6 +42,7 @@ DATABASES = { "hbase" : "com.yahoo.ycsb.db.HBaseClient", "hbase-10" : "com.yahoo.ycsb.db.HBaseClient10", "hypertable" : "com.yahoo.ycsb.db.HypertableClient", + "infinispan-cs": "com.yahoo.ycsb.db.InfinispanRemoteClient", "infinispan" : "com.yahoo.ycsb.db.InfinispanClient", "jdbc" : "com.yahoo.ycsb.db.JdbcDBClient", "mapkeeper" : "com.yahoo.ycsb.db.MapKeeperClient", diff --git a/infinispan/README.md b/infinispan/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d1303ceb001daac36e07992fbcd7cfa92bccd365 --- /dev/null +++ b/infinispan/README.md @@ -0,0 +1,41 @@ +## Quick Start + +This section describes how to run YCSB on infinispan. + +### 1. Install Java and Maven + +### 2. Set Up YCSB +1. Git clone YCSB and compile: + ``` +git clone http://github.com/brianfrankcooper/YCSB.git +cd YCSB +mvn clean package + ``` + +2. Copy and untar YCSB distribution in distribution/target/ycsb-x.x.x.tar.gz to target machine + +### 4. Load data and run tests +####4.1 embedded mode with cluster or not +Load the data: +``` +./bin/ycsb load infinispan -P workloads/workloada -p infinispan.clustered=<true or false> +``` +Run the workload test: +``` +./bin/ycsb run infinispan -s -P workloads/workloada -p infinispan.clustered=<true or false> +``` +####4.2 client-server mode + +1. start infinispan server + +2. read [RemoteCacheManager](http://docs.jboss.org/infinispan/7.2/apidocs/org/infinispan/client/hotrod/RemoteCacheManager.html) doc and customize hotrod client properties in infinispan-binding/conf/remote-cache.properties + +3. Load the data with specified cache: + ``` +./bin/ycsb load infinispan-cs -s -P workloads/workloada -P infinispan-binding/conf/remote-cache.properties -p cache=<cache name> + ``` + +4. Run the workload test with specified cache: + ``` +./bin/ycsb run infinispan-cs -s -P workloads/workloada -P infinispan-binding/conf/remote-cache.properties -p cache=<cache name> + ``` \ No newline at end of file diff --git a/infinispan/pom.xml b/infinispan/pom.xml index d7e0fe09fce1e25a4157faa7ee70f2f0c870d72e..b0577e8325445e0b405c414c4c4852c26e8e360e 100644 --- a/infinispan/pom.xml +++ b/infinispan/pom.xml @@ -14,8 +14,13 @@ <dependencies> <dependency> - <groupId>org.jboss.as</groupId> - <artifactId>jboss-as-clustering-infinispan</artifactId> + <groupId>org.infinispan</groupId> + <artifactId>infinispan-client-hotrod</artifactId> + <version>${infinispan.version}</version> + </dependency> + <dependency> + <groupId>org.infinispan</groupId> + <artifactId>infinispan-core</artifactId> <version>${infinispan.version}</version> </dependency> <dependency> diff --git a/infinispan/src/main/conf/remote-cache.properties b/infinispan/src/main/conf/remote-cache.properties new file mode 100644 index 0000000000000000000000000000000000000000..04e50054dab7267c0bfeea1f4b662cfb7cbe31c3 --- /dev/null +++ b/infinispan/src/main/conf/remote-cache.properties @@ -0,0 +1,9 @@ +infinispan.client.hotrod.server_list=192.168.101.17:11222 +infinispan.client.hotrod.force_return_values=false + +maxActive=-1 +maxIdle=-1 +minIdle=1 +maxTotal=-1 + +whenExhaustedAction=1 diff --git a/infinispan/src/main/java/com/yahoo/ycsb/db/InfinispanRemoteClient.java b/infinispan/src/main/java/com/yahoo/ycsb/db/InfinispanRemoteClient.java new file mode 100644 index 0000000000000000000000000000000000000000..f670357ad014534d69c5b451c321b8a58ff4462e --- /dev/null +++ b/infinispan/src/main/java/com/yahoo/ycsb/db/InfinispanRemoteClient.java @@ -0,0 +1,128 @@ +package com.yahoo.ycsb.db; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.infinispan.client.hotrod.RemoteCache; +import org.infinispan.client.hotrod.RemoteCacheManager; +import org.infinispan.util.logging.Log; +import org.infinispan.util.logging.LogFactory; + +import com.yahoo.ycsb.ByteIterator; +import com.yahoo.ycsb.DB; +import com.yahoo.ycsb.DBException; +import com.yahoo.ycsb.StringByteIterator; + +/** + * This is a client implementation for Infinispan 5.x in client-server mode. + * + * @author mylesjao + * + */ +public class InfinispanRemoteClient extends DB { + + private RemoteCacheManager remoteIspnManager; + + private String cacheName = null; + + private static final Log logger = LogFactory.getLog(InfinispanRemoteClient.class); + + public InfinispanRemoteClient() { + + } + + @Override + public void init() throws DBException { + remoteIspnManager = RemoteCacheManagerHolder.getInstance(getProperties()); + cacheName = getProperties().getProperty("cache"); + } + + @Override + public void cleanup() { + remoteIspnManager.stop(); + remoteIspnManager = null; + } + + @Override + public int insert(String table, String recordKey, HashMap<String, ByteIterator> values) { + String compositKey = createKey(table, recordKey); + Map<String, String> stringValues = new HashMap<String,String>(); + StringByteIterator.putAllAsStrings(stringValues, values); + try { + cache().put(compositKey, stringValues); + return Status.OK; + } catch (Exception e) { + return Status.ERROR; + } + } + + @Override + public int read(String table, String recordKey, Set<String> fields, HashMap<String, ByteIterator> result) { + String compositKey = createKey(table, recordKey); + try { + Map<String, String> values = cache().get(compositKey); + + if(values == null || values.isEmpty()){ + return Status.NOT_FOUND; + } + + if(fields == null){ //get all field/value pairs + StringByteIterator.putAllAsByteIterators(result, values); + }else{ + for(String field: fields){ + String value = values.get(field); + if(value != null){ + result.put(field, new StringByteIterator(value) ); + } + } + } + + return Status.OK; + } catch (Exception e) { + return Status.ERROR; + } + } + + @Override + public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { + logger.warn("Infinispan does not support scan semantics"); + return Status.NOT_SUPPORT; + } + + @Override + public int update(String table, String recordKey, HashMap<String, ByteIterator> values) { + String compositKey = createKey(table, recordKey); + try { + Map<String, String> stringValues = new HashMap<String, String>(); + StringByteIterator.putAllAsStrings(stringValues, values); + cache().put(compositKey, stringValues); + return Status.OK; + } catch (Exception e) { + return Status.ERROR; + } + } + @Override + public int delete(String table, String recordKey) { + String compositKey = createKey(table, recordKey); + try { + cache().remove(compositKey); + return Status.OK; + } catch (Exception e) { + return Status.ERROR; + } + } + + private RemoteCache<String, Map<String,String>> cache(){ + if(this.cacheName != null){ + return remoteIspnManager.getCache(cacheName); + }else{ + return remoteIspnManager.getCache(); + } + } + + private String createKey(String table, String recordKey){ + return table + "-" + recordKey; + } +} diff --git a/infinispan/src/main/java/com/yahoo/ycsb/db/RemoteCacheManagerHolder.java b/infinispan/src/main/java/com/yahoo/ycsb/db/RemoteCacheManagerHolder.java new file mode 100644 index 0000000000000000000000000000000000000000..ffdc9371b4fda49d16d8d5be947d2857d2d772af --- /dev/null +++ b/infinispan/src/main/java/com/yahoo/ycsb/db/RemoteCacheManagerHolder.java @@ -0,0 +1,25 @@ +package com.yahoo.ycsb.db; + +import java.util.Properties; + +import org.infinispan.client.hotrod.RemoteCacheManager; + +public class RemoteCacheManagerHolder { + + private static volatile RemoteCacheManager cacheManager = null; + + private RemoteCacheManagerHolder() {} + + public static RemoteCacheManager getInstance(Properties props){ + RemoteCacheManager result = cacheManager; + if(result == null){ + synchronized (RemoteCacheManagerHolder.class) { + result = cacheManager; + if (result == null) { + cacheManager = result = new RemoteCacheManager(props); + } + } + } + return result; + } +} diff --git a/infinispan/src/main/java/com/yahoo/ycsb/db/Status.java b/infinispan/src/main/java/com/yahoo/ycsb/db/Status.java new file mode 100644 index 0000000000000000000000000000000000000000..661dc72376e9a27ab41adeaae680ef7a15f289e2 --- /dev/null +++ b/infinispan/src/main/java/com/yahoo/ycsb/db/Status.java @@ -0,0 +1,9 @@ +package com.yahoo.ycsb.db; + +public class Status { + public static final int OK = 0; + public static final int ERROR = 1; + public static final int NOT_FOUND = 2; + public static final int CONFLICT = 3; + public static final int NOT_SUPPORT = 4; +} diff --git a/pom.xml b/pom.xml index 50979d3fd59897bb0052a50778ece1068e081de7..799c0b2bef31fc9050e62c3185af6059d63747ca 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ <cassandra.version>1.2.9</cassandra.version> <cassandra.cql.version>1.0.3</cassandra.cql.version> <gemfire.version>8.1.0</gemfire.version> - <infinispan.version>7.1.0.CR1</infinispan.version> + <infinispan.version>7.2.2.Final</infinispan.version> <openjpa.jdbc.version>2.1.1</openjpa.jdbc.version> <!--<mapkeeper.version>1.0</mapkeeper.version>--> <mongodb.version>3.0.2</mongodb.version>