Skip to content

Commit

Permalink
[core] Fix checkstyle for CoreWorkload (brianfrankcooper#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
risdenk authored Jan 31, 2017
1 parent 7fa8331 commit a564c4c
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.Status;

import static com.yahoo.ycsb.workloads.CoreWorkload.TABLENAME_PROPERTY;
import static com.yahoo.ycsb.workloads.CoreWorkload.TABLENAME_PROPERTY_DEFAULT;

/**
* Alternative Java client for Apache HBase.
*
Expand Down Expand Up @@ -140,7 +143,7 @@ public void init() throws DBException {
// Terminate right now if table does not exist, since the client
// will not propagate this error upstream once the workload
// starts.
String table = com.yahoo.ycsb.workloads.CoreWorkload.table;
String table = getProperties().getProperty(TABLENAME_PROPERTY, TABLENAME_PROPERTY_DEFAULT);
try {
client.ensureTableExists(table).join(joinTimeout);
} catch (InterruptedException e1) {
Expand Down
17 changes: 10 additions & 7 deletions asynchbase/src/test/java/com/yahoo/ycsb/db/AsyncHBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.yahoo.ycsb.db;

import static com.yahoo.ycsb.workloads.CoreWorkload.TABLENAME_PROPERTY;
import static com.yahoo.ycsb.workloads.CoreWorkload.TABLENAME_PROPERTY_DEFAULT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -25,7 +27,6 @@
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.Status;
import com.yahoo.ycsb.StringByteIterator;
import com.yahoo.ycsb.db.AsyncHBaseClient;
import com.yahoo.ycsb.measurements.Measurements;
import com.yahoo.ycsb.workloads.CoreWorkload;

Expand Down Expand Up @@ -61,6 +62,7 @@ public class AsyncHBaseTest {
private static HBaseTestingUtility testingUtil;
private AsyncHBaseClient client;
private Table table = null;
private String tableName;

private static boolean isWindows() {
final String os = System.getProperty("os.name");
Expand Down Expand Up @@ -105,7 +107,8 @@ public void setUp() throws Exception {
final CoreWorkload workload = new CoreWorkload();
workload.init(p);

table = testingUtil.createTable(TableName.valueOf(CoreWorkload.table), Bytes.toBytes(COLUMN_FAMILY));
tableName = p.getProperty(TABLENAME_PROPERTY, TABLENAME_PROPERTY_DEFAULT);
table = testingUtil.createTable(TableName.valueOf(tableName), Bytes.toBytes(COLUMN_FAMILY));

final String zkQuorum = "127.0.0.1:" + testingUtil.getZkCluster().getClientPort();
p.setProperty("hbase.zookeeper.quorum", zkQuorum);
Expand All @@ -117,7 +120,7 @@ public void setUp() throws Exception {
@After
public void tearDown() throws Exception {
table.close();
testingUtil.deleteTable(CoreWorkload.table);
testingUtil.deleteTable(tableName);
}

@Test
Expand All @@ -131,7 +134,7 @@ public void testRead() throws Exception {
table.put(p);

final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(CoreWorkload.table, rowKey, null, result);
final Status status = client.read(tableName, rowKey, null, result);
assertEquals(Status.OK, status);
assertEquals(2, result.size());
assertEquals("value1", result.get("column1").toString());
Expand All @@ -141,7 +144,7 @@ public void testRead() throws Exception {
@Test
public void testReadMissingRow() throws Exception {
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(CoreWorkload.table, "Missing row", null, result);
final Status status = client.read(tableName, "Missing row", null, result);
assertEquals(Status.NOT_FOUND, status);
assertEquals(0, result.size());
}
Expand All @@ -167,7 +170,7 @@ public void testScan() throws Exception {
new Vector<HashMap<String, ByteIterator>>();

// Scan 5 records, skipping the first
client.scan(CoreWorkload.table, "00001", 5, null, result);
client.scan(tableName, "00001", 5, null, result);

assertEquals(5, result.size());
for(int i = 0; i < 5; i++) {
Expand All @@ -187,7 +190,7 @@ public void testUpdate() throws Exception{
final HashMap<String, String> input = new HashMap<String, String>();
input.put("column1", "value1");
input.put("column2", "value2");
final Status status = client.insert(CoreWorkload.table, key, StringByteIterator.getByteIteratorMap(input));
final Status status = client.insert(tableName, key, StringByteIterator.getByteIteratorMap(input));
assertEquals(Status.OK, status);

// Verify result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testRead() throws Exception {
insertRow();

final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(CoreWorkload.table, DEFAULT_ROW_KEY, null, result);
final Status status = client.read(TABLE, DEFAULT_ROW_KEY, null, result);
assertThat(status, is(Status.OK));
assertThat(result.entrySet(), hasSize(11));
assertThat(result, hasEntry("field2", null));
Expand All @@ -147,7 +147,7 @@ public void testReadSingleColumn() throws Exception {
insertRow();
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Set<String> fields = Sets.newHashSet("field1");
final Status status = client.read(CoreWorkload.table, DEFAULT_ROW_KEY, fields, result);
final Status status = client.read(TABLE, DEFAULT_ROW_KEY, fields, result);
assertThat(status, is(Status.OK));
assertThat(result.entrySet(), hasSize(1));
final Map<String, String> strResult = StringByteIterator.getStringMap(result);
Expand Down
4 changes: 3 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ LICENSE file.
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
</module>


<!-- Miscellaneous other checks. -->
Expand Down
Loading

0 comments on commit a564c4c

Please sign in to comment.