You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by vi...@apache.org on 2018/08/03 20:37:41 UTC
[40/50] [abbrv] phoenix git commit: PHOENIX-4789 Exception when
setting TTL on Tephra transactional table
PHOENIX-4789 Exception when setting TTL on Tephra transactional table
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a9170b23
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a9170b23
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a9170b23
Branch: refs/heads/4.14-HBase-1.3
Commit: a9170b232b839ee2441982adda49d9a034e22d44
Parents: a0ef661
Author: James Taylor <ja...@apache.org>
Authored: Mon Jun 18 15:00:02 2018 +0200
Committer: James Taylor <ja...@apache.org>
Committed: Mon Jun 18 15:01:38 2018 +0200
----------------------------------------------------------------------
.../org/apache/phoenix/tx/TransactionIT.java | 30 ++++++++++++++++++++
.../query/ConnectionQueryServicesImpl.java | 3 ++
2 files changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9170b23/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
index c0ec6b8..12c3b7a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
@@ -38,6 +39,9 @@ import java.util.Properties;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableNotFoundException;
+import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
import org.apache.phoenix.exception.SQLExceptionCode;
@@ -54,6 +58,7 @@ import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.StringUtil;
import org.apache.phoenix.util.TestUtil;
+import org.apache.tephra.TxConstants;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -370,4 +375,29 @@ public class TransactionIT extends ParallelStatsDisabledIT {
conn.close();
}
}
+
+ private static void assertTTL(Admin admin, String tableName, int ttl) throws TableNotFoundException, IOException {
+ HTableDescriptor tableDesc = admin.getTableDescriptor(TableName.valueOf(tableName));
+ for (HColumnDescriptor colDesc : tableDesc.getFamilies()) {
+ assertEquals(ttl,Integer.parseInt(colDesc.getValue(TxConstants.PROPERTY_TTL)));
+ assertEquals(HColumnDescriptor.DEFAULT_TTL,colDesc.getTimeToLive());
+ }
+ }
+
+ @Test
+ public void testSetTTL() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ TransactionFactory.Provider txProvider = TransactionFactory.Provider.valueOf(this.txProvider);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props); Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+ String tableName = generateUniqueName();
+ conn.createStatement().execute("CREATE TABLE " + tableName +
+ "(K VARCHAR PRIMARY KEY) TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + txProvider + "',TTL=100");
+ assertTTL(admin, tableName, 100);
+ tableName = generateUniqueName();
+ conn.createStatement().execute("CREATE TABLE " + tableName +
+ "(K VARCHAR PRIMARY KEY) TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + txProvider + "'");
+ conn.createStatement().execute("ALTER TABLE " + tableName + " SET TTL=" + 200);
+ assertTTL(admin, tableName, 200);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9170b23/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 63a598f..71d4b3d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -2234,6 +2234,8 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
Map<String, Object> props = entry.getValue();
if (props == null) {
props = new HashMap<String, Object>();
+ } else {
+ props = new HashMap<String, Object>(props);
}
props.put(PhoenixTransactionContext.PROPERTY_TTL, ttl);
// Remove HBase TTL if we're not transitioning an existing table to become transactional
@@ -2241,6 +2243,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
if (!willBeTransactional && !Boolean.valueOf(newTableDescriptor.getValue(PhoenixTransactionContext.READ_NON_TX_DATA))) {
props.remove(TTL);
}
+ entry.setValue(props);
}
}
}