You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/06/06 18:40:05 UTC

[GitHub] [hbase] saintstack commented on a change in pull request #289: HBASE-13798 TestFromClientSide* don't close the Table (branch-2)

saintstack commented on a change in pull request #289: HBASE-13798 TestFromClientSide* don't close the Table (branch-2)
URL: https://github.com/apache/hbase/pull/289#discussion_r291319156
 
 

 ##########
 File path: hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
 ##########
 @@ -1542,230 +1564,232 @@ public void testVersionLimits() throws Exception {
     int [] LIMITS = {1,3,5};
     long [] STAMPS = makeStamps(10);
     byte [][] VALUES = makeNAscii(VALUE, 10);
-    Table ht = TEST_UTIL.createTable(tableName, FAMILIES, LIMITS);
-
-    // Insert limit + 1 on each family
-    Put put = new Put(ROW);
-    put.addColumn(FAMILIES[0], QUALIFIER, STAMPS[0], VALUES[0]);
-    put.addColumn(FAMILIES[0], QUALIFIER, STAMPS[1], VALUES[1]);
-    put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[0], VALUES[0]);
-    put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[1], VALUES[1]);
-    put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[2], VALUES[2]);
-    put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[3], VALUES[3]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[0], VALUES[0]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[1], VALUES[1]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[2], VALUES[2]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[3], VALUES[3]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[4], VALUES[4]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[5], VALUES[5]);
-    put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[6], VALUES[6]);
-    ht.put(put);
-
-    // Verify we only get the right number out of each
-
-    // Family0
-
-    Get get = new Get(ROW);
-    get.addColumn(FAMILIES[0], QUALIFIER);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    Result result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
-        new long [] {STAMPS[1]},
-        new byte[][] {VALUES[1]},
-        0, 0);
-
-    get = new Get(ROW);
-    get.addFamily(FAMILIES[0]);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
-        new long [] {STAMPS[1]},
-        new byte[][] {VALUES[1]},
-        0, 0);
-
-    Scan scan = new Scan(ROW);
-    scan.addColumn(FAMILIES[0], QUALIFIER);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
-        new long [] {STAMPS[1]},
-        new byte[][] {VALUES[1]},
-        0, 0);
-
-    scan = new Scan(ROW);
-    scan.addFamily(FAMILIES[0]);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
-        new long [] {STAMPS[1]},
-        new byte[][] {VALUES[1]},
-        0, 0);
+    try (Table ht = TEST_UTIL.createTable(tableName, FAMILIES, LIMITS)) {
 
-    // Family1
+      // Insert limit + 1 on each family
+      Put put = new Put(ROW);
+      put.addColumn(FAMILIES[0], QUALIFIER, STAMPS[0], VALUES[0]);
+      put.addColumn(FAMILIES[0], QUALIFIER, STAMPS[1], VALUES[1]);
+      put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[0], VALUES[0]);
+      put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[1], VALUES[1]);
+      put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[2], VALUES[2]);
+      put.addColumn(FAMILIES[1], QUALIFIER, STAMPS[3], VALUES[3]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[0], VALUES[0]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[1], VALUES[1]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[2], VALUES[2]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[3], VALUES[3]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[4], VALUES[4]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[5], VALUES[5]);
+      put.addColumn(FAMILIES[2], QUALIFIER, STAMPS[6], VALUES[6]);
+      ht.put(put);
 
-    get = new Get(ROW);
-    get.addColumn(FAMILIES[1], QUALIFIER);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
-        new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
-        new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
-        0, 2);
+      // Verify we only get the right number out of each
 
-    get = new Get(ROW);
-    get.addFamily(FAMILIES[1]);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
-        new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
-        new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
-        0, 2);
+      // Family0
 
-    scan = new Scan(ROW);
-    scan.addColumn(FAMILIES[1], QUALIFIER);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
-        new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
-        new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
-        0, 2);
-
-    scan = new Scan(ROW);
-    scan.addFamily(FAMILIES[1]);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
-        new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
-        new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
-        0, 2);
+      Get get = new Get(ROW);
+      get.addColumn(FAMILIES[0], QUALIFIER);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      Result result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
+          new long [] {STAMPS[1]},
+          new byte[][] {VALUES[1]},
+          0, 0);
 
-    // Family2
+      get = new Get(ROW);
+      get.addFamily(FAMILIES[0]);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
+          new long [] {STAMPS[1]},
+          new byte[][] {VALUES[1]},
+          0, 0);
+
+      Scan scan = new Scan(ROW);
+      scan.addColumn(FAMILIES[0], QUALIFIER);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
+              new long[]{STAMPS[1]},
+              new byte[][]{VALUES[1]},
+              0, 0);
+
+      scan = new Scan(ROW);
+      scan.addFamily(FAMILIES[0]);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[0], QUALIFIER,
+              new long[]{STAMPS[1]},
+              new byte[][]{VALUES[1]},
+              0, 0);
 
-    get = new Get(ROW);
-    get.addColumn(FAMILIES[2], QUALIFIER);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
-        new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
-        new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
-        0, 4);
+      // Family1
 
-    get = new Get(ROW);
-    get.addFamily(FAMILIES[2]);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
-        new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
-        new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
-        0, 4);
+      get = new Get(ROW);
+      get.addColumn(FAMILIES[1], QUALIFIER);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
+          new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
+          new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
+          0, 2);
 
-    scan = new Scan(ROW);
-    scan.addColumn(FAMILIES[2], QUALIFIER);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
-        new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
-        new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
-        0, 4);
+      get = new Get(ROW);
+      get.addFamily(FAMILIES[1]);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
+          new long [] {STAMPS[1], STAMPS[2], STAMPS[3]},
+          new byte[][] {VALUES[1], VALUES[2], VALUES[3]},
+          0, 2);
 
