hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject hbase git commit: HBASE-13333 Renew Scanner Lease without advancing the RegionScanner.
Date Sun, 03 May 2015 00:57:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 38288ebca -> f2bfe84f7


HBASE-13333 Renew Scanner Lease without advancing the RegionScanner.


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

Branch: refs/heads/0.98
Commit: f2bfe84f77d20ba8737d7d550c02e0df7a772747
Parents: 38288eb
Author: Lars Hofhansl <larsh@apache.org>
Authored: Sat May 2 17:58:30 2015 -0700
Committer: Lars Hofhansl <larsh@apache.org>
Committed: Sat May 2 17:58:30 2015 -0700

----------------------------------------------------------------------
 .../hbase/client/AbstractClientScanner.java     |  7 ++++++
 .../hadoop/hbase/client/ClientScanner.java      | 17 +++++++++++++
 .../hbase/client/ClientSideRegionScanner.java   |  5 ++++
 .../hbase/client/TableSnapshotScanner.java      |  5 ++++
 .../hbase/client/TestFromClientSide3.java       | 26 ++++++++++++++++++++
 5 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f2bfe84f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AbstractClientScanner.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AbstractClientScanner.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AbstractClientScanner.java
index 54c97d7..1137626 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AbstractClientScanner.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AbstractClientScanner.java
@@ -121,4 +121,11 @@ public abstract class AbstractClientScanner implements ResultScanner
{
       }
     };
   }
+  /**
+   * Allow the client to renew the scanner's lease on the server.
+   * @return true if the lease was successfully renewed, false otherwise.
+   */
+  // Note that this method should be on ResultScanner, but that is marked stable.
+  // Callers have to cast their instance of ResultScanner to AbstractClientScanner to use
this.
+  public abstract boolean renewLease();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f2bfe84f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
index e2a41fe..cced035 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
@@ -501,4 +501,21 @@ public class ClientScanner extends AbstractClientScanner {
       }
       closed = true;
     }
+
+    @Override
+    public boolean renewLease() {
+      if (callable != null) {
+        // do not return any rows, do not advance the scanner
+        callable.setCaching(0);
+        try {
+          this.caller.callWithoutRetries(callable, this.scannerTimeout);
+        } catch (Exception e) {
+          return false;
+        } finally {
+          callable.setCaching(this.caching);
+        }
+        return true;
+      }
+      return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f2bfe84f/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientSideRegionScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientSideRegionScanner.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientSideRegionScanner.java
index 587eff7..584d434 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientSideRegionScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientSideRegionScanner.java
@@ -113,4 +113,9 @@ public class ClientSideRegionScanner extends AbstractClientScanner {
       }
     }
   }
+
+  @Override
+  public boolean renewLease() {
+    throw new UnsupportedOperationException();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f2bfe84f/hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java
index 2928f26..4737ee7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java
@@ -202,4 +202,9 @@ public class TableSnapshotScanner extends AbstractClientScanner {
     }
   }
 
+  @Override
+  public boolean renewLease() {
+    throw new UnsupportedOperationException();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f2bfe84f/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
index 7080f09..900b40a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.client;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
@@ -431,4 +432,29 @@ public class TestFromClientSide3 {
     assertTrue(Arrays.equals(res.getValue(FAMILY, COL_QUAL), VAL_BYTES));
     table.close();
   }
+
+  @Test
+  public void testLeaseRenewal() throws Exception {
+    HTable table = TEST_UTIL.createTable(
+      Bytes.toBytes("testLeaseRenewal"), FAMILY);
+    Put p = new Put(ROW_BYTES);
+    p.add(FAMILY, COL_QUAL, VAL_BYTES);
+    table.put(p);
+    p = new Put(ANOTHERROW);
+    p.add(FAMILY, COL_QUAL, VAL_BYTES);
+    table.put(p);
+    Scan s = new Scan();
+    s.setCaching(1);
+    ResultScanner rs = table.getScanner(s);
+    // make sure that calling renewLease does not impact the scan results
+    assertTrue(((AbstractClientScanner)rs).renewLease());
+    assertTrue(Arrays.equals(rs.next().getRow(), ANOTHERROW));
+    assertTrue(((AbstractClientScanner)rs).renewLease());
+    assertTrue(Arrays.equals(rs.next().getRow(), ROW_BYTES));
+    assertTrue(((AbstractClientScanner)rs).renewLease());
+    assertNull(rs.next());
+    assertFalse(((AbstractClientScanner)rs).renewLease());
+    rs.close();
+    table.close();
+  }
 }


Mime
View raw message