You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2016/06/29 02:49:08 UTC

phoenix git commit: PHOENIX-3018 Write local updates to region than HTable in master branch(Rajeshbabu)

Repository: phoenix
Updated Branches:
  refs/heads/master 60293d2f6 -> 93e7c1b30


PHOENIX-3018 Write local updates to region than HTable in master branch(Rajeshbabu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/93e7c1b3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/93e7c1b3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/93e7c1b3

Branch: refs/heads/master
Commit: 93e7c1b30d5934a0c2c668f79a0db8ebac5a92fb
Parents: 60293d2
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Wed Jun 29 08:25:32 2016 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Wed Jun 29 08:25:32 2016 +0530

----------------------------------------------------------------------
 .../write/ParallelWriterIndexCommitter.java     | 22 ++++++++++++++------
 .../TrackingParallelWriterIndexCommitter.java   | 21 ++++++++++++++-----
 .../java/org/apache/phoenix/util/IndexUtil.java | 14 +++++++++++++
 3 files changed, 46 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/93e7c1b3/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/ParallelWriterIndexCommitter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/ParallelWriterIndexCommitter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/ParallelWriterIndexCommitter.java
index 0dc11bc..dd30db5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/ParallelWriterIndexCommitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/ParallelWriterIndexCommitter.java
@@ -152,14 +152,24 @@ public class ParallelWriterIndexCommitter implements IndexCommitter {
                         LOG.debug("Writing index update:" + mutations + " to table: " + tableReference);
                     }
                     try {
-						if (allowLocalUpdates) {
-							for (Mutation m : mutations) {
-								m.setDurability(Durability.SKIP_WAL);
-							}
-						}
+                        if (allowLocalUpdates
+                                && env != null
+                                && tableReference.getTableName().equals(
+                                    env.getRegion().getTableDesc().getNameAsString())) {
+                            try {
+                                throwFailureIfDone();
+                                IndexUtil.writeLocalUpdates(env.getRegion(), mutations, true);
+                                return null;
+                            } catch (IOException ignord) {
+                                // when it's failed we fall back to the standard & slow way
+                                if (LOG.isDebugEnabled()) {
+                                    LOG.debug("indexRegion.batchMutate failed and fall back to HTable.batch(). Got error="
+                                            + ignord);
+                                }
+                            }
+                        }
                         HTableInterface table = factory.getTable(tableReference.get());
                         throwFailureIfDone();
-                        int i = 0;
                         table.batch(mutations);
                     } catch (SingleIndexWriteFailureException e) {
                         throw e;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/93e7c1b3/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java
index fec74ca..f3888ed 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/recovery/TrackingParallelWriterIndexCommitter.java
@@ -151,11 +151,22 @@ public class TrackingParallelWriterIndexCommitter implements IndexCommitter {
                     try {
                         // this may have been queued, but there was an abort/stop so we try to early exit
                         throwFailureIfDone();
-						if (allowLocalUpdates) {
-							for (Mutation m : mutations) {
-								m.setDurability(Durability.SKIP_WAL);
-							}
-						}
+                        if (allowLocalUpdates
+                                && env != null
+                                && tableReference.getTableName().equals(
+                                    env.getRegion().getTableDesc().getNameAsString())) {
+                            try {
+                                throwFailureIfDone();
+                                IndexUtil.writeLocalUpdates(env.getRegion(), mutations, true);
+                                return Boolean.TRUE;
+                            } catch (IOException ignord) {
+                                // when it's failed we fall back to the standard & slow way
+                                if (LOG.isDebugEnabled()) {
+                                    LOG.debug("indexRegion.batchMutate failed and fall back to HTable.batch(). Got error="
+                                            + ignord);
+                                }
+                            }
+                        }
 
                         if (LOG.isDebugEnabled()) {
                             LOG.debug("Writing index update:" + mutations + " to table: " + tableReference);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/93e7c1b3/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
index 86fa8ca..b0abe36 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
@@ -30,10 +30,12 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.Mutation;
@@ -659,4 +661,16 @@ public class IndexUtil {
         return viewConstants.isEmpty() ? null : viewConstants
                 .toArray(new byte[viewConstants.size()][]);
     }
+
+    public static void writeLocalUpdates(Region region, final List<Mutation> mutations, boolean skipWAL) throws IOException {
+        if(skipWAL) {
+            for (Mutation m : mutations) {
+                m.setDurability(Durability.SKIP_WAL);
+            }
+        }
+        region.batchMutate(
+            mutations.toArray(new Mutation[mutations.size()]),
+            HConstants.NO_NONCE, HConstants.NO_NONCE);
+    }
+
 }