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:07 UTC
[3/4] incubator-omid git commit: OMID-107 Replace pre 1.0 deprecated
HBase APIs
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