phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject phoenix git commit: PHOENIX-2852 Dropping columns could trigger upgrade code on server side
Date Wed, 27 Apr 2016 22:56:37 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master 5574811dd -> 1fb6b1b79


PHOENIX-2852 Dropping columns could trigger upgrade code on server side


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

Branch: refs/heads/master
Commit: 1fb6b1b795609f7f2df35c2482cd4ec95bcc0cbe
Parents: 5574811
Author: Thomas D'Silva <tdsilva@salesforce.com>
Authored: Tue Apr 26 17:34:19 2016 -0700
Committer: Thomas D'Silva <tdsilva@salesforce.com>
Committed: Wed Apr 27 15:56:10 2016 -0700

----------------------------------------------------------------------
 .../IndexHalfStoreFileReaderGenerator.java      |  4 ++--
 .../hbase/regionserver/LocalIndexSplitter.java  |  2 +-
 .../coprocessor/MetaDataEndpointImpl.java       |  4 ++--
 .../coprocessor/MetaDataRegionObserver.java     | 16 ++-----------
 .../index/PhoenixIndexFailurePolicy.java        |  2 +-
 .../mapreduce/FormatToBytesWritableMapper.java  |  2 +-
 .../mapreduce/FormatToKeyValueReducer.java      |  2 +-
 .../phoenix/trace/PhoenixMetricsSink.java       |  2 +-
 .../java/org/apache/phoenix/util/QueryUtil.java | 24 +++++++++++++++++---
 9 files changed, 32 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
