hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zg...@apache.org
Subject [1/2] hbase git commit: HBASE-18950 Remove Optional parameters in AsyncAdmin interface
Date Mon, 06 Nov 2017 12:46:08 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 061a73db6 -> 47c614c70


http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
index c3c4045..83ba244 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
@@ -21,10 +21,8 @@ import static org.apache.hadoop.hbase.client.AsyncProcess.START_LOG_ERRORS_AFTER
 
 import java.util.Arrays;
 import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 import java.util.regex.Pattern;
 
@@ -41,8 +39,6 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.rules.TestName;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
 
@@ -106,7 +102,7 @@ public abstract class TestAsyncAdminBase {
 
   @After
   public void tearDown() throws Exception {
-    admin.listTableNames(Optional.of(Pattern.compile(tableName.getNameAsString() + ".*")),
false)
+    admin.listTableNames(Pattern.compile(tableName.getNameAsString() + ".*"), false)
         .whenCompleteAsync((tables, err) -> {
           if (tables != null) {
             tables.forEach(table -> {
@@ -122,19 +118,21 @@ public abstract class TestAsyncAdminBase {
   }
 
   protected void createTableWithDefaultConf(TableName tableName) {
-    createTableWithDefaultConf(tableName, Optional.empty());
+    createTableWithDefaultConf(tableName, null);
   }
 
-  protected void createTableWithDefaultConf(TableName tableName, Optional<byte[][]>
splitKeys) {
+  protected void createTableWithDefaultConf(TableName tableName, byte[][] splitKeys) {
     createTableWithDefaultConf(tableName, splitKeys, FAMILY);
   }
 
-  protected void createTableWithDefaultConf(TableName tableName, Optional<byte[][]>
splitKeys,
+  protected void createTableWithDefaultConf(TableName tableName, byte[][] splitKeys,
       byte[]... families) {
     TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
     for (byte[] family : families) {
       builder.addColumnFamily(ColumnFamilyDescriptorBuilder.of(family));
     }
-    admin.createTable(builder.build(), splitKeys).join();
+    CompletableFuture<Void> future = splitKeys == null ? admin.createTable(builder.build())
+        : admin.createTable(builder.build(), splitKeys);
+    future.join();
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncClusterAdminApi.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncClusterAdminApi.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncClusterAdminApi.java
index 53de2b5..e7c439b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncClusterAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncClusterAdminApi.java
@@ -31,7 +31,6 @@ import java.util.Collection;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.ClusterStatus;
@@ -254,7 +253,7 @@ public class TestAsyncClusterAdminApi extends TestAsyncAdminBase {
       List<RegionInfo> tableRegions = admin.getTableRegions(table).get();
       List<RegionLoad> regionLoads = Lists.newArrayList();
       for (ServerName serverName : servers) {
-        regionLoads.addAll(admin.getRegionLoads(serverName, Optional.of(table)).get());
+        regionLoads.addAll(admin.getRegionLoads(serverName, table).get());
       }
       checkRegionsAndRegionLoads(tableRegions, regionLoads);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
index 262cac6..1ee1b94 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
@@ -200,7 +200,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
     }
 
     assertTrue(destServerName != null && !destServerName.equals(serverName));
-    admin.move(hri.getRegionName(), Optional.of(destServerName)).get();
+    admin.move(hri.getRegionName(), destServerName).get();
 
     long timeoutTime = System.currentTimeMillis() + 30000;
     while (true) {
@@ -362,7 +362,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
   @Test
   public void testMergeRegions() throws Exception {
     byte[][] splitRows = new byte[][] { Bytes.toBytes("3"), Bytes.toBytes("6") };
-    createTableWithDefaultConf(tableName, Optional.of(splitRows));
+    createTableWithDefaultConf(tableName, splitRows);
 
     RawAsyncTable metaTable = ASYNC_CONN.getRawTable(META_TABLE_NAME);
     List<HRegionLocation> regionLocations =
@@ -419,8 +419,11 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
     table.putAll(puts).join();
 
     if (isSplitRegion) {
-      admin.splitRegion(regionLocations.get(0).getRegionInfo().getRegionName(),
-        Optional.ofNullable(splitPoint)).get();
+      if (splitPoint == null) {
+        admin.splitRegion(regionLocations.get(0).getRegionInfo().getRegionName()).get();
+      } else {
+        admin.splitRegion(regionLocations.get(0).getRegionInfo().getRegionName(), splitPoint).get();
+      }
     } else {
       if (splitPoint == null) {
         admin.split(tableName).get();
@@ -450,7 +453,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
   @Test
   public void testCompactRegionServer() throws Exception {
     byte[][] families = { Bytes.toBytes("f1"), Bytes.toBytes("f2"), Bytes.toBytes("f3") };
-    createTableWithDefaultConf(tableName, Optional.empty(), families);
+    createTableWithDefaultConf(tableName, null, families);
     loadData(tableName, families, 3000, 8);
 
     List<HRegionServer> rsList =
@@ -491,7 +494,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
     byte[] family = Bytes.toBytes("family");
     byte[][] families =
         { family, Bytes.add(family, Bytes.toBytes("2")), Bytes.add(family, Bytes.toBytes("3"))
};
-    createTableWithDefaultConf(tableName, Optional.empty(), families);
+    createTableWithDefaultConf(tableName, null, families);
     loadData(tableName, families, 3000, flushes);
 
     List<Region> regions = new ArrayList<>();
@@ -506,15 +509,15 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
     assertTrue(countBefore > 0); // there should be some data files
     if (expectedState == CompactionState.MINOR) {
       if (singleFamily) {
-        admin.compact(tableName, Optional.of(family)).get();
+        admin.compact(tableName, family).get();
       } else {
-        admin.compact(tableName, Optional.empty()).get();
+        admin.compact(tableName).get();
       }
     } else {
       if (singleFamily) {
-        admin.majorCompact(tableName, Optional.of(family)).get();
+        admin.majorCompact(tableName, family).get();
       } else {
-        admin.majorCompact(tableName, Optional.empty()).get();
+        admin.majorCompact(tableName).get();
       }
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java
index f789da5..5014e96 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java
@@ -32,7 +32,6 @@ import org.junit.runners.Parameterized;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
-import java.util.Optional;
 import java.util.regex.Pattern;
 
 @RunWith(Parameterized.class)
@@ -169,13 +168,10 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase {
     admin.snapshot(snapshotName3, tableName).get();
     Assert.assertEquals(admin.listSnapshots().get().size(), 3);
 
-    Assert.assertEquals(admin.listSnapshots(Optional.of(Pattern.compile("(.*)"))).get().size(),
3);
-    Assert.assertEquals(admin.listSnapshots(Optional.of(Pattern.compile("snapshotName(\\d+)")))
-        .get().size(), 3);
-    Assert.assertEquals(admin.listSnapshots(Optional.of(Pattern.compile("snapshotName[1|3]")))
-        .get().size(), 2);
-    Assert.assertEquals(admin.listSnapshots(Optional.of(Pattern.compile("snapshot(.*)"))).get()
-        .size(), 3);
+    Assert.assertEquals(admin.listSnapshots(Pattern.compile("(.*)")).get().size(), 3);
+    Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshotName(\\d+)")).get().size(),
3);
+    Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshotName[1|3]")).get().size(),
2);
+    Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshot(.*)")).get().size(),
3);
     Assert.assertEquals(
       admin.listTableSnapshots(Pattern.compile("testListSnapshots"), Pattern.compile("s(.*)")).get()
           .size(),

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java
index 4df5947..7bbbd71 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java
@@ -120,9 +120,9 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
       admin.deleteTable(tables[i]).join();
     }
 
-    tableDescs = admin.listTables(Optional.empty(), true).get();
+    tableDescs = admin.listTables(true).get();
     assertTrue("Not found system tables", tableDescs.size() > 0);
-    tableNames = admin.listTableNames(Optional.empty(), true).get();
+    tableNames = admin.listTableNames(true).get();
     assertTrue("Not found system tables", tableNames.size() > 0);
   }
 
@@ -169,7 +169,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     assertEquals("Table should have only 1 region", 1, regionLocations.size());
 
     final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "_2");
-    createTableWithDefaultConf(tableName2, Optional.of(new byte[][] { new byte[] { 42 } }));
+    createTableWithDefaultConf(tableName2, new byte[][] { new byte[] { 42 } });
     regionLocations =
         AsyncMetaTableAccessor.getTableHRegionLocations(metaTable, Optional.of(tableName2)).get();
     assertEquals("Table should have only 2 region", 2, regionLocations.size());
@@ -208,7 +208,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
         new byte[] { 7, 7, 7 }, new byte[] { 8, 8, 8 }, new byte[] { 9, 9, 9 }, };
     int expectedRegions = splitKeys.length + 1;
     boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration());
-    createTableWithDefaultConf(tableName, Optional.of(splitKeys));
+    createTableWithDefaultConf(tableName, splitKeys);
 
     boolean tableAvailable = admin.isTableAvailable(tableName, splitKeys).get();
     assertTrue("Table should be created with splitKyes + 1 rows in META", tableAvailable);
@@ -342,7 +342,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
         new byte[] { 3, 3, 3 }, new byte[] { 2, 2, 2 } };
     final TableName tableName4 = TableName.valueOf(tableName.getNameAsString() + "_4");;
     try {
-      createTableWithDefaultConf(tableName4, Optional.of(splitKeys));
+      createTableWithDefaultConf(tableName4, splitKeys);
       fail("Should not be able to create this table because of " + "duplicate split keys");
     } catch (CompletionException e) {
       assertTrue(e.getCause() instanceof IllegalArgumentException);
@@ -376,7 +376,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     byte[][] splitKeys = new byte[1][];
     splitKeys[0] = HConstants.EMPTY_BYTE_ARRAY;
     try {
-      createTableWithDefaultConf(tableName, Optional.of(splitKeys));
+      createTableWithDefaultConf(tableName, splitKeys);
       fail("Test case should fail as empty split key is passed.");
     } catch (CompletionException e) {
       assertTrue(e.getCause() instanceof IllegalArgumentException);
@@ -390,7 +390,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     splitKeys[1] = HConstants.EMPTY_BYTE_ARRAY;
     splitKeys[2] = "region2".getBytes();
     try {
-      createTableWithDefaultConf(tableName, Optional.of(splitKeys));
+      createTableWithDefaultConf(tableName, splitKeys);
       fail("Test case should fail as empty split key is passed.");
     } catch (CompletionException e) {
       assertTrue(e.getCause() instanceof IllegalArgumentException);
@@ -423,7 +423,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     splitKeys[1] = Bytes.toBytes(8);
 
     // Create & Fill the table
-    createTableWithDefaultConf(tableName, Optional.of(splitKeys));
+    createTableWithDefaultConf(tableName, splitKeys);
     RawAsyncTable table = ASYNC_CONN.getRawTable(tableName);
     int expectedRows = 10;
     for (int i = 0; i < expectedRows; i++) {
@@ -517,7 +517,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     table1.get(get).get();
     table2.get(get).get();
 
-    admin.listTableNames(Optional.of(Pattern.compile(tableName.getNameAsString() + ".*")),
false)
+    admin.listTableNames(Pattern.compile(tableName.getNameAsString() + ".*"), false)
         .get().forEach(t -> admin.disableTable(t).join());
 
     // Test that tables are disabled
@@ -541,7 +541,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
     assertEquals(TableState.State.DISABLED, getStateFromMeta(tableName1));
     assertEquals(TableState.State.DISABLED, getStateFromMeta(tableName2));
 
-    admin.listTableNames(Optional.of(Pattern.compile(tableName.getNameAsString() + ".*")),
false)
+    admin.listTableNames(Pattern.compile(tableName.getNameAsString() + ".*"), false)
         .get().forEach(t -> admin.enableTable(t).join());
 
     // Test that tables are enabled
@@ -567,7 +567,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
             new byte[] { 4, 4, 4 }, new byte[] { 5, 5, 5 }, new byte[] { 6, 6, 6 },
             new byte[] { 7, 7, 7 }, new byte[] { 8, 8, 8 }, new byte[] { 9, 9, 9 } };
     int expectedRegions = splitKeys.length + 1;
-    createTableWithDefaultConf(tableName, Optional.of(splitKeys));
+    createTableWithDefaultConf(tableName, splitKeys);
 
     RawAsyncTable metaTable = ASYNC_CONN.getRawTable(META_TABLE_NAME);
     List<HRegionLocation> regions =

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
index 60b0260..d24711a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
@@ -1543,7 +1543,7 @@ public class TestMasterObserver {
       assertTrue("Found server", found);
       LOG.info("Found " + destName);
       master.getMasterRpcServices().moveRegion(null, RequestConverter.buildMoveRegionRequest(
-          firstGoodPair.getRegionInfo().getEncodedNameAsBytes(),Bytes.toBytes(destName)));
+          firstGoodPair.getRegionInfo().getEncodedNameAsBytes(), ServerName.valueOf(destName)));
       assertTrue("Coprocessor should have been called on region move",
         cp.wasMoveCalled());
 
@@ -1565,11 +1565,12 @@ public class TestMasterObserver {
       UTIL.waitUntilNoRegionsInTransition();
       List<RegionInfo> openRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
       int moveCnt = openRegions.size()/2;
-      for (int i=0; i<moveCnt; i++) {
+      for (int i = 0; i < moveCnt; i++) {
         RegionInfo info = openRegions.get(i);
         if (!info.isMetaRegion()) {
-          master.getMasterRpcServices().moveRegion(null, RequestConverter.buildMoveRegionRequest(
-              openRegions.get(i).getEncodedNameAsBytes(), destRS));
+          master.getMasterRpcServices().moveRegion(null,
+            RequestConverter.buildMoveRegionRequest(openRegions.get(i).getEncodedNameAsBytes(),
+              ServerName.valueOf(Bytes.toString(destRS))));
         }
       }
       //Make sure no regions are in transition now

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
index 53d9741..723b570 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
@@ -242,7 +242,7 @@ public class TestHRegionServerBulkLoad {
             AdminProtos.AdminService.BlockingInterface server =
               conn.getAdmin(getLocation().getServerName());
             CompactRegionRequest request = RequestConverter.buildCompactRegionRequest(
-                getLocation().getRegionInfo().getRegionName(), true, Optional.empty());
+                getLocation().getRegionInfo().getRegionName(), true, null);
             server.compactRegion(null, request);
             numCompactions.incrementAndGet();
             return null;

http://git-wip-us.apache.org/repos/asf/hbase/blob/47c614c7/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoadWithOldClient.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoadWithOldClient.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoadWithOldClient.java
index 7f486e4..da4b740 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoadWithOldClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoadWithOldClient.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.regionserver;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.logging.Log;
@@ -124,7 +123,7 @@ public class TestHRegionServerBulkLoadWithOldClient extends TestHRegionServerBul
               conn.getAdmin(getLocation().getServerName());
             CompactRegionRequest request =
               RequestConverter.buildCompactRegionRequest(
-                getLocation().getRegionInfo().getRegionName(), true, Optional.empty());
+                getLocation().getRegionInfo().getRegionName(), true, null);
             server.compactRegion(null, request);
             numCompactions.incrementAndGet();
             return null;


Mime
View raw message