trafodion-commits mailing list archives

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


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

Branch: refs/heads/master
Commit: 11f9686b5df87f70b79edac5621da0610c7e70b8
Parents: fc9651f
Author: mashengchen <mashengchen@gmail.com>
Authored: Mon Jan 11 02:49:44 2016 +0000
Committer: mashengchen <mashengchen@gmail.com>
Committed: Mon Jan 11 02:49:44 2016 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/trafcoprocess.properties   |  1 +
 .../org/trafodion/sql/CoprocessorUtils.java     | 55 ++++++++++++++++++++
 .../java/org/trafodion/sql/HBaseClient.java     | 10 +++-
 3 files changed, 64 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/11f9686b/core/sqf/sql/scripts/trafcoprocess.properties
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/trafcoprocess.properties b/core/sqf/sql/scripts/trafcoprocess.properties
new file mode 100644
index 0000000..0bc56f5
--- /dev/null
+++ b/core/sqf/sql/scripts/trafcoprocess.properties
@@ -0,0 +1 @@
+coprocessors=org.apache.hadoop.hbase.coprocessor.transactional.TrxRegionObserver,org.apache.hadoop.hbase.coprocessor.transactional.TrxRegionEndpoint,org.apache.hadoop.hbase.coprocessor.transactional.SsccRegionEndpoint,org.apache.hadoop.hbase.coprocessor.AggregateImplementation

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/11f9686b/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
new file mode 100644
index 0000000..e9535c4
--- /dev/null
+++ b/core/sql/src/main/java/org/trafodion/sql/CoprocessorUtils.java
@@ -0,0 +1,55 @@
+package org.trafodion.sql;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.log4j.Logger;
+
+public class CoprocessorUtils {
+    private static Logger logger = Logger.getLogger(HBaseClient.class.getName());
+    private static String[] coprocessors = null;
+
+    static {
+        init();
+    }
+
+    private static void init() {
+        Configuration config = null;
+        try {
+            String path = System.getenv("MY_SQROOT") + "/etc/trafcoprocess.properties";
+            config = new PropertiesConfiguration(path);
+        } catch (Exception e) {
+            logger.info("error when finding trafcoprocess.properties");
+            e.printStackTrace();
+        }
+
+        if (config != null) {
+            coprocessors = config.getStringArray("coprocessors");
+        }
+    }
+
+    public static void addCoprocessor(String currentAllClassName, HTableDescriptor desc)
throws IOException {
+        if (coprocessors == null) {
+            return;
+        }
+        for (String coprocess : coprocessors) {
+            if (!currentAllClassName.contains(coprocess)) {
+                desc.addCoprocessor(coprocess);
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        System.out.println("================CoprocessorUtils.main======================");
+        //init();
+        if (coprocessors == null) {
+            return;
+        }
+        for (String coprocess : coprocessors) {
+            System.out.println(coprocess);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/11f9686b/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 98ac1b1..66de284 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
@@ -235,6 +235,10 @@ public class HBaseClient {
             if (logger.isDebugEnabled()) logger.debug("HBaseClient.create(" + tblName + ")
called, and MVCC is " + isMVCC + ".");
             cleanupCache(tblName);
             HTableDescriptor desc = new HTableDescriptor(tblName);
+            CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"),
desc);
+            for (String str : desc.getCoprocessors()) {
+                logger.debug(tblName + "has coprocessor : " + str);
+            }
             for (int i = 0; i < colFamNameList.length ; i++) {
 		String  colFam = (String)colFamNameList[i];
                 HColumnDescriptor colDesc = new HColumnDescriptor(colFam);
@@ -486,7 +490,10 @@ public class HBaseClient {
             String trueStr = "TRUE";
             cleanupCache(tblName);
             HTableDescriptor desc = new HTableDescriptor(tblName);
-
+        CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"), desc);
+        for (String str : desc.getCoprocessors()) {
+            logger.debug(tblName + "has coprocessor : " + str);
+        }
             int defaultVersionsValue = 0;
             if (isMVCC)
                 defaultVersionsValue = DtmConst.MVCC_MAX_VERSION;
@@ -518,7 +525,6 @@ public class HBaseClient {
             metaColDesc.setInMemory(true);
             desc.addFamily(metaColDesc);
             HBaseAdmin admin = new HBaseAdmin(config);
-
             try {
                if (beginEndKeys != null && beginEndKeys.length > 0)
                {


Mime
View raw message