Repository: phoenix Updated Branches: refs/heads/omid 6b16183ed -> 476d13d53
Initial version of transaction abstraction layer Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7c2ca8c5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7c2ca8c5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7c2ca8c5 Branch: refs/heads/omid Commit: 7c2ca8c51a5c551c6027e70bd2ad218e6743f3d6 Parents: 3519b3b Author: Ohad Shacham <[email protected]> Authored: Thu Feb 9 10:45:07 2017 +0200 Committer: Ohad Shacham <[email protected]> Committed: Thu Feb 9 10:45:07 2017 +0200 ---------------------------------------------------------------------- .../transaction/OmidTransactionContext.java | 95 +++++++++++++ .../transaction/OmidTransactionTable.java | 139 +++++++++++++++++++ .../transaction/PhoenixTransactionContext.java | 106 ++++++++++++++ .../transaction/PhoenixTransactionalTable.java | 138 ++++++++++++++++++ .../transaction/TephraTransactionContext.java | 95 +++++++++++++ .../transaction/TephraTransactionTable.java | 139 +++++++++++++++++++ 6 files changed, 712 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionContext.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionContext.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionContext.java new file mode 100644 index 0000000..5f0bdce --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionContext.java @@ -0,0 +1,95 @@ +package org.apache.phoenix.transaction; + +import java.sql.SQLException; +import java.util.concurrent.TimeoutException; + +import org.apache.phoenix.schema.PTable; + +public class OmidTransactionContext implements PhoenixTransactionContext { + + @Override + public void begin() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void commit() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void abort() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void abort(SQLException e) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void checkpoint() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void commitDDL(PTable dataTable) throws SQLException, + InterruptedException, TimeoutException { + // TODO Auto-generated method stub + + } + + @Override + public void markDML(PTable table) { + // TODO Auto-generated method stub + + } + + @Override + public void join(PhoenixTransactionContext ctx) { + // TODO Auto-generated method stub + + } + + @Override + public void addTransactionTable(PhoenixTransactionalTable table) { + // TODO Auto-generated method stub + + } + + @Override + public void addTransactionToTable(PhoenixTransactionalTable table) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isTransactionRunning() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void reset() { + // TODO Auto-generated method stub + + } + + @Override + public long getTransactionId() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getReadPointer() { + // TODO Auto-generated method stub + return 0; + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionTable.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionTable.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionTable.java new file mode 100644 index 0000000..f5cdd17 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionTable.java @@ -0,0 +1,139 @@ +package org.apache.phoenix.transaction; + +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HTableDescriptor; +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.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; + +public class OmidTransactionTable implements PhoenixTransactionalTable { + + @Override + public Result get(Get get) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void put(Put put) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void delete(Delete delete) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public ResultScanner getScanner(Scan scan) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getTableName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Configuration getConfiguration() { + // TODO Auto-generated method stub + return null; + } + + @Override + public HTableDescriptor getTableDescriptor() throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean exists(Get get) throws IOException { + // TODO Auto-generated method stub + return false; + } + + @Override + public Result[] get(List<Get> gets) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultScanner getScanner(byte[] family) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultScanner getScanner(byte[] family, byte[] qualifier) + throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void put(List<Put> puts) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void delete(List<Delete> deletes) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public HTableInterface getHTable() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setAutoFlush(boolean autoFlush) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isAutoFlush() { + // TODO Auto-generated method stub + return false; + } + + @Override + public long getWriteBufferSize() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setWriteBufferSize(long writeBufferSize) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void flushCommits() throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void close() throws IOException { + // TODO Auto-generated method stub + + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java new file mode 100644 index 0000000..b391144 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java @@ -0,0 +1,106 @@ +package org.apache.phoenix.transaction; + +import org.apache.phoenix.schema.PTable; + +import java.sql.SQLException; +import java.util.concurrent.TimeoutException; + +public interface PhoenixTransactionContext { + + /** + * Starts a transaction + * + * @throws SQLException + */ + public void begin() throws SQLException; + + /** + * Commits a transaction + * + * @throws SQLException + */ + public void commit() throws SQLException; + + /** + * Rollback a transaction + * + * @throws SQLException + */ + public void abort() throws SQLException; + + /** + * Rollback a transaction + * + * @param e + * @throws SQLException + */ + public void abort(SQLException e) throws SQLException; + + /** + * Create a checkpoint in a transaction as defined in [TEPHRA-96] + * @throws SQLException + */ + public void checkpoint() throws SQLException; + + /** + * Commit DDL to guarantee that no transaction started before create index + * and committed afterwards, as explained in [PHOENIX-2478], [TEPHRA-157] and [OMID-56]. + * + * @param dataTable the table that the DDL command works on + * @throws SQLException + * @throws InterruptedException + * @throws TimeoutException + */ + public void commitDDL(PTable dataTable) + throws SQLException, InterruptedException, TimeoutException; + + /** + * mark DML with table information for conflict detection of concurrent + * DDL operation, as explained in [PHOENIX-2478], [TEPHRA-157] and [OMID-56]. + * + * @param table the table that the DML command works on + */ + public void markDML(PTable table); + + /** + * Augment the current context with ctx modified keys + * + * @param ctx + */ + public void join(PhoenixTransactionContext ctx); + + /** + * Add transaction table to the context. + * Will be mostly used by Tephra, since Omid keeps the changeset inside the transaction while + * Tephra keeps it distributed at the different awares. + * + * @param table + */ + public void addTransactionTable(PhoenixTransactionalTable table); + + /** + * Add transaction to the table. + * @param table + */ + public void addTransactionToTable(PhoenixTransactionalTable table); + + /** + * Is there a transaction in flight? + */ + public boolean isTransactionRunning(); + + /** + * Reset transaction state + */ + public void reset(); + + /** + * Returns transaction unique identifier + */ + long getTransactionId(); + + /** + * Returns transaction snapshot id + */ + long getReadPointer(); +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionalTable.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionalTable.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionalTable.java new file mode 100644 index 0000000..2316dc4 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionalTable.java @@ -0,0 +1,138 @@ +package org.apache.phoenix.transaction; + +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.Put; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HTableDescriptor; + +import java.io.IOException; +import java.util.List; + +public interface PhoenixTransactionalTable { + + /** + * Transaction version of {@link HTableInterface#get(Get get)} + * @param get + * @return + * @throws IOException + */ + public Result get(Get get) throws IOException; + + /** + * Transactional version of {@link HTableInterface#put(Put put)} + * @param put + * @throws IOException + */ + public void put(Put put) throws IOException; + + /** + * Transactional version of {@link HTableInterface#delete(Delete delete)} + * + * @param delete + * @throws IOException + */ + public void delete(Delete delete) throws IOException; + + /** + * Transactional version of {@link HTableInterface#getScanner(Scan scan)} + * + * @param scan + * @return ResultScanner + * @throws IOException + */ + public ResultScanner getScanner(Scan scan) throws IOException; + + /** + * Returns Htable name + */ + public byte[] getTableName(); + + /** + * Returns Htable configuration object + */ + public Configuration getConfiguration(); + + /** + * Returns HTableDescriptor of Htable + * @throws IOException + */ + public HTableDescriptor getTableDescriptor() throws IOException; + + /** + * Checks if cell exists + * @throws IOException + */ + public boolean exists(Get get) throws IOException; + + /** + * Transactional version of {@link HTableInterface#get(List gets)} + * @throws IOException + */ + public Result[] get(List<Get> gets) throws IOException; + + /** + * Transactional version of {@link HTableInterface#getScanner(byte[] family)} + * @throws IOException + */ + public ResultScanner getScanner(byte[] family) throws IOException; + + /** + * Transactional version of {@link HTableInterface#getScanner(byte[] family, byte[] qualifier)} + * @throws IOException + */ + public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException; + + /** + * Transactional version of {@link HTableInterface#put(List puts)} + * @throws IOException + */ + public void put(List<Put> puts) throws IOException; + + /** + * Transactional version of {@link HTableInterface#delete(List deletes)} + * @throws IOException + */ + public void delete(List<Delete> deletes) throws IOException; + + /** + * Return the underling htable + */ + public HTableInterface getHTable(); + + /** + * Delegates to {@link HTable#setAutoFlush(boolean autoFlush)} + */ + public void setAutoFlush(boolean autoFlush); + + /** + * Delegates to {@link HTable#isAutoFlush()} + */ + public boolean isAutoFlush(); + + /** + * Delegates to see HTable.getWriteBufferSize() + */ + public long getWriteBufferSize(); + + /** + * Delegates to see HTable.setWriteBufferSize() + */ + public void setWriteBufferSize(long writeBufferSize) throws IOException; + + /** + * Delegates to see HTable.flushCommits() + */ + public void flushCommits() throws IOException; + + /** + * Releases resources + * @throws IOException + */ + public void close() throws IOException; +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java new file mode 100644 index 0000000..cfe8e9b --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionContext.java @@ -0,0 +1,95 @@ +package org.apache.phoenix.transaction; + +import java.sql.SQLException; +import java.util.concurrent.TimeoutException; + +import org.apache.phoenix.schema.PTable; + +public class TephraTransactionContext implements PhoenixTransactionContext { + + @Override + public void begin() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void commit() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void abort() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void abort(SQLException e) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void checkpoint() throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void commitDDL(PTable dataTable) throws SQLException, + InterruptedException, TimeoutException { + // TODO Auto-generated method stub + + } + + @Override + public void markDML(PTable table) { + // TODO Auto-generated method stub + + } + + @Override + public void join(PhoenixTransactionContext ctx) { + // TODO Auto-generated method stub + + } + + @Override + public void addTransactionTable(PhoenixTransactionalTable table) { + // TODO Auto-generated method stub + + } + + @Override + public void addTransactionToTable(PhoenixTransactionalTable table) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isTransactionRunning() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void reset() { + // TODO Auto-generated method stub + + } + + @Override + public long getTransactionId() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getReadPointer() { + // TODO Auto-generated method stub + return 0; + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7c2ca8c5/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionTable.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionTable.java b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionTable.java new file mode 100644 index 0000000..09d37c3 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/TephraTransactionTable.java @@ -0,0 +1,139 @@ +package org.apache.phoenix.transaction; + +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HTableDescriptor; +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.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; + +public class TephraTransactionTable implements PhoenixTransactionalTable { + + @Override + public Result get(Get get) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void put(Put put) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void delete(Delete delete) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public ResultScanner getScanner(Scan scan) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getTableName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Configuration getConfiguration() { + // TODO Auto-generated method stub + return null; + } + + @Override + public HTableDescriptor getTableDescriptor() throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean exists(Get get) throws IOException { + // TODO Auto-generated method stub + return false; + } + + @Override + public Result[] get(List<Get> gets) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultScanner getScanner(byte[] family) throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResultScanner getScanner(byte[] family, byte[] qualifier) + throws IOException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void put(List<Put> puts) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void delete(List<Delete> deletes) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public HTableInterface getHTable() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setAutoFlush(boolean autoFlush) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isAutoFlush() { + // TODO Auto-generated method stub + return false; + } + + @Override + public long getWriteBufferSize() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setWriteBufferSize(long writeBufferSize) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void flushCommits() throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void close() throws IOException { + // TODO Auto-generated method stub + + } + +}
