Skip to content
Snippets Groups Projects
Commit 6fddd7cf authored by charliemblack's avatar charliemblack Committed by Sean Busbey
Browse files

[geode] Update to Apache Geode version 1.0.0-incubating.M3 (#828)

[geode] Update to Apache Geode version 1.0.0-incubating.M3
parent 8c39cdff
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ Start a locator and two servers: ...@@ -42,6 +42,7 @@ Start a locator and two servers:
gfsh> start locator --name=locator1 gfsh> start locator --name=locator1
gfsh> start server --name=server1 --server-port=40404 gfsh> start server --name=server1 --server-port=40404
gfsh> start server --name=server2 --server-port=40405 gfsh> start server --name=server2 --server-port=40405
gfsh> configure pdx --read-serialized=true
``` ```
Create the "usertable" region required by YCSB driver: Create the "usertable" region required by YCSB driver:
......
...@@ -23,6 +23,10 @@ import com.gemstone.gemfire.cache.client.ClientCacheFactory; ...@@ -23,6 +23,10 @@ import com.gemstone.gemfire.cache.client.ClientCacheFactory;
import com.gemstone.gemfire.cache.client.ClientRegionFactory; import com.gemstone.gemfire.cache.client.ClientRegionFactory;
import com.gemstone.gemfire.cache.client.ClientRegionShortcut; import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId; import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.pdx.JSONFormatter;
import com.gemstone.gemfire.pdx.PdxInstance;
import com.gemstone.gemfire.pdx.PdxInstanceFactory;
import com.yahoo.ycsb.*; import com.yahoo.ycsb.*;
import java.util.*; import java.util.*;
...@@ -36,42 +40,55 @@ import java.util.*; ...@@ -36,42 +40,55 @@ import java.util.*;
* geode.serverhost=host</code> properties on YCSB command line. * geode.serverhost=host</code> properties on YCSB command line.
* A locator may also be used for discovering a cacheServer * A locator may also be used for discovering a cacheServer
* by using the property <code>geode.locator=host[port]</code></p> * by using the property <code>geode.locator=host[port]</code></p>
* * <p>
* <p>To run this client in a peer-to-peer topology with other Geode * <p>To run this client in a peer-to-peer topology with other Geode
* nodes, use the property <code>geode.topology=p2p</code>. Running * nodes, use the property <code>geode.topology=p2p</code>. Running
* in p2p mode will enable embedded caching in this client.</p> * in p2p mode will enable embedded caching in this client.</p>
* * <p>
* <p>YCSB by default does its operations against "usertable". When running * <p>YCSB by default does its operations against "usertable". When running
* as a client this is a <code>ClientRegionShortcut.PROXY</code> region, * as a client this is a <code>ClientRegionShortcut.PROXY</code> region,
* when running in p2p mode it is a <code>RegionShortcut.PARTITION</code> * when running in p2p mode it is a <code>RegionShortcut.PARTITION</code>
* region. A cache.xml defining "usertable" region can be placed in the * region. A cache.xml defining "usertable" region can be placed in the
* working directory to override these region definitions.</p> * working directory to override these region definitions.</p>
*
*/ */
public class GeodeClient extends DB { public class GeodeClient extends DB {
/** property name of the port where Geode server is listening for connections. */ /**
* property name of the port where Geode server is listening for connections.
*/
private static final String SERVERPORT_PROPERTY_NAME = "geode.serverport"; private static final String SERVERPORT_PROPERTY_NAME = "geode.serverport";
/** property name of the host where Geode server is running. */ /**
* property name of the host where Geode server is running.
*/
private static final String SERVERHOST_PROPERTY_NAME = "geode.serverhost"; private static final String SERVERHOST_PROPERTY_NAME = "geode.serverhost";
/** default value of {@link #SERVERHOST_PROPERTY_NAME}. */ /**
* default value of {@link #SERVERHOST_PROPERTY_NAME}.
*/
private static final String SERVERHOST_PROPERTY_DEFAULT = "localhost"; private static final String SERVERHOST_PROPERTY_DEFAULT = "localhost";
/** property name to specify a Geode locator. This property can be used in both /**
* client server and p2p topology */ * property name to specify a Geode locator. This property can be used in both
* client server and p2p topology
*/
private static final String LOCATOR_PROPERTY_NAME = "geode.locator"; private static final String LOCATOR_PROPERTY_NAME = "geode.locator";
/** property name to specify Geode topology. */ /**
* property name to specify Geode topology.
*/
private static final String TOPOLOGY_PROPERTY_NAME = "geode.topology"; private static final String TOPOLOGY_PROPERTY_NAME = "geode.topology";
/** value of {@value #TOPOLOGY_PROPERTY_NAME} when peer to peer topology should be used. /**
* (client-server topology is default) */ * value of {@value #TOPOLOGY_PROPERTY_NAME} when peer to peer topology should be used.
* (client-server topology is default)
*/
private static final String TOPOLOGY_P2P_VALUE = "p2p"; private static final String TOPOLOGY_P2P_VALUE = "p2p";
private GemFireCache cache; private GemFireCache cache;
/** true if ycsb client runs as a client to a Geode cache server. */ /**
* true if ycsb client runs as a client to a Geode cache server.
*/
private boolean isClient; private boolean isClient;
@Override @Override
...@@ -119,16 +136,16 @@ public class GeodeClient extends DB { ...@@ -119,16 +136,16 @@ public class GeodeClient extends DB {
@Override @Override
public Status read(String table, String key, Set<String> fields, public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) { HashMap<String, ByteIterator> result) {
Region<String, Map<String, byte[]>> r = getRegion(table); Region<String, PdxInstance> r = getRegion(table);
Map<String, byte[]> val = r.get(key); PdxInstance val = r.get(key);
if (val != null) { if (val != null) {
if (fields == null) { if (fields == null) {
for (Map.Entry<String, byte[]> entry : val.entrySet()) { for (String fieldName : val.getFieldNames()) {
result.put(entry.getKey(), new ByteArrayByteIterator(entry.getValue())); result.put(fieldName, new ByteArrayByteIterator((byte[]) val.getField(fieldName)));
} }
} else { } else {
for (String field : fields) { for (String field : fields) {
result.put(field, new ByteArrayByteIterator(val.get(field))); result.put(field, new ByteArrayByteIterator((byte[]) val.getField(field)));
} }
} }
return Status.OK; return Status.OK;
...@@ -161,24 +178,26 @@ public class GeodeClient extends DB { ...@@ -161,24 +178,26 @@ public class GeodeClient extends DB {
return Status.OK; return Status.OK;
} }
private Map<String, byte[]> convertToBytearrayMap(Map<String, ByteIterator> values) { private PdxInstance convertToBytearrayMap(Map<String, ByteIterator> values) {
Map<String, byte[]> retVal = new HashMap<String, byte[]>(); GemFireCacheImpl gci = (GemFireCacheImpl) CacheFactory.getAnyInstance();
PdxInstanceFactory pdxInstanceFactory = gci.createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME);
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
retVal.put(entry.getKey(), entry.getValue().toArray()); pdxInstanceFactory.writeByteArray(entry.getKey(), entry.getValue().toArray());
} }
return retVal; return pdxInstanceFactory.create();
} }
private Region<String, Map<String, byte[]>> getRegion(String table) { private Region<String, PdxInstance> getRegion(String table) {
Region<String, Map<String, byte[]>> r = cache.getRegion(table); Region<String, PdxInstance> r = cache.getRegion(table);
if (r == null) { if (r == null) {
try { try {
if (isClient) { if (isClient) {
ClientRegionFactory<String, Map<String, byte[]>> crf = ClientRegionFactory<String, PdxInstance> crf =
((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY); ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY);
r = crf.create(table); r = crf.create(table);
} else { } else {
RegionFactory<String, Map<String, byte[]>> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARTITION); RegionFactory<String, PdxInstance> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARTITION);
r = rf.create(table); r = rf.create(table);
} }
} catch (RegionExistsException e) { } catch (RegionExistsException e) {
......
...@@ -74,7 +74,7 @@ LICENSE file. ...@@ -74,7 +74,7 @@ LICENSE file.
<hbase10.version>1.0.2</hbase10.version> <hbase10.version>1.0.2</hbase10.version>
<accumulo.version>1.6.0</accumulo.version> <accumulo.version>1.6.0</accumulo.version>
<cassandra.cql.version>3.0.0</cassandra.cql.version> <cassandra.cql.version>3.0.0</cassandra.cql.version>
<geode.version>1.0.0-incubating.M2</geode.version> <geode.version>1.0.0-incubating.M3</geode.version>
<googlebigtable.version>0.2.3</googlebigtable.version> <googlebigtable.version>0.2.3</googlebigtable.version>
<infinispan.version>7.2.2.Final</infinispan.version> <infinispan.version>7.2.2.Final</infinispan.version>
<kudu.version>0.9.0</kudu.version> <kudu.version>0.9.0</kudu.version>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment