Skip to content
Snippets Groups Projects
Commit 280a2d18 authored by Sean Busbey's avatar Sean Busbey
Browse files

Merge pull request #648 from risdenk/pr-483

[geode] Checkstyle updates for Apache Geode (incubating)
parents f23aa0ec fa281eb5
No related branches found
No related tags found
No related merge requests found
...@@ -46,5 +46,29 @@ LICENSE file. ...@@ -46,5 +46,29 @@ LICENSE file.
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>../checkstyle.xml</configLocation>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
/** /**
* Copyright (c) 2013 - 2016 YCSB Contributors. All rights reserved. * Copyright (c) 2013 - 2016 YCSB Contributors. All rights reserved.
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you * Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You * may not use this file except in compliance with the License. You
* may obtain a copy of the License at * may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
...@@ -17,32 +17,18 @@ ...@@ -17,32 +17,18 @@
package com.yahoo.ycsb.db; package com.yahoo.ycsb.db;
import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.*;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionExistsException;
import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.RegionShortcut;
import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory; 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.yahoo.ycsb.ByteArrayByteIterator; import com.yahoo.ycsb.*;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DB; import java.util.*;
import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.Status;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
/** /**
* Apache Geode (incubating) client for the YCSB benchmark.<br /> * Apache Geode (incubating) client for the YCSB benchmark.<br />
* <p>By default acts as a Geode client and tries to connect * <p>By default acts as a Geode client and tries to connect
* to Geode cache server running on localhost with default * to Geode cache server running on localhost with default
* cache server port. Hostname and port of a Geode cacheServer * cache server port. Hostname and port of a Geode cacheServer
...@@ -50,34 +36,33 @@ import java.util.Vector; ...@@ -50,34 +36,33 @@ import java.util.Vector;
* 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>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>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 /** property name to specify a Geode locator. This property can be used in both
* client server and p2p topology */ * 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. /** value of {@value #TOPOLOGY_PROPERTY_NAME} when peer to peer topology should be used.
...@@ -86,12 +71,9 @@ public class GeodeClient extends DB { ...@@ -86,12 +71,9 @@ public class GeodeClient extends DB {
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
public void init() throws DBException { public void init() throws DBException {
Properties props = getProperties(); Properties props = getProperties();
...@@ -108,7 +90,7 @@ public class GeodeClient extends DB { ...@@ -108,7 +90,7 @@ public class GeodeClient extends DB {
} }
serverHost = props.getProperty(SERVERHOST_PROPERTY_NAME, SERVERHOST_PROPERTY_DEFAULT); serverHost = props.getProperty(SERVERHOST_PROPERTY_NAME, SERVERHOST_PROPERTY_DEFAULT);
locatorStr = props.getProperty(LOCATOR_PROPERTY_NAME); locatorStr = props.getProperty(LOCATOR_PROPERTY_NAME);
String topology = props.getProperty(TOPOLOGY_PROPERTY_NAME); String topology = props.getProperty(TOPOLOGY_PROPERTY_NAME);
if (topology != null && topology.equals(TOPOLOGY_P2P_VALUE)) { if (topology != null && topology.equals(TOPOLOGY_P2P_VALUE)) {
CacheFactory cf = new CacheFactory(); CacheFactory cf = new CacheFactory();
...@@ -133,10 +115,10 @@ public class GeodeClient extends DB { ...@@ -133,10 +115,10 @@ public class GeodeClient extends DB {
} }
cache = ccf.create(); cache = ccf.create();
} }
@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, Map<String, byte[]>> r = getRegion(table);
Map<String, byte[]> val = r.get(key); Map<String, byte[]> val = r.get(key);
if (val != null) { if (val != null) {
...@@ -156,7 +138,7 @@ public class GeodeClient extends DB { ...@@ -156,7 +138,7 @@ public class GeodeClient extends DB {
@Override @Override
public Status scan(String table, String startkey, int recordcount, public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
// Geode does not support scan // Geode does not support scan
return Status.ERROR; return Status.ERROR;
} }
...@@ -179,23 +161,24 @@ public class GeodeClient extends DB { ...@@ -179,23 +161,24 @@ public class GeodeClient extends DB {
return Status.OK; return Status.OK;
} }
private Map<String, byte[]> convertToBytearrayMap(Map<String,ByteIterator> values) { private Map<String, byte[]> convertToBytearrayMap(Map<String, ByteIterator> values) {
Map<String, byte[]> retVal = new HashMap<String, byte[]>(); Map<String, byte[]> retVal = new HashMap<String, byte[]>();
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
retVal.put(entry.getKey(), entry.getValue().toArray()); retVal.put(entry.getKey(), entry.getValue().toArray());
} }
return retVal; return retVal;
} }
private Region<String, Map<String, byte[]>> getRegion(String table) { private Region<String, Map<String, byte[]>> getRegion(String table) {
Region<String, Map<String, byte[]>> r = cache.getRegion(table); Region<String, Map<String, byte[]>> r = cache.getRegion(table);
if (r == null) { if (r == null) {
try { try {
if (isClient) { if (isClient) {
ClientRegionFactory<String, Map<String, byte[]>> crf = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY); ClientRegionFactory<String, Map<String, byte[]>> crf =
((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, Map<String, byte[]>> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARTITION);
r = rf.create(table); r = rf.create(table);
} }
} catch (RegionExistsException e) { } catch (RegionExistsException e) {
...@@ -205,5 +188,4 @@ public class GeodeClient extends DB { ...@@ -205,5 +188,4 @@ public class GeodeClient extends DB {
} }
return r; return r;
} }
}
} \ No newline at end of file
/*
* Copyright (c) 2014-2016, Yahoo!, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
/**
* YCSB binding for <a href="https://geode.incubator.apache.org/">Apache Geode (incubating)</a>.
*/
package com.yahoo.ycsb.db;
\ No newline at end of file
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