hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hbase git commit: HBASE-12991 Use HBase 1.0 interfaces in hbase-rest (Solomon Duskis)
Date Thu, 12 Feb 2015 00:45:26 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.0 6cc29ce04 -> cda791de1


HBASE-12991 Use HBase 1.0 interfaces in hbase-rest (Solomon Duskis)

Conflicts:
	hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
	hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java

Conflicts:
	hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java


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

Branch: refs/heads/branch-1.0
Commit: cda791de174012c608f813e99c71855489c123b6
Parents: 6cc29ce
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Feb 11 16:31:27 2015 -0800
Committer: Enis Soztutar <enis@apache.org>
Committed: Wed Feb 11 16:45:15 2015 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/rest/RESTServlet.java   |  4 +-
 .../hadoop/hbase/rest/SchemaResource.java       | 27 +++++-----
 .../apache/hadoop/hbase/rest/TableResource.java |  3 +-
 .../hadoop/hbase/rest/client/RemoteHTable.java  | 56 +++++++-------------
 .../hadoop/hbase/rest/RowResourceBase.java      |  1 -
 .../hadoop/hbase/rest/TestGzipFilter.java       |  3 +-
 .../hbase/rest/TestScannersWithFilters.java     |  3 +-
 .../hadoop/hbase/rest/TestStatusResource.java   |  1 +
 .../hadoop/hbase/rest/TestTableResource.java    | 54 ++++++++++++-------
 9 files changed, 74 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
index ff42271..6f74894 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServlet.java
@@ -22,7 +22,7 @@ import java.io.IOException;
 
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.filter.ParseFilter;
 import org.apache.hadoop.hbase.security.UserProvider;
@@ -98,7 +98,7 @@ public class RESTServlet implements Constants {
     }
   }
 
-  HBaseAdmin getAdmin() throws IOException {
+  Admin getAdmin() throws IOException {
     return connectionCache.getAdmin();
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
index 45dd9ee..9826b67 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
@@ -37,18 +37,17 @@ import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.TableNotEnabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.rest.model.ColumnSchemaModel;
 import org.apache.hadoop.hbase.rest.model.TableSchemaModel;
-import org.apache.hadoop.hbase.util.Bytes;
 
 @InterfaceAudience.Private
 public class SchemaResource extends ResourceBase {
@@ -103,15 +102,15 @@ public class SchemaResource extends ResourceBase {
     } 
   }
 
-  private Response replace(final byte[] name, final TableSchemaModel model,
-      final UriInfo uriInfo, final HBaseAdmin admin) {
+  private Response replace(final TableName name, final TableSchemaModel model,
+      final UriInfo uriInfo, final Admin admin) {
     if (servlet.isReadOnly()) {
       return Response.status(Response.Status.FORBIDDEN)
         .type(MIMETYPE_TEXT).entity("Forbidden" + CRLF)
         .build();
     }
     try {
-      HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name));
+      HTableDescriptor htd = new HTableDescriptor(name);
       for (Map.Entry<QName,Object> e: model.getAny().entrySet()) {
         htd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
       }
@@ -143,8 +142,8 @@ public class SchemaResource extends ResourceBase {
     }
   }
 
-  private Response update(final byte[] name, final TableSchemaModel model,
-      final UriInfo uriInfo, final HBaseAdmin admin) {
+  private Response update(final TableName name, final TableSchemaModel model,
+      final UriInfo uriInfo, final Admin admin) {
     if (servlet.isReadOnly()) {
       return Response.status(Response.Status.FORBIDDEN)
         .type(MIMETYPE_TEXT).entity("Forbidden" + CRLF)
@@ -170,7 +169,7 @@ public class SchemaResource extends ResourceBase {
           .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
           .build();
       } finally {
-        admin.enableTable(tableResource.getName());
+        admin.enableTable(TableName.valueOf(tableResource.getName()));
       }
       servlet.getMetrics().incrementSucessfulPutRequests(1);
       return Response.ok().build();
@@ -183,8 +182,8 @@ public class SchemaResource extends ResourceBase {
   private Response update(final TableSchemaModel model, final boolean replace,
       final UriInfo uriInfo) {
     try {
-      byte[] name = Bytes.toBytes(tableResource.getName());
-      HBaseAdmin admin = servlet.getAdmin();
+      TableName name = TableName.valueOf(tableResource.getName());
+      Admin admin = servlet.getAdmin();
       if (replace || !admin.tableExists(name)) {
         return replace(name, model, uriInfo, admin);
       } else {
@@ -233,11 +232,11 @@ public class SchemaResource extends ResourceBase {
           .entity("Forbidden" + CRLF).build();
     }
     try {
-      HBaseAdmin admin = servlet.getAdmin();
+      Admin admin = servlet.getAdmin();
       try {
-        admin.disableTable(tableResource.getName());
+        admin.disableTable(TableName.valueOf(tableResource.getName()));
       } catch (TableNotEnabledException e) { /* this is what we want anyway */ }
-      admin.deleteTable(tableResource.getName());
+      admin.deleteTable(TableName.valueOf(tableResource.getName()));
       servlet.getMetrics().incrementSucessfulDeleteRequests(1);
       return Response.ok().build();
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
index caf1431..556425f 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
@@ -34,6 +34,7 @@ import javax.ws.rs.core.UriInfo;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
@@ -69,7 +70,7 @@ public class TableResource extends ResourceBase {
    * @throws IOException
    */
   boolean exists() throws IOException {
-    return servlet.getAdmin().tableExists(table);
+    return servlet.getAdmin().tableExists(TableName.valueOf(table));
   }
 
   @Path("exists")

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
index 65bf509..eb5f506 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
@@ -19,14 +19,18 @@
 
 package org.apache.hadoop.hbase.rest.client;
 
-import com.google.protobuf.Descriptors;
-import com.google.protobuf.Message;
-import com.google.protobuf.Service;
-import com.google.protobuf.ServiceException;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellUtil;
@@ -35,11 +39,12 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.hbase.client.Append;
 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.Increment;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
@@ -47,6 +52,7 @@ import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Row;
 import org.apache.hadoop.hbase.client.RowMutations;
 import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.client.coprocessor.Batch;
 import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback;
 import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
@@ -61,22 +67,17 @@ import org.apache.hadoop.hbase.rest.model.TableSchemaModel;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.util.StringUtils;
 
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
+import com.google.protobuf.Descriptors;
+import com.google.protobuf.Message;
+import com.google.protobuf.Service;
+import com.google.protobuf.ServiceException;
 
 /**
  * HTable interface to remote tables accessed via REST gateway
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class RemoteHTable implements HTableInterface {
+public class RemoteHTable implements Table {
 
   private static final Log LOG = LogFactory.getLog(RemoteHTable.class);
 
@@ -806,21 +807,6 @@ public class RemoteHTable implements HTableInterface {
   }
 
   @Override
-  public void setAutoFlush(boolean autoFlush) {
-    throw new UnsupportedOperationException("setAutoFlush not implemented");
-  }
-
-  @Override
-  public void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail) {
-    throw new UnsupportedOperationException("setAutoFlush not implemented");
-  }
-
-  @Override
-  public void setAutoFlushTo(boolean autoFlush) {
-    throw new UnsupportedOperationException("setAutoFlushTo not implemented");
-  }
-
-  @Override
   public long getWriteBufferSize() {
     throw new UnsupportedOperationException("getWriteBufferSize not implemented");
   }
@@ -831,12 +817,6 @@ public class RemoteHTable implements HTableInterface {
   }
 
   @Override
-  public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier,
-      long amount, boolean writeToWAL) throws IOException {
-    throw new IOException("incrementColumnValue not supported");
-  }
-
-  @Override
   public <R extends Message> Map<byte[], R> batchCoprocessorService(
       Descriptors.MethodDescriptor method, Message request,
       byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable
{

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java
index 876b089..0e74b46 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java
@@ -35,7 +35,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.rest.client.Client;
 import org.apache.hadoop.hbase.rest.client.Cluster;
 import org.apache.hadoop.hbase.rest.client.Response;

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java
index 5eca15a..c984b69 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.rest.client.Client;
@@ -101,7 +100,7 @@ public class TestGzipFilter {
     Response response = client.put(path, headers, value_1_gzip);
     assertEquals(response.getCode(), 200);
 
-    Table table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
+    Table table = TEST_UTIL.getConnection().getTable(TABLE);
     Get get = new Get(Bytes.toBytes(ROW_1));
     get.addColumn(Bytes.toBytes(CFA), Bytes.toBytes("1"));
     Result result = table.get(get);

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java
index a7498b8..a06d650 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java
@@ -35,7 +35,6 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Durability;
@@ -136,7 +135,7 @@ public class TestScannersWithFilters {
       htd.addFamily(new HColumnDescriptor(FAMILIES[0]));
       htd.addFamily(new HColumnDescriptor(FAMILIES[1]));
       admin.createTable(htd);
-      Table table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
+      Table table = TEST_UTIL.getConnection().getTable(TABLE);
       // Insert first half
       for(byte [] ROW : ROWS_ONE) {
         Put p = new Put(ROW);

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
index b332b1d..58a9139 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
@@ -28,6 +28,7 @@ import javax.xml.bind.JAXBException;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.rest.client.Client;
 import org.apache.hadoop.hbase.rest.client.Cluster;
 import org.apache.hadoop.hbase.rest.client.Response;

http://git-wip-us.apache.org/repos/asf/hbase/blob/cda791de/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
index 81612ce..a7de2f1 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
@@ -19,35 +19,45 @@
 
 package org.apache.hadoop.hbase.rest;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.rest.client.Client;
 import org.apache.hadoop.hbase.rest.client.Cluster;
 import org.apache.hadoop.hbase.rest.client.Response;
-import org.apache.hadoop.hbase.rest.model.TableModel;
 import org.apache.hadoop.hbase.rest.model.TableInfoModel;
 import org.apache.hadoop.hbase.rest.model.TableListModel;
+import org.apache.hadoop.hbase.rest.model.TableModel;
 import org.apache.hadoop.hbase.rest.model.TableRegionModel;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.util.StringUtils;
-
-import static org.junit.Assert.*;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -60,7 +70,7 @@ public class TestTableResource {
   private static TableName TABLE = TableName.valueOf("TestTableResource");
   private static String COLUMN_FAMILY = "test";
   private static String COLUMN = COLUMN_FAMILY + ":qualifier";
-  private static Map<HRegionInfo, ServerName> regionMap;
+  private static List<HRegionLocation> regionMap;
 
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
   private static final HBaseRESTTestingUtility REST_TEST_UTIL =
@@ -86,9 +96,9 @@ public class TestTableResource {
     HTableDescriptor htd = new HTableDescriptor(TABLE);
     htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
     admin.createTable(htd);
-    HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
     byte[] k = new byte[3];
     byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
+    List<Put> puts = new ArrayList<>();
     for (byte b1 = 'a'; b1 < 'z'; b1++) {
       for (byte b2 = 'a'; b2 < 'z'; b2++) {
         for (byte b3 = 'a'; b3 < 'z'; b3++) {
@@ -98,13 +108,19 @@ public class TestTableResource {
           Put put = new Put(k);
           put.setDurability(Durability.SKIP_WAL);
           put.add(famAndQf[0], famAndQf[1], k);
-          table.put(put);
+          puts.add(put);
         }
       }
     }
-    table.flushCommits();
+    Connection connection = TEST_UTIL.getConnection();
+    
+    Table table =  connection.getTable(TABLE);
+    table.put(puts);
+    table.close();
     // get the initial layout (should just be one region)
-    Map<HRegionInfo, ServerName> m = table.getRegionLocations();
+    
+    RegionLocator regionLocator = connection.getRegionLocator(TABLE);
+    List<HRegionLocation> m = regionLocator.getAllRegionLocations();
     assertEquals(m.size(), 1);
     // tell the master to split the table
     admin.split(TABLE);
@@ -118,14 +134,14 @@ public class TestTableResource {
         LOG.warn(StringUtils.stringifyException(e));
       }
       // check again
-      m = table.getRegionLocations();
+      m = regionLocator.getAllRegionLocations();
     }
 
     // should have two regions now
     assertEquals(m.size(), 2);
     regionMap = m;
     LOG.info("regions: " + regionMap);
-    table.close();
+    regionLocator.close();
   }
 
   @AfterClass
@@ -155,15 +171,17 @@ public class TestTableResource {
     while (regions.hasNext()) {
       TableRegionModel region = regions.next();
       boolean found = false;
-      for (Map.Entry<HRegionInfo, ServerName> e: regionMap.entrySet()) {
-        HRegionInfo hri = e.getKey();
+      for (HRegionLocation e: regionMap) {
+        HRegionInfo hri = e.getRegionInfo();
         String hriRegionName = hri.getRegionNameAsString();
         String regionName = region.getName();
         if (hriRegionName.equals(regionName)) {
           found = true;
           byte[] startKey = hri.getStartKey();
           byte[] endKey = hri.getEndKey();
-          InetSocketAddress sa = new InetSocketAddress(e.getValue().getHostname(), e.getValue().getPort());
+          ServerName serverName = e.getServerName();
+          InetSocketAddress sa =
+              new InetSocketAddress(serverName.getHostname(), serverName.getPort());
           String location = sa.getHostName() + ":" +
             Integer.valueOf(sa.getPort());
           assertEquals(hri.getRegionId(), region.getId());


Mime
View raw message