Java Code Examples for org.apache.hadoop.hbase.client.HTable#getRegionLocations()
The following examples show how to use
org.apache.hadoop.hbase.client.HTable#getRegionLocations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BalanceRuleTest.java From hbase-tools with Apache License 2.0 | 6 votes |
private void validateST2(HTable table1) throws IOException { NavigableMap<HRegionInfo, ServerName> regionLocations; List<Map.Entry<HRegionInfo, ServerName>> hRegionInfoList; regionLocations = table1.getRegionLocations(); hRegionInfoList = new ArrayList<>(regionLocations.entrySet()); Map<ServerName, Integer> serverCountMap = new HashMap<>(); for (Map.Entry<HRegionInfo, ServerName> entry : hRegionInfoList) { if (serverCountMap.get(entry.getValue()) == null) { serverCountMap.put(entry.getValue(), 1); } else { serverCountMap.put(entry.getValue(), serverCountMap.get(entry.getValue()) + 1); } } Assert.assertEquals(Math.min(getServerNameList().size(), regionLocations.size()), serverCountMap.size()); int regionCount; regionCount = 0; for (ServerName serverName : getServerNameList()) { List<HRegionInfo> regionInfoList = getRegionInfoList(serverName, Bytes.toString(table1.getTableName())); Assert.assertNotEquals(4, regionInfoList.size()); Assert.assertEquals(2, regionInfoList.size()); regionCount += regionInfoList.size(); } Assert.assertEquals(4, regionCount); }
Example 2
Source File: BalanceRuleTest.java From hbase-tools with Apache License 2.0 | 6 votes |
private void validateST2(HTable table1) throws IOException { NavigableMap<HRegionInfo, ServerName> regionLocations; List<Map.Entry<HRegionInfo, ServerName>> hRegionInfoList; regionLocations = table1.getRegionLocations(); hRegionInfoList = new ArrayList<>(regionLocations.entrySet()); Map<ServerName, Integer> serverCountMap = new HashMap<>(); for (Map.Entry<HRegionInfo, ServerName> entry : hRegionInfoList) { if (serverCountMap.get(entry.getValue()) == null) { serverCountMap.put(entry.getValue(), 1); } else { serverCountMap.put(entry.getValue(), serverCountMap.get(entry.getValue()) + 1); } } Assert.assertEquals(Math.min(getServerNameList().size(), regionLocations.size()), serverCountMap.size()); int regionCount; regionCount = 0; for (ServerName serverName : getServerNameList()) { List<HRegionInfo> regionInfoList = getRegionInfoList(serverName, Bytes.toString(table1.getTableName())); Assert.assertNotEquals(4, regionInfoList.size()); Assert.assertEquals(2, regionInfoList.size()); regionCount += regionInfoList.size(); } Assert.assertEquals(4, regionCount); }