jpisaac commented on code in PR #1748:
URL: https://github.com/apache/phoenix/pull/1748#discussion_r1428541478


##########
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -544,32 +548,51 @@ public ConnectionQueryServicesImpl(QueryServices 
services, ConnectionInfo connec
 
     }
 
-    private void openConnection() throws SQLException {
+    private Connection openConnection(Configuration conf) throws SQLException {
+        Connection localConnection;
         try {
-            this.connection = 
HBaseFactoryProvider.getHConnectionFactory().createConnection(this.config);
+            localConnection = 
HBaseFactoryProvider.getHConnectionFactory().createConnection(conf);
             GLOBAL_HCONNECTIONS_COUNTER.increment();
             LOGGER.info("HConnection established. Stacktrace for informational 
purposes: "
-                    + connection + " " +  LogUtil.getCallerStackTrace());
+                    + localConnection + " " +  LogUtil.getCallerStackTrace());
         } catch (IOException e) {
             throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_ESTABLISH_CONNECTION)
             .setRootCause(e).build().buildException();
         }
-        if (this.connection.isClosed()) { // TODO: why the heck doesn't this 
throw above?
+        if (localConnection.isClosed()) { // TODO: why the heck doesn't this 
throw above?
             throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_ESTABLISH_CONNECTION).build().buildException();
         }
+        return localConnection;
+    }
+
+    /*
+    We create a long-lived hbase connection to run invalidate cache RPCs. We 
override
+    CUSTOM_CONTROLLER_CONF_KEY to instantiate 
InvalidateMetadataCacheController which has
+    a special priority for invalidate metadata cache operations.
+     */
+    public Connection getInvalidateMetadataCacheConnection() throws 
SQLException {

Review Comment:
   nit: Refactoring suggestions - 
   Maybe the initialization of the invalidateMetadataCacheConnection can be 
done in CQSI init itself, since these are one time actions. Instead of late 
binding/initialization. You may be able to simplify the connection creation 
without cloning the config and overriding the CUSTOM_CONTROLLER_CONF_KEY. See 
ServerSideRPCControllerFactory usage for eg



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to