You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by oh...@apache.org on 2018/09/16 08:23:05 UTC
[1/4] incubator-omid git commit: OMID-107 Replace pre 1.0 deprecated
HBase APIs
Repository: incubator-omid
Updated Branches:
refs/heads/phoenix-integration 81672f016 -> 75dc81775
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-tools/src/main/java/org/apache/omid/tools/hbase/OmidTableManager.java
----------------------------------------------------------------------
diff --git a/hbase-tools/src/main/java/org/apache/omid/tools/hbase/OmidTableManager.java b/hbase-tools/src/main/java/org/apache/omid/tools/hbase/OmidTableManager.java
index 126cb99..8e25530 100644
--- a/hbase-tools/src/main/java/org/apache/omid/tools/hbase/OmidTableManager.java
+++ b/hbase-tools/src/main/java/org/apache/omid/tools/hbase/OmidTableManager.java
@@ -17,18 +17,16 @@
*/
package org.apache.omid.tools.hbase;
-import com.beust.jcommander.IParameterValidator;
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.ParameterException;
-import com.beust.jcommander.Parameters;
-import com.beust.jcommander.ParametersDelegate;
+import java.io.IOException;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.HBaseShims;
import org.apache.omid.committable.hbase.HBaseCommitTableConfig;
@@ -39,7 +37,12 @@ import org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
+import com.beust.jcommander.IParameterValidator;
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.ParameterException;
+import com.beust.jcommander.Parameters;
+import com.beust.jcommander.ParametersDelegate;
/**
* Helper class to create required HBase tables by Omid
@@ -78,7 +81,8 @@ public class OmidTableManager {
HBaseLogin.loginIfNeeded(mainConfig.loginFlags);
- try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) {
+ try (Connection conn = ConnectionFactory.createConnection(hbaseConf);
+ Admin hBaseAdmin = conn.getAdmin()) {
byte[][] tableFamilies;
byte[][] splitKeys = new byte[0][0];
String tableName;
@@ -134,13 +138,14 @@ public class OmidTableManager {
}
- private static void createTable(HBaseAdmin admin, String tableName, byte[][] families, byte[][] splitKeys,
+ private static void createTable(Admin admin, String tableName, byte[][] families, byte[][] splitKeys,
int maxVersions)
throws IOException {
LOG.info("About to create Table named {} with {} splits", tableName, splitKeys.length);
- if (admin.tableExists(tableName)) {
+ TableName hTableName = TableName.valueOf(tableName);
+ if (admin.tableExists(hTableName)) {
LOG.error("Table {} already exists. Table creation cancelled", tableName);
return;
}
@@ -156,7 +161,7 @@ public class OmidTableManager {
admin.createTable(tableDescriptor, splitKeys);
- LOG.info("Table {} created. Regions: {}", tableName, admin.getTableRegions(Bytes.toBytes(tableName)).size());
+ LOG.info("Table {} created. Regions: {}", tableName, admin.getTableRegions(hTableName).size());
}
@@ -191,6 +196,7 @@ public class OmidTableManager {
public static class IntegerGreaterThanZero implements IParameterValidator {
+ @Override
public void validate(String name, String value) throws ParameterException {
int n = Integer.parseInt(value);
if (n <= 0) {
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fb53b9d..0a1910e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,7 +135,7 @@
<!-- 3rd-Party Library Versioning -->
<hbase0.version>0.98.10.1-hadoop1</hbase0.version>
- <hbase1.version>1.1.1</hbase1.version>
+ <hbase1.version>1.2.5</hbase1.version>
<guava.version>14.0.1</guava.version>
<guice.version>3.0</guice.version>
<testng.version>6.10</testng.version>
@@ -150,7 +150,7 @@
<commons.conf.version>1.10</commons.conf.version>
<hamcrest.version>1.3</hamcrest.version>
<curator.version>2.6.0</curator.version>
- <zookeeper.version>3.4.3</zookeeper.version>
+ <zookeeper.version>3.4.9</zookeeper.version>
<snakeyaml.version>1.11</snakeyaml.version>
<beanutils.version>1.8.3</beanutils.version>
<commons-io.version>2.4</commons-io.version>
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
index dc4246a..a33c9dd 100644
--- a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
@@ -17,20 +17,24 @@
*/
package org.apache.omid.timestamp.storage;
+import static com.google.common.base.Charsets.UTF_8;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.inject.Inject;
-import java.io.IOException;
-
-import static com.google.common.base.Charsets.UTF_8;
-
/**
* Stores the max timestamp assigned by the TO in HBase.
* It's always written non-transactionally in the same row and column
@@ -45,12 +49,13 @@ public class HBaseTimestampStorage implements TimestampStorage {
private static final byte[] TSO_ROW = "MAX_TIMESTAMP_R".getBytes(UTF_8);
private static final byte[] TSO_QUALIFIER = "MAX_TIMESTAMP_Q".getBytes(UTF_8);
- private final HTable table;
+ private final Table table;
private final byte[] cfName;
@Inject
public HBaseTimestampStorage(Configuration hbaseConfig, HBaseTimestampStorageConfig config) throws IOException {
- this.table = new HTable(hbaseConfig, config.getTableName());
+ Connection conn = ConnectionFactory.createConnection(hbaseConfig);
+ this.table = conn.getTable(TableName.valueOf(config.getTableName()));
this.cfName = config.getFamilyName().getBytes(UTF_8);
}
@@ -61,7 +66,7 @@ public class HBaseTimestampStorage implements TimestampStorage {
throw new IllegalArgumentException("Negative value received for maxTimestamp" + newMaxTimestamp);
}
Put put = new Put(TSO_ROW);
- put.add(cfName, TSO_QUALIFIER, Bytes.toBytes(newMaxTimestamp));
+ put.addColumn(cfName, TSO_QUALIFIER, Bytes.toBytes(newMaxTimestamp));
byte[] previousVal = null;
if (previousMaxTimestamp != INITIAL_MAX_TS_VALUE) {
previousVal = Bytes.toBytes(previousMaxTimestamp);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/tso-server/src/main/java/org/apache/omid/tso/CacheEvaluation.java
----------------------------------------------------------------------
diff --git a/tso-server/src/main/java/org/apache/omid/tso/CacheEvaluation.java b/tso-server/src/main/java/org/apache/omid/tso/CacheEvaluation.java
index 68ead7a..91216f2 100644
--- a/tso-server/src/main/java/org/apache/omid/tso/CacheEvaluation.java
+++ b/tso-server/src/main/java/org/apache/omid/tso/CacheEvaluation.java
@@ -96,7 +96,7 @@ public class CacheEvaluation {
Runtime.getRuntime().gc();
writer.println("# Free mem (MB) :" + (Runtime.getRuntime().freeMemory() / (double) (1024 * 1024)));
writer.println("# Elapsed (s): " + elapsedSeconds);
- writer.println("# Elapsed per 100 ops (ms): " + (elapsed / (double) totalOps / 100 / (double) 1000000));
+ writer.println("# Elapsed per 100 ops (ms): " + (elapsed / (double) totalOps / 100 / 1000000));
writer.println("# Ops per s : " + (totalOps / elapsedSeconds));
writer.println("# Avg gap: " + (tempAvg));
writer.println("# Std dev gap: " + Math.sqrt((tempStdDev / ENTRIES)));
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/tso-server/src/test/java/org/apache/omid/tso/TestLeaseManager.java
----------------------------------------------------------------------
diff --git a/tso-server/src/test/java/org/apache/omid/tso/TestLeaseManager.java b/tso-server/src/test/java/org/apache/omid/tso/TestLeaseManager.java
index baef807..5c970e8 100644
--- a/tso-server/src/test/java/org/apache/omid/tso/TestLeaseManager.java
+++ b/tso-server/src/test/java/org/apache/omid/tso/TestLeaseManager.java
@@ -17,7 +17,22 @@
*/
package org.apache.omid.tso;
-import com.google.common.base.Charsets;
+import static org.apache.omid.tso.client.TSOClient.DEFAULT_ZK_CLUSTER;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.test.TestingServer;
import org.apache.curator.utils.CloseableUtils;
@@ -31,21 +46,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import java.io.IOException;
-
-import static org.apache.omid.tso.client.TSOClient.DEFAULT_ZK_CLUSTER;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Charsets;
public class TestLeaseManager {
@@ -361,7 +362,7 @@ public class TestLeaseManager {
ArgumentCaptor<IllegalArgumentException> trowableIAE = ArgumentCaptor.forClass(IllegalArgumentException.class);
verify(panicker, times(2)).panic(anyString(), trowableIAE.capture());
- assertTrue(trowableIAE.getValue() instanceof IllegalArgumentException);
+ assertTrue(trowableIAE.getValue() != null);
assertTrue(trowableIAE.getValue().getMessage().contains("Incorrect TSO Info found"));
// 2nd Panic test) Simulate that a new master appeared in the meantime, force reelection
@@ -380,7 +381,7 @@ public class TestLeaseManager {
ArgumentCaptor<LeaseManagement.LeaseManagementException> trowableLME =
ArgumentCaptor.forClass(LeaseManagement.LeaseManagementException.class);
verify(panicker, times(2)).panic(anyString(), trowableLME.capture());
- assertTrue(trowableLME.getValue() instanceof LeaseManagement.LeaseManagementException);
+ assertTrue(trowableLME.getValue() != null);
assertTrue(trowableLME.getValue().getMessage().contains("Another TSO replica was found"));
}
[2/4] incubator-omid git commit: OMID-107 Replace pre 1.0 deprecated
HBase APIs
Posted by oh...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
index 21745c4..abdd602 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
@@ -17,12 +17,18 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -33,10 +39,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
@Test(groups = "sharedHBase")
public class TestTransactionConflict extends OmidTestBase {
@@ -45,7 +47,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestWriteWriteConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -60,11 +62,11 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
tm.commit(t2);
@@ -79,27 +81,29 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestMultiTableConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
String table2 = TEST_TABLE + 2;
TableName table2Name = TableName.valueOf(table2);
- HBaseAdmin admin = new HBaseAdmin(hbaseConf);
-
- if (!admin.tableExists(table2)) {
- HTableDescriptor desc = new HTableDescriptor(table2Name);
- HColumnDescriptor datafam = new HColumnDescriptor(TEST_FAMILY);
- datafam.setMaxVersions(Integer.MAX_VALUE);
- desc.addFamily(datafam);
-
- admin.createTable(desc);
- }
-
- if (admin.isTableDisabled(table2)) {
- admin.enableTable(table2);
+ try (Connection conn = ConnectionFactory.createConnection(hbaseConf);
+ Admin admin = conn.getAdmin()) {
+ TableName htable2 = TableName.valueOf(table2);
+
+ if (!admin.tableExists(htable2)) {
+ HTableDescriptor desc = new HTableDescriptor(table2Name);
+ HColumnDescriptor datafam = new HColumnDescriptor(TEST_FAMILY);
+ datafam.setMaxVersions(Integer.MAX_VALUE);
+ desc.addFamily(datafam);
+
+ admin.createTable(desc);
+ }
+
+ if (admin.isTableDisabled(htable2)) {
+ admin.enableTable(htable2);
+ }
}
- admin.close();
- TTable tt2 = new TTable(hbaseConf, table2);
+ TTable tt2 = new TTable(connection, table2);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -115,15 +119,15 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
tt2.put(t1, p);
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
p2 = new Put(row2);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt2.put(t2, p2);
tm.commit(t2);
@@ -150,7 +154,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestCleanupAfterConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -165,7 +169,7 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
Get g = new Get(row).setMaxVersions();
@@ -176,7 +180,7 @@ public class TestTransactionConflict extends OmidTestBase {
"Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)));
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
r = tt.getHTable().get(g);
@@ -207,7 +211,7 @@ public class TestTransactionConflict extends OmidTestBase {
public void testCleanupWithDeleteRow(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -225,7 +229,7 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] row = Bytes.toBytes("test-del" + i);
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
}
tm.commit(t1);
@@ -248,7 +252,7 @@ public class TestTransactionConflict extends OmidTestBase {
Transaction t3 = tm.begin();
LOG.info("Transaction created " + t3);
Put p = new Put(modrow);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
tt.put(t3, p);
tm.commit(t3);
@@ -277,7 +281,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void testMultipleCellChangesOnSameRow(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
Transaction t2 = tm.begin();
@@ -290,12 +294,12 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data = Bytes.toBytes("testWrite-1");
Put p2 = new Put(row);
- p2.add(fam, col1, data);
+ p2.addColumn(fam, col1, data);
tt.put(t2, p2);
tm.commit(t2);
Put p1 = new Put(row);
- p1.add(fam, col2, data);
+ p1.addColumn(fam, col2, data);
tt.put(t1, p1);
tm.commit(t1);
}
@@ -303,7 +307,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestWriteWriteConflictWithAdditionalConflictFreeWrites(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -318,21 +322,21 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
row = Bytes.toBytes("test-simple-cf");
p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.markPutAsConflictFreeMutation(p);
tt.put(t1, p);
p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.markPutAsConflictFreeMutation(p2);
tt.put(t2, p2);
@@ -348,7 +352,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestWriteWriteConflictFreeWrites(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -363,23 +367,23 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.markPutAsConflictFreeMutation(p);
tt.put(t1, p);
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.markPutAsConflictFreeMutation(p2);
tt.put(t2, p2);
row = Bytes.toBytes("test-simple-cf");
p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.markPutAsConflictFreeMutation(p);
tt.put(t1, p);
p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.markPutAsConflictFreeMutation(p2);
tt.put(t2, p2);
@@ -395,7 +399,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestWriteWriteConflictFreeWritesWithOtherWrites(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -411,21 +415,21 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
Put p2 = new Put(row1);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
row = Bytes.toBytes("test-simple-cf");
p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.markPutAsConflictFreeMutation(p);
tt.put(t1, p);
p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.markPutAsConflictFreeMutation(p2);
tt.put(t2, p2);
@@ -441,7 +445,7 @@ public class TestTransactionConflict extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestCleanupConflictFreeWritesAfterConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -457,7 +461,7 @@ public class TestTransactionConflict extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
Get g = new Get(row).setMaxVersions();
@@ -468,11 +472,11 @@ public class TestTransactionConflict extends OmidTestBase {
"Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)));
Put p2 = new Put(row);
- p2.add(fam, col, data2);
+ p2.addColumn(fam, col, data2);
tt.put(t2, p2);
Put p3 = new Put(row1);
- p3.add(fam, col, data2);
+ p3.addColumn(fam, col, data2);
tt.markPutAsConflictFreeMutation(p3);
tt.put(t2, p3);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestTxMgrFailover.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTxMgrFailover.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTxMgrFailover.java
index d507c24..4dad9bb 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTxMgrFailover.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTxMgrFailover.java
@@ -17,13 +17,22 @@
*/
package org.apache.omid.transaction;
+import static org.mockito.Mockito.spy;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+
+import javax.annotation.Nullable;
+
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.TestUtils;
import org.apache.omid.committable.CommitTable;
@@ -37,14 +46,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import javax.annotation.Nullable;
-import java.io.IOException;
-
-import static org.mockito.Mockito.spy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.fail;
-
@Test(groups = "sharedHBase")
public class TestTxMgrFailover extends OmidTestBase {
@@ -54,7 +55,6 @@ public class TestTxMgrFailover extends OmidTestBase {
private static final String TSO_SERVER_HOST = "localhost";
private static final long TX1_ST = 1L;
- private static final long TX1_CT = 2L;
private static final byte[] qualifier = Bytes.toBytes("test-qual");
private static final byte[] row1 = Bytes.toBytes("row1");
@@ -103,14 +103,14 @@ public class TestTxMgrFailover extends OmidTestBase {
tso.queueResponse(new ProgrammableTSOServer.TimestampResponse(TX1_ST));
tso.queueResponse(new ProgrammableTSOServer.AbortResponse(TX1_ST));
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
assertEquals(tx1.getStartTimestamp(), TX1_ST);
Put put = new Put(row1);
- put.add(TEST_FAMILY.getBytes(), qualifier, data1);
+ put.addColumn(TEST_FAMILY.getBytes(), qualifier, data1);
txTable.put(tx1, put);
- assertEquals(hBaseUtils.countRows(new HTable(hbaseConf, TEST_TABLE)), 1, "Rows should be 1!");
- checkOperationSuccessOnCell(KeyValue.Type.Put, data1, TEST_TABLE.getBytes(), row1, TEST_FAMILY.getBytes(),
+ assertEquals(hBaseUtils.countRows(txTable.getHTable()), 1, "Rows should be 1!");
+ checkOperationSuccessOnCell(txTable.getHTable(), KeyValue.Type.Put, data1, TEST_TABLE.getBytes(), row1, TEST_FAMILY.getBytes(),
qualifier);
try {
@@ -125,7 +125,7 @@ public class TestTxMgrFailover extends OmidTestBase {
assertEquals(tx1.getStatus(), Status.ROLLEDBACK);
assertEquals(tx1.getCommitTimestamp(), 0);
// Check the cleanup process did its job and the committed data is NOT there
- checkOperationSuccessOnCell(KeyValue.Type.Delete, null, TEST_TABLE.getBytes(), row1, TEST_FAMILY.getBytes(),
+ checkOperationSuccessOnCell(txTable.getHTable(), KeyValue.Type.Delete, null, TEST_TABLE.getBytes(), row1, TEST_FAMILY.getBytes(),
qualifier);
}
@@ -135,14 +135,15 @@ public class TestTxMgrFailover extends OmidTestBase {
// Helper methods
// ----------------------------------------------------------------------------------------------------------------
- protected void checkOperationSuccessOnCell(KeyValue.Type targetOp,
+ protected void checkOperationSuccessOnCell(Table table,
+ KeyValue.Type targetOp,
@Nullable byte[] expectedValue,
byte[] tableName,
byte[] row,
byte[] fam,
byte[] col) {
- try (HTable table = new HTable(hbaseConf, tableName)) {
+ try {
Get get = new Get(row).setMaxVersions(1);
Result result = table.get(get);
Cell latestCell = result.getColumnLatestCell(fam, col);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
index 0f92d54..255a12d 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
@@ -17,6 +17,9 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -34,9 +37,6 @@ import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestUpdateScan extends OmidTestBase {
private static final Logger LOG = LoggerFactory.getLogger(TestUpdateScan.class);
@@ -48,13 +48,13 @@ public class TestUpdateScan extends OmidTestBase {
public void testGet(ITestContext context) throws Exception {
try {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
Transaction t = tm.begin();
int[] lInts = new int[]{100, 243, 2342, 22, 1, 5, 43, 56};
for (int i = 0; i < lInts.length; i++) {
byte[] data = Bytes.toBytes(lInts[i]);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(t, put);
}
int startKeyValue = lInts[3];
@@ -105,15 +105,15 @@ public class TestUpdateScan extends OmidTestBase {
@Test(timeOut = 10_000)
public void testScan(ITestContext context) throws Exception {
- try (TTable table = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable table = new TTable(connection, TEST_TABLE)) {
TransactionManager tm = newTransactionManager(context);
Transaction t = tm.begin();
int[] lInts = new int[]{100, 243, 2342, 22, 1, 5, 43, 56};
for (int lInt : lInts) {
byte[] data = Bytes.toBytes(lInt);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL_2), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL_2), data);
table.put(t, put);
}
@@ -154,13 +154,13 @@ public class TestUpdateScan extends OmidTestBase {
public void testScanUncommitted(ITestContext context) throws Exception {
try {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
Transaction t = tm.begin();
int[] lIntsA = new int[]{100, 243, 2342, 22, 1, 5, 43, 56};
for (int aLIntsA : lIntsA) {
byte[] data = Bytes.toBytes(aLIntsA);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(t, put);
}
tm.commit(t);
@@ -170,7 +170,7 @@ public class TestUpdateScan extends OmidTestBase {
for (int aLIntsB : lIntsB) {
byte[] data = Bytes.toBytes(aLIntsB);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(tu, put);
}
@@ -179,7 +179,7 @@ public class TestUpdateScan extends OmidTestBase {
for (int aLIntsC : lIntsC) {
byte[] data = Bytes.toBytes(aLIntsC);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(t, put);
}
tm.commit(t);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-commit-table/src/main/java/org/apache/omid/committable/hbase/HBaseCommitTable.java
----------------------------------------------------------------------
diff --git a/hbase-commit-table/src/main/java/org/apache/omid/committable/hbase/HBaseCommitTable.java b/hbase-commit-table/src/main/java/org/apache/omid/committable/hbase/HBaseCommitTable.java
index 89815c4..eb0ba04 100644
--- a/hbase-commit-table/src/main/java/org/apache/omid/committable/hbase/HBaseCommitTable.java
+++ b/hbase-commit-table/src/main/java/org/apache/omid/committable/hbase/HBaseCommitTable.java
@@ -17,26 +17,11 @@
*/
package org.apache.omid.committable.hbase;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.AbstractFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.committable.CommitTable.CommitTimestamp.Location;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.COMMIT_TABLE_QUALIFIER;
+import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.INVALID_TX_QUALIFIER;
+import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.LOW_WATERMARK_QUALIFIER;
+import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.LOW_WATERMARK_ROW;
-import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -47,16 +32,36 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.COMMIT_TABLE_QUALIFIER;
-import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.INVALID_TX_QUALIFIER;
-import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.LOW_WATERMARK_QUALIFIER;
-import static org.apache.omid.committable.hbase.HBaseCommitTableConfig.LOW_WATERMARK_ROW;
+import javax.inject.Inject;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.committable.CommitTable.CommitTimestamp.Location;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.AbstractFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.protobuf.CodedInputStream;
+import com.google.protobuf.CodedOutputStream;
public class HBaseCommitTable implements CommitTable {
private static final Logger LOG = LoggerFactory.getLogger(HBaseCommitTable.class);
- private final Configuration hbaseConfig;
+ private final Connection hbaseConnection;
private final String tableName;
private final byte[] commitTableFamily;
private final byte[] lowWatermarkFamily;
@@ -65,15 +70,16 @@ public class HBaseCommitTable implements CommitTable {
/**
* Create a hbase commit table.
* Note that we do not take ownership of the passed htable, it is just used to construct the writer and client.
+ * @throws IOException
*/
@Inject
- public HBaseCommitTable(Configuration hbaseConfig, HBaseCommitTableConfig config) {
+ public HBaseCommitTable(Configuration hbaseConfig, HBaseCommitTableConfig config) throws IOException {
this(hbaseConfig, config, KeyGeneratorImplementations.defaultKeyGenerator());
}
- public HBaseCommitTable(Configuration hbaseConfig, HBaseCommitTableConfig config, KeyGenerator keygen) {
+ public HBaseCommitTable(Configuration hbaseConfig, HBaseCommitTableConfig config, KeyGenerator keygen) throws IOException {
- this.hbaseConfig = hbaseConfig;
+ this.hbaseConnection = ConnectionFactory.createConnection(hbaseConfig);
this.tableName = config.getTableName();
this.commitTableFamily = config.getCommitTableFamily();
this.lowWatermarkFamily = config.getLowWatermarkFamily();
@@ -88,13 +94,13 @@ public class HBaseCommitTable implements CommitTable {
private class HBaseWriter implements Writer {
private static final long INITIAL_LWM_VALUE = -1L;
- final HTable table;
+ final Table table;
// Our own buffer for operations
final List<Put> writeBuffer = new LinkedList<>();
volatile long lowWatermarkToStore = INITIAL_LWM_VALUE;
HBaseWriter() throws IOException {
- table = new HTable(hbaseConfig, tableName);
+ table = hbaseConnection.getTable(TableName.valueOf(tableName));
}
@Override
@@ -102,7 +108,7 @@ public class HBaseCommitTable implements CommitTable {
assert (startTimestamp < commitTimestamp);
Put put = new Put(startTimestampToKey(startTimestamp), startTimestamp);
byte[] value = encodeCommitTimestamp(startTimestamp, commitTimestamp);
- put.add(commitTableFamily, COMMIT_TABLE_QUALIFIER, value);
+ put.addColumn(commitTableFamily, COMMIT_TABLE_QUALIFIER, value);
writeBuffer.add(put);
}
@@ -138,7 +144,7 @@ public class HBaseCommitTable implements CommitTable {
long lowWatermark = lowWatermarkToStore;
if(lowWatermark != INITIAL_LWM_VALUE) {
Put put = new Put(LOW_WATERMARK_ROW);
- put.add(lowWatermarkFamily, LOW_WATERMARK_QUALIFIER, Bytes.toBytes(lowWatermark));
+ put.addColumn(lowWatermarkFamily, LOW_WATERMARK_QUALIFIER, Bytes.toBytes(lowWatermark));
writeBuffer.add(put);
}
}
@@ -147,17 +153,19 @@ public class HBaseCommitTable implements CommitTable {
class HBaseClient implements Client, Runnable {
- final HTable table;
- final HTable deleteTable;
+ final Table table;
+ final Table deleteTable;
final ExecutorService deleteBatchExecutor;
final BlockingQueue<DeleteRequest> deleteQueue;
boolean isClosed = false; // @GuardedBy("this")
final static int DELETE_BATCH_SIZE = 1024;
HBaseClient() throws IOException {
- table = new HTable(hbaseConfig, tableName);
- table.setAutoFlush(false, true);
- deleteTable = new HTable(hbaseConfig, tableName);
+ // TODO: create TTable here instead
+ table = hbaseConnection.getTable(TableName.valueOf(tableName));
+ // FIXME: why is this using autoFlush of false? Why would every Delete
+ // need to be send through a separate RPC?
+ deleteTable = hbaseConnection.getTable(TableName.valueOf(tableName));
deleteQueue = new ArrayBlockingQueue<>(DELETE_BATCH_SIZE);
deleteBatchExecutor = Executors.newSingleThreadExecutor(
@@ -254,7 +262,7 @@ public class HBaseCommitTable implements CommitTable {
try {
byte[] row = startTimestampToKey(startTimestamp);
Put invalidationPut = new Put(row, startTimestamp);
- invalidationPut.add(commitTableFamily, INVALID_TX_QUALIFIER, null);
+ invalidationPut.addColumn(commitTableFamily, INVALID_TX_QUALIFIER, null);
// We need to write to the invalid column only if the commit timestamp
// is empty. This has to be done atomically. Otherwise, if we first
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
----------------------------------------------------------------------
diff --git a/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java b/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
index 9493a44..5bb860d 100644
--- a/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
+++ b/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
@@ -17,8 +17,13 @@
*/
package org.apache.omid.committable.hbase;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -26,10 +31,12 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.coprocessor.AggregationClient;
-import org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.omid.committable.CommitTable;
import org.apache.omid.committable.CommitTable.Client;
import org.apache.omid.committable.CommitTable.CommitTimestamp;
@@ -44,12 +51,8 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
public class TestHBaseCommitTable {
@@ -62,7 +65,7 @@ public class TestHBaseCommitTable {
private static HBaseTestingUtility testutil;
private static MiniHBaseCluster hbasecluster;
protected static Configuration hbaseConf;
- private static AggregationClient aggregationClient;
+ protected static Connection connection;
private byte[] commitTableFamily;
private byte[] lowWatermarkFamily;
@@ -77,8 +80,7 @@ public class TestHBaseCommitTable {
LOG.info("Create hbase");
testutil = new HBaseTestingUtility(hbaseConf);
hbasecluster = testutil.startMiniCluster(1);
- aggregationClient = new AggregationClient(hbaseConf);
-
+ connection = ConnectionFactory.createConnection(hbaseConf);
}
@AfterClass
@@ -90,9 +92,9 @@ public class TestHBaseCommitTable {
@BeforeMethod
public void setUp() throws Exception {
- HBaseAdmin admin = testutil.getHBaseAdmin();
+ Admin admin = testutil.getHBaseAdmin();
- if (!admin.tableExists(TEST_TABLE)) {
+ if (!admin.tableExists(TableName.valueOf(TEST_TABLE))) {
HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor datafam = new HColumnDescriptor(commitTableFamily);
@@ -103,12 +105,13 @@ public class TestHBaseCommitTable {
lowWatermarkFam.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(lowWatermarkFam);
- desc.addCoprocessor("org.apache.hadoop.hbase.coprocessor.AggregateImplementation");
+ // Move to HBaseSims for 2.0 support
+ // For 2.0, use TableDescriptorBuilder to build TableDescriptor
admin.createTable(desc);
}
- if (admin.isTableDisabled(TEST_TABLE)) {
- admin.enableTable(TEST_TABLE);
+ if (admin.isTableDisabled(TableName.valueOf(TEST_TABLE))) {
+ admin.enableTable(TableName.valueOf(TEST_TABLE));
}
HTableDescriptor[] tables = admin.listTables();
for (HTableDescriptor t : tables) {
@@ -120,9 +123,9 @@ public class TestHBaseCommitTable {
public void tearDown() {
try {
LOG.info("tearing Down");
- HBaseAdmin admin = testutil.getHBaseAdmin();
- admin.disableTable(TEST_TABLE);
- admin.deleteTable(TEST_TABLE);
+ Admin admin = testutil.getHBaseAdmin();
+ admin.disableTable(TableName.valueOf(TEST_TABLE));
+ admin.deleteTable(TableName.valueOf(TEST_TABLE));
} catch (Exception e) {
LOG.error("Error tearing down", e);
@@ -289,10 +292,17 @@ public class TestHBaseCommitTable {
}
- private static long rowCount(TableName table, byte[] family) throws Throwable {
+ private static long rowCount(TableName tableName, byte[] family) throws Throwable {
Scan scan = new Scan();
scan.addFamily(family);
- return aggregationClient.rowCount(table, new LongColumnInterpreter(), scan);
+ Table table = connection.getTable(tableName);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ int count = 0;
+ while (scanner.next() != null) {
+ count++;
+ }
+ return count;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-common/src/main/java/org/apache/omid/transaction/CellUtils.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/omid/transaction/CellUtils.java b/hbase-common/src/main/java/org/apache/omid/transaction/CellUtils.java
index 04900a6..df22e70 100644
--- a/hbase-common/src/main/java/org/apache/omid/transaction/CellUtils.java
+++ b/hbase-common/src/main/java/org/apache/omid/transaction/CellUtils.java
@@ -17,13 +17,13 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Charsets;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
@@ -36,13 +36,13 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import com.google.common.base.Charsets;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
@SuppressWarnings("all")
public final class CellUtils {
@@ -301,6 +301,8 @@ public final class CellUtils {
*/
public static SortedMap<Cell, Optional<Cell>> mapCellsToShadowCells(List<Cell> cells) {
+ // Move CellComparator to HBaseSims for 2.0 support
+ // Need to access through CellComparatorImpl.COMPARATOR
SortedMap<Cell, Optional<Cell>> cellToShadowCellMap
= new TreeMap<Cell, Optional<Cell>>(new CellComparator());
@@ -315,7 +317,7 @@ public final class CellUtils {
// TODO: Should we check also here the MVCC and swap if its greater???
// Values are the same, ignore
} else {
- if (cell.getMvccVersion() > storedCell.getMvccVersion()) { // Swap values
+ if (cell.getSequenceId() > storedCell.getSequenceId()) { // Swap values
Optional<Cell> previousValue = cellToShadowCellMap.remove(storedCell);
Preconditions.checkNotNull(previousValue, "Should contain an Optional<Cell> value");
cellIdToCellMap.put(key, cell);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestCompaction.java
----------------------------------------------------------------------
diff --git a/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestCompaction.java b/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestCompaction.java
index 3dfcb2a..2aae1b5 100644
--- a/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestCompaction.java
+++ b/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestCompaction.java
@@ -17,9 +17,25 @@
*/
package org.apache.omid.transaction;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
@@ -28,17 +44,18 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.client.Row;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.coprocessor.AggregationClient;
import org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter;
import org.apache.hadoop.hbase.util.Bytes;
@@ -59,24 +76,9 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.spy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import com.google.common.util.concurrent.SettableFuture;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
public class TestCompaction {
@@ -96,7 +98,7 @@ public class TestCompaction {
private Injector injector;
- private HBaseAdmin admin;
+ private Admin admin;
private Configuration hbaseConf;
private HBaseTestingUtility hbaseTestUtil;
private MiniHBaseCluster hbaseCluster;
@@ -106,6 +108,7 @@ public class TestCompaction {
private AggregationClient aggregationClient;
private CommitTable commitTable;
private PostCommitActions syncPostCommitter;
+ private Connection connection;
@BeforeClass
public void setupTestCompation() throws Exception {
@@ -122,8 +125,9 @@ public class TestCompaction {
hbaseConf.setInt("hbase.hstore.compaction.max", 2);
setupHBase();
+ connection = ConnectionFactory.createConnection(hbaseConf);
aggregationClient = new AggregationClient(hbaseConf);
- admin = new HBaseAdmin(hbaseConf);
+ admin = connection.getAdmin();
createRequiredHBaseTables(hBaseTimestampStorageConfig, hBaseCommitTableConfig);
setupTSO();
@@ -149,7 +153,7 @@ public class TestCompaction {
}
private void createTableIfNotExists(String tableName, byte[]... families) throws IOException {
- if (!admin.tableExists(tableName)) {
+ if (!admin.tableExists(TableName.valueOf(tableName))) {
LOG.info("Creating {} table...", tableName);
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
@@ -209,7 +213,7 @@ public class TestCompaction {
public void testStandardTXsWithShadowCellsAndWithSTBelowAndAboveLWMArePresevedAfterCompaction() throws Throwable {
String TEST_TABLE = "testStandardTXsWithShadowCellsAndWithSTBelowAndAboveLWMArePresevedAfterCompaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
final int ROWS_TO_ADD = 5;
@@ -222,13 +226,13 @@ public class TestCompaction {
LOG.info("AssignedLowWatermark " + fakeAssignedLowWatermark);
}
Put put = new Put(Bytes.toBytes(rowId));
- put.add(fam, qual, data);
+ put.addColumn(fam, qual, data);
txTable.put(tx, put);
tm.commit(tx);
}
LOG.info("Flushing table {}", TEST_TABLE);
- admin.flush(TEST_TABLE);
+ admin.flush(TableName.valueOf(TEST_TABLE));
// Return a LWM that triggers compaction & stays between 1 and the max start timestamp assigned to previous TXs
LOG.info("Regions in table {}: {}", TEST_TABLE, hbaseCluster.getRegions(Bytes.toBytes(TEST_TABLE)).size());
@@ -241,7 +245,7 @@ public class TestCompaction {
doReturn(f).when(commitTableClient).readLowWatermark();
omidCompactor.commitTableClientQueue.add(commitTableClient);
LOG.info("Compacting table {}", TEST_TABLE);
- admin.majorCompact(TEST_TABLE);
+ admin.majorCompact(TableName.valueOf(TEST_TABLE));
LOG.info("Sleeping for 3 secs");
Thread.sleep(3000);
@@ -255,7 +259,7 @@ public class TestCompaction {
public void testTXWithoutShadowCellsAndWithSTBelowLWMGetsShadowCellHealedAfterCompaction() throws Exception {
String TEST_TABLE = "testTXWithoutShadowCellsAndWithSTBelowLWMGetsShadowCellHealedAfterCompaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// The following line emulates a crash after commit that is observed in (*) below
doThrow(new RuntimeException()).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
@@ -266,7 +270,7 @@ public class TestCompaction {
// Test shadow cell are created properly
Put put = new Put(Bytes.toBytes(row));
- put.add(fam, qual, data);
+ put.addColumn(fam, qual, data);
txTable.put(problematicTx, put);
try {
tm.commit(problematicTx);
@@ -293,10 +297,10 @@ public class TestCompaction {
omidCompactor.commitTableClientQueue.add(commitTableClient);
LOG.info("Flushing table {}", TEST_TABLE);
- admin.flush(TEST_TABLE);
+ admin.flush(TableName.valueOf(TEST_TABLE));
LOG.info("Compacting table {}", TEST_TABLE);
- admin.majorCompact(TEST_TABLE);
+ admin.majorCompact(TableName.valueOf(TEST_TABLE));
LOG.info("Sleeping for 3 secs");
Thread.sleep(3000);
@@ -317,13 +321,13 @@ public class TestCompaction {
TEST_TABLE =
"testNeverendingTXsWithSTBelowAndAboveLWMAreDiscardedAndPreservedRespectivelyAfterCompaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// The KV in this transaction should be discarded
HBaseTransaction neverendingTxBelowLowWatermark = (HBaseTransaction) tm.begin();
long rowId = randomGenerator.nextLong();
Put put = new Put(Bytes.toBytes(rowId));
- put.add(fam, qual, data);
+ put.addColumn(fam, qual, data);
txTable.put(neverendingTxBelowLowWatermark, put);
assertTrue(CellUtils.hasCell(Bytes.toBytes(rowId), fam, qual, neverendingTxBelowLowWatermark.getStartTimestamp(),
new TTableCellGetterAdapter(txTable)),
@@ -336,7 +340,7 @@ public class TestCompaction {
HBaseTransaction neverendingTxAboveLowWatermark = (HBaseTransaction) tm.begin();
long anotherRowId = randomGenerator.nextLong();
put = new Put(Bytes.toBytes(anotherRowId));
- put.add(fam, qual, data);
+ put.addColumn(fam, qual, data);
txTable.put(neverendingTxAboveLowWatermark, put);
assertTrue(CellUtils.hasCell(Bytes.toBytes(anotherRowId), fam, qual, neverendingTxAboveLowWatermark.getStartTimestamp(),
new TTableCellGetterAdapter(txTable)),
@@ -347,7 +351,7 @@ public class TestCompaction {
assertEquals(rowCount(TEST_TABLE, fam), 2, "Rows in table before flushing should be 2");
LOG.info("Flushing table {}", TEST_TABLE);
- admin.flush(TEST_TABLE);
+ admin.flush(TableName.valueOf(TEST_TABLE));
assertEquals(rowCount(TEST_TABLE, fam), 2, "Rows in table after flushing should be 2");
// Return a LWM that triggers compaction and stays between both ST of TXs, so assign 1st TX's start timestamp
@@ -361,7 +365,7 @@ public class TestCompaction {
doReturn(f).when(commitTableClient).readLowWatermark();
omidCompactor.commitTableClientQueue.add(commitTableClient);
LOG.info("Compacting table {}", TEST_TABLE);
- admin.majorCompact(TEST_TABLE);
+ admin.majorCompact(TableName.valueOf(TEST_TABLE));
LOG.info("Sleeping for 3 secs");
Thread.sleep(3000);
@@ -390,14 +394,14 @@ public class TestCompaction {
public void testRowsUnalteredWhenCommitTableCannotBeReached() throws Throwable {
String TEST_TABLE = "testRowsUnalteredWhenCommitTableCannotBeReached";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// The KV in this transaction should be discarded but in the end should remain there because
// the commit table won't be accessed (simulating an error on access)
HBaseTransaction neverendingTx = (HBaseTransaction) tm.begin();
long rowId = randomGenerator.nextLong();
Put put = new Put(Bytes.toBytes(rowId));
- put.add(fam, qual, data);
+ put.addColumn(fam, qual, data);
txTable.put(neverendingTx, put);
assertTrue(CellUtils.hasCell(Bytes.toBytes(rowId), fam, qual, neverendingTx.getStartTimestamp(),
new TTableCellGetterAdapter(txTable)),
@@ -408,7 +412,7 @@ public class TestCompaction {
assertEquals(rowCount(TEST_TABLE, fam), 1, "There should be only one rows in table before flushing");
LOG.info("Flushing table {}", TEST_TABLE);
- admin.flush(TEST_TABLE);
+ admin.flush(TableName.valueOf(TEST_TABLE));
assertEquals(rowCount(TEST_TABLE, fam), 1, "There should be only one rows in table after flushing");
// Break access to CommitTable functionality in Compactor
@@ -423,7 +427,7 @@ public class TestCompaction {
omidCompactor.commitTableClientQueue.add(commitTableClient);
LOG.info("Compacting table {}", TEST_TABLE);
- admin.majorCompact(TEST_TABLE); // Should trigger the error when accessing CommitTable funct.
+ admin.majorCompact(TableName.valueOf(TEST_TABLE)); // Should trigger the error when accessing CommitTable funct.
LOG.info("Sleeping for 3 secs");
Thread.sleep(3000);
@@ -443,13 +447,13 @@ public class TestCompaction {
public void testOriginalTableParametersAreAvoidedAlsoWhenCompacting() throws Throwable {
String TEST_TABLE = "testOriginalTableParametersAreAvoidedAlsoWhenCompacting";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
long rowId = randomGenerator.nextLong();
for (int versionCount = 0; versionCount <= (2 * MAX_VERSIONS); versionCount++) {
Transaction tx = tm.begin();
Put put = new Put(Bytes.toBytes(rowId));
- put.add(fam, qual, Bytes.toBytes("testWrite-" + versionCount));
+ put.addColumn(fam, qual, Bytes.toBytes("testWrite-" + versionCount));
txTable.put(tx, put);
tm.commit(tx);
}
@@ -466,7 +470,7 @@ public class TestCompaction {
assertEquals(rowCount(TEST_TABLE, fam), 1, "There should be only one row in table before flushing");
LOG.info("Flushing table {}", TEST_TABLE);
- admin.flush(TEST_TABLE);
+ admin.flush(TableName.valueOf(TEST_TABLE));
assertEquals(rowCount(TEST_TABLE, fam), 1, "There should be only one row in table after flushing");
// Return a LWM that triggers compaction
@@ -502,26 +506,26 @@ public class TestCompaction {
public void testOldCellsAreDiscardedAfterCompaction() throws Exception {
String TEST_TABLE = "testOldCellsAreDiscardedAfterCompaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
byte[] rowId = Bytes.toBytes("row");
// Create 3 transactions modifying the same cell in a particular row
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put1 = new Put(rowId);
- put1.add(fam, qual, Bytes.toBytes("testValue 1"));
+ put1.addColumn(fam, qual, Bytes.toBytes("testValue 1"));
txTable.put(tx1, put1);
tm.commit(tx1);
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Put put2 = new Put(rowId);
- put2.add(fam, qual, Bytes.toBytes("testValue 2"));
+ put2.addColumn(fam, qual, Bytes.toBytes("testValue 2"));
txTable.put(tx2, put2);
tm.commit(tx2);
HBaseTransaction tx3 = (HBaseTransaction) tm.begin();
Put put3 = new Put(rowId);
- put3.add(fam, qual, Bytes.toBytes("testValue 3"));
+ put3.addColumn(fam, qual, Bytes.toBytes("testValue 3"));
txTable.put(tx3, put3);
tm.commit(tx3);
@@ -566,7 +570,7 @@ public class TestCompaction {
assertEquals(Bytes.toBytes("testValue 3"), result.getValue(fam, qual));
// Write a new value
Put newPut1 = new Put(rowId);
- newPut1.add(fam, qual, Bytes.toBytes("new testValue 1"));
+ newPut1.addColumn(fam, qual, Bytes.toBytes("new testValue 1"));
txTable.put(newTx1, newPut1);
// Start a second new transaction
@@ -608,7 +612,7 @@ public class TestCompaction {
public void testDuplicateDeletes() throws Throwable {
String TEST_TABLE = "testDuplicateDeletes";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// jump through hoops to trigger a minor compaction.
// a minor compaction will only run if there are enough
@@ -620,7 +624,7 @@ public class TestCompaction {
byte[] firstRow = "FirstRow".getBytes();
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
Put put0 = new Put(firstRow);
- put0.add(fam, qual, Bytes.toBytes("testWrite-1"));
+ put0.addColumn(fam, qual, Bytes.toBytes("testWrite-1"));
txTable.put(tx0, put0);
tm.commit(tx0);
@@ -631,7 +635,7 @@ public class TestCompaction {
byte[] rowToBeCompactedAway = "compactMe".getBytes();
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put1 = new Put(rowToBeCompactedAway);
- put1.add(fam, qual, Bytes.toBytes("testWrite-1"));
+ put1.addColumn(fam, qual, Bytes.toBytes("testWrite-1"));
txTable.put(tx1, put1);
txTable.flushCommits();
@@ -639,13 +643,13 @@ public class TestCompaction {
byte[] row = "iCauseErrors".getBytes();
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Put put2 = new Put(row);
- put2.add(fam, qual, Bytes.toBytes("testWrite-1"));
+ put2.addColumn(fam, qual, Bytes.toBytes("testWrite-1"));
txTable.put(tx2, put2);
tm.commit(tx2);
HBaseTransaction tx3 = (HBaseTransaction) tm.begin();
Put put3 = new Put(row);
- put3.add(fam, qual, Bytes.toBytes("testWrite-1"));
+ put3.addColumn(fam, qual, Bytes.toBytes("testWrite-1"));
txTable.put(tx3, put3);
txTable.flushCommits();
@@ -655,7 +659,7 @@ public class TestCompaction {
List<HBaseCellId> newWriteSet = new ArrayList<>();
final AtomicBoolean flushFailing = new AtomicBoolean(true);
for (HBaseCellId id : writeSet) {
- HTableInterface failableHTable = spy(id.getTable());
+ TTable failableHTable = spy(id.getTable());
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation)
@@ -693,7 +697,7 @@ public class TestCompaction {
byte[] anotherRow = "someotherrow".getBytes();
HBaseTransaction tx4 = (HBaseTransaction) tm.begin();
Put put4 = new Put(anotherRow);
- put4.add(fam, qual, Bytes.toBytes("testWrite-1"));
+ put4.addColumn(fam, qual, Bytes.toBytes("testWrite-1"));
txTable.put(tx4, put4);
tm.commit(tx4);
@@ -702,7 +706,7 @@ public class TestCompaction {
// trigger minor compaction and give it time to run
setCompactorLWM(tx4.getStartTimestamp(), TEST_TABLE);
- admin.compact(TEST_TABLE);
+ admin.compact(TableName.valueOf(TEST_TABLE));
Thread.sleep(3000);
// check if the cell that should be compacted, is compacted
@@ -715,24 +719,24 @@ public class TestCompaction {
public void testNonOmidCFIsUntouched() throws Throwable {
String TEST_TABLE = "testNonOmidCFIsUntouched";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
- admin.disableTable(TEST_TABLE);
+ admin.disableTable(TableName.valueOf(TEST_TABLE));
byte[] nonOmidCF = Bytes.toBytes("nonOmidCF");
byte[] nonOmidQual = Bytes.toBytes("nonOmidCol");
HColumnDescriptor nonomidfam = new HColumnDescriptor(nonOmidCF);
nonomidfam.setMaxVersions(MAX_VERSIONS);
- admin.addColumn(TEST_TABLE, nonomidfam);
- admin.enableTable(TEST_TABLE);
+ admin.addColumn(TableName.valueOf(TEST_TABLE), nonomidfam);
+ admin.enableTable(TableName.valueOf(TEST_TABLE));
byte[] rowId = Bytes.toBytes("testRow");
Transaction tx = tm.begin();
Put put = new Put(rowId);
- put.add(fam, qual, Bytes.toBytes("testValue"));
+ put.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx, put);
Put nonTxPut = new Put(rowId);
- nonTxPut.add(nonOmidCF, nonOmidQual, Bytes.toBytes("nonTxVal"));
+ nonTxPut.addColumn(nonOmidCF, nonOmidQual, Bytes.toBytes("nonTxVal"));
txTable.getHTable().put(nonTxPut);
txTable.flushCommits(); // to make sure it left the client
@@ -759,21 +763,21 @@ public class TestCompaction {
public void testACellDeletedNonTransactionallyDoesNotAppearWhenAMajorCompactionOccurs() throws Throwable {
String TEST_TABLE = "testACellDeletedNonTransactionallyDoesNotAppearWhenAMajorCompactionOccurs";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
- HTable table = new HTable(hbaseConf, TEST_TABLE);
+ Table table = txTable.getHTable();
// Write first a value transactionally
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("row1");
Put p0 = new Put(rowId);
- p0.add(fam, qual, Bytes.toBytes("testValue-0"));
+ p0.addColumn(fam, qual, Bytes.toBytes("testValue-0"));
txTable.put(tx0, p0);
tm.commit(tx0);
// Then perform a non-transactional Delete
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
table.delete(d);
// Trigger a major compaction
@@ -800,9 +804,9 @@ public class TestCompaction {
public void testACellDeletedNonTransactionallyIsPreservedWhenMinorCompactionOccurs() throws Throwable {
String TEST_TABLE = "testACellDeletedNonTransactionallyIsPreservedWhenMinorCompactionOccurs";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
- HTable table = new HTable(hbaseConf, TEST_TABLE);
+ Table table = txTable.getHTable();
// Configure the environment to create a minor compaction
@@ -810,7 +814,7 @@ public class TestCompaction {
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("row1");
Put p0 = new Put(rowId);
- p0.add(fam, qual, Bytes.toBytes("testValue-0"));
+ p0.addColumn(fam, qual, Bytes.toBytes("testValue-0"));
txTable.put(tx0, p0);
tm.commit(tx0);
@@ -820,7 +824,7 @@ public class TestCompaction {
// Write another value transactionally
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put p1 = new Put(rowId);
- p1.add(fam, qual, Bytes.toBytes("testValue-1"));
+ p1.addColumn(fam, qual, Bytes.toBytes("testValue-1"));
txTable.put(tx1, p1);
tm.commit(tx1);
@@ -830,7 +834,7 @@ public class TestCompaction {
// Write yet another value transactionally
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Put p2 = new Put(rowId);
- p2.add(fam, qual, Bytes.toBytes("testValue-2"));
+ p2.addColumn(fam, qual, Bytes.toBytes("testValue-2"));
txTable.put(tx2, p2);
tm.commit(tx2);
@@ -839,7 +843,7 @@ public class TestCompaction {
// Then perform a non-transactional Delete
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
table.delete(d);
// create the fourth hfile
@@ -848,7 +852,7 @@ public class TestCompaction {
// Trigger the minor compaction
HBaseTransaction lwmTx = (HBaseTransaction) tm.begin();
setCompactorLWM(lwmTx.getStartTimestamp(), TEST_TABLE);
- admin.compact(TEST_TABLE);
+ admin.compact(TableName.valueOf(TEST_TABLE));
Thread.sleep(5000);
// Then perform a non-tx (raw) scan...
@@ -887,14 +891,14 @@ public class TestCompaction {
public void testTombstonesAreNotCleanedUpWhenMinorCompactionOccurs() throws Throwable {
String TEST_TABLE = "testTombstonesAreNotCleanedUpWhenMinorCompactionOccurs";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// Configure the environment to create a minor compaction
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case1");
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue-0"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue-0"));
txTable.put(tx0, p);
tm.commit(tx0);
@@ -904,7 +908,7 @@ public class TestCompaction {
// Create the tombstone
HBaseTransaction deleteTx = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(deleteTx, d);
tm.commit(deleteTx);
@@ -913,7 +917,7 @@ public class TestCompaction {
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put p1 = new Put(rowId);
- p1.add(fam, qual, Bytes.toBytes("testValue-11"));
+ p1.addColumn(fam, qual, Bytes.toBytes("testValue-11"));
txTable.put(tx1, p1);
tm.commit(tx1);
@@ -922,14 +926,14 @@ public class TestCompaction {
HBaseTransaction lastTx = (HBaseTransaction) tm.begin();
Put p2 = new Put(rowId);
- p2.add(fam, qual, Bytes.toBytes("testValue-222"));
+ p2.addColumn(fam, qual, Bytes.toBytes("testValue-222"));
txTable.put(lastTx, p2);
tm.commit(lastTx);
// Trigger the minor compaction
HBaseTransaction lwmTx = (HBaseTransaction) tm.begin();
setCompactorLWM(lwmTx.getStartTimestamp(), TEST_TABLE);
- admin.compact(TEST_TABLE);
+ admin.compact(TableName.valueOf(TEST_TABLE));
Thread.sleep(5000);
// Checks on results after compaction
@@ -958,12 +962,12 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase1() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase1";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case1");
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx1, p);
tm.commit(tx1);
@@ -972,7 +976,7 @@ public class TestCompaction {
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx2, d);
tm.commit(tx2);
@@ -994,18 +998,18 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase2() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase2";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case2");
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx1, p);
tm.commit(tx1);
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx2, d);
tm.commit(tx2);
@@ -1031,18 +1035,18 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase3() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase3";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case3");
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx1, p);
tm.commit(tx1);
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx2, d);
HBaseTransaction lwmTx = (HBaseTransaction) tm.begin();
@@ -1067,12 +1071,12 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase4() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase4";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case4");
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx1, p);
tm.commit(tx1);
@@ -1080,7 +1084,7 @@ public class TestCompaction {
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx2, d);
compactWithLWM(lwmTx.getStartTimestamp(), TEST_TABLE);
@@ -1102,12 +1106,12 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase5() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase5";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
byte[] rowId = Bytes.toBytes("case5");
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx1, d);
tm.commit(tx1);
@@ -1128,18 +1132,18 @@ public class TestCompaction {
public void testTombstonesAreCleanedUpCase6() throws Exception {
String TEST_TABLE = "testTombstonesAreCleanedUpCase6";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
byte[] rowId = Bytes.toBytes("case6");
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Delete d = new Delete(rowId);
- d.deleteColumn(fam, qual);
+ d.addColumn(fam, qual);
txTable.delete(tx1, d);
tm.commit(tx1);
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Put p = new Put(rowId);
- p.add(fam, qual, Bytes.toBytes("testValue"));
+ p.addColumn(fam, qual, Bytes.toBytes("testValue"));
txTable.put(tx2, p);
tm.commit(tx2);
@@ -1173,12 +1177,12 @@ public class TestCompaction {
}
private void compactWithLWM(long lwm, String tableName) throws Exception {
- admin.flush(tableName);
+ admin.flush(TableName.valueOf(tableName));
LOG.info("Regions in table {}: {}", tableName, hbaseCluster.getRegions(Bytes.toBytes(tableName)).size());
setCompactorLWM(lwm, tableName);
LOG.info("Compacting table {}", tableName);
- admin.majorCompact(tableName);
+ admin.majorCompact(TableName.valueOf(tableName));
LOG.info("Sleeping for 3 secs");
Thread.sleep(3000);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestSnapshotFilter.java
----------------------------------------------------------------------
diff --git a/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestSnapshotFilter.java b/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestSnapshotFilter.java
index 90dd5dd..8934b08 100644
--- a/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestSnapshotFilter.java
+++ b/hbase-coprocessor/src/test/java/org/apache/omid/transaction/TestSnapshotFilter.java
@@ -17,26 +17,32 @@
*/
package org.apache.omid.transaction;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
-import org.apache.hadoop.conf.Configuration;
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.coprocessor.AggregationClient;
-
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.FamilyFilter;
@@ -52,7 +58,6 @@ import org.apache.omid.metrics.NullMetricsProvider;
import org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig;
import org.apache.omid.tso.TSOServer;
import org.apache.omid.tso.TSOServerConfig;
-
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -62,16 +67,9 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.spy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
public class TestSnapshotFilter {
@@ -85,16 +83,16 @@ public class TestSnapshotFilter {
private Injector injector;
- private HBaseAdmin admin;
+ private Admin admin;
private Configuration hbaseConf;
private HBaseTestingUtility hbaseTestUtil;
private MiniHBaseCluster hbaseCluster;
private TSOServer tso;
- private AggregationClient aggregationClient;
private CommitTable commitTable;
private PostCommitActions syncPostCommitter;
+ private Connection connection;
@BeforeClass
public void setupTestSnapshotFilter() throws Exception {
@@ -110,8 +108,8 @@ public class TestSnapshotFilter {
HBaseTimestampStorageConfig hBaseTimestampStorageConfig = injector.getInstance(HBaseTimestampStorageConfig.class);
setupHBase();
- aggregationClient = new AggregationClient(hbaseConf);
- admin = new HBaseAdmin(hbaseConf);
+ connection = ConnectionFactory.createConnection(hbaseConf);
+ admin = connection.getAdmin();
createRequiredHBaseTables(hBaseTimestampStorageConfig, hBaseCommitTableConfig);
setupTSO();
@@ -137,7 +135,7 @@ public class TestSnapshotFilter {
}
private void createTableIfNotExists(String tableName, byte[]... families) throws IOException {
- if (!admin.tableExists(tableName)) {
+ if (!admin.tableExists(TableName.valueOf(tableName))) {
LOG.info("Creating {} table...", tableName);
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
@@ -199,12 +197,12 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testGetFirstResult";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
tm.commit(tx1);
@@ -224,7 +222,7 @@ public class TestSnapshotFilter {
Transaction tx3 = tm.begin();
Put put3 = new Put(rowName1);
- put3.add(famName1, colName1, dataValue1);
+ put3.addColumn(famName1, colName1, dataValue1);
tt.put(tx3, put3);
tm.commit(tx3);
@@ -257,17 +255,17 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testServerSideSnapshotFiltering";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName1, colName1, dataValue2);
+ put2.addColumn(famName1, colName1, dataValue2);
tt.put(tx2, put2);
Transaction tx3 = tm.begin();
@@ -299,17 +297,17 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testServerSideSnapshotFiltering";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName1, colName1, dataValue2);
+ put2.addColumn(famName1, colName1, dataValue2);
// tt.put(tx2, put2);
Transaction tx3 = tm.begin();
@@ -344,19 +342,19 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testGetWithFamilyDelete";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY), famName2);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName2, colName2, dataValue1);
+ put2.addColumn(famName2, colName2, dataValue1);
tt.put(tx2, put2);
tm.commit(tx2);
@@ -425,7 +423,7 @@ public class TestSnapshotFilter {
readAfterCommit.await();
Transaction tx4 = tm.begin();
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Get get = new Get(rowName1);
Filter filter1 = new FilterList(FilterList.Operator.MUST_PASS_ONE,
@@ -451,10 +449,10 @@ public class TestSnapshotFilter {
};
readThread.start();
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
final HBaseTransaction t1 = (HBaseTransaction) tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
table.put(t1, put1);
tm.commit(t1);
@@ -477,19 +475,19 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testGetWithFilter";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY), famName2);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName2, colName2, dataValue1);
+ put2.addColumn(famName2, colName2, dataValue1);
tt.put(tx2, put2);
tm.commit(tx2);
@@ -528,19 +526,19 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testGetSecondResult";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName1, colName1, dataValue1);
+ put2.addColumn(famName1, colName1, dataValue1);
tt.put(tx2, put2);
Transaction tx3 = tm.begin();
@@ -568,12 +566,12 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanFirstResult";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
tm.commit(tx1);
@@ -592,7 +590,7 @@ public class TestSnapshotFilter {
Transaction tx3 = tm.begin();
Put put3 = new Put(rowName1);
- put3.add(famName1, colName1, dataValue1);
+ put3.addColumn(famName1, colName1, dataValue1);
tt.put(tx3, put3);
tm.commit(tx3);
@@ -623,17 +621,17 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanWithFilter";
createTableIfNotExists(TEST_TABLE, famName1, famName2);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName2, colName2, dataValue1);
+ put2.addColumn(famName2, colName2, dataValue1);
tt.put(tx2, put2);
tm.commit(tx2);
@@ -673,12 +671,12 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanSecondResult";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName1, colName1, dataValue1);
+ put1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
@@ -686,7 +684,7 @@ public class TestSnapshotFilter {
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName1);
- put2.add(famName1, colName1, dataValue1);
+ put2.addColumn(famName1, colName1, dataValue1);
tt.put(tx2, put2);
Transaction tx3 = tm.begin();
@@ -717,12 +715,12 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanFewResults";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName, colName1, dataValue1);
+ put1.addColumn(famName, colName1, dataValue1);
tt.put(tx1, put1);
tm.commit(tx1);
@@ -730,7 +728,7 @@ public class TestSnapshotFilter {
Transaction tx2 = tm.begin();
Put put2 = new Put(rowName2);
- put2.add(famName, colName2, dataValue2);
+ put2.addColumn(famName, colName2, dataValue2);
tt.put(tx2, put2);
tm.commit(tx2);
@@ -767,15 +765,15 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanFewResultsDifferentTransaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName, colName1, dataValue1);
+ put1.addColumn(famName, colName1, dataValue1);
tt.put(tx1, put1);
Put put2 = new Put(rowName2);
- put2.add(famName, colName2, dataValue2);
+ put2.addColumn(famName, colName2, dataValue2);
tt.put(tx1, put2);
tm.commit(tx1);
@@ -783,7 +781,7 @@ public class TestSnapshotFilter {
Transaction tx2 = tm.begin();
put2 = new Put(rowName2);
- put2.add(famName, colName2, dataValue2);
+ put2.addColumn(famName, colName2, dataValue2);
tt.put(tx2, put2);
tm.commit(tx2);
@@ -820,15 +818,15 @@ public class TestSnapshotFilter {
String TEST_TABLE = "testScanFewResultsSameTransaction";
createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY));
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Put put1 = new Put(rowName1);
- put1.add(famName, colName1, dataValue1);
+ put1.addColumn(famName, colName1, dataValue1);
tt.put(tx1, put1);
Put put2 = new Put(rowName2);
- put2.add(famName, colName2, dataValue2);
+ put2.addColumn(famName, colName2, dataValue2);
tt.put(tx1, put2);
tm.commit(tx1);
@@ -836,7 +834,7 @@ public class TestSnapshotFilter {
Transaction tx2 = tm.begin();
put2 = new Put(rowName2);
- put2.add(famName, colName2, dataValue2);
+ put2.addColumn(famName, colName2, dataValue2);
tt.put(tx2, put2);
Transaction tx3 = tm.begin();
[4/4] incubator-omid git commit: OMID-107 Replace pre 1.0 deprecated
HBase APIs
Posted by oh...@apache.org.
OMID-107 Replace pre 1.0 deprecated HBase APIs
Signed-off-by: Ohad Shacham <oh...@yahoo-inc.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/75dc8177
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/75dc8177
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/75dc8177
Branch: refs/heads/phoenix-integration
Commit: 75dc817753c08626c376c582148e8af197fdcd63
Parents: 81672f0
Author: James Taylor <ja...@apache.org>
Authored: Sun Aug 26 08:49:50 2018 -0700
Committer: Ohad Shacham <oh...@yahoo-inc.com>
Committed: Sun Sep 16 11:22:22 2018 +0300
----------------------------------------------------------------------
.../org/apache/omid/examples/BasicExample.java | 15 +-
.../omid/examples/ConfigurationExample.java | 23 +-
.../omid/examples/SnapshotIsolationExample.java | 9 +-
.../transaction/AttributeSetSnapshotFilter.java | 6 +-
.../apache/omid/transaction/HBaseCellId.java | 14 +-
.../transaction/HBaseSyncPostCommitter.java | 21 +-
.../omid/transaction/HBaseTransaction.java | 21 +-
.../transaction/HBaseTransactionManager.java | 26 +--
.../omid/transaction/HTableAccessWrapper.java | 14 +-
.../omid/transaction/SnapshotFilterImpl.java | 16 +-
.../org/apache/omid/transaction/TTable.java | 208 +++++++++----------
.../apache/omid/transaction/OmidTestBase.java | 60 +++---
.../TestAsynchronousPostCommitter.java | 62 +++---
.../apache/omid/transaction/TestAutoFlush.java | 8 +-
.../TestBaillisAnomaliesWithTXs.java | 60 +++---
.../omid/transaction/TestBasicTransaction.java | 60 +++---
.../apache/omid/transaction/TestCheckpoint.java | 51 ++---
.../apache/omid/transaction/TestDeletion.java | 62 +++---
.../TestEndToEndScenariosWithHA.java | 63 +++---
.../apache/omid/transaction/TestFilters.java | 29 +--
.../transaction/TestHBaseTransactionClient.java | 114 +++++-----
.../TestHBaseTransactionManager.java | 20 +-
.../transaction/TestMarkPutAsCommitted.java | 26 +--
.../omid/transaction/TestMultiplePut.java | 29 ++-
.../apache/omid/transaction/TestReadPath.java | 26 +--
.../omid/transaction/TestShadowCells.java | 96 +++++----
.../transaction/TestSingleColumnFamily.java | 12 +-
.../omid/transaction/TestTTableBehaviour.java | 25 +--
.../transaction/TestTransactionCleanup.java | 17 +-
.../transaction/TestTransactionConflict.java | 114 +++++-----
.../omid/transaction/TestTxMgrFailover.java | 35 ++--
.../apache/omid/transaction/TestUpdateScan.java | 24 +--
.../committable/hbase/HBaseCommitTable.java | 82 ++++----
.../committable/hbase/TestHBaseCommitTable.java | 58 +++---
.../org/apache/omid/transaction/CellUtils.java | 32 +--
.../apache/omid/transaction/TestCompaction.java | 208 ++++++++++---------
.../omid/transaction/TestSnapshotFilter.java | 126 ++++++-----
.../omid/tools/hbase/OmidTableManager.java | 30 +--
pom.xml | 4 +-
.../storage/HBaseTimestampStorage.java | 23 +-
.../org/apache/omid/tso/CacheEvaluation.java | 2 +-
.../org/apache/omid/tso/TestLeaseManager.java | 37 ++--
42 files changed, 1009 insertions(+), 959 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/examples/src/main/java/org/apache/omid/examples/BasicExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/omid/examples/BasicExample.java b/examples/src/main/java/org/apache/omid/examples/BasicExample.java
index d5f68eb..9090b05 100644
--- a/examples/src/main/java/org/apache/omid/examples/BasicExample.java
+++ b/examples/src/main/java/org/apache/omid/examples/BasicExample.java
@@ -17,13 +17,15 @@
*/
package org.apache.omid.examples;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.transaction.HBaseTransactionManager;
import org.apache.omid.transaction.TTable;
import org.apache.omid.transaction.Transaction;
import org.apache.omid.transaction.TransactionManager;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,20 +86,21 @@ public class BasicExample {
LOG.info("Creating access to Omid Transaction Manager & Transactional Table '{}'", userTableName);
try (TransactionManager tm = HBaseTransactionManager.newInstance();
- TTable txTable = new TTable(userTableName))
+ Connection conn = ConnectionFactory.createConnection();
+ TTable txTable = new TTable(conn, userTableName))
{
Transaction tx = tm.begin();
LOG.info("Transaction {} STARTED", tx);
Put row1 = new Put(exampleRow1);
- row1.add(family, qualifier, dataValue1);
+ row1.addColumn(family, qualifier, dataValue1);
txTable.put(tx, row1);
LOG.info("Transaction {} trying to write a new value in [TABLE:ROW/CF/Q] => {}:{}/{}/{} = {} ",
tx, userTableName, Bytes.toString(exampleRow1), Bytes.toString(family),
Bytes.toString(qualifier), Bytes.toString(dataValue1));
Put row2 = new Put(exampleRow2);
- row2.add(family, qualifier, dataValue2);
+ row2.addColumn(family, qualifier, dataValue2);
txTable.put(tx, row2);
LOG.info("Transaction {} trying to write a new value in [TABLE:ROW/CF/Q] => {}:{}/{}/{} = {} ",
tx, userTableName, Bytes.toString(exampleRow2), Bytes.toString(family),
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/examples/src/main/java/org/apache/omid/examples/ConfigurationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/omid/examples/ConfigurationExample.java b/examples/src/main/java/org/apache/omid/examples/ConfigurationExample.java
index aa59245..ec0678f 100644
--- a/examples/src/main/java/org/apache/omid/examples/ConfigurationExample.java
+++ b/examples/src/main/java/org/apache/omid/examples/ConfigurationExample.java
@@ -17,22 +17,24 @@
*/
package org.apache.omid.examples;
+import static org.apache.omid.tso.client.OmidClientConfiguration.ConnType.DIRECT;
+
+import java.io.IOException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.transaction.HBaseOmidClientConfiguration;
import org.apache.omid.transaction.HBaseTransactionManager;
import org.apache.omid.transaction.RollbackException;
import org.apache.omid.transaction.TTable;
import org.apache.omid.transaction.Transaction;
import org.apache.omid.transaction.TransactionManager;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-import static org.apache.omid.tso.client.OmidClientConfiguration.ConnType.DIRECT;
-
/**
* ****************************************************************************************************************
*
@@ -100,21 +102,22 @@ public class ConfigurationExample {
LOG.info("Creating access to Omid Transaction Manager & Transactional Table '{}'", userTableName);
try (TransactionManager tm = HBaseTransactionManager.newInstance(configuration);
- TTable txTable = new TTable(userTableName))
+ Connection conn = ConnectionFactory.createConnection();
+ TTable txTable = new TTable(conn, userTableName))
{
for (int i = 0; i < 100; i++) {
Transaction tx = tm.begin();
LOG.info("Transaction #{} {} STARTED", i, tx);
Put row1 = new Put(exampleRow1);
- row1.add(family, qualifier, dataValue1);
+ row1.addColumn(family, qualifier, dataValue1);
txTable.put(tx, row1);
LOG.info("Transaction {} trying to write a new value in [TABLE:ROW/CF/Q] => {}:{}/{}/{} = {} ",
tx, userTableName, Bytes.toString(exampleRow1), Bytes.toString(family),
Bytes.toString(qualifier), Bytes.toString(dataValue1));
Put row2 = new Put(exampleRow2);
- row2.add(family, qualifier, dataValue2);
+ row2.addColumn(family, qualifier, dataValue2);
txTable.put(tx, row2);
LOG.info("Transaction {} trying to write a new value in [TABLE:ROW/CF/Q] => {}:{}/{}/{} = {} ",
tx, userTableName, Bytes.toString(exampleRow2), Bytes.toString(family),
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/examples/src/main/java/org/apache/omid/examples/SnapshotIsolationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/omid/examples/SnapshotIsolationExample.java b/examples/src/main/java/org/apache/omid/examples/SnapshotIsolationExample.java
index 60ea22b..b68e19b 100644
--- a/examples/src/main/java/org/apache/omid/examples/SnapshotIsolationExample.java
+++ b/examples/src/main/java/org/apache/omid/examples/SnapshotIsolationExample.java
@@ -17,9 +17,11 @@
*/
package org.apache.omid.examples;
-import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -32,8 +34,7 @@ import org.apache.omid.transaction.TransactionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Arrays;
+import com.google.common.base.Preconditions;
/**
* ****************************************************************************************************************
@@ -118,7 +119,7 @@ public class SnapshotIsolationExample {
LOG.info("Creating access to Omid Transaction Manager & Transactional Table '{}'", userTableName);
tm = HBaseTransactionManager.newInstance();
- txTable = new TTable(userTableName);
+ txTable = new TTable(ConnectionFactory.createConnection(), userTableName);
}
void execute() throws IOException, RollbackException {
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/AttributeSetSnapshotFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/AttributeSetSnapshotFilter.java b/hbase-client/src/main/java/org/apache/omid/transaction/AttributeSetSnapshotFilter.java
index f4b6191..734ad5c 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/AttributeSetSnapshotFilter.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/AttributeSetSnapshotFilter.java
@@ -23,10 +23,10 @@ import java.util.Map;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable.CommitTimestamp;
import org.apache.omid.proto.TSOProto;
@@ -35,9 +35,9 @@ import com.google.common.base.Optional;
public class AttributeSetSnapshotFilter implements SnapshotFilter {
- private HTableInterface table;
+ private Table table;
- public AttributeSetSnapshotFilter(HTableInterface table) {
+ public AttributeSetSnapshotFilter(Table table) {
this.table = table;
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/HBaseCellId.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseCellId.java b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseCellId.java
index 63e6376..a70cfef 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseCellId.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseCellId.java
@@ -17,23 +17,22 @@
*/
package org.apache.omid.transaction;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
+import static com.google.common.base.Charsets.UTF_8;
import org.apache.omid.tso.client.CellId;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import static com.google.common.base.Charsets.UTF_8;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
public class HBaseCellId implements CellId {
- private final HTableInterface table;
+ private final TTable table;
private final byte[] row;
private final byte[] family;
private final byte[] qualifier;
private long timestamp;
- public HBaseCellId(HTableInterface table, byte[] row, byte[] family, byte[] qualifier, long timestamp) {
+ public HBaseCellId(TTable table, byte[] row, byte[] family, byte[] qualifier, long timestamp) {
this.timestamp = timestamp;
this.table = table;
this.row = row;
@@ -41,7 +40,7 @@ public class HBaseCellId implements CellId {
this.qualifier = qualifier;
}
- public HTableInterface getTable() {
+ public TTable getTable() {
return table;
}
@@ -61,6 +60,7 @@ public class HBaseCellId implements CellId {
return timestamp;
}
+ @Override
public String toString() {
return new String(table.getTableName(), UTF_8)
+ ":" + new String(row, UTF_8)
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java
index 4b3560f..d5f9c4d 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java
@@ -17,21 +17,22 @@
*/
package org.apache.omid.transaction;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
+import static org.apache.omid.metrics.MetricsUtils.name;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable;
import org.apache.omid.metrics.MetricsRegistry;
import org.apache.omid.metrics.Timer;
import org.apache.omid.tso.client.CellId;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import static org.apache.omid.metrics.MetricsUtils.name;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
public class HBaseSyncPostCommitter implements PostCommitActions {
@@ -53,12 +54,12 @@ public class HBaseSyncPostCommitter implements PostCommitActions {
private void addShadowCell(HBaseCellId cell, HBaseTransaction tx, SettableFuture<Void> updateSCFuture) {
Put put = new Put(cell.getRow());
- put.add(cell.getFamily(),
+ put.addColumn(cell.getFamily(),
CellUtils.addShadowCellSuffixPrefix(cell.getQualifier(), 0, cell.getQualifier().length),
cell.getTimestamp(),
Bytes.toBytes(tx.getCommitTimestamp()));
try {
- cell.getTable().put(put);
+ cell.getTable().getHTable().put(put);
} catch (IOException e) {
LOG.warn("{}: Error inserting shadow cell {}", tx, cell, e);
updateSCFuture.setException(
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransaction.java b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransaction.java
index feb042f..ffd93d9 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransaction.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransaction.java
@@ -17,17 +17,14 @@
*/
package org.apache.omid.transaction;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.omid.transaction.AbstractTransaction.VisibilityLevel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
+import org.apache.hadoop.hbase.client.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class HBaseTransaction extends AbstractTransaction<HBaseCellId> {
private static final Logger LOG = LoggerFactory.getLogger(HBaseTransaction.class);
@@ -45,9 +42,9 @@ public class HBaseTransaction extends AbstractTransaction<HBaseCellId> {
private void deleteCell(HBaseCellId cell) {
Delete delete = new Delete(cell.getRow());
- delete.deleteColumn(cell.getFamily(), cell.getQualifier(), cell.getTimestamp());
+ delete.addColumn(cell.getFamily(), cell.getQualifier(), cell.getTimestamp());
try {
- cell.getTable().delete(delete);
+ cell.getTable().getHTable().delete(delete);
} catch (IOException e) {
LOG.warn("Failed cleanup cell {} for Tx {}. This issue has been ignored", cell, getTransactionId(), e);
}
@@ -74,7 +71,7 @@ public class HBaseTransaction extends AbstractTransaction<HBaseCellId> {
*/
public void flushTables() throws IOException {
- for (HTableInterface writtenTable : getWrittenTables()) {
+ for (TTable writtenTable : getWrittenTables()) {
writtenTable.flushCommits();
}
@@ -84,9 +81,9 @@ public class HBaseTransaction extends AbstractTransaction<HBaseCellId> {
// Helper methods
// ****************************************************************************************************************
- private Set<HTableInterface> getWrittenTables() {
+ private Set<TTable> getWrittenTables() {
HashSet<HBaseCellId> writeSet = (HashSet<HBaseCellId>) getWriteSet();
- Set<HTableInterface> tables = new HashSet<HTableInterface>();
+ Set<TTable> tables = new HashSet<TTable>();
for (HBaseCellId cell : writeSet) {
tables.add(cell.getTable());
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransactionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransactionManager.java b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransactionManager.java
index e20f873..12323c3 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransactionManager.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/HBaseTransactionManager.java
@@ -17,11 +17,15 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable;
import org.apache.omid.committable.hbase.HBaseCommitTable;
import org.apache.omid.committable.hbase.HBaseCommitTableConfig;
@@ -29,17 +33,13 @@ import org.apache.omid.tools.hbase.HBaseLogin;
import org.apache.omid.tso.client.CellId;
import org.apache.omid.tso.client.OmidClientConfiguration.ConflictDetectionLevel;
import org.apache.omid.tso.client.TSOClient;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
public class HBaseTransactionManager extends AbstractTransactionManager implements HBaseTransactionClient {
@@ -248,7 +248,7 @@ public class HBaseTransactionManager extends AbstractTransactionManager implemen
this.hBaseCellId = hBaseCellId;
this.commitCache = commitCache;
this.tableAccessWrapper = null;
- this.tableAccessWrapper = new HTableAccessWrapper(hBaseCellId.getTable(), hBaseCellId.getTable());
+ this.tableAccessWrapper = new HTableAccessWrapper(hBaseCellId.getTable().getHTable(), hBaseCellId.getTable().getHTable());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/HTableAccessWrapper.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/HTableAccessWrapper.java b/hbase-client/src/main/java/org/apache/omid/transaction/HTableAccessWrapper.java
index 84c8d2c..f48fa55 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/HTableAccessWrapper.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/HTableAccessWrapper.java
@@ -17,25 +17,25 @@
*/
package org.apache.omid.transaction;
+import java.io.IOException;
+import java.util.List;
+
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
-
-import java.io.IOException;
-import java.util.List;
+import org.apache.hadoop.hbase.client.Table;
// This class wraps the HTableInterface object when doing client side filtering.
public class HTableAccessWrapper implements TableAccessWrapper {
- private final HTableInterface writeTable;
- private final HTableInterface readTable;
+ private final Table writeTable;
+ private final Table readTable;
- public HTableAccessWrapper(HTableInterface table, HTableInterface healerTable) {
+ public HTableAccessWrapper(Table table, Table healerTable) {
this.readTable = table;
this.writeTable = healerTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java b/hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java
index 65bbcc5..9f3628d 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java
@@ -23,7 +23,6 @@ import static org.apache.omid.committable.CommitTable.CommitTimestamp.Location.N
import static org.apache.omid.committable.CommitTable.CommitTimestamp.Location.SHADOW_CELL;
import java.io.IOException;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -41,6 +40,7 @@ import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable;
import org.apache.omid.committable.CommitTable.CommitTimestamp;
@@ -122,7 +122,7 @@ public class SnapshotFilterImpl implements SnapshotFilter {
byte[] shadowCellQualifier = CellUtils.addShadowCellSuffixPrefix(cell.getQualifierArray(),
cell.getQualifierOffset(),
cell.getQualifierLength());
- put.add(family, shadowCellQualifier, cell.getTimestamp(), Bytes.toBytes(commitTimestamp));
+ put.addColumn(family, shadowCellQualifier, cell.getTimestamp(), Bytes.toBytes(commitTimestamp));
try {
tableAccessWrapper.put(put);
} catch (IOException e) {
@@ -633,6 +633,18 @@ public class SnapshotFilterImpl implements SnapshotFilter {
public void close() {
innerScanner.close();
}
+
+ // So that Omid works with both HBase 1.3 and 1.4 without needing
+ // a new profile. Since this doesn't existing in 1.3, we don't
+ // add an @Override for it.
+ public ScanMetrics getScanMetrics() {
+ return null;
+ }
+
+ // Same as above
+ public boolean renewLease() {
+ return false;
+ }
@Override
public Iterator<Result> iterator() {
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/main/java/org/apache/omid/transaction/TTable.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/omid/transaction/TTable.java b/hbase-client/src/main/java/org/apache/omid/transaction/TTable.java
index 4813d5b..16400b8 100644
--- a/hbase-client/src/main/java/org/apache/omid/transaction/TTable.java
+++ b/hbase-client/src/main/java/org/apache/omid/transaction/TTable.java
@@ -19,6 +19,7 @@ package org.apache.omid.transaction;
import java.io.Closeable;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -29,21 +30,21 @@ import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.OperationWithAttributes;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable;
@@ -57,88 +58,68 @@ import com.google.common.base.Optional;
/**
* Provides transactional methods for accessing and modifying a given snapshot of data identified by an opaque {@link
- * Transaction} object. It mimics the behavior in {@link org.apache.hadoop.hbase.client.HTableInterface}
+ * Transaction} object. It mimics the behavior in {@link org.apache.hadoop.hbase.client.Table}
*/
public class TTable implements Closeable {
private static Logger LOG = LoggerFactory.getLogger(TTable.class);
- private final HTableInterface healerTable;
-
- private HTableInterface table;
+ private Table table;
private SnapshotFilter snapshotFilter;
private boolean serverSideFilter;
-
+
+ private final List<Mutation> mutations;
+
+ private boolean autoFlush = true;
+
// ----------------------------------------------------------------------------------------------------------------
// Construction
// ----------------------------------------------------------------------------------------------------------------
- public TTable(Configuration conf, byte[] tableName) throws IOException {
- this(new HTable(conf, tableName));
- }
-
- public TTable(Configuration conf, byte[] tableName, CommitTable.Client commitTableClient) throws IOException {
- this(new HTable(conf, tableName), commitTableClient);
+ public TTable(Connection connection, byte[] tableName) throws IOException {
+ this(connection.getTable(TableName.valueOf(tableName)));
}
- public TTable(String tableName) throws IOException {
- this(HBaseConfiguration.create(), Bytes.toBytes(tableName));
+ public TTable(Connection connection, byte[] tableName, CommitTable.Client commitTableClient) throws IOException {
+ this(connection.getTable(TableName.valueOf(tableName)), commitTableClient);
}
- public TTable(Configuration conf, String tableName) throws IOException {
- this(conf, Bytes.toBytes(tableName));
+ public TTable(Connection connection, String tableName) throws IOException {
+ this(connection.getTable(TableName.valueOf(tableName)));
}
- public TTable(Configuration conf, String tableName, CommitTable.Client commitTableClient) throws IOException {
- this(conf, Bytes.toBytes(tableName), commitTableClient);
+ public TTable(Connection connection, String tableName, CommitTable.Client commitTableClient) throws IOException {
+ this(connection.getTable(TableName.valueOf(tableName)), commitTableClient);
}
- public TTable(HTableInterface hTable) throws IOException {
+ public TTable(Table hTable) throws IOException {
this(hTable, hTable.getConfiguration().getBoolean("omid.server.side.filter", false));
}
- public TTable(HTableInterface hTable, boolean serverSideFilter) throws IOException {
+ public TTable(Table hTable, boolean serverSideFilter) throws IOException {
table = hTable;
- healerTable = new HTable(table.getConfiguration(), table.getTableName());
+ mutations = new ArrayList<Mutation>();
this.serverSideFilter = serverSideFilter;
snapshotFilter = (serverSideFilter) ? new AttributeSetSnapshotFilter(hTable) :
- new SnapshotFilterImpl(new HTableAccessWrapper(hTable, healerTable));
+ new SnapshotFilterImpl(new HTableAccessWrapper(hTable, hTable));
}
- public TTable(HTableInterface hTable, SnapshotFilter snapshotFilter ) throws IOException {
+ public TTable(Table hTable, SnapshotFilter snapshotFilter ) throws IOException {
table = hTable;
- healerTable = new HTable(table.getConfiguration(), table.getTableName());
+ mutations = new ArrayList<Mutation>();
this.snapshotFilter = snapshotFilter;
}
- public TTable(HTableInterface hTable, CommitTable.Client commitTableClient) throws IOException {
- table = hTable;
- healerTable = new HTable(table.getConfiguration(), table.getTableName());
- serverSideFilter = table.getConfiguration().getBoolean("omid.server.side.filter", false);
- snapshotFilter = (serverSideFilter) ? new AttributeSetSnapshotFilter(hTable) :
- new SnapshotFilterImpl(new HTableAccessWrapper(hTable, healerTable), commitTableClient);
- }
-
- public TTable(HTableInterface hTable, HTableInterface healerTable) throws IOException {
- table = hTable;
- this.healerTable = healerTable;
- Configuration config = table.getConfiguration();
- serverSideFilter = (config == null) ? false : config.getBoolean("omid.server.side.filter", false);
- snapshotFilter = (serverSideFilter) ? new AttributeSetSnapshotFilter(hTable) :
- new SnapshotFilterImpl(new HTableAccessWrapper(hTable, healerTable));
- }
-
- public TTable(HTableInterface hTable, HTableInterface healerTable, CommitTable.Client commitTableClient) throws IOException {
+ public TTable(Table hTable, CommitTable.Client commitTableClient) throws IOException {
table = hTable;
- this.healerTable = healerTable;
+ mutations = new ArrayList<Mutation>();
serverSideFilter = table.getConfiguration().getBoolean("omid.server.side.filter", false);
snapshotFilter = (serverSideFilter) ? new AttributeSetSnapshotFilter(hTable) :
- new SnapshotFilterImpl(new HTableAccessWrapper(hTable, healerTable), commitTableClient);
+ new SnapshotFilterImpl(new HTableAccessWrapper(hTable, hTable), commitTableClient);
}
-
// ----------------------------------------------------------------------------------------------------------------
// Closeable implementation
// ----------------------------------------------------------------------------------------------------------------
@@ -151,7 +132,6 @@ public class TTable implements Closeable {
@Override
public void close() throws IOException {
table.close();
- healerTable.close();
}
// ----------------------------------------------------------------------------------------------------------------
@@ -159,7 +139,7 @@ public class TTable implements Closeable {
// ----------------------------------------------------------------------------------------------------------------
/**
- * Transactional version of {@link HTableInterface#get(Get get)}
+ * Transactional version of {@link Table#get(Get get)}
*
* @param get an instance of Get
* @param tx an instance of transaction to be used
@@ -215,12 +195,12 @@ public class TTable implements Closeable {
byte[] family = entryF.getKey();
for (Entry<byte[], NavigableMap<Long, byte[]>> entryQ : entryF.getValue().entrySet()) {
byte[] qualifier = entryQ.getKey();
- tx.addWriteSetElement(new HBaseCellId(table, deleteP.getRow(), family, qualifier,
+ tx.addWriteSetElement(new HBaseCellId(this, deleteP.getRow(), family, qualifier,
tx.getWriteTimestamp()));
}
- deleteP.add(family, CellUtils.FAMILY_DELETE_QUALIFIER, tx.getWriteTimestamp(),
+ deleteP.addColumn(family, CellUtils.FAMILY_DELETE_QUALIFIER, tx.getWriteTimestamp(),
HConstants.EMPTY_BYTE_ARRAY);
- tx.addWriteSetElement(new HBaseCellId(table, deleteP.getRow(), family, CellUtils.FAMILY_DELETE_QUALIFIER,
+ tx.addWriteSetElement(new HBaseCellId(this, deleteP.getRow(), family, CellUtils.FAMILY_DELETE_QUALIFIER,
tx.getWriteTimestamp()));
}
}
@@ -230,16 +210,16 @@ public class TTable implements Closeable {
Set<byte[]> fset = deleteG.getFamilyMap().keySet();
for (byte[] family : fset) {
- deleteP.add(family, CellUtils.FAMILY_DELETE_QUALIFIER, tx.getWriteTimestamp(),
+ deleteP.addColumn(family, CellUtils.FAMILY_DELETE_QUALIFIER, tx.getWriteTimestamp(),
HConstants.EMPTY_BYTE_ARRAY);
- tx.addWriteSetElement(new HBaseCellId(table, deleteP.getRow(), family, CellUtils.FAMILY_DELETE_QUALIFIER,
+ tx.addWriteSetElement(new HBaseCellId(this, deleteP.getRow(), family, CellUtils.FAMILY_DELETE_QUALIFIER,
tx.getWriteTimestamp()));
}
}
/**
- * Transactional version of {@link HTableInterface#delete(Delete delete)}
+ * Transactional version of {@link Table#delete(Delete delete)}
*
* @param delete an instance of Delete
* @param tx an instance of transaction to be used
@@ -268,12 +248,12 @@ public class TTable implements Closeable {
CellUtils.validateCell(cell, writeTimestamp);
switch (KeyValue.Type.codeToType(cell.getTypeByte())) {
case DeleteColumn:
- deleteP.add(CellUtil.cloneFamily(cell),
+ deleteP.addColumn(CellUtil.cloneFamily(cell),
CellUtil.cloneQualifier(cell),
writeTimestamp,
CellUtils.DELETE_TOMBSTONE);
transaction.addWriteSetElement(
- new HBaseCellId(table,
+ new HBaseCellId(this,
delete.getRow(),
CellUtil.cloneFamily(cell),
CellUtil.cloneQualifier(cell),
@@ -285,12 +265,12 @@ public class TTable implements Closeable {
break;
case Delete:
if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {
- deleteP.add(CellUtil.cloneFamily(cell),
+ deleteP.addColumn(CellUtil.cloneFamily(cell),
CellUtil.cloneQualifier(cell),
writeTimestamp,
CellUtils.DELETE_TOMBSTONE);
transaction.addWriteSetElement(
- new HBaseCellId(table,
+ new HBaseCellId(this,
delete.getRow(),
CellUtil.cloneFamily(cell),
CellUtil.cloneQualifier(cell),
@@ -314,7 +294,7 @@ public class TTable implements Closeable {
}
if (!deleteP.isEmpty()) {
- table.put(deleteP);
+ addMutation(deleteP);
}
}
@@ -324,7 +304,7 @@ public class TTable implements Closeable {
}
/**
- * Transactional version of {@link HTableInterface#put(Put put)}
+ * Transactional version of {@link Table#put(Put put)}
*
* @param put an instance of Put
* @param tx an instance of transaction to be used
@@ -351,7 +331,7 @@ public class TTable implements Closeable {
KeyValue kv = KeyValueUtil.ensureKeyValue(c);
Bytes.putLong(kv.getValueArray(), kv.getTimestampOffset(), timestamp);
tsput.add(kv);
- tsput.add(CellUtil.cloneFamily(kv),
+ tsput.addColumn(CellUtil.cloneFamily(kv),
CellUtils.addShadowCellSuffixPrefix(CellUtil.cloneQualifier(kv), 0, CellUtil.cloneQualifier(kv).length),
kv.getTimestamp(),
Bytes.toBytes(commitTimestamp));
@@ -365,10 +345,10 @@ public class TTable implements Closeable {
/**
* @param put an instance of Put
* @param tx an instance of transaction to be used
- * @param autoCommit denotes whether to automatically commit the put
+ * @param addShadowCell denotes whether to add the shadow cell
* @throws IOException if a remote or network exception occurs.
*/
- public void put(Transaction tx, Put put, boolean autoCommit) throws IOException {
+ public void put(Transaction tx, Put put, boolean addShadowCell) throws IOException {
throwExceptionIfOpSetsTimerange(put);
@@ -390,14 +370,14 @@ public class TTable implements Closeable {
Bytes.putLong(kv.getValueArray(), kv.getTimestampOffset(), writeTimestamp);
tsput.add(kv);
- if (autoCommit) {
- tsput.add(CellUtil.cloneFamily(kv),
+ if (addShadowCell) {
+ tsput.addColumn(CellUtil.cloneFamily(kv),
CellUtils.addShadowCellSuffixPrefix(CellUtil.cloneQualifier(kv), 0, CellUtil.cloneQualifier(kv).length),
kv.getTimestamp(),
Bytes.toBytes(kv.getTimestamp()));
} else {
byte[] conflictFree = put.getAttribute(CellUtils.CONFLICT_FREE_MUTATION);
- HBaseCellId cellId = new HBaseCellId(table,
+ HBaseCellId cellId = new HBaseCellId(this,
CellUtil.cloneRow(kv),
CellUtil.cloneFamily(kv),
CellUtil.cloneQualifier(kv),
@@ -411,12 +391,18 @@ public class TTable implements Closeable {
}
}
}
-
- table.put(tsput);
+ addMutation(tsput);
}
+ private void addMutation(Mutation m) throws IOException {
+ mutations.add(m);
+ if (autoFlush) {
+ flushCommits();
+ }
+ }
+
/**
- * Transactional version of {@link HTableInterface#getScanner(Scan scan)}
+ * Transactional version of {@link Table#getScanner(Scan scan)}
*
* @param scan an instance of Scan
* @param tx an instance of transaction to be used
@@ -452,16 +438,15 @@ public class TTable implements Closeable {
}
/**
- * Delegates to {@link HTable#getTableName()}
*
* @return array of byte
*/
public byte[] getTableName() {
- return table.getTableName();
+ return table.getName().getName();
}
/**
- * Delegates to {@link HTable#getConfiguration()}
+ * Delegates to {@link Table#getConfiguration()}
*
* @return standard configuration object
*/
@@ -470,7 +455,7 @@ public class TTable implements Closeable {
}
/**
- * Delegates to {@link HTable#getTableDescriptor()}
+ * Delegates to {@link Table#getTableDescriptor()}
*
* @return HTableDescriptor an instance of HTableDescriptor
* @throws IOException if a remote or network exception occurs.
@@ -480,7 +465,7 @@ public class TTable implements Closeable {
}
/**
- * Transactional version of {@link HTableInterface#exists(Get get)}
+ * Transactional version of {@link Table#exists(Get get)}
*
* @param transaction an instance of transaction to be used
* @param get an instance of Get
@@ -508,7 +493,7 @@ public class TTable implements Closeable {
*/
/**
- * Transactional version of {@link HTableInterface#get(List gets)}
+ * Transactional version of {@link Table#get(List gets)}
*
* @param transaction an instance of transaction to be used
* @param gets list of Get instances
@@ -525,7 +510,7 @@ public class TTable implements Closeable {
}
/**
- * Transactional version of {@link HTableInterface#getScanner(byte[] family)}
+ * Transactional version of {@link Table#getScanner(byte[] family)}
*
* @param transaction an instance of transaction to be used
* @param family column family
@@ -539,7 +524,7 @@ public class TTable implements Closeable {
}
/**
- * Transactional version of {@link HTableInterface#getScanner(byte[] family, byte[] qualifier)}
+ * Transactional version of {@link Table#getScanner(byte[] family, byte[] qualifier)}
*
* @param transaction an instance of transaction to be used
* @param family column family
@@ -555,7 +540,7 @@ public class TTable implements Closeable {
}
/**
- * Transactional version of {@link HTableInterface#put(List puts)}
+ * Transactional version of {@link Table#put(List puts)}
*
* @param transaction an instance of transaction to be used
* @param puts List of puts
@@ -563,12 +548,31 @@ public class TTable implements Closeable {
*/
public void put(Transaction transaction, List<Put> puts) throws IOException {
for (Put put : puts) {
- put(transaction, put);
+ put(transaction, put, false);
}
}
/**
- * Transactional version of {@link HTableInterface#delete(List deletes)}
+ * Transactional version of {@link Table#put(List puts)}
+ *
+ * @param transaction an instance of transaction to be used
+ * @param puts List of puts
+ * @throws IOException if a remote or network exception occurs
+ */
+ public void batch(Transaction transaction, List<Mutation> mutations) throws IOException {
+ for (Mutation mutation : mutations) {
+ if (mutation instanceof Put) {
+ put(transaction, (Put)mutation);
+ } else if (mutation instanceof Delete) {
+ delete(transaction, (Delete)mutation);
+ } else {
+ throw new UnsupportedOperationException("Unsupported mutation: " + mutation);
+ }
+ }
+ }
+
+ /**
+ * Transactional version of {@link Table#delete(List deletes)}
*
* @param transaction an instance of transaction to be used
* @param deletes List of deletes
@@ -581,48 +585,32 @@ public class TTable implements Closeable {
}
/**
- * Provides access to the underliying HTable in order to configure it or to perform unsafe (non-transactional)
+ * Provides access to the underliying Table in order to configure it or to perform unsafe (non-transactional)
* operations. The latter would break the transactional guarantees of the whole system.
*
- * @return The underlying HTable object
+ * @return The underlying Table object
*/
- public HTableInterface getHTable() {
+ public Table getHTable() {
return table;
}
- /**
- * Delegates to {@link HTable#setAutoFlush(boolean autoFlush)}
- */
public void setAutoFlush(boolean autoFlush) {
- table.setAutoFlush(autoFlush, true);
+ this.autoFlush = autoFlush;
}
- /**
- * Delegates to {@link HTable#isAutoFlush()}
- */
public boolean isAutoFlush() {
- return table.isAutoFlush();
+ return autoFlush;
}
- /**
- * Delegates to see HTable.getWriteBufferSize()
- */
- public long getWriteBufferSize() {
- return table.getWriteBufferSize();
- }
-
- /**
- * Delegates to see HTable.setWriteBufferSize()
- */
- public void setWriteBufferSize(long writeBufferSize) throws IOException {
- table.setWriteBufferSize(writeBufferSize);
- }
-
- /**
- * Delegates to see HTable.flushCommits()
- */
public void flushCommits() throws IOException {
- table.flushCommits();
+ try {
+ table.batch(this.mutations, new Object[mutations.size()]);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new RuntimeException(e);
+ } finally {
+ this.mutations.clear();
+ }
}
// ----------------------------------------------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/OmidTestBase.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/OmidTestBase.java b/hbase-client/src/test/java/org/apache/omid/transaction/OmidTestBase.java
index 226db44..79f02eb 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/OmidTestBase.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/OmidTestBase.java
@@ -17,19 +17,12 @@
*/
package org.apache.omid.transaction;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.apache.omid.TestUtils;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.committable.InMemoryCommitTable;
-import org.apache.omid.committable.hbase.HBaseCommitTableConfig;
-import org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig;
-import org.apache.omid.tools.hbase.OmidTableManager;
-import org.apache.omid.tso.TSOMockModule;
-import org.apache.omid.tso.TSOServer;
-import org.apache.omid.tso.TSOServerConfig;
-import org.apache.omid.tso.client.OmidClientConfiguration;
-import org.apache.omid.tso.client.TSOClient;
+import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
@@ -39,11 +32,25 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.TestUtils;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.committable.InMemoryCommitTable;
+import org.apache.omid.committable.hbase.HBaseCommitTableConfig;
+import org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig;
+import org.apache.omid.tools.hbase.OmidTableManager;
+import org.apache.omid.tso.TSOMockModule;
+import org.apache.omid.tso.TSOServer;
+import org.apache.omid.tso.TSOServerConfig;
+import org.apache.omid.tso.client.OmidClientConfiguration;
+import org.apache.omid.tso.client.TSOClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
@@ -52,11 +59,8 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
public abstract class OmidTestBase {
@@ -65,6 +69,7 @@ public abstract class OmidTestBase {
static HBaseTestingUtility hBaseUtils;
private static MiniHBaseCluster hbaseCluster;
static Configuration hbaseConf;
+ static Connection connection;
protected static final String TEST_TABLE = "test";
protected static final String TEST_FAMILY = "data";
@@ -119,6 +124,7 @@ public abstract class OmidTestBase {
hBaseUtils = new HBaseTestingUtility(hbaseConf);
hbaseCluster = hBaseUtils.startMiniCluster(1);
+ connection = ConnectionFactory.createConnection(hbaseConf);
hBaseUtils.createTable(Bytes.toBytes(hBaseTimestampStorageConfig.getTableName()),
new byte[][]{hBaseTimestampStorageConfig.getFamilyName().getBytes()},
Integer.MAX_VALUE);
@@ -210,17 +216,19 @@ public abstract class OmidTestBase {
public void afterMethod() {
try {
LOG.info("tearing Down");
- HBaseAdmin admin = hBaseUtils.getHBaseAdmin();
+ Admin admin = hBaseUtils.getHBaseAdmin();
deleteTable(admin, TableName.valueOf(TEST_TABLE));
createTestTable();
- deleteTable(admin, TableName.valueOf(hBaseCommitTableConfig.getTableName()));
+ if (hBaseCommitTableConfig != null) {
+ deleteTable(admin, TableName.valueOf(hBaseCommitTableConfig.getTableName()));
+ }
createCommitTable();
} catch (Exception e) {
LOG.error("Error tearing down", e);
}
}
- void deleteTable(HBaseAdmin admin, TableName tableName) throws IOException {
+ void deleteTable(Admin admin, TableName tableName) throws IOException {
if (admin.tableExists(tableName)) {
if (admin.isTableDisabled(tableName)) {
admin.deleteTable(tableName);
@@ -231,16 +239,16 @@ public abstract class OmidTestBase {
}
}
- static boolean verifyValue(byte[] tableName, byte[] row,
+ static boolean verifyValue(Table table, byte[] row,
byte[] fam, byte[] col, byte[] value) {
- try (HTable table = new HTable(hbaseConf, tableName)) {
+ try {
Get g = new Get(row).setMaxVersions(1);
Result r = table.get(g);
Cell cell = r.getColumnLatestCell(fam, col);
if (LOG.isTraceEnabled()) {
- LOG.trace("Value for " + Bytes.toString(tableName) + ":"
+ LOG.trace("Value for " + table.getName().getNameAsString() + ":"
+ Bytes.toString(row) + ":" + Bytes.toString(fam)
+ Bytes.toString(col) + "=>" + Bytes.toString(CellUtil.cloneValue(cell))
+ " (" + Bytes.toString(value) + " expected)");
@@ -248,7 +256,7 @@ public abstract class OmidTestBase {
return Bytes.equals(CellUtil.cloneValue(cell), value);
} catch (IOException e) {
- LOG.error("Error reading row " + Bytes.toString(tableName) + ":"
+ LOG.error("Error reading row " + table.getName().getNameAsString() + ":"
+ Bytes.toString(row) + ":" + Bytes.toString(fam)
+ Bytes.toString(col), e);
return false;
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestAsynchronousPostCommitter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestAsynchronousPostCommitter.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestAsynchronousPostCommitter.java
index 1dc59f8..5979c80 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestAsynchronousPostCommitter.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestAsynchronousPostCommitter.java
@@ -17,18 +17,25 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.metrics.NullMetricsProvider;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.metrics.NullMetricsProvider;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -36,18 +43,12 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executors;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.SettableFuture;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
@Test(groups = "sharedHBase")
public class TestAsynchronousPostCommitter extends OmidTestBase {
@@ -55,12 +56,11 @@ public class TestAsynchronousPostCommitter extends OmidTestBase {
private static final Logger LOG = LoggerFactory.getLogger(TestAsynchronousPostCommitter.class);
private static final byte[] family = Bytes.toBytes(TEST_FAMILY);
- private static final byte[] nonExistentFamily = Bytes.toBytes("non-existent");
private static final byte[] qualifier = Bytes.toBytes("test-qual");
byte[] row1 = Bytes.toBytes("test-is-committed1");
byte[] row2 = Bytes.toBytes("test-is-committed2");
-
+
@Test(timeOut = 30_000)
public void testPostCommitActionsAreCalledAsynchronously(ITestContext context) throws Exception {
@@ -107,16 +107,16 @@ public class TestAsynchronousPostCommitter extends OmidTestBase {
}
}).when(syncPostCommitter).removeCommitTableEntry(any(AbstractTransaction.class));
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Execute tx with async post commit actions
Transaction tx1 = tm.begin();
Put put1 = new Put(row1);
- put1.add(family, qualifier, Bytes.toBytes("hey!"));
+ put1.addColumn(family, qualifier, Bytes.toBytes("hey!"));
txTable.put(tx1, put1);
Put put2 = new Put(row2);
- put2.add(family, qualifier, Bytes.toBytes("hou!"));
+ put2.addColumn(family, qualifier, Bytes.toBytes("hou!"));
txTable.put(tx1, put2);
tm.commit(tx1);
@@ -214,16 +214,16 @@ public class TestAsynchronousPostCommitter extends OmidTestBase {
}).when(syncPostCommitter).removeCommitTableEntry(any(AbstractTransaction.class));
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Execute tx with async post commit actions
Transaction tx1 = tm.begin();
Put put1 = new Put(row1);
- put1.add(family, qualifier, Bytes.toBytes("hey!"));
+ put1.addColumn(family, qualifier, Bytes.toBytes("hey!"));
txTable.put(tx1, put1);
Put put2 = new Put(row2);
- put2.add(family, qualifier, Bytes.toBytes("hou!"));
+ put2.addColumn(family, qualifier, Bytes.toBytes("hou!"));
txTable.put(tx1, put2);
tm.commit(tx1);
@@ -283,16 +283,16 @@ public class TestAsynchronousPostCommitter extends OmidTestBase {
}).when(syncPostCommitter).removeCommitTableEntry(any(AbstractTransaction.class));
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Execute tx with async post commit actions
Transaction tx1 = tm.begin();
Put put1 = new Put(row1);
- put1.add(family, qualifier, Bytes.toBytes("hey!"));
+ put1.addColumn(family, qualifier, Bytes.toBytes("hey!"));
txTable.put(tx1, put1);
Put put2 = new Put(row2);
- put2.add(family, qualifier, Bytes.toBytes("hou!"));
+ put2.addColumn(family, qualifier, Bytes.toBytes("hou!"));
txTable.put(tx1, put2);
tm.commit(tx1);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
index 305e80a..fac64ac 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
@@ -17,6 +17,8 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertEquals;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -24,8 +26,6 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-
@Test(groups = "sharedHBase")
public class TestAutoFlush extends OmidTestBase {
@@ -37,14 +37,14 @@ public class TestAutoFlush extends OmidTestBase {
byte[] col = Bytes.toBytes("col1");
byte[] data = Bytes.toBytes("data");
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
// Turn off autoflush
table.setAutoFlush(false);
Transaction t = tm.begin();
Put put = new Put(row);
- put.add(family, col, data);
+ put.addColumn(family, col, data);
table.put(t, put);
// Data shouldn't be in DB yet
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestBaillisAnomaliesWithTXs.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestBaillisAnomaliesWithTXs.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestBaillisAnomaliesWithTXs.java
index cd6216c..9315751 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestBaillisAnomaliesWithTXs.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestBaillisAnomaliesWithTXs.java
@@ -17,6 +17,14 @@
*/
package org.apache.omid.transaction;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.util.Arrays;
+
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -31,14 +39,6 @@ import org.testng.ITestContext;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.fail;
-
/**
* These tests try to analyze the transactional anomalies described by P. Baillis et al. in
* http://arxiv.org/pdf/1302.0309.pdf
@@ -89,7 +89,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -103,7 +103,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 2) insert into test (id, value) values(3, 30); -- T2
Put newRow = new Put(rowId3);
- newRow.add(famName, colName, dataValue3);
+ newRow.addColumn(famName, colName, dataValue3);
txTable.put(tx2, newRow);
// 3) Commit TX 2
@@ -129,7 +129,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -143,7 +143,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
Put row = new Put(updateRes.getRow());
int val = Bytes.toInt(updateRes.getValue(famName, colName));
LOG.info("Updating row id {} with value {}", Bytes.toString(updateRes.getRow()), val);
- row.add(famName, colName, Bytes.toBytes(val + 10));
+ row.addColumn(famName, colName, Bytes.toBytes(val + 10));
txTable.put(tx1, row);
updateRes = tx1Scanner.next();
count++;
@@ -198,7 +198,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -237,12 +237,12 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 3) update test set value = 11 where id = 1; -- T1
Put updateRow1Tx1 = new Put(rowId1);
- updateRow1Tx1.add(famName, colName, Bytes.toBytes("11"));
+ updateRow1Tx1.addColumn(famName, colName, Bytes.toBytes("11"));
txTable.put(tx1, updateRow1Tx1);
// 4) update test set value = 11 where id = 1; -- T2
Put updateRow1Tx2 = new Put(rowId1);
- updateRow1Tx2.add(famName, colName, Bytes.toBytes("11"));
+ updateRow1Tx2.addColumn(famName, colName, Bytes.toBytes("11"));
txTable.put(tx2, updateRow1Tx2);
// 5) commit -- T1
@@ -274,7 +274,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -329,12 +329,12 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 4) update test set value = 12 where id = 1; -- T2
Put updateRow1Tx2 = new Put(rowId1);
- updateRow1Tx2.add(famName, colName, Bytes.toBytes("12"));
+ updateRow1Tx2.addColumn(famName, colName, Bytes.toBytes("12"));
txTable.put(tx1, updateRow1Tx2);
// 5) update test set value = 18 where id = 1; -- T2
Put updateRow2Tx2 = new Put(rowId2);
- updateRow2Tx2.add(famName, colName, Bytes.toBytes("18"));
+ updateRow2Tx2.addColumn(famName, colName, Bytes.toBytes("18"));
txTable.put(tx2, updateRow2Tx2);
// 6) commit -- T2
@@ -374,7 +374,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -387,9 +387,9 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 3) update test set value = 12 where id = 1; -- T2
// 4) update test set value = 18 where id = 2; -- T2
Put updateRow1Tx2 = new Put(rowId1);
- updateRow1Tx2.add(famName, colName, Bytes.toBytes(12));
+ updateRow1Tx2.addColumn(famName, colName, Bytes.toBytes(12));
Put updateRow2Tx2 = new Put(rowId2);
- updateRow2Tx2.add(famName, colName, Bytes.toBytes(18));
+ updateRow2Tx2.addColumn(famName, colName, Bytes.toBytes(18));
txTable.put(tx2, Arrays.asList(updateRow1Tx2, updateRow2Tx2));
// 5) commit; -- T2
@@ -435,7 +435,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -492,12 +492,12 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 3) update test set value = 11 where id = 1; -- T1
Put updateRow1Tx1 = new Put(rowId1);
- updateRow1Tx1.add(famName, colName, Bytes.toBytes("11"));
+ updateRow1Tx1.addColumn(famName, colName, Bytes.toBytes("11"));
txTable.put(tx1, updateRow1Tx1);
// 4) update test set value = 21 where id = 2; -- T2
Put updateRow2Tx2 = new Put(rowId2);
- updateRow2Tx2.add(famName, colName, Bytes.toBytes("21"));
+ updateRow2Tx2.addColumn(famName, colName, Bytes.toBytes("21"));
txTable.put(tx2, updateRow2Tx2);
// 5) commit; -- T1
@@ -523,7 +523,7 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 0) Start transactions
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
Transaction tx2 = tm.begin();
@@ -542,12 +542,12 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
// 3) insert into test (id, value) values(3, 30); -- T1
Put insertRow3Tx1 = new Put(rowId1);
- insertRow3Tx1.add(famName, colName, Bytes.toBytes("30"));
+ insertRow3Tx1.addColumn(famName, colName, Bytes.toBytes("30"));
txTable.put(tx1, insertRow3Tx1);
// 4) insert into test (id, value) values(4, 42); -- T2
Put updateRow4Tx2 = new Put(rowId2);
- updateRow4Tx2.add(famName, colName, Bytes.toBytes("42"));
+ updateRow4Tx2.addColumn(famName, colName, Bytes.toBytes("42"));
txTable.put(tx2, updateRow4Tx2);
// 5) commit; -- T1
@@ -570,14 +570,14 @@ public class TestBaillisAnomaliesWithTXs extends OmidTestBase {
private void loadBaseDataOnTestTable(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction initializationTx = tm.begin();
Put row1 = new Put(rowId1);
- row1.add(famName, colName, dataValue1);
+ row1.addColumn(famName, colName, dataValue1);
txTable.put(initializationTx, row1);
Put row2 = new Put(rowId2);
- row2.add(famName, colName, dataValue2);
+ row2.addColumn(famName, colName, dataValue2);
txTable.put(initializationTx, row2);
tm.commit(initializationTx);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestBasicTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestBasicTransaction.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestBasicTransaction.java
index 1b793a1..28af0a6 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestBasicTransaction.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestBasicTransaction.java
@@ -17,6 +17,10 @@
*/
package org.apache.omid.transaction;
+import static org.junit.Assert.fail;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -28,10 +32,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.junit.Assert.fail;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestBasicTransaction extends OmidTestBase {
@@ -42,7 +42,7 @@ public class TestBasicTransaction extends OmidTestBase {
public void testTimestampsOfTwoRowsInstertedAfterCommitOfSingleTransactionAreEquals(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] rowName2 = Bytes.toBytes("row2");
@@ -54,10 +54,10 @@ public class TestBasicTransaction extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
Put row2 = new Put(rowName2);
- row2.add(famName1, colName1, dataValue2);
+ row2.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row2);
tm.commit(tx1);
@@ -88,7 +88,7 @@ public class TestBasicTransaction extends OmidTestBase {
throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] rowName2 = Bytes.toBytes("row2");
@@ -103,10 +103,10 @@ public class TestBasicTransaction extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
Put row2 = new Put(rowName2);
- row2.add(famName1, colName1, dataValue2);
+ row2.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row2);
tm.commit(tx1);
@@ -114,10 +114,10 @@ public class TestBasicTransaction extends OmidTestBase {
Transaction tx2 = tm.begin();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue3);
+ row1.addColumn(famName1, colName1, dataValue3);
tt.put(tx2, row1);
row2 = new Put(rowName2);
- row2.add(famName1, colName1, dataValue4);
+ row2.addColumn(famName1, colName1, dataValue4);
tt.put(tx2, row2);
tm.commit(tx2);
@@ -155,7 +155,7 @@ public class TestBasicTransaction extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -167,14 +167,14 @@ public class TestBasicTransaction extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
tm.commit(t1);
Transaction tread = tm.begin();
Transaction t2 = tm.begin();
p = new Put(row);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
tt.put(t2, p);
tm.commit(t2);
@@ -192,7 +192,7 @@ public class TestBasicTransaction extends OmidTestBase {
public void runTestManyVersions(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -204,14 +204,14 @@ public class TestBasicTransaction extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
tm.commit(t1);
for (int i = 0; i < 5; ++i) {
Transaction t2 = tm.begin();
p = new Put(row);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
tt.put(t2, p);
}
Transaction tread = tm.begin();
@@ -231,7 +231,7 @@ public class TestBasicTransaction extends OmidTestBase {
public void runTestInterleave(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -243,13 +243,13 @@ public class TestBasicTransaction extends OmidTestBase {
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
tt.put(t1, p);
tm.commit(t1);
Transaction t2 = tm.begin();
p = new Put(row);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
tt.put(t2, p);
Transaction tread = tm.begin();
@@ -278,7 +278,7 @@ public class TestBasicTransaction extends OmidTestBase {
public void testInterleavedScanReturnsTheRightSnapshotResults(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// Basic data-scaffolding for test
byte[] fam = Bytes.toBytes(TEST_FAMILY);
@@ -296,7 +296,7 @@ public class TestBasicTransaction extends OmidTestBase {
byte[] row = Bytes.toBytes("row-to-scan" + i);
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
txTable.put(tx1, p);
}
tm.commit(tx1);
@@ -305,7 +305,7 @@ public class TestBasicTransaction extends OmidTestBase {
// that scans the table, gets the proper snapshot with the stuff written by Tx1
Transaction tx2 = tm.begin();
Put p = new Put(randomRow);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
txTable.put(tx2, p);
Transaction scanTx = tm.begin(); // This is the concurrent transactional scanner
@@ -362,7 +362,7 @@ public class TestBasicTransaction extends OmidTestBase {
throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
// Basic data-scaffolding for test
byte[] fam = Bytes.toBytes(TEST_FAMILY);
@@ -380,7 +380,7 @@ public class TestBasicTransaction extends OmidTestBase {
byte[] row = Bytes.toBytes("row-to-scan" + i);
Put p = new Put(row);
- p.add(fam, col, data1);
+ p.addColumn(fam, col, data1);
txTable.put(tx1, p);
}
tm.commit(tx1);
@@ -389,7 +389,7 @@ public class TestBasicTransaction extends OmidTestBase {
// right snapshot with the new value in the random row just written by Tx2
Transaction tx2 = tm.begin();
Put p = new Put(randomRow);
- p.add(fam, col, data2);
+ p.addColumn(fam, col, data2);
txTable.put(tx2, p);
int modifiedRows = 0;
@@ -442,7 +442,7 @@ public class TestBasicTransaction extends OmidTestBase {
throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -452,7 +452,7 @@ public class TestBasicTransaction extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
Transaction tx2 = tm.begin();
@@ -465,7 +465,7 @@ public class TestBasicTransaction extends OmidTestBase {
assertEquals(r.size(), 0, "Unexpected size for read.");
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx2, row1, true);
r = tt.get(tx3, g);
[3/4] incubator-omid git commit: OMID-107 Replace pre 1.0 deprecated
HBase APIs
Posted by oh...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestCheckpoint.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestCheckpoint.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestCheckpoint.java
index 65a2ac5..e3763b4 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestCheckpoint.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestCheckpoint.java
@@ -17,9 +17,12 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertTrue;
+
import java.util.List;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
@@ -32,8 +35,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestCheckpoint extends OmidTestBase {
@@ -53,7 +54,7 @@ public class TestCheckpoint extends OmidTestBase {
public void testFewCheckPoints(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -67,7 +68,7 @@ public class TestCheckpoint extends OmidTestBase {
HBaseTransaction hbaseTx1 = enforceHBaseTransactionAsParam(tx1);
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
Get g = new Get(rowName1).setMaxVersions(1);
@@ -79,7 +80,7 @@ public class TestCheckpoint extends OmidTestBase {
hbaseTx1.checkpoint();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue2);
+ row1.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row1);
r = tt.get(tx1, g);
@@ -95,7 +96,7 @@ public class TestCheckpoint extends OmidTestBase {
hbaseTx1.checkpoint();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue3);
+ row1.addColumn(famName1, colName1, dataValue3);
tt.put(tx1, row1);
r = tt.get(tx1, g);
@@ -115,13 +116,13 @@ public class TestCheckpoint extends OmidTestBase {
assertTrue(r.size() == 3, "Expected 3 results and found " + r.size());
List<Cell> cells = r.getColumnCells(famName1, colName1);
- assertTrue(Bytes.equals(dataValue3, cells.get(0).getValue()),
+ assertTrue(Bytes.equals(dataValue3, CellUtil.cloneValue(cells.get(0))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
- assertTrue(Bytes.equals(dataValue2, cells.get(1).getValue()),
+ assertTrue(Bytes.equals(dataValue2, CellUtil.cloneValue(cells.get(1))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
- assertTrue(Bytes.equals(dataValue1, cells.get(2).getValue()),
+ assertTrue(Bytes.equals(dataValue1, CellUtil.cloneValue(cells.get(2))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
tt.close();
@@ -130,7 +131,7 @@ public class TestCheckpoint extends OmidTestBase {
@Test(timeOut = 30_000)
public void testSNAPSHOT(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -142,7 +143,7 @@ public class TestCheckpoint extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue0);
+ row1.addColumn(famName1, colName1, dataValue0);
tt.put(tx1, row1);
tm.commit(tx1);
@@ -158,7 +159,7 @@ public class TestCheckpoint extends OmidTestBase {
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
@@ -169,7 +170,7 @@ public class TestCheckpoint extends OmidTestBase {
hbaseTx1.checkpoint();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue2);
+ row1.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row1);
r = tt.get(tx1, g);
@@ -188,7 +189,7 @@ public class TestCheckpoint extends OmidTestBase {
@Test(timeOut = 30_000)
public void testSNAPSHOT_ALL(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -200,7 +201,7 @@ public class TestCheckpoint extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue0);
+ row1.addColumn(famName1, colName1, dataValue0);
tt.put(tx1, row1);
tm.commit(tx1);
@@ -216,7 +217,7 @@ public class TestCheckpoint extends OmidTestBase {
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
g = new Get(rowName1).setMaxVersions(100);
@@ -228,7 +229,7 @@ public class TestCheckpoint extends OmidTestBase {
hbaseTx1.checkpoint();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue2);
+ row1.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row1);
r = tt.get(tx1, g);
@@ -242,13 +243,13 @@ public class TestCheckpoint extends OmidTestBase {
assertTrue(r.size() == 3, "Expected 3 results and found " + r.size());
List<Cell> cells = r.getColumnCells(famName1, colName1);
- assertTrue(Bytes.equals(dataValue2, cells.get(0).getValue()),
+ assertTrue(Bytes.equals(dataValue2, CellUtil.cloneValue(cells.get(0))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
- assertTrue(Bytes.equals(dataValue1, cells.get(1).getValue()),
+ assertTrue(Bytes.equals(dataValue1, CellUtil.cloneValue(cells.get(1))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
- assertTrue(Bytes.equals(dataValue0, cells.get(2).getValue()),
+ assertTrue(Bytes.equals(dataValue0, CellUtil.cloneValue(cells.get(2))),
"Unexpected value for SI read " + tx1 + ": " + Bytes.toString(r.getValue(famName1, colName1)));
tt.close();
@@ -257,7 +258,7 @@ public class TestCheckpoint extends OmidTestBase {
@Test(timeOut = 30_000)
public void testSNAPSHOT_EXCLUDE_CURRENT(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -270,7 +271,7 @@ public class TestCheckpoint extends OmidTestBase {
HBaseTransaction hbaseTx1 = enforceHBaseTransactionAsParam(tx1);
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
Get g = new Get(rowName1).setMaxVersions(1);
@@ -282,7 +283,7 @@ public class TestCheckpoint extends OmidTestBase {
hbaseTx1.checkpoint();
row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue2);
+ row1.addColumn(famName1, colName1, dataValue2);
tt.put(tx1, row1);
r = tt.get(tx1, g);
@@ -301,7 +302,7 @@ public class TestCheckpoint extends OmidTestBase {
@Test(timeOut = 30_000)
public void testDeleteAfterCheckpoint(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
byte[] rowName1 = Bytes.toBytes("row1");
byte[] famName1 = Bytes.toBytes(TEST_FAMILY);
@@ -311,7 +312,7 @@ public class TestCheckpoint extends OmidTestBase {
Transaction tx1 = tm.begin();
Put row1 = new Put(rowName1);
- row1.add(famName1, colName1, dataValue1);
+ row1.addColumn(famName1, colName1, dataValue1);
tt.put(tx1, row1);
tm.commit(tx1);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
index c426c1b..1fce295 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
@@ -17,9 +17,15 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -31,13 +37,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestDeletion extends OmidTestBase {
@@ -66,7 +65,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteFamilyRow(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
((HBaseTransactionManager) tm).setConflictDetectionLevel(ConflictDetectionLevel.ROW);
@@ -80,7 +79,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -98,7 +97,7 @@ public class TestDeletion extends OmidTestBase {
assertEquals(countFamColA, null);
Transaction t3 = tm.begin();
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t3, d);
tscan = tm.begin();
@@ -116,7 +115,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteFamilyCell(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -128,7 +127,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -146,7 +145,7 @@ public class TestDeletion extends OmidTestBase {
assertEquals(countFamColA, null);
Transaction t3 = tm.begin();
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t3, d);
tscan = tm.begin();
@@ -162,7 +161,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteFamily(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -175,7 +174,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -198,7 +197,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteFamilyRowLevelCA(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
((HBaseTransactionManager) tm).setConflictDetectionLevel(ConflictDetectionLevel.ROW);
@@ -213,7 +212,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -238,7 +237,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteFamilyAborts(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
((HBaseTransactionManager) tm).setConflictDetectionLevel(ConflictDetectionLevel.ROW);
@@ -255,7 +254,7 @@ public class TestDeletion extends OmidTestBase {
tm.commit(t1);
Delete d = new Delete(modrow);
- d.deleteFamily(famA);
+ d.addFamily(famA);
tt.delete(t2, d);
try {
@@ -279,7 +278,7 @@ public class TestDeletion extends OmidTestBase {
public void runTestDeleteColumn(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -293,7 +292,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteColumn(famA, colA);
+ d.addColumn(famA, colA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -314,13 +313,13 @@ public class TestDeletion extends OmidTestBase {
}
/**
- * This test is very similar to #runTestDeleteColumn() but exercises Delete#deleteColumns()
+ * This test is very similar to #runTestDeleteColumn() but exercises Delete#addColumns()
*/
@Test(timeOut = 10_000)
public void runTestDeleteColumns(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -334,7 +333,7 @@ public class TestDeletion extends OmidTestBase {
Transaction t2 = tm.begin();
Delete d = new Delete(modrow);
- d.deleteColumns(famA, colA);
+ d.addColumns(famA, colA);
tt.delete(t2, d);
Transaction tscan = tm.begin();
@@ -358,7 +357,7 @@ public class TestDeletion extends OmidTestBase {
@Test(timeOut = 10_000)
public void runTestDeleteRow(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
+ TTable tt = new TTable(connection, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
@@ -397,12 +396,12 @@ public class TestDeletion extends OmidTestBase {
// Setup initial environment for the test
// --------------------------------------------------------------------
TransactionManager tm = newTransactionManager(context);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE);
+ TTable txTable = new TTable(connection, TEST_TABLE);
Transaction tx1 = tm.begin();
LOG.info("{} writing initial data created ", tx1);
Put p = new Put(Bytes.toBytes("row1"));
- p.add(famA, colA, data1);
+ p.addColumn(famA, colA, data1);
txTable.put(tx1, p);
tm.commit(tx1);
@@ -412,17 +411,16 @@ public class TestDeletion extends OmidTestBase {
Transaction deleteTx = tm.begin();
LOG.info("{} trying to delete a non-existing family created ", deleteTx);
Delete del = new Delete(Bytes.toBytes("row1"));
- del.deleteFamily(famB);
+ del.addFamily(famB);
// This delete should not put data on HBase
txTable.delete(deleteTx, del);
// --------------------------------------------------------------------
// Check data has not been written to HBase
// --------------------------------------------------------------------
- HTable table = new HTable(hbaseConf, TEST_TABLE);
Get get = new Get(Bytes.toBytes("row1"));
get.setTimeStamp(deleteTx.getTransactionId());
- Result result = table.get(get);
+ Result result = txTable.getHTable().get(get);
assertTrue(result.isEmpty());
}
@@ -445,7 +443,7 @@ public class TestDeletion extends OmidTestBase {
Put p = new Put(row);
for (FamCol col : famCols) {
- p.add(col.fam, col.col, data1);
+ p.addColumn(col.fam, col.col, data1);
}
tt.put(t1, p);
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestEndToEndScenariosWithHA.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestEndToEndScenariosWithHA.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestEndToEndScenariosWithHA.java
index c15a2c2..71c9508 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestEndToEndScenariosWithHA.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestEndToEndScenariosWithHA.java
@@ -17,14 +17,18 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Charsets;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.apache.omid.TestUtils;
-import org.apache.omid.tso.LeaseManagement;
-import org.apache.omid.tso.PausableLeaseManager;
-import org.apache.omid.tso.TSOServer;
-import org.apache.omid.tso.TSOServerConfig;
+import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER;
+import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
+import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
+import static org.apache.omid.tso.client.OmidClientConfiguration.ConnType.HA;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -37,23 +41,20 @@ import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.TestUtils;
+import org.apache.omid.tso.LeaseManagement;
+import org.apache.omid.tso.PausableLeaseManager;
+import org.apache.omid.tso.TSOServer;
+import org.apache.omid.tso.TSOServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
-import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
-import static org.apache.omid.tso.client.OmidClientConfiguration.ConnType.HA;
-import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import com.google.common.base.Charsets;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
@Test(groups = "sharedHBase")
public class TestEndToEndScenariosWithHA extends OmidTestBase {
@@ -191,17 +192,17 @@ public class TestEndToEndScenariosWithHA extends OmidTestBase {
// End of Test state: R1C1 & R2C2 (v0)
@Test(timeOut = 60_000)
public void testScenario1() throws Exception {
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Write initial values for the test
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
long initialEpoch = tx0.getEpoch();
LOG.info("Starting Tx {} writing initial values for cells ({}) ", tx0, Bytes.toString(initialData));
Put putInitialDataRow1 = new Put(row1);
- putInitialDataRow1.add(TEST_FAMILY.getBytes(), qualifier1, initialData);
+ putInitialDataRow1.addColumn(TEST_FAMILY.getBytes(), qualifier1, initialData);
txTable.put(tx0, putInitialDataRow1);
Put putInitialDataRow2 = new Put(row2);
- putInitialDataRow2.add(TEST_FAMILY.getBytes(), qualifier2, initialData);
+ putInitialDataRow2.addColumn(TEST_FAMILY.getBytes(), qualifier2, initialData);
txTable.put(tx0, putInitialDataRow2);
tm.commit(tx0);
@@ -212,10 +213,10 @@ public class TestEndToEndScenariosWithHA extends OmidTestBase {
LOG.info("Starting Tx {} writing values for cells ({}, {}) ", tx1, Bytes.toString(data1_q1),
Bytes.toString(data1_q2));
Put putData1R1Q1 = new Put(row1);
- putData1R1Q1.add(TEST_FAMILY.getBytes(), qualifier1, data1_q1);
+ putData1R1Q1.addColumn(TEST_FAMILY.getBytes(), qualifier1, data1_q1);
txTable.put(tx1, putData1R1Q1);
Put putData1R2Q2 = new Put(row2);
- putData1R2Q2.add(TEST_FAMILY.getBytes(), qualifier2, data1_q2);
+ putData1R2Q2.addColumn(TEST_FAMILY.getBytes(), qualifier2, data1_q2);
txTable.put(tx1, putData1R2Q2);
Transaction interleavedReadTx = tm.begin();
@@ -288,17 +289,17 @@ public class TestEndToEndScenariosWithHA extends OmidTestBase {
// End of Test state: R1C1 & R2C2 (v2)
@Test(timeOut = 60_000)
public void testScenario2() throws Exception {
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Write initial values for the test
HBaseTransaction tx0 = (HBaseTransaction) tm.begin();
long initialEpoch = tx0.getEpoch();
LOG.info("Starting Tx {} writing initial values for cells ({}) ", tx0, Bytes.toString(initialData));
Put putInitialDataRow1 = new Put(row1);
- putInitialDataRow1.add(TEST_FAMILY.getBytes(), qualifier1, initialData);
+ putInitialDataRow1.addColumn(TEST_FAMILY.getBytes(), qualifier1, initialData);
txTable.put(tx0, putInitialDataRow1);
Put putInitialDataRow2 = new Put(row2);
- putInitialDataRow2.add(TEST_FAMILY.getBytes(), qualifier2, initialData);
+ putInitialDataRow2.addColumn(TEST_FAMILY.getBytes(), qualifier2, initialData);
txTable.put(tx0, putInitialDataRow2);
tm.commit(tx0);
@@ -306,10 +307,10 @@ public class TestEndToEndScenariosWithHA extends OmidTestBase {
LOG.info("Starting Tx {} writing values for cells ({}, {}) ", tx1, Bytes.toString(data1_q1),
Bytes.toString(data1_q2));
Put putData1R1Q1 = new Put(row1);
- putData1R1Q1.add(TEST_FAMILY.getBytes(), qualifier1, data1_q1);
+ putData1R1Q1.addColumn(TEST_FAMILY.getBytes(), qualifier1, data1_q1);
txTable.put(tx1, putData1R1Q1);
Put putData1R2Q2 = new Put(row2);
- putData1R2Q2.add(TEST_FAMILY.getBytes(), qualifier2, data1_q2);
+ putData1R2Q2.addColumn(TEST_FAMILY.getBytes(), qualifier2, data1_q2);
txTable.put(tx1, putData1R2Q2);
// Provoke change in mastership (should throw a Connection exception)
@@ -352,10 +353,10 @@ public class TestEndToEndScenariosWithHA extends OmidTestBase {
+ Bytes.toString(r.getValue(TEST_FAMILY.getBytes(), qualifier2)));
Put putData2R1Q1 = new Put(row1);
- putData2R1Q1.add(TEST_FAMILY.getBytes(), qualifier1, data2_q1);
+ putData2R1Q1.addColumn(TEST_FAMILY.getBytes(), qualifier1, data2_q1);
txTable.put(tx2, putData2R1Q1);
Put putData2R2Q2 = new Put(row2);
- putData2R2Q2.add(TEST_FAMILY.getBytes(), qualifier2, data2_q2);
+ putData2R2Q2.addColumn(TEST_FAMILY.getBytes(), qualifier2, data2_q2);
txTable.put(tx2, putData2R2Q2);
// This one should commit in the new TSO
tm.commit(tx2);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
index 32288b5..c92ca02 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
@@ -17,8 +17,12 @@
*/
package org.apache.omid.transaction;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -37,11 +41,8 @@ import org.mockito.stubbing.Answer;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.spy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
/**
* Tests to verify that Get and Scan filters still work with transactions tables
@@ -75,7 +76,7 @@ public class TestFilters extends OmidTestBase {
hbaseOmidClientConf.setConnectionString("localhost:1234");
hbaseOmidClientConf.setHBaseConfiguration(hbaseConf);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
PostCommitActions syncPostCommitter = spy(
new HBaseSyncPostCommitter(new NullMetricsProvider(), commitTableClient));
AbstractTransactionManager tm = HBaseTransactionManager.builder(hbaseOmidClientConf)
@@ -123,7 +124,7 @@ public class TestFilters extends OmidTestBase {
HBaseOmidClientConfiguration hbaseOmidClientConf = new HBaseOmidClientConfiguration();
hbaseOmidClientConf.getOmidClientConfiguration().setConnectionString("localhost:1234");
hbaseOmidClientConf.setHBaseConfiguration(hbaseConf);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
PostCommitActions syncPostCommitter = spy(
new HBaseSyncPostCommitter(new NullMetricsProvider(), commitTableClient));
AbstractTransactionManager tm = HBaseTransactionManager.builder(hbaseOmidClientConf)
@@ -156,8 +157,8 @@ public class TestFilters extends OmidTestBase {
// create normal row with both cells
Transaction t = tm.begin();
Put p = new Put(row1);
- p.add(family, col1, col1);
- p.add(family, col2, col2);
+ p.addColumn(family, col1, col1);
+ p.addColumn(family, col2, col2);
table.put(t, p);
tm.commit(t);
@@ -171,8 +172,8 @@ public class TestFilters extends OmidTestBase {
t = tm.begin();
p = new Put(row2);
- p.add(family, col1, col1);
- p.add(family, col2, col2);
+ p.addColumn(family, col1, col1);
+ p.addColumn(family, col2, col2);
table.put(t, p);
try {
tm.commit(t);
@@ -183,7 +184,7 @@ public class TestFilters extends OmidTestBase {
// create normal row with only one cell
t = tm.begin();
p = new Put(row3);
- p.add(family, col2, col2);
+ p.addColumn(family, col2, col2);
table.put(t, p);
try {
tm.commit(t);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
index 735af04..288a3ce 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
@@ -17,21 +17,6 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Optional;
-import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.SettableFuture;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.committable.CommitTable.CommitTimestamp;
-import org.apache.omid.metrics.NullMetricsProvider;
-import org.apache.omid.transaction.HBaseTransactionManager.CommitTimestampLocatorImpl;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.testng.ITestContext;
-import org.testng.annotations.Test;
-
-import java.util.Map;
-
import static org.apache.omid.committable.CommitTable.CommitTimestamp.Location.CACHE;
import static org.apache.omid.committable.CommitTable.CommitTimestamp.Location.COMMIT_TABLE;
import static org.apache.omid.committable.CommitTable.CommitTimestamp.Location.NOT_PRESENT;
@@ -44,6 +29,23 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.committable.CommitTable.CommitTimestamp;
+import org.apache.omid.metrics.NullMetricsProvider;
+import org.apache.omid.transaction.HBaseTransactionManager.CommitTimestampLocatorImpl;
+import org.testng.ITestContext;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.SettableFuture;
+
@Test(groups = "sharedHBase")
public class TestHBaseTransactionClient extends OmidTestBase {
@@ -56,31 +58,30 @@ public class TestHBaseTransactionClient extends OmidTestBase {
@Test(timeOut = 30_000)
public void testIsCommitted(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable table = spy(new TTable(hbaseConf, TEST_TABLE, ((AbstractTransactionManager)tm).getCommitTableClient()));
+ TTable table = spy(new TTable(connection, TEST_TABLE, ((AbstractTransactionManager)tm).getCommitTableClient()));
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
tm.commit(t1);
HBaseTransaction t2 = (HBaseTransaction) tm.begin();
put = new Put(row2);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t2, put);
- table.getHTable().flushCommits();
+ table.flushCommits();
HBaseTransaction t3 = (HBaseTransaction) tm.begin();
put = new Put(row2);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t3, put);
tm.commit(t3);
- HTable htable = new HTable(hbaseConf, TEST_TABLE);
- HBaseCellId hBaseCellId1 = new HBaseCellId(htable, row1, family, qualifier, t1.getStartTimestamp());
- HBaseCellId hBaseCellId2 = new HBaseCellId(htable, row2, family, qualifier, t2.getStartTimestamp());
- HBaseCellId hBaseCellId3 = new HBaseCellId(htable, row2, family, qualifier, t3.getStartTimestamp());
+ HBaseCellId hBaseCellId1 = new HBaseCellId(table, row1, family, qualifier, t1.getStartTimestamp());
+ HBaseCellId hBaseCellId2 = new HBaseCellId(table, row2, family, qualifier, t2.getStartTimestamp());
+ HBaseCellId hBaseCellId3 = new HBaseCellId(table, row2, family, qualifier, t3.getStartTimestamp());
HBaseTransactionClient hbaseTm = (HBaseTransactionClient) newTransactionManager(context);
assertTrue(table.isCommitted(hBaseCellId1, 0), "row1 should be committed");
@@ -96,13 +97,13 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// The following line emulates a crash after commit that is observed in (*) below
doThrow(new RuntimeException()).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
- TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()));
+ TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()));
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
// Test shadow cell are created properly
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
try {
tm.commit(t1);
@@ -115,8 +116,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
assertFalse(CellUtils.hasShadowCell(row1, family, qualifier, t1.getStartTimestamp(), new TTableCellGetterAdapter(table)),
"Shadow cell should not be there");
- HTable htable = new HTable(hbaseConf, TEST_TABLE);
- HBaseCellId hBaseCellId = new HBaseCellId(htable, row1, family, qualifier, t1.getStartTimestamp());
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier, t1.getStartTimestamp());
HBaseTransactionClient hbaseTm = (HBaseTransactionClient) newTransactionManager(context);
assertTrue(table.isCommitted(hBaseCellId, 0), "row1 should be committed");
@@ -125,6 +125,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
@Test(timeOut = 30_000)
public void testReadCommitTimestampFromCommitTable(ITestContext context) throws Exception {
+ //connection = ConnectionFactory.createConnection(hbaseConf);
final long NON_EXISTING_CELL_TS = 1000L;
PostCommitActions syncPostCommitter =
@@ -137,13 +138,13 @@ public class TestHBaseTransactionClient extends OmidTestBase {
Optional<CommitTimestamp> optionalCT = tm.commitTableClient.getCommitTimestamp(NON_EXISTING_CELL_TS).get();
assertFalse(optionalCT.isPresent());
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
// Test that we get an invalidation mark for an invalidated transaction
// Start a transaction and invalidate it before commiting it
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
assertTrue(tm.commitTableClient.tryInvalidateTransaction(tx1.getStartTimestamp()).get());
@@ -158,7 +159,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// that couldn't get
HBaseTransaction tx2 = (HBaseTransaction) tm.begin();
Put otherPut = new Put(row1);
- otherPut.add(family, qualifier, data1);
+ otherPut.addColumn(family, qualifier, data1);
table.put(tx2, otherPut);
try {
tm.commit(tx2);
@@ -182,10 +183,10 @@ public class TestHBaseTransactionClient extends OmidTestBase {
HBaseTransactionManager tm = (HBaseTransactionManager) newTransactionManager(context);
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
// Test first we can not found a non-existent cell ts
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier, NON_EXISTING_CELL_TS);
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier, NON_EXISTING_CELL_TS);
// Set an empty cache to allow to bypass the checking
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -196,7 +197,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// Then test that for a transaction committed, we get the right CT
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
tm.commit(tx1);
// Upon commit, the commit data should be in the shadow cells, so test it
@@ -221,14 +222,15 @@ public class TestHBaseTransactionClient extends OmidTestBase {
HBaseTransactionManager tm = (HBaseTransactionManager) newTransactionManager(context);
// Pre-load the element to look for in the cache
- HTable table = new HTable(hbaseConf, TEST_TABLE);
+ Table htable = hBaseUtils.getConnection().getTable(TableName.valueOf(TEST_TABLE));
+ TTable table = new TTable(htable);
HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier, CELL_ST);
Map<Long, Long> fakeCache = Maps.newHashMap();
fakeCache.put(CELL_ST, CELL_CT);
// Then test that locator finds it in the cache
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId, fakeCache);
- CommitTimestamp ct = (new TTable(table)).locateCellCommitTimestamp(CELL_ST, tm.tsoClient.getEpoch(), ctLocator);
+ CommitTimestamp ct = table.locateCellCommitTimestamp(CELL_ST, tm.tsoClient.getEpoch(), ctLocator);
assertTrue(ct.isValid());
assertEquals(ct.getValue(), CELL_CT);
assertTrue(ct.getLocation().compareTo(CACHE) == 0);
@@ -247,12 +249,12 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// The following line emulates a crash after commit that is observed in (*) below
doThrow(new RuntimeException()).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
// Commit a transaction that is broken on commit to avoid
// write to the shadow cells and avoid cleaning the commit table
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
try {
tm.commit(tx1);
@@ -261,7 +263,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
}
// Test the locator finds the appropriate data in the commit table
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier,
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier,
tx1.getStartTimestamp());
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -281,17 +283,17 @@ public class TestHBaseTransactionClient extends OmidTestBase {
HBaseTransactionManager tm = (HBaseTransactionManager) newTransactionManager(context);
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
- // Commit a transaction to add ST/CT in commit table
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
+ // Commit a transaction to addColumn ST/CT in commit table
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
tm.commit(tx1);
// Upon commit, the commit data should be in the shadow cells
// Test the locator finds the appropriate data in the shadow cells
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier,
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier,
tx1.getStartTimestamp());
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -319,17 +321,17 @@ public class TestHBaseTransactionClient extends OmidTestBase {
doReturn(f).when(commitTableClient).getCommitTimestamp(any(Long.class));
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
- // Commit a transaction to add ST/CT in commit table
+ // Commit a transaction to addColumn ST/CT in commit table
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
// Upon commit, the commit data should be in the shadow cells
// Test a transaction in the previous epoch gets an InvalidCommitTimestamp class
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier,
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier,
tx1.getStartTimestamp());
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -358,13 +360,13 @@ public class TestHBaseTransactionClient extends OmidTestBase {
f.set(Optional.<CommitTimestamp>absent());
doReturn(f).doCallRealMethod().when(commitTableClient).getCommitTimestamp(any(Long.class));
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
// Commit a transaction that is broken on commit to avoid
// write to the shadow cells and avoid cleaning the commit table
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
try {
tm.commit(tx1);
@@ -373,7 +375,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
}
// Test the locator finds the appropriate data in the commit table
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier,
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier,
tx1.getStartTimestamp());
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -398,18 +400,18 @@ public class TestHBaseTransactionClient extends OmidTestBase {
f.set(Optional.<CommitTimestamp>absent());
doReturn(f).when(commitTableClient).getCommitTimestamp(any(Long.class));
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
- // Commit a transaction to add ST/CT in commit table
+ // Commit a transaction to addColumn ST/CT in commit table
HBaseTransaction tx1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx1, put);
tm.commit(tx1);
// Upon commit, the commit data should be in the shadow cells
// Test the locator finds the appropriate data in the shadow cells
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier,
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier,
tx1.getStartTimestamp());
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
@@ -435,8 +437,8 @@ public class TestHBaseTransactionClient extends OmidTestBase {
f.set(Optional.<CommitTimestamp>absent());
doReturn(f).when(commitTableClient).getCommitTimestamp(any(Long.class));
- try (TTable table = spy(new TTable(hbaseConf, TEST_TABLE, tm.getCommitTableClient()))) {
- HBaseCellId hBaseCellId = new HBaseCellId(table.getHTable(), row1, family, qualifier, CELL_TS);
+ try (TTable table = spy(new TTable(connection, TEST_TABLE, tm.getCommitTableClient()))) {
+ HBaseCellId hBaseCellId = new HBaseCellId(table, row1, family, qualifier, CELL_TS);
CommitTimestampLocator ctLocator = new CommitTimestampLocatorImpl(hBaseCellId,
Maps.<Long, Long>newHashMap());
CommitTimestamp ct = table.locateCellCommitTimestamp(CELL_TS, tm.tsoClient.getEpoch(), ctLocator);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
index 51ec0c1..91cd56c 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
@@ -17,14 +17,6 @@
*/
package org.apache.omid.transaction;
-import org.apache.omid.tso.client.TSOClient;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.testng.ITestContext;
-import org.testng.annotations.Test;
-
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anySetOf;
import static org.mockito.Mockito.doReturn;
@@ -35,6 +27,14 @@ import static org.mockito.Mockito.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.tso.client.TSOClient;
+import org.testng.ITestContext;
+import org.testng.annotations.Test;
+
// TODO These tests should be adapted to a future test for AbstractTransactionManager as they should be DB independent
@Test(groups = "sharedHBase")
public class TestHBaseTransactionManager extends OmidTestBase {
@@ -74,12 +74,12 @@ public class TestHBaseTransactionManager extends OmidTestBase {
TSOClient tsoClient = spy(getClient(context));
TransactionManager tm = newTransactionManager(context, tsoClient);
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
// Add initial data in a transactional context
Transaction tx1 = tm.begin();
Put put = new Put(row1);
- put.add(testFamily, qualifier, data1);
+ put.addColumn(testFamily, qualifier, data1);
txTable.put(tx1, put);
tm.commit(tx1);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestMarkPutAsCommitted.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestMarkPutAsCommitted.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestMarkPutAsCommitted.java
index 5ae4dd2..4cb5d98 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestMarkPutAsCommitted.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestMarkPutAsCommitted.java
@@ -17,7 +17,12 @@
*/
package org.apache.omid.transaction;
-import org.apache.hadoop.hbase.Cell;
+import static org.apache.omid.transaction.CellUtils.hasCell;
+import static org.apache.omid.transaction.CellUtils.hasShadowCell;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -27,15 +32,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.omid.transaction.CellUtils.hasCell;
-import static org.apache.omid.transaction.CellUtils.hasShadowCell;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestMarkPutAsCommitted extends OmidTestBase {
@@ -54,13 +50,13 @@ public class TestMarkPutAsCommitted extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
// Test shadow cells are created properly
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
put = TTable.markPutAsCommitted(put, t1.getWriteTimestamp(), t1.getWriteTimestamp());
@@ -78,12 +74,12 @@ public class TestMarkPutAsCommitted extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
@@ -106,7 +102,7 @@ public class TestMarkPutAsCommitted extends OmidTestBase {
HBaseTransaction t3 = (HBaseTransaction) tm.begin();
Put put1 = new Put(row);
- put1.add(family, qualifier, data2);
+ put1.addColumn(family, qualifier, data2);
put1 = TTable.markPutAsCommitted(put1, t3.getWriteTimestamp(), t3.getWriteTimestamp());
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestMultiplePut.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestMultiplePut.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestMultiplePut.java
index e0f3b23..dd7ecc4 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestMultiplePut.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestMultiplePut.java
@@ -17,6 +17,8 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertTrue;
+
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -26,14 +28,11 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestMultiplePut extends OmidTestBase {
private static final Logger LOG = LoggerFactory.getLogger(TestMultiplePut.class);
- private static final byte[] testTable = Bytes.toBytes(TEST_TABLE);
private static final byte[] family = Bytes.toBytes(TEST_FAMILY);
private static final byte[] col1 = Bytes.toBytes("col1");
private static final byte[] col2 = Bytes.toBytes("col2");
@@ -44,24 +43,24 @@ public class TestMultiplePut extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
Transaction tx = tm.begin();
byte[] rowToAdd = Bytes.toBytes(1000);
Put put1 = new Put(rowToAdd);
- put1.add(family, col1, data);
+ put1.addColumn(family, col1, data);
txTable.put(tx, put1);
Put put2 = new Put(rowToAdd);
- put2.add(family, col2, data);
+ put2.addColumn(family, col2, data);
txTable.put(tx, put2);
tm.commit(tx);
- assertTrue(verifyValue(testTable, rowToAdd, family, col1, data), "Invalid value in table");
- assertTrue(verifyValue(testTable, rowToAdd, family, col2, data), "Invalid value in table");
+ assertTrue(verifyValue(txTable.getHTable(), rowToAdd, family, col1, data), "Invalid value in table");
+ assertTrue(verifyValue(txTable.getHTable(), rowToAdd, family, col2, data), "Invalid value in table");
}
}
@@ -73,7 +72,7 @@ public class TestMultiplePut extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
Transaction tx = tm.begin();
@@ -81,7 +80,7 @@ public class TestMultiplePut extends OmidTestBase {
byte[] rowToAdd = Bytes.toBytes(i);
byte[] dataForRowCol = Bytes.toBytes("testData" + i);
Put put = new Put(rowToAdd);
- put.add(family, col1, dataForRowCol);
+ put.addColumn(family, col1, dataForRowCol);
txTable.put(tx, put);
}
@@ -90,13 +89,13 @@ public class TestMultiplePut extends OmidTestBase {
// Check some of the added values are there in the table
byte[] rowToCheck = Bytes.toBytes(0);
byte[] dataToCheck = Bytes.toBytes("testData" + 0);
- assertTrue(verifyValue(testTable, rowToCheck, family, col1, dataToCheck), "Invalid value in table");
+ assertTrue(verifyValue(txTable.getHTable(), rowToCheck, family, col1, dataToCheck), "Invalid value in table");
rowToCheck = Bytes.toBytes(NUM_ROWS_TO_ADD / 2);
dataToCheck = Bytes.toBytes("testData" + (NUM_ROWS_TO_ADD / 2));
- assertTrue(verifyValue(testTable, rowToCheck, family, col1, dataToCheck), "Invalid value in table");
+ assertTrue(verifyValue(txTable.getHTable(), rowToCheck, family, col1, dataToCheck), "Invalid value in table");
rowToCheck = Bytes.toBytes(NUM_ROWS_TO_ADD);
dataToCheck = Bytes.toBytes("testData" + NUM_ROWS_TO_ADD);
- assertTrue(verifyValue(testTable, rowToCheck, family, col1, dataToCheck), "Invalid value in table");
+ assertTrue(verifyValue(txTable.getHTable(), rowToCheck, family, col1, dataToCheck), "Invalid value in table");
}
}
@@ -108,14 +107,14 @@ public class TestMultiplePut extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- try (TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ try (TTable txTable = new TTable(connection, TEST_TABLE)) {
Transaction tx = tm.begin();
for (int i = 0; i < NUM_ROWS_TO_ADD; i++) {
byte[] rowToAdd = Bytes.toBytes(i);
Put put = new Put(rowToAdd);
- put.add(family, col1, Bytes.toBytes("testData" + i));
+ put.addColumn(family, col1, Bytes.toBytes("testData" + i));
txTable.put(tx, put);
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
index 08a2e1b..dea5921 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
@@ -17,6 +17,14 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Get;
@@ -26,14 +34,6 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestReadPath extends OmidTestBase {
@@ -46,14 +46,14 @@ public class TestReadPath extends OmidTestBase {
@Test(timeOut = 10_000)
public void testReadInterleaved(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
// Put some data on the DB
Transaction t1 = tm.begin();
Transaction t2 = tm.begin();
Put put = new Put(row);
- put.add(family, col, data);
+ put.addColumn(family, col, data);
table.put(t1, put);
tm.commit(t1);
@@ -65,12 +65,12 @@ public class TestReadPath extends OmidTestBase {
@Test(timeOut = 10_000)
public void testReadWithSeveralUncommitted(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
// Put some data on the DB
Transaction t = tm.begin();
Put put = new Put(row);
- put.add(family, col, data);
+ put.addColumn(family, col, data);
table.put(t, put);
tm.commit(t);
List<Transaction> running = new ArrayList<>();
@@ -79,7 +79,7 @@ public class TestReadPath extends OmidTestBase {
for (int i = 0; i < 10; ++i) {
t = tm.begin();
put = new Put(row);
- put.add(family, col, uncommitted);
+ put.addColumn(family, col, uncommitted);
table.put(t, put);
running.add(t);
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestShadowCells.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestShadowCells.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestShadowCells.java
index 18606a8..42fd406 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestShadowCells.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestShadowCells.java
@@ -17,26 +17,41 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
+import static org.apache.omid.transaction.CellUtils.hasCell;
+import static org.apache.omid.transaction.CellUtils.hasShadowCell;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
import org.apache.omid.committable.CommitTable;
import org.apache.omid.metrics.NullMetricsProvider;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.util.Bytes;
import org.mockito.Matchers;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -45,26 +60,9 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.apache.omid.transaction.CellUtils.hasCell;
-import static org.apache.omid.transaction.CellUtils.hasShadowCell;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
@Test(groups = "sharedHBase")
public class TestShadowCells extends OmidTestBase {
@@ -91,13 +89,13 @@ public class TestShadowCells extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
// Test shadow cells are created properly
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
// Before commit test that only the cell is there
@@ -151,13 +149,13 @@ public class TestShadowCells extends OmidTestBase {
// The following line emulates a crash after commit that is observed in (*) below
doThrow(new RuntimeException()).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
// Test shadow cell are created properly
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
try {
tm.commit(t1);
@@ -198,13 +196,13 @@ public class TestShadowCells extends OmidTestBase {
// The following line emulates a crash after commit that is observed in (*) below
doThrow(new RuntimeException()).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
// Test shadow cell are created properly
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
try {
tm.commit(t1);
@@ -255,12 +253,12 @@ public class TestShadowCells extends OmidTestBase {
.commitTableClient(commitTableClient)
.build());
- final TTable table = new TTable(hbaseConf, TEST_TABLE);
+ final TTable table = new TTable(connection, TEST_TABLE);
HBaseTransaction tx = (HBaseTransaction) tm.begin();
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(tx, put);
// This line emulates an error accessing the target table by disabling it
@@ -324,7 +322,7 @@ public class TestShadowCells extends OmidTestBase {
}).when(syncPostCommitter).updateShadowCells(any(HBaseTransaction.class));
// Start transaction on write thread
- TTable table = new TTable(hbaseConf, TEST_TABLE);
+ final TTable table = new TTable(connection, TEST_TABLE);
final HBaseTransaction t1 = (HBaseTransaction) tm.begin();
@@ -335,8 +333,8 @@ public class TestShadowCells extends OmidTestBase {
LOG.info("Waiting readAfterCommit barrier");
try {
readAfterCommit.await();
- HTable htable = new HTable(hbaseConf, TEST_TABLE);
- HTable healer = new HTable(hbaseConf, TEST_TABLE);
+ Table htable = table.getHTable();
+ Table healer = table.getHTable();
final SnapshotFilter snapshotFilter = spy(new SnapshotFilterImpl(new HTableAccessWrapper(htable, healer)));
final TTable table = new TTable(htable ,snapshotFilter);
@@ -388,7 +386,7 @@ public class TestShadowCells extends OmidTestBase {
// Write data
Put put = new Put(row);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
tm.commit(t1);
@@ -409,25 +407,25 @@ public class TestShadowCells extends OmidTestBase {
TransactionManager tm = newTransactionManager(context);
- TTable table = new TTable(hbaseConf, TEST_TABLE);
- HTableInterface htable = table.getHTable();
+ TTable table = new TTable(connection, TEST_TABLE);
+ Table htable = table.getHTable();
// Test shadow cell are created properly
HBaseTransaction t1 = (HBaseTransaction) tm.begin();
Put put = new Put(row1);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t1, put);
tm.commit(t1);
HBaseTransaction t2 = (HBaseTransaction) tm.begin();
put = new Put(row2);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t2, put);
tm.commit(t2);
HBaseTransaction t3 = (HBaseTransaction) tm.begin();
put = new Put(row3);
- put.add(family, qualifier, data1);
+ put.addColumn(family, qualifier, data1);
table.put(t3, put);
tm.commit(t3);
@@ -443,9 +441,9 @@ public class TestShadowCells extends OmidTestBase {
// delete new shadow cell
Delete del = new Delete(row2);
- del.deleteColumn(family, CellUtils.addShadowCellSuffixPrefix(qualifier));
+ del.addColumn(family, CellUtils.addShadowCellSuffixPrefix(qualifier));
htable.delete(del);
- htable.flushCommits();
+ table.flushCommits();
// verify that we can't read now (since shadow cell is missing)
Transaction t4 = tm.begin();
@@ -471,7 +469,7 @@ public class TestShadowCells extends OmidTestBase {
// now add in the previous legacy shadow cell for that row
put = new Put(row2);
- put.add(family,
+ put.addColumn(family,
addLegacyShadowCellSuffix(qualifier),
t2.getStartTimestamp(),
Bytes.toBytes(t2.getCommitTimestamp()));
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
index 5d141fd..251c6ec 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
@@ -17,6 +17,8 @@
*/
package org.apache.omid.transaction;
+import static org.testng.Assert.assertTrue;
+
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -27,8 +29,6 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertTrue;
-
@Test(groups = "sharedHBase")
public class TestSingleColumnFamily extends OmidTestBase {
@@ -37,14 +37,14 @@ public class TestSingleColumnFamily extends OmidTestBase {
@Test(timeOut = 10_000)
public void testSingleColumnFamily(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
- TTable table1 = new TTable(hbaseConf, TEST_TABLE);
+ TTable table1 = new TTable(connection, TEST_TABLE);
int num = 10;
Transaction t = tm.begin();
for (int j = 0; j < num; j++) {
byte[] data = Bytes.toBytes(j);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value1"), data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value2"), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value1"), data);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value2"), data);
table1.put(t, put);
}
//tm.tryCommit(t);
@@ -68,7 +68,7 @@ public class TestSingleColumnFamily extends OmidTestBase {
byte[] data = Bytes.toBytes(j);
byte[] ndata = Bytes.toBytes(j * 10);
Put put = new Put(data);
- put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value2"), ndata);
+ put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value2"), ndata);
table1.put(t, put);
}
tm.commit(t);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestTTableBehaviour.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTTableBehaviour.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTTableBehaviour.java
index 07421c9..c58f414 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTTableBehaviour.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTTableBehaviour.java
@@ -17,17 +17,18 @@
*/
package org.apache.omid.transaction;
-import com.google.common.base.Charsets;
+import static org.testng.Assert.fail;
+
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import org.mockito.Mockito;
import org.testng.annotations.Test;
-import static org.testng.Assert.fail;
+import com.google.common.base.Charsets;
@Test(groups = "noHBase")
public class TestTTableBehaviour {
@@ -41,7 +42,7 @@ public class TestTTableBehaviour {
public void testUserOperationsDontAllowTimestampSpecification() throws Exception {
// Component under test
- TTable tt = new TTable(Mockito.mock(HTableInterface.class), Mockito.mock(HTableInterface.class));
+ TTable tt = new TTable(Mockito.mock(Table.class), false);
long randomTimestampValue = Bytes.toLong("deadbeef".getBytes());
@@ -49,7 +50,7 @@ public class TestTTableBehaviour {
// Test put fails when a timestamp is specified in the put
Put put = new Put(row, randomTimestampValue);
- put.add(famName, colName, dataValue);
+ put.addColumn(famName, colName, dataValue);
try {
tt.put(tx, put);
fail("Should have thrown an IllegalArgumentException due to timestamp specification");
@@ -59,7 +60,7 @@ public class TestTTableBehaviour {
// Test put fails when a timestamp is specified in a qualifier
put = new Put(row);
- put.add(famName, colName, randomTimestampValue, dataValue);
+ put.addColumn(famName, colName, randomTimestampValue, dataValue);
try {
tt.put(tx, put);
fail("Should have thrown an IllegalArgumentException due to timestamp specification");
@@ -98,7 +99,7 @@ public class TestTTableBehaviour {
// Test delete fails when a timestamp is specified in a qualifier
delete = new Delete(row);
- delete.deleteColumn(famName, colName, randomTimestampValue);
+ delete.addColumn(famName, colName, randomTimestampValue);
try {
tt.delete(tx, delete);
fail("Should have thrown an IllegalArgumentException due to timestamp specification");
@@ -116,11 +117,11 @@ public class TestTTableBehaviour {
byte[] nonValidQualifier1 = "blahblah\u0080".getBytes(Charsets.UTF_8);
byte[] validQualifierIncludingOldShadowCellSuffix = "blahblah:OMID_CTS".getBytes(Charsets.UTF_8);
- TTable table = new TTable(Mockito.mock(HTableInterface.class), Mockito.mock(HTableInterface.class));
+ TTable table = new TTable(Mockito.mock(Table.class), false);
HBaseTransaction t1 = Mockito.mock(HBaseTransaction.class);
Put put = new Put(row);
- put.add(famName, nonValidQualifier1, dataValue);
+ put.addColumn(famName, nonValidQualifier1, dataValue);
try {
table.put(t1, put);
fail("Shouldn't be able to put this");
@@ -128,7 +129,7 @@ public class TestTTableBehaviour {
// correct
}
Delete del = new Delete(row);
- del.deleteColumn(famName, nonValidQualifier1);
+ del.addColumn(famName, nonValidQualifier1);
try {
table.delete(t1, del);
fail("Shouldn't be able to delete this");
@@ -137,14 +138,14 @@ public class TestTTableBehaviour {
}
put = new Put(row);
- put.add(famName, validQualifierIncludingOldShadowCellSuffix, dataValue);
+ put.addColumn(famName, validQualifierIncludingOldShadowCellSuffix, dataValue);
try {
table.put(t1, put);
} catch (IllegalArgumentException iae) {
fail("Qualifier shouldn't be rejected anymore");
}
del = new Delete(row);
- del.deleteColumn(famName, validQualifierIncludingOldShadowCellSuffix);
+ del.addColumn(famName, validQualifierIncludingOldShadowCellSuffix);
try {
table.delete(t1, del);
} catch (IllegalArgumentException iae) {
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/75dc8177/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
index 2060bc3..acc74af 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
@@ -17,7 +17,12 @@
*/
package org.apache.omid.transaction;
-import com.google.common.util.concurrent.SettableFuture;
+import static org.mockito.Matchers.anySetOf;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.testng.Assert.assertEquals;
+
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -32,11 +37,7 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.mockito.Matchers.anySetOf;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.testng.Assert.assertEquals;
+import com.google.common.util.concurrent.SettableFuture;
@Test(groups = "sharedHBase")
public class TestTransactionCleanup extends OmidTestBase {
@@ -80,13 +81,13 @@ public class TestTransactionCleanup extends OmidTestBase {
.when(mockedTSOClient).commit(eq(START_TS), anySetOf(HBaseCellId.class), anySetOf(HBaseCellId.class));
try (TransactionManager tm = newTransactionManager(context, mockedTSOClient);
- TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
+ TTable txTable = new TTable(connection, TEST_TABLE)) {
// Start a transaction and put some data in a column
Transaction tx = tm.begin();
Put put = new Put(row);
- put.add(family, qual, data);
+ put.addColumn(family, qual, data);
txTable.put(tx, put);
// Abort transaction when committing, so the cleanup