-    scan = new Scan(ROW);
-    scan.addFamily(FAMILIES[2]);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
-        new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
-        new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
-        0, 4);
+      scan = new Scan(ROW);
+      scan.addColumn(FAMILIES[1], QUALIFIER);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
+              new long[]{STAMPS[1], STAMPS[2], STAMPS[3]},
+              new byte[][]{VALUES[1], VALUES[2], VALUES[3]},
+              0, 2);
+
+      scan = new Scan(ROW);
+      scan.addFamily(FAMILIES[1]);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[1], QUALIFIER,
+              new long[]{STAMPS[1], STAMPS[2], STAMPS[3]},
+              new byte[][]{VALUES[1], VALUES[2], VALUES[3]},
+              0, 2);
 
-    // Try all families
+      // Family2
 
-    get = new Get(ROW);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      get = new Get(ROW);
+      get.addColumn(FAMILIES[2], QUALIFIER);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
+          new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
+          new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
+          0, 4);
 
-    get = new Get(ROW);
-    get.addFamily(FAMILIES[0]);
-    get.addFamily(FAMILIES[1]);
-    get.addFamily(FAMILIES[2]);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      get = new Get(ROW);
+      get.addFamily(FAMILIES[2]);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
+          new long [] {STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
+          new byte[][] {VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
+          0, 4);
+
+      scan = new Scan(ROW);
+      scan.addColumn(FAMILIES[2], QUALIFIER);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
+              new long[]{STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
+              new byte[][]{VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
+              0, 4);
+
+      scan = new Scan(ROW);
+      scan.addFamily(FAMILIES[2]);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertNResult(result, ROW, FAMILIES[2], QUALIFIER,
+              new long[]{STAMPS[2], STAMPS[3], STAMPS[4], STAMPS[5], STAMPS[6]},
+              new byte[][]{VALUES[2], VALUES[3], VALUES[4], VALUES[5], VALUES[6]},
+              0, 4);
 
-    get = new Get(ROW);
-    get.addColumn(FAMILIES[0], QUALIFIER);
-    get.addColumn(FAMILIES[1], QUALIFIER);
-    get.addColumn(FAMILIES[2], QUALIFIER);
-    get.setMaxVersions(Integer.MAX_VALUE);
-    result = ht.get(get);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      // Try all families
 
-    scan = new Scan(ROW);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    result = getSingleScanResult(ht, scan);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      get = new Get(ROW);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertTrue("Expected 9 keys but received " + result.size(),
+          result.size() == 9);
 
-    scan = new Scan(ROW);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    scan.addFamily(FAMILIES[0]);
-    scan.addFamily(FAMILIES[1]);
-    scan.addFamily(FAMILIES[2]);
-    result = getSingleScanResult(ht, scan);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      get = new Get(ROW);
+      get.addFamily(FAMILIES[0]);
+      get.addFamily(FAMILIES[1]);
+      get.addFamily(FAMILIES[2]);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertTrue("Expected 9 keys but received " + result.size(),
+          result.size() == 9);
 
-    scan = new Scan(ROW);
-    scan.setMaxVersions(Integer.MAX_VALUE);
-    scan.addColumn(FAMILIES[0], QUALIFIER);
-    scan.addColumn(FAMILIES[1], QUALIFIER);
-    scan.addColumn(FAMILIES[2], QUALIFIER);
-    result = getSingleScanResult(ht, scan);
-    assertTrue("Expected 9 keys but received " + result.size(),
-        result.size() == 9);
+      get = new Get(ROW);
+      get.addColumn(FAMILIES[0], QUALIFIER);
+      get.addColumn(FAMILIES[1], QUALIFIER);
+      get.addColumn(FAMILIES[2], QUALIFIER);
+      get.setMaxVersions(Integer.MAX_VALUE);
+      result = ht.get(get);
+      assertTrue("Expected 9 keys but received " + result.size(),
+          result.size() == 9);
 
+      scan = new Scan(ROW);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      result = getSingleScanResult(ht, scan);
+      assertTrue("Expected 9 keys but received " + result.size(),
+              result.size() == 9);
+
+      scan = new Scan(ROW);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      scan.addFamily(FAMILIES[0]);
+      scan.addFamily(FAMILIES[1]);
+      scan.addFamily(FAMILIES[2]);
+      result = getSingleScanResult(ht, scan);
+      assertTrue("Expected 9 keys but received " + result.size(),
+              result.size() == 9);
+
+      scan = new Scan(ROW);
+      scan.setMaxVersions(Integer.MAX_VALUE);
+      scan.addColumn(FAMILIES[0], QUALIFIER);
+      scan.addColumn(FAMILIES[1], QUALIFIER);
+      scan.addColumn(FAMILIES[2], QUALIFIER);
+      result = getSingleScanResult(ht, scan);
+      assertTrue("Expected 9 keys but received " + result.size(),
+              result.size() == 9);
+    }
   }
 
   @Test
   public void testDeleteFamilyVersion() throws Exception {
-    Admin admin = TEST_UTIL.getAdmin();
-    final TableName tableName = TableName.valueOf(name.getMethodName());
-
-    byte [][] QUALIFIERS = makeNAscii(QUALIFIER, 1);
-    byte [][] VALUES = makeN(VALUE, 5);
-    long [] ts = {1000, 2000, 3000, 4000, 5000};
-
-    Table ht = TEST_UTIL.createTable(tableName, FAMILY, 5);
+    try (Admin admin = TEST_UTIL.getAdmin()) {
 
 Review comment:
   If the TEST_UTIL is not created per test, but is setup once only for all tests, then indeed, closing the Admin made by TEST_UTIL will mess up subsequent attempts at using admin.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services