virajjasani commented on code in PR #1477:
URL: https://github.com/apache/phoenix/pull/1477#discussion_r935022316


##########
phoenix-core/src/main/java/org/apache/phoenix/query/AdminUtilWithFallback.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.phoenix.query;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.TableState;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
+import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
+import org.apache.zookeeper.KeeperException;
+
+/**
+ * Admin utility class specifically useful for running Admin APIs in the 
middle of the
+ * rolling upgrade from HBase 1.x to 2.x versions. Some of the Admin APIs fail 
to retrieve
+ * table state details from meta table if master is running on 1.x version and 
coprocs are
+ * running on 2.x version. Hence, as a fallback, server side coproc can 
directly perform
+ * zookeeper look-up to retrieve table state data. The fallback usecases would 
not be
+ * encountered for fully upgraded 2.x cluster.
+ */
+public class AdminUtilWithFallback {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(AdminUtilWithFallback.class);
+
+  public static boolean tableExists(Admin admin, TableName tableName)
+      throws IOException, InterruptedException {
+    try {
+      return admin.tableExists(tableName);
+    } catch (IOException e) {
+      if (e instanceof NoSuchColumnFamilyException || (e.getCause() != null
+          && e.getCause() instanceof NoSuchColumnFamilyException)) {
+        LOG.error("Admin API to retrieve table existence failed due to missing 
CF in meta."

Review Comment:
   I can make it WARN level. Besides, this log would appear only once per CQSI 
initialization. Once initiated, connections are anyways cached.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to