diff --git a/geode/pom.xml b/geode/pom.xml index fa36bbd53c1ea2f05f546f124f189dd210928c4e..6d614cdf17e4e2c5a6b1f780799e6f71f215da29 100644 --- a/geode/pom.xml +++ b/geode/pom.xml @@ -46,5 +46,29 @@ LICENSE file. <scope>provided</scope> </dependency> </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> diff --git a/geode/src/main/java/com/yahoo/ycsb/db/GeodeClient.java b/geode/src/main/java/com/yahoo/ycsb/db/GeodeClient.java index cdbfc96189ed635219e37bf28f2db960ef7eb43f..f6bcc01a92ad385202e2950706b605bd0e5212b5 100644 --- a/geode/src/main/java/com/yahoo/ycsb/db/GeodeClient.java +++ b/geode/src/main/java/com/yahoo/ycsb/db/GeodeClient.java @@ -1,12 +1,12 @@ /** * Copyright (c) 2013 - 2016 YCSB Contributors. All rights reserved. - * + * <p> * 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 - * + * <p> * http://www.apache.org/licenses/LICENSE-2.0 - * + * <p> * 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 @@ -17,32 +17,18 @@ package com.yahoo.ycsb.db; -import com.gemstone.gemfire.cache.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.*; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.ClientRegionFactory; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId; -import com.yahoo.ycsb.ByteArrayByteIterator; -import com.yahoo.ycsb.ByteIterator; -import com.yahoo.ycsb.DB; -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; +import com.yahoo.ycsb.*; + +import java.util.*; /** - * 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 * to Geode cache server running on localhost with default * cache server port. Hostname and port of a Geode cacheServer @@ -50,34 +36,33 @@ import java.util.Vector; * geode.serverhost=host</code> properties on YCSB command line. * A locator may also be used for discovering a cacheServer * 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 * nodes, use the property <code>geode.topology=p2p</code>. Running * in p2p mode will enable embedded caching in this client.</p> - * + * * <p>YCSB by default does its operations against "usertable". When running * as a client this is a <code>ClientRegionShortcut.PROXY</code> region, * when running in p2p mode it is a <code>RegionShortcut.PARTITION</code> * region. A cache.xml defining "usertable" region can be placed in the * working directory to override these region definitions.</p> - * + * */ 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"; - /** 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"; - /** default value of {@link #SERVERHOST_PROPERTY_NAME} */ + /** default value of {@link #SERVERHOST_PROPERTY_NAME}. */ 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 */ 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"; /** value of {@value #TOPOLOGY_PROPERTY_NAME} when peer to peer topology should be used. @@ -86,12 +71,9 @@ public class GeodeClient extends DB { 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; - + @Override public void init() throws DBException { Properties props = getProperties(); @@ -108,7 +90,7 @@ public class GeodeClient extends DB { } serverHost = props.getProperty(SERVERHOST_PROPERTY_NAME, SERVERHOST_PROPERTY_DEFAULT); locatorStr = props.getProperty(LOCATOR_PROPERTY_NAME); - + String topology = props.getProperty(TOPOLOGY_PROPERTY_NAME); if (topology != null && topology.equals(TOPOLOGY_P2P_VALUE)) { CacheFactory cf = new CacheFactory(); @@ -133,10 +115,10 @@ public class GeodeClient extends DB { } cache = ccf.create(); } - + @Override 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); Map<String, byte[]> val = r.get(key); if (val != null) { @@ -156,7 +138,7 @@ public class GeodeClient extends DB { @Override 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 return Status.ERROR; } @@ -179,23 +161,24 @@ public class GeodeClient extends DB { 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[]>(); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { retVal.put(entry.getKey(), entry.getValue().toArray()); } return retVal; } - + private Region<String, Map<String, byte[]>> getRegion(String table) { Region<String, Map<String, byte[]>> r = cache.getRegion(table); if (r == null) { try { 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); } 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); } } catch (RegionExistsException e) { @@ -205,5 +188,4 @@ public class GeodeClient extends DB { } return r; } - -} +} \ No newline at end of file diff --git a/geode/src/main/java/com/yahoo/ycsb/db/package-info.java b/geode/src/main/java/com/yahoo/ycsb/db/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..1b6db476efe15b518a452d6b7cc06432fd1a267d --- /dev/null +++ b/geode/src/main/java/com/yahoo/ycsb/db/package-info.java @@ -0,0 +1,21 @@ +/* + * 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