Repository: phoenix
Updated Branches:
  refs/heads/omid [created] 3431902fd


Initial implementation for TAL


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/96f8d09a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/96f8d09a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/96f8d09a

Branch: refs/heads/omid
Commit: 96f8d09a5b08636d2859692ead3618f15036a11b
Parents: c6a7a71
Author: Ohad Shacham <oh...@yahoo-inc.com>
Authored: Thu Mar 9 11:03:11 2017 +0200
Committer: Thomas D'Silva <tdsi...@apache.org>
Committed: Thu Mar 9 13:26:47 2017 -0800

----------------------------------------------------------------------
 .../transaction/PhoenixTransactionContext.java  |  91 ++++++++++++
 .../transaction/PhoenixTransactionalTable.java  | 138 +++++++++++++++++++
 2 files changed, 229 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/96f8d09a/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..f07640e
--- /dev/null
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/transaction/PhoenixTransactionContext.java
@@ -0,0 +1,91 @@
+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 commitDDLFence(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 markDMLFence(PTable table);
+
+    /**
+     * Augment the current context with ctx modified keys
+     *
+     * @param ctx
+     */
+    public void join(PhoenixTransactionContext ctx);
+
+    /**
+     * 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/96f8d09a/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..7495c5b
--- /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 extends HTableInterface {
+
+    /**
+     * 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;
+}

Reply via email to