You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2015/12/10 05:28:39 UTC

[2/4] incubator-trafodion git commit: Update TrxTransactionState.java

Update TrxTransactionState.java

move scaninfoConstructor to static block

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

Branch: refs/heads/master
Commit: fff855f2d5bf60f6baa87930f74249e2898725b0
Parents: e2d32a5
Author: mashengchen <ma...@gmail.com>
Authored: Mon Dec 7 17:38:45 2015 +0800
Committer: mashengchen <ma...@gmail.com>
Committed: Mon Dec 7 17:38:45 2015 +0800

----------------------------------------------------------------------
 .../transactional/TrxTransactionState.java      | 75 ++++++++++----------
 1 file changed, 39 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fff855f2/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java
index 29b21f7..c53211a 100644
--- a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java
+++ b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java
@@ -94,6 +94,9 @@ public class TrxTransactionState  extends TransactionState{
     static java.lang.reflect.Constructor c98_1 = null;
     static java.lang.reflect.Constructor c98_4 = null;
 
+    static Constructor scaninfoConstructor = null;
+    static Object[] scaninfoArgs = null;
+
     static {
 	sb_sqm_98_1 = true;
 	try {
@@ -136,6 +139,40 @@ public class TrxTransactionState  extends TransactionState{
 	if (sb_sqm_98_4) {
 	    LOG.info("Got info of Class ScanQueryMatcher for HBase 98.4");
 	}
+	
+	
+	Class scaninfoClazz = null;
+        try {
+            scaninfoClazz = Class.forName("org.apache.hadoop.hbase.regionserver.ScanInfo");
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        Class[] types = null;
+
+        try {
+            types = new Class[] { byte[].class, int.class, int.class, long.class, boolean.class, long.class, KVComparator.class };
+            scaninfoConstructor = scaninfoClazz.getConstructor(types);
+            scaninfoArgs = new Object[] { null, 0, 1, HConstants.FOREVER, false, 0, KeyValue.COMPARATOR };
+            if (LOG.isTraceEnabled())
+                LOG.trace("Created ScanInfo instance before HBase 98.8");
+        } catch (Exception e) {
+            Class clazz = null;
+            try {
+                clazz = Class.forName("org.apache.hadoop.hbase.KeepDeletedCells");
+            } catch (ClassNotFoundException e1) {
+                throw new RuntimeException(e1.getMessage());
+            }
+            types = new Class[] { byte[].class, int.class, int.class, long.class, clazz, long.class, KVComparator.class };
+            try {
+                scaninfoConstructor = scaninfoClazz.getConstructor(types);
+                scaninfoArgs = new Object[] { null, 0, 1, HConstants.FOREVER, Enum.valueOf(clazz, "FALSE"), 0, KeyValue.COMPARATOR };
+                if (LOG.isTraceEnabled())
+                    LOG.trace("Created ScanInfo instance after HBase 98.8");
+            } catch (Exception e1) {
+                LOG.error("Created ScanInfo instance ERROR");
+                throw new RuntimeException(e1.getMessage());
+            }
+        }
     }
 
     /**
@@ -662,44 +699,10 @@ public class TrxTransactionState  extends TransactionState{
             //Store.ScanInfo scaninfo = new Store.ScanInfo(null, 0, 1, HConstants.FOREVER, false, 0, Cell.COMPARATOR);
             //after hbase 0.98.8, ScanInfo instance need KeepDeletedCells as param instead of boolean
             ScanInfo scaninfo = null;
-            Class scaninfoClazz = null;
             try {
-                scaninfoClazz = Class.forName("org.apache.hadoop.hbase.regionserver.ScanInfo");
-            } catch (ClassNotFoundException e) {
-                throw new RuntimeException(e.getMessage());
-            }
-            Class[] types = null;
-            Object[] args = null;
-            try {
-                types = new Class[] { byte[].class, int.class, int.class, long.class, boolean.class, long.class, KVComparator.class };
-                Constructor constructor = scaninfoClazz.getConstructor(types);
-                args = new Object[] { null, 0, 1, HConstants.FOREVER, false, 0, KeyValue.COMPARATOR };
-                scaninfo = (ScanInfo) constructor.newInstance(args);
-
-                if (LOG.isTraceEnabled())
-                    LOG.trace("Created ScanInfo instance before HBase 98.8");
+                scaninfo = (ScanInfo) scaninfoConstructor.newInstance(scaninfoArgs);
             } catch (Exception e) {
-                Class clazz = null;
-                try {
-                    clazz = Class.forName("org.apache.hadoop.hbase.KeepDeletedCells");
-                } catch (ClassNotFoundException e1) {
-                    throw new RuntimeException(e1.getMessage());
-                }
-                types = new Class[] { byte[].class, int.class, int.class, long.class, clazz, long.class, KVComparator.class };
-                Constructor constructor = null;
-                try {
-                    constructor = scaninfoClazz.getConstructor(types);
-                } catch (Exception e1) {
-                    throw new RuntimeException(e1.getMessage());
-                }
-                args = new Object[] { null, 0, 1, HConstants.FOREVER, Enum.valueOf(clazz, "FALSE"), 0, KeyValue.COMPARATOR };
-                try {
-                    scaninfo = (ScanInfo) constructor.newInstance(args);
-                } catch (Exception e1) {
-                    throw new RuntimeException(e1.getMessage());
-                }
-                if (LOG.isTraceEnabled())
-                    LOG.trace("Created ScanInfo instance after HBase 98.8");
+                throw new RuntimeException(e.getMessage());
             }
 
             try {