Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 44e43d7c2 -> dab384345
http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java index 21ea072..14bcd70 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java @@ -30,26 +30,20 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.execute.MutationState; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.tephra.Transaction.VisibilityLevel; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.google.common.collect.Maps; - @RunWith(Parameterized.class) public class TxCheckpointIT extends ParallelStatsDisabledIT { @@ -62,13 +56,14 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { } - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(2); - props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection() throws SQLException { + return getConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES)); + } + + private static Connection getConnection(Properties props) throws SQLException { + props.setProperty(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } @Parameters(name="TxCheckpointIT_localIndex={0},mutable={1}") // name is used by failsafe as file name in reports @@ -88,7 +83,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { props.setProperty(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3)); props.setProperty(QueryServices.SCAN_CACHE_SIZE_ATTRIB, Integer.toString(3)); props.setProperty(QueryServices.SCAN_RESULT_CHUNK_SIZE, Integer.toString(3)); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(props); conn.setAutoCommit(true); conn.createStatement().execute("CREATE SEQUENCE "+seqName); conn.createStatement().execute("CREATE TABLE " + fullTableName + "(pk INTEGER PRIMARY KEY, val INTEGER)"+(!mutable? " IMMUTABLE_ROWS=true" : "")); @@ -123,7 +118,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { private void testRollbackOfUncommittedDelete(String indexDDL, String fullTableName) throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); @@ -212,7 +207,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(tableName, tableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); Statement stmt = conn.createStatement(); @@ -303,7 +298,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { String fullTableName = SchemaUtil.getTableName(tableName, tableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); ResultSet rs; - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName + "1(ID1 BIGINT NOT NULL PRIMARY KEY, FK1A INTEGER, FK1B INTEGER)" http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java index 9b87361..ef3ac39 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java @@ -37,6 +37,7 @@ import static org.apache.phoenix.query.QueryServices.GLOBAL_METRICS_ENABLED; import static org.apache.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB; import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILLABLE_ATTRIB; import static org.apache.phoenix.query.QueryServices.GROUPBY_SPILL_FILES_ATTRIB; +import static org.apache.phoenix.query.QueryServices.HBASE_CLIENT_SCANNER_TIMEOUT_ATTRIB; import static org.apache.phoenix.query.QueryServices.IMMUTABLE_ROWS_ATTRIB; import static org.apache.phoenix.query.QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB; import static org.apache.phoenix.query.QueryServices.INDEX_POPULATION_SLEEP_TIME; @@ -59,7 +60,6 @@ import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB; import static org.apache.phoenix.query.QueryServices.NUM_RETRIES_FOR_SCHEMA_UPDATE_CHECK; import static org.apache.phoenix.query.QueryServices.QUEUE_SIZE_ATTRIB; import static org.apache.phoenix.query.QueryServices.REGIONSERVER_INFO_PORT_ATTRIB; -import static org.apache.phoenix.query.QueryServices.HBASE_CLIENT_SCANNER_TIMEOUT_ATTRIB; import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_ENABLED; import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_THREAD_POOL_SIZE; import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_THRESHOLD_MILLISECONDS; @@ -78,6 +78,7 @@ import static org.apache.phoenix.query.QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB import static org.apache.phoenix.query.QueryServices.STATS_USE_CURRENT_TIME_ATTRIB; import static org.apache.phoenix.query.QueryServices.THREAD_POOL_SIZE_ATTRIB; import static org.apache.phoenix.query.QueryServices.THREAD_TIMEOUT_MS_ATTRIB; +import static org.apache.phoenix.query.QueryServices.TRANSACTIONS_ENABLED; import static org.apache.phoenix.query.QueryServices.USE_BYTE_BASED_REGEX_ATTRIB; import static org.apache.phoenix.query.QueryServices.USE_INDEXES_ATTRIB; @@ -598,6 +599,11 @@ public class QueryServicesOptions { return this; } + public QueryServicesOptions setTransactionsEnabled(boolean transactionsEnabled) { + config.setBoolean(TRANSACTIONS_ENABLED, transactionsEnabled); + return this; + } + public QueryServicesOptions setExplainRowCount(boolean showRowCount) { config.setBoolean(EXPLAIN_ROW_COUNT_ATTRIB, showRowCount); return this; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java index bab52a4..58fb151 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java @@ -382,7 +382,7 @@ public final class QueryUtil { HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); String url = getUrl(server, port, znodeParent, principal); // Mainly for testing to tack on the test=true part to ensure driver is found on server - String extraArgs = conf.get(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + String extraArgs = props.getProperty(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, conf.get(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS)); if (extraArgs.length() > 0) { url += extraArgs + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java index fde70d0..4ab75a9 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java @@ -34,6 +34,7 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; +import org.junit.Ignore; import org.junit.Test; public class PhoenixDriverTest extends BaseConnectionlessQueryTest { @@ -89,6 +90,7 @@ public class PhoenixDriverTest extends BaseConnectionlessQueryTest { } } + @Ignore @Test public void testDisallowIsolationLevel() throws SQLException { Connection conn = DriverManager.getConnection(getUrl()); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index 7008911..3de0b77 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -536,9 +536,7 @@ public abstract class BaseTest { } private static void checkTxManagerInitialized(ReadOnlyProps clientProps) throws SQLException, IOException { - if (txService == null - && clientProps.getBoolean(QueryServices.TRANSACTIONS_ENABLED, - QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { + if (txService == null) { setupTxManager(); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java index f2b1519..d1d50d5 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java @@ -63,6 +63,7 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl { public static final int DEFAULT_HCONNECTION_POOL_MAX_SIZE = 10; public static final int DEFAULT_HTABLE_MAX_THREADS = 10; public static final long DEFAULT_INDEX_POPULATION_WAIT_TIME = 0; + public static final boolean DEFAULT_TRANSACTIONS_ENABLED = true; /** @@ -79,6 +80,7 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl { private static QueryServicesOptions getDefaultServicesOptions() { return withDefaults() + .setTransactionsEnabled(DEFAULT_TRANSACTIONS_ENABLED) .setExplainChunkCount(DEFAULT_EXPLAIN_CHUNK_COUNT) .setExplainRowCount(DEFAULT_EXPLAIN_ROW_COUNT) .setSequenceSaltBuckets(DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS)