trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [24/25] incubator-trafodion git commit: TRAFODION-1729
Date Tue, 02 Feb 2016 16:57:58 GMT
TRAFODION-1729


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/65cc64fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/65cc64fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/65cc64fe

Branch: refs/heads/master
Commit: 65cc64fef3b0079fb5c018d499b7130baff67536
Parents: accdfe2
Author: mashengchen <mashengchen@gmail.com>
Authored: Wed Jan 27 06:15:54 2016 +0000
Committer: mashengchen <mashengchen@gmail.com>
Committed: Wed Jan 27 06:15:54 2016 +0000

----------------------------------------------------------------------
 .../org/trafodion/sql/CoprocessorUtils.java     | 21 +++++++++++++++-----
 .../java/org/trafodion/sql/HBaseClient.java     | 15 ++++++++++++++
 2 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/65cc64fe/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java b/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java
index 714156a..9a3d75c 100644
--- a/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java
+++ b/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java
@@ -60,22 +60,33 @@ public class CoprocessorUtils {
         }
     }
 
-    public static void addCoprocessor(String currentAllClassName, HTableDescriptor desc,
boolean isMVCC) throws IOException {
+    //boolean as return ,to make sure whether changes take place in HTableDescriptor
+    public static boolean addCoprocessor(String currentAllClassName, HTableDescriptor desc,
boolean isMVCC) throws IOException {
+        boolean retVal = false; 
         if (coprocessors == null) {
-            return;
+            return retVal;
         }
         for (String coprocess : coprocessors) {
-            if (currentAllClassName == null || !currentAllClassName.contains(coprocess))
{
+            if ((currentAllClassName == null || !currentAllClassName.contains(coprocess))
&& !desc.hasCoprocessor(coprocess)) {
                 desc.addCoprocessor(coprocess);
+                retVal = true;
             }
         }
-        if (isMVCC && (currentAllClassName == null || !currentAllClassName.contains(MVCC)))
{
+        
+        if (isMVCC && (currentAllClassName == null || !currentAllClassName.contains(MVCC))
&& !desc.hasCoprocessor(MVCC)) {
             desc.addCoprocessor(MVCC);
-        } else if (!isMVCC && (currentAllClassName == null || !currentAllClassName.contains(SSCC)))
{
+            retVal = true;
+        } else if (!isMVCC && (currentAllClassName == null || !currentAllClassName.contains(SSCC))
&& !desc.hasCoprocessor(SSCC)) {
             desc.addCoprocessor(SSCC);
+            retVal = true;
         }
+
+        return retVal;
     }
 
+    public static boolean addCoprocessor(String currentAllClassName, HTableDescriptor desc)
throws IOException {
+        return addCoprocessor(currentAllClassName, desc, true);
+    }
     public static void main(String[] args) throws IOException {
         System.out.println("================CoprocessorUtils.main======================");
         String currentAllClassName = "";

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/65cc64fe/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
index a363098..61f8081 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
@@ -854,6 +854,21 @@ public class HBaseClient {
              if (logger.isDebugEnabled()) logger.debug("  ==> Error in init(), returning
empty.");
              return null;
           }
+
+          HBaseAdmin admin = new HBaseAdmin(config);
+          HTableDescriptor tblDesc = admin.getTableDescriptor(TableName.valueOf(tblName));
+          if (logger.isDebugEnabled()) logger.debug("check coprocessor num for tbl : "+ tblName+".
coprocessor size : "+tblDesc.getCoprocessors().size());
+          boolean added = CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"),
tblDesc);
+          if (added) {
+              if (logger.isDebugEnabled())
+                  logger.debug("  ==> add coprocessor for table : " + tblName);
+              synchronized (admin) {
+                  admin.disableTable(tblName);
+                  admin.modifyTable(tblName, tblDesc);
+                  admin.enableTable(tblName);
+              }
+          }
+
           if (logger.isDebugEnabled()) logger.debug("  ==> Created new object.");
           hTableClientsInUse.put(htable.getTableName(), htable);
           htable.setJniObject(jniObject);


Mime
View raw message