hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject [2/2] hbase git commit: HBASE-13333 Renew Scanner Lease without advancing the RegionScanner.
Date Sun, 03 May 2015 00:55:12 GMT
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/955a0548
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/955a0548
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/955a0548

Branch: refs/heads/branch-1.1
Commit: 955a054850f566745f62d6d72109a58207c38bb3
Parents: 49ab39d
Author: Lars Hofhansl <larsh@apache.org>
Authored: Sat May 2 17:52:27 2015 -0700
Committer: Lars Hofhansl <larsh@apache.org>
Committed: Sat May 2 17:52:58 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/955a0548/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 dc325a3..440400a 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
@@ -124,4 +124,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/955a0548/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 33afce4..947eb69 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
@@ -752,4 +752,21 @@ public class ClientScanner extends AbstractClientScanner {
       return closestFrontRow;
     }
   }
+
+  @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/955a0548/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 9d7bcc0..1ec085f 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
@@ -109,4 +109,9 @@ public class ClientSideRegionScanner extends AbstractClientScanner {
       }
     }
   }
+
+  @Override
+  public boolean renewLease() {
+    throw new UnsupportedOperationException();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/955a0548/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 f44e845..c8e34e5 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
@@ -201,4 +201,9 @@ public class TableSnapshotScanner extends AbstractClientScanner {
     }
   }
 
+  @Override
+  public boolean renewLease() {
+    throw new UnsupportedOperationException();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/955a0548/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 39379e4..e2bd999 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;
@@ -428,4 +429,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