index 94d5912..b48314d 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
@@ -134,7 +134,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver
{
                 if (metaTable != null) metaTable.close();
             }
             try {
-                conn = QueryUtil.getConnection(ctx.getEnvironment().getConfiguration()).unwrap(
+                conn = QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()).unwrap(
                             PhoenixConnection.class);
                 String userTableName = MetaDataUtil.getUserTableName(tableName.getNameAsString());
                 PTable dataTable = PhoenixRuntime.getTable(conn, userTableName);
@@ -196,7 +196,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver
{
         if(compactedFilesCount == storeFilesCount) {
             PhoenixConnection conn = null;
             try {
-                conn = QueryUtil.getConnection(e.getEnvironment().getConfiguration()).unwrap(
+                conn = QueryUtil.getConnectionOnServer(e.getEnvironment().getConfiguration()).unwrap(
                     PhoenixConnection.class);
                 MetaDataClient client = new MetaDataClient(conn);
                 String userTableName = MetaDataUtil.getUserTableName(e.getEnvironment().getRegion().getTableDesc().getNameAsString());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/LocalIndexSplitter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/LocalIndexSplitter.java
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/LocalIndexSplitter.java
index 63dc1e8..63cf3ba 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/LocalIndexSplitter.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/LocalIndexSplitter.java
@@ -146,7 +146,7 @@ public class LocalIndexSplitter extends BaseRegionObserver {
         RegionCoprocessorEnvironment environment = ctx.getEnvironment();
         PhoenixConnection conn = null;
         try {
-            conn = QueryUtil.getConnection(ctx.getEnvironment().getConfiguration()).unwrap(
+            conn = QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()).unwrap(
                 PhoenixConnection.class);
             MetaDataClient client = new MetaDataClient(conn);
             String userTableName = ctx.getEnvironment().getRegion().getTableDesc().getNameAsString();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 77f87be..c8382ec 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -2377,7 +2377,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements
Coprocesso
                             new SQLParser(view.getViewStatement()).parseQuery().getWhere();
                     PhoenixConnection conn=null;
                     try {
-                        conn = QueryUtil.getConnection(env.getConfiguration()).unwrap(
+                        conn = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(
                             PhoenixConnection.class);
                     } catch (ClassNotFoundException e) {
                     }
@@ -3003,7 +3003,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements
Coprocesso
         // Covered columns are deleted from the index by the client
         PhoenixConnection connection = null;
         try {
-            connection = table.getIndexes().isEmpty() ? null : QueryUtil.getConnection(
+            connection = table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
                 env.getConfiguration()).unwrap(PhoenixConnection.class);
         } catch (ClassNotFoundException e) {
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 9bcf2d0..39532cd 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -18,7 +18,6 @@
 package org.apache.phoenix.coprocessor;
 
 import java.io.IOException;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -75,6 +74,7 @@ import org.apache.phoenix.schema.types.PLong;
 import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.UpgradeUtil;
 
@@ -121,17 +121,6 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
         	QueryServicesOptions.DEFAULT_INDEX_FAILURE_BLOCK_WRITE);
     }
     
-    private static String getJdbcUrl(RegionCoprocessorEnvironment env) {
-        String zkQuorum = env.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM);
-        String zkClientPort = env.getConfiguration().get(HConstants.ZOOKEEPER_CLIENT_PORT,
-            Integer.toString(HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT));
-        String zkParentNode = env.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT,
-            HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-        return PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum
-            + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkClientPort
-            + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkParentNode;
-    }
-
     @Override
     public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
         final RegionCoprocessorEnvironment env = e.getEnvironment();
@@ -282,13 +271,12 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
 
                     if (conn == null) {
                     	final Properties props = new Properties();
-                    	props.setProperty(PhoenixRuntime.NO_UPGRADE_ATTRIB, Boolean.TRUE.toString());
                     	// Set SCN so that we don't ping server and have the upper bound set
back to
                     	// the timestamp when the failure occurred.
                     	props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(Long.MAX_VALUE));
                     	// don't run a second index populations upsert select 
                         props.setProperty(QueryServices.INDEX_POPULATION_SLEEP_TIME, "0");

-                        conn = DriverManager.getConnection(getJdbcUrl(env), props).unwrap(PhoenixConnection.class);
+                        conn = QueryUtil.getConnectionOnServer(props, env.getConfiguration()).unwrap(PhoenixConnection.class);
                         String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTable);
                         dataPTable = PhoenixRuntime.getTable(conn, dataTableFullName);
                         indexesToPartiallyRebuild = Lists.newArrayListWithExpectedSize(dataPTable.getIndexes().size());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
index ea245cc..17da04e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
@@ -222,7 +222,7 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy
{
         Set<String> indexTableNames = new HashSet<String>(1);
         PhoenixConnection conn = null;
         try {
-            conn = QueryUtil.getConnection(this.env.getConfiguration()).unwrap(
+            conn = QueryUtil.getConnectionOnServer(this.env.getConfiguration()).unwrap(
                     PhoenixConnection.class);
             String userTableName = MetaDataUtil.getUserTableName(ref.getTableName());
             PTable dataTable = PhoenixRuntime.getTable(conn, userTableName);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
index 1211b83..ff21d4f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
@@ -125,7 +125,7 @@ public abstract class FormatToBytesWritableMapper<RECORD> extends
Mapper<LongWri
         }
 
         try {
-            conn = (PhoenixConnection) QueryUtil.getConnection(clientInfos, conf);
+            conn = (PhoenixConnection) QueryUtil.getConnectionOnServer(clientInfos, conf);
             // We are dependent on rolling back before performing commits, so we need to
be sure
             // that auto-commit is not turned on
             conn.setAutoCommit(false);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
index e906431..799b3dc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
@@ -78,7 +78,7 @@ public class FormatToKeyValueReducer
         }
 
         try {
-            PhoenixConnection conn = (PhoenixConnection) QueryUtil.getConnection(clientInfos,
conf);
+            PhoenixConnection conn = (PhoenixConnection) QueryUtil.getConnectionOnServer(clientInfos,
conf);
             builder = conn.getKeyValueBuilder();
             final String tableNamesConf = conf.get(FormatToBytesWritableMapper.TABLE_NAMES_CONFKEY);
             final String logicalNamesConf = conf.get(FormatToBytesWritableMapper.LOGICAL_NAMES_CONFKEY);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java b/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
index 00b6637..af0d6e7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
@@ -119,7 +119,7 @@ public class PhoenixMetricsSink implements MetricsSink {
                 props.setProperty(QueryServices.TRACING_FREQ_ATTRIB,
                         Tracing.Frequency.NEVER.getKey());
                 org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
-                Connection conn = QueryUtil.getConnection(props, conf);
+                Connection conn = QueryUtil.getConnectionOnServer(props, conf);
                 // enable bulk loading when we have enough data
                 conn.setAutoCommit(true);
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1fb6b1b7/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 daab198..a2b598c 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
@@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.util.Addressing;
 import org.apache.hadoop.hbase.zookeeper.ZKConfig;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.iterate.ResultIterator;
+import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver;
 import org.apache.phoenix.parse.HintNode;
 import org.apache.phoenix.parse.HintNode.Hint;
@@ -293,14 +294,31 @@ public final class QueryUtil {
         return buf.toString();
     }
 
-    public static Connection getConnection(Configuration conf) throws ClassNotFoundException,
+    /**
+     * @return {@link PhoenixConnection} with NO_UPGRADE_ATTRIB set so that we don't initiate
server upgrade
+     */
+    public static Connection getConnectionOnServer(Configuration conf) throws ClassNotFoundException,
             SQLException {
-        return getConnection(new Properties(), conf);
+        return getConnectionOnServer(new Properties(), conf);
     }
 
-    public static Connection getConnection(Properties props, Configuration conf)
+    /**
+     * @return {@link PhoenixConnection} with NO_UPGRADE_ATTRIB set so that we don't initiate
server upgrade
+     */
+    public static Connection getConnectionOnServer(Properties props, Configuration conf)
             throws ClassNotFoundException,
             SQLException {
+        props.setProperty(PhoenixRuntime.NO_UPGRADE_ATTRIB, Boolean.TRUE.toString());
+        return getConnection(props, conf);
+    }
+
+    public static Connection getConnection(Configuration conf) throws ClassNotFoundException,
+            SQLException {
+        return getConnection(new Properties(), conf);
+    }
+    
+    private static Connection getConnection(Properties props, Configuration conf)
+            throws ClassNotFoundException, SQLException {
         String url = getConnectionUrl(props, conf);
         LOG.info("Creating connection with the jdbc url: " + url);
         PropertiesUtil.extractProperties(props, conf);


Mime
View raw message