From fa281eb5bbffae3e105cdd4e2faf082d0cd94323 Mon Sep 17 00:00:00 2001 From: "Robert J. Moore" Date: Sun, 8 Nov 2015 14:22:39 -0500 Subject: [PATCH] [geode] Checkstyle updates for Apache Geode (incubating) --- geode/pom.xml | 24 +++++++ .../java/com/yahoo/ycsb/db/GeodeClient.java | 72 +++++++------------ .../java/com/yahoo/ycsb/db/package-info.java | 21 ++++++ 3 files changed, 72 insertions(+), 45 deletions(-) create mode 100644 geode/src/main/java/com/yahoo/ycsb/db/package-info.java diff --git a/geode/pom.xml b/geode/pom.xml index fa36bbd53c..6d614cdf17 100644 --- a/geode/pom.xml +++ b/geode/pom.xml @@ -46,5 +46,29 @@ LICENSE file. provided + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.15 + + true + ../checkstyle.xml + true + true + + + + validate + validate + + checkstyle + + + + + + 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 cdbfc96189..f6bcc01a92 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. - * + *

* 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 @@ -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.
+ * Apache Geode (incubating) client for the YCSB benchmark.
*

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 @@ * geode.serverhost=host properties on YCSB command line. * A locator may also be used for discovering a cacheServer * by using the property geode.locator=host[port]

- * + * *

To run this client in a peer-to-peer topology with other Geode * nodes, use the property geode.topology=p2p. Running * in p2p mode will enable embedded caching in this client.

- * + * *

YCSB by default does its operations against "usertable". When running * as a client this is a ClientRegionShortcut.PROXY region, * when running in p2p mode it is a RegionShortcut.PARTITION * region. A cache.xml defining "usertable" region can be placed in the * working directory to override these region definitions.

- * + * */ 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 void init() throws DBException { } 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 void init() throws DBException { } cache = ccf.create(); } - + @Override public Status read(String table, String key, Set fields, - HashMap result) { + HashMap result) { Region> r = getRegion(table); Map val = r.get(key); if (val != null) { @@ -156,7 +138,7 @@ public Status read(String table, String key, Set fields, @Override public Status scan(String table, String startkey, int recordcount, - Set fields, Vector> result) { + Set fields, Vector> result) { // Geode does not support scan return Status.ERROR; } @@ -179,23 +161,24 @@ public Status delete(String table, String key) { return Status.OK; } - private Map convertToBytearrayMap(Map values) { + private Map convertToBytearrayMap(Map values) { Map retVal = new HashMap(); for (Map.Entry entry : values.entrySet()) { retVal.put(entry.getKey(), entry.getValue().toArray()); } return retVal; } - + private Region> getRegion(String table) { Region> r = cache.getRegion(table); if (r == null) { try { if (isClient) { - ClientRegionFactory> crf = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY); + ClientRegionFactory> crf = + ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY); r = crf.create(table); } else { - RegionFactory> rf = ((Cache)cache).createRegionFactory(RegionShortcut.PARTITION); + RegionFactory> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARTITION); r = rf.create(table); } } catch (RegionExistsException e) { @@ -205,5 +188,4 @@ private Region> getRegion(String table) { } 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 0000000000..1b6db476ef --- /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 Apache Geode (incubating). + */ +package com.yahoo.ycsb.db; \ No newline at end of file