http://git-wip-us.apache.org/repos/asf/phoenix/blob/260fe5ca/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsWriter.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsWriter.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsWriter.java index f2d4fb5..5a410ea 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsWriter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsWriter.java @@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType; import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MultiRowMutationService; import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest; -import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; @@ -100,7 +100,7 @@ public class StatisticsWriter implements Closeable { statsWriterTable.close(); } - public void splitStats(HRegion p, HRegion l, HRegion r, StatisticsCollector tracker, ImmutableBytesPtr cfKey, + public void splitStats(Region p, Region l, Region r, StatisticsCollector tracker, ImmutableBytesPtr cfKey, List<Mutation> mutations) throws IOException { if (tracker == null) { return; } boolean useMaxTimeStamp = clientTimeStamp == StatisticsCollector.NO_TIMESTAMP; @@ -108,8 +108,8 @@ public class StatisticsWriter implements Closeable { mutations.add(getLastStatsUpdatedTimePut(clientTimeStamp)); } long readTimeStamp = useMaxTimeStamp ? HConstants.LATEST_TIMESTAMP : clientTimeStamp; - Result result = StatisticsUtil.readRegionStatistics(statsReaderTable, tableName, cfKey, p.getRegionName(), - readTimeStamp); + Result result = StatisticsUtil.readRegionStatistics(statsReaderTable, tableName, cfKey, + p.getRegionInfo().getRegionName(), readTimeStamp); if (result != null && !result.isEmpty()) { Cell cell = result.getColumnLatestCell(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, PhoenixDatabaseMetaData.GUIDE_POSTS_BYTES); Cell rowCountCell = result.getColumnLatestCell(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, PhoenixDatabaseMetaData.GUIDE_POSTS_ROW_COUNT_BYTES); @@ -119,13 +119,13 @@ public class StatisticsWriter implements Closeable { GuidePostsInfo guidePostsRegionInfo = GuidePostsInfo.deserializeGuidePostsInfo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength(), rowCount); - byte[] pPrefix = StatisticsUtil.getRowKey(tableName, cfKey, p.getRegionName()); + byte[] pPrefix = StatisticsUtil.getRowKey(tableName, cfKey, p.getRegionInfo().getRegionName()); mutations.add(new Delete(pPrefix, writeTimeStamp)); long byteSize = 0; Cell byteSizeCell = result.getColumnLatestCell(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, PhoenixDatabaseMetaData.GUIDE_POSTS_WIDTH_BYTES); - int index = Collections.binarySearch(guidePostsRegionInfo.getGuidePosts(), r.getStartKey(), + int index = Collections.binarySearch(guidePostsRegionInfo.getGuidePosts(), r.getRegionInfo().getStartKey(), Bytes.BYTES_COMPARATOR); int size = guidePostsRegionInfo.getGuidePosts().size(); int midEndIndex, midStartIndex; @@ -159,7 +159,7 @@ public class StatisticsWriter implements Closeable { .getGuidePosts().subList(0, midEndIndex), leftRowCount); tracker.clear(); tracker.addGuidePost(cfKey, lguidePosts, leftByteCount, cell.getTimestamp()); - addStats(l.getRegionName(), tracker, cfKey, mutations); + addStats(l.getRegionInfo().getRegionName(), tracker, cfKey, mutations); } if (midStartIndex < size) { GuidePostsInfo rguidePosts = new GuidePostsInfo(rightByteCount, guidePostsRegionInfo @@ -167,7 +167,7 @@ public class StatisticsWriter implements Closeable { rightRowCount); tracker.clear(); tracker.addGuidePost(cfKey, rguidePosts, rightByteCount, cell.getTimestamp()); - addStats(r.getRegionName(), tracker, cfKey, mutations); + addStats(r.getRegionInfo().getRegionName(), tracker, cfKey, mutations); } } }
http://git-wip-us.apache.org/repos/asf/phoenix/blob/260fe5ca/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java index ca25348..3bf6f23 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java @@ -40,7 +40,7 @@ import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.WritableUtils; @@ -305,47 +305,49 @@ public class IndexUtil { }); } - public static HRegion getIndexRegion(RegionCoprocessorEnvironment environment) + public static Region getIndexRegion(RegionCoprocessorEnvironment environment) throws IOException { - HRegion dataRegion = environment.getRegion(); + Region dataRegion = environment.getRegion(); return getIndexRegion(dataRegion, environment.getRegionServerServices()); } - public static HRegion - getIndexRegion(HRegion dataRegion, RegionServerCoprocessorEnvironment env) + public static Region + getIndexRegion(Region dataRegion, RegionServerCoprocessorEnvironment env) throws IOException { return getIndexRegion(dataRegion, env.getRegionServerServices()); } - public static HRegion getDataRegion(RegionCoprocessorEnvironment env) throws IOException { - HRegion indexRegion = env.getRegion(); + public static Region getDataRegion(RegionCoprocessorEnvironment env) throws IOException { + Region indexRegion = env.getRegion(); return getDataRegion(indexRegion, env.getRegionServerServices()); } - public static HRegion - getDataRegion(HRegion indexRegion, RegionServerCoprocessorEnvironment env) + public static Region + getDataRegion(Region indexRegion, RegionServerCoprocessorEnvironment env) throws IOException { return getDataRegion(indexRegion, env.getRegionServerServices()); } - public static HRegion getIndexRegion(HRegion dataRegion, RegionServerServices rss) throws IOException { + public static Region getIndexRegion(Region dataRegion, RegionServerServices rss) throws IOException { TableName indexTableName = TableName.valueOf(MetaDataUtil.getLocalIndexPhysicalName(dataRegion.getTableDesc() .getName())); - List<HRegion> onlineRegions = rss.getOnlineRegions(indexTableName); - for(HRegion indexRegion : onlineRegions) { - if (Bytes.compareTo(dataRegion.getStartKey(), indexRegion.getStartKey()) == 0) { + List<Region> onlineRegions = rss.getOnlineRegions(indexTableName); + for(Region indexRegion : onlineRegions) { + if (Bytes.compareTo(dataRegion.getRegionInfo().getStartKey(), + indexRegion.getRegionInfo().getStartKey()) == 0) { return indexRegion; } } return null; } - public static HRegion getDataRegion(HRegion indexRegion, RegionServerServices rss) throws IOException { + public static Region getDataRegion(Region indexRegion, RegionServerServices rss) throws IOException { TableName dataTableName = TableName.valueOf(MetaDataUtil.getUserTableName(indexRegion.getTableDesc().getNameAsString())); - List<HRegion> onlineRegions = rss.getOnlineRegions(dataTableName); - for(HRegion region : onlineRegions) { - if (Bytes.compareTo(indexRegion.getStartKey(), region.getStartKey()) == 0) { + List<Region> onlineRegions = rss.getOnlineRegions(dataTableName); + for(Region region : onlineRegions) { + if (Bytes.compareTo(indexRegion.getRegionInfo().getStartKey(), + region.getRegionInfo().getStartKey()) == 0) { return region; } } @@ -466,7 +468,7 @@ public class IndexUtil { public static void wrapResultUsingOffset(final ObserverContext<RegionCoprocessorEnvironment> c, List<Cell> result, final int offset, ColumnReference[] dataColumns, - TupleProjector tupleProjector, HRegion dataRegion, IndexMaintainer indexMaintainer, + TupleProjector tupleProjector, Region dataRegion, IndexMaintainer indexMaintainer, byte[][] viewConstants, ImmutableBytesWritable ptr) throws IOException { if (tupleProjector != null) { // Join back to data table here by issuing a local get projecting http://git-wip-us.apache.org/repos/asf/phoenix/blob/260fe5ca/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/TestLocalTableState.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/TestLocalTableState.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/TestLocalTableState.java index e996b23..fa8bd85 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/TestLocalTableState.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/TestLocalTableState.java @@ -29,7 +29,7 @@ import org.apache.hadoop.hbase.KeyValue.Type; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; -import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.regionserver.RegionScanner; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; @@ -65,7 +65,7 @@ public class TestLocalTableState { RegionCoprocessorEnvironment env = Mockito.mock(RegionCoprocessorEnvironment.class); Mockito.when(env.getConfiguration()).thenReturn(conf); - HRegion region = Mockito.mock(HRegion.class); + Region region = Mockito.mock(Region.class); Mockito.when(env.getRegion()).thenReturn(region); RegionScanner scanner = Mockito.mock(RegionScanner.class); Mockito.when(region.getScanner(Mockito.any(Scan.class))).thenReturn(scanner); @@ -108,7 +108,7 @@ public class TestLocalTableState { // setup mocks RegionCoprocessorEnvironment env = Mockito.mock(RegionCoprocessorEnvironment.class); - HRegion region = Mockito.mock(HRegion.class); + Region region = Mockito.mock(Region.class); Mockito.when(env.getRegion()).thenReturn(region); RegionScanner scanner = Mockito.mock(RegionScanner.class); Mockito.when(region.getScanner(Mockito.any(Scan.class))).thenReturn(scanner); @@ -154,7 +154,7 @@ public class TestLocalTableState { // setup mocks RegionCoprocessorEnvironment env = Mockito.mock(RegionCoprocessorEnvironment.class); - HRegion region = Mockito.mock(HRegion.class); + Region region = Mockito.mock(Region.class); Mockito.when(env.getRegion()).thenReturn(region); RegionScanner scanner = Mockito.mock(RegionScanner.class); Mockito.when(region.getScanner(Mockito.any(Scan.class))).thenReturn(scanner); http://git-wip-us.apache.org/repos/asf/phoenix/blob/260fe5ca/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java index ae577bd..b381e9f 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java @@ -50,8 +50,8 @@ import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; -import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; import org.apache.hadoop.hbase.util.Bytes; @@ -201,7 +201,7 @@ public class TestWALRecoveryCaching { // kill the server where the tables live - this should trigger distributed log splitting // find the regionserver that matches the passed server - List<HRegion> online = new ArrayList<HRegion>(); + List<Region> online = new ArrayList<Region>(); online.addAll(getRegionsFromServerForTable(util.getMiniHBaseCluster(), shared, testTable.getTableName())); online.addAll(getRegionsFromServerForTable(util.getMiniHBaseCluster(), shared, @@ -267,9 +267,9 @@ public class TestWALRecoveryCaching { * @param table * @return */ - private List<HRegion> getRegionsFromServerForTable(MiniHBaseCluster cluster, ServerName server, + private List<Region> getRegionsFromServerForTable(MiniHBaseCluster cluster, ServerName server, byte[] table) { - List<HRegion> online = Collections.emptyList(); + List<Region> online = Collections.emptyList(); for (RegionServerThread rst : cluster.getRegionServerThreads()) { // if its the server we are going to kill, get the regions we want to reassign if (rst.getRegionServer().getServerName().equals(server)) { @@ -305,14 +305,14 @@ public class TestWALRecoveryCaching { tryIndex = !tryIndex; for (ServerName server : servers) { // find the regionserver that matches the passed server - List<HRegion> online = getRegionsFromServerForTable(cluster, server, table); + List<Region> online = getRegionsFromServerForTable(cluster, server, table); LOG.info("Shutting down and reassigning regions from " + server); cluster.stopRegionServer(server); cluster.waitForRegionServerToStop(server, TIMEOUT); // force reassign the regions from the table - for (HRegion region : online) { + for (Region region : online) { cluster.getMaster().assignRegion(region.getRegionInfo()); } @@ -363,10 +363,9 @@ public class TestWALRecoveryCaching { private Set<ServerName> getServersForTable(MiniHBaseCluster cluster, byte[] table) throws Exception { - List<HRegion> indexRegions = cluster.getRegions(table); Set<ServerName> indexServers = new HashSet<ServerName>(); - for (HRegion region : indexRegions) { - indexServers.add(cluster.getServerHoldingRegion(null, region.getRegionName())); + for (Region region : cluster.getRegions(table)) { + indexServers.add(cluster.getServerHoldingRegion(null, region.getRegionInfo().getRegionName())); } return indexServers; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/260fe5ca/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java index f42dbd7..c928d49 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/recovery/TestPerRegionIndexWriteCache.java @@ -64,8 +64,8 @@ public class TestPerRegionIndexWriteCache { p2.add(family, qual, val); } - HRegion r1; - HRegion r2; + HRegion r1; // FIXME: Uses private type + HRegion r2; // FIXME: Uses private type @SuppressWarnings("deprecation") @Before
