热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.hadoop.hbase.client.HTable.getRegionLocations()方法的使用及代码示例

本文整理了Java中org.apache.hadoop.hbase.client.HTable.getRegionLocations()方法的一些代码示例,展示了

本文整理了Java中org.apache.hadoop.hbase.client.HTable.getRegionLocations()方法的一些代码示例,展示了HTable.getRegionLocations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTable.getRegionLocations()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.HTable
类名称:HTable
方法名:getRegionLocations

HTable.getRegionLocations介绍

[英]Gets all the regions and their address for this table.

This is mainly useful for the MapReduce integration.
[中]获取此表的所有区域及其地址。
这对于MapReduce集成非常有用。

代码示例

代码示例来源:origin: thinkaurelius/titan

@Override
public List getLocalKeyPartition() throws BackendException {
List result = new LinkedList();
HTable table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = new HTable(hconf, tableName);
Map normed =
normalizeKeyBounds(table.getRegionLocations());
for (Map.Entry e : normed.entrySet()) {
if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
result.add(e.getKey());
logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
} else {
logger.debug("Discarding remote {}", e.getValue());
}
}
} catch (MasterNotRunningException e) {
logger.warn("Unexpected MasterNotRunningException", e);
} catch (ZooKeeperConnectionException e) {
logger.warn("Unexpected ZooKeeperConnectionException", e);
} catch (IOException e) {
logger.warn("Unexpected IOException", e);
} finally {
IOUtils.closeQuietly(table);
}
return result;
}

代码示例来源:origin: KylinOLAP/Kylin

Set tableRegiOnInfos= table.getRegionLocations().keySet();
Set tableRegiOns= new TreeSet(Bytes.BYTES_COMPARATOR);

代码示例来源:origin: forcedotcom/phoenix

HTable htable = (HTable)conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(tableName);
htable.clearRegionCache();
int nRegiOns= htable.getRegionLocations().size();
admin.split(tableName, ByteUtil.concat(Bytes.toBytes(tenantId), Bytes.toBytes("00A" + Character.valueOf((char)('3' + nextRunCount()))+ ts))); // vary split point with test run
int retryCount = 0;
retryCount++;
} while (retryCount <10 && htable.getRegionLocations().size() == nRegions);
assertNotEquals(nRegions,htable.getRegionLocations().size());

代码示例来源:origin: kakao/hbase-tools

private void split(HTable table, byte[] splitPoint) throws IOException, InterruptedException, DecoderException {
int regiOnCountPrev= table.getRegionLocations().size();
admin.split(table.getTableName(), splitPoint);
for (int j = 0; j int regiOnCountNow= table.getRegionLocations().size();
if (regionCountPrev break;
} else {
Thread.sleep(Constant.WAIT_INTERVAL_MS);
}
}
}

代码示例来源:origin: org.cloudgraph/cloudgraph-hbase

/**
* Sets the number of reduce tasks for the given job configuration to the
* number of regions the given table has.
*
* @param table
* The table to get the region count for.
* @param job
* The current job to adjust.
* @throws IOException
* When retrieving the table details fails.
*/
public static void setNumReduceTasks(String table, Job job) throws IOException {
HTable outputTable = new HTable(job.getConfiguration(), table);
int regiOns= outputTable.getRegionLocations().size();
job.setNumReduceTasks(regions);
}

代码示例来源:origin: kakao/hbase-tools

private static void getRegionLocations(HBaseAdmin admin, String tableName) throws IOException {
try (HTable table = new HTable(admin.getConfiguration(), tableName)) {
regionLocations.putAll(table.getRegionLocations());
cachedTableNames.add(tableName);
}
}

代码示例来源:origin: OpenSOC/opensoc-streaming

private void refreshRegionInfo(String tableName) throws IOException {
System.out.println("in refreshRegionInfo ");
Map regiOnMap= hTable.getRegionLocations();
synchronized (regionStartKeys) {
synchronized (regionStartKeyRegionNameMap) {
regiOnStartKeys= new String[regionMap.size()];
int index = 0;
String startKey = null;
regionStartKeyRegionNameMap.clear();
for (HRegionInfo regionInfo : regionMap.keySet()) {
startKey = new String(regionInfo.getStartKey());
regionStartKeyRegionNameMap.put(startKey, regionInfo.getRegionNameAsString());
regionStartKeys[index] = startKey;
index++;
}
Arrays.sort(regionStartKeys);
regiOnCheckTime= System.currentTimeMillis();
}
}
}
}

代码示例来源:origin: org.cloudgraph/cloudgraph-hbase

/**
* Ensures that the given number of reduce tasks for the given job
* configuration does not exceed the number of regions for the given table.
*
* @param table
* The table to get the region count for.
* @param job
* The current job to adjust.
* @throws IOException
* When retrieving the table details fails.
*/
public static void limitNumReduceTasks(String table, Job job) throws IOException {
HTable outputTable = new HTable(job.getConfiguration(), table);
int regiOns= outputTable.getRegionLocations().size();
if (job.getNumReduceTasks() > regions)
job.setNumReduceTasks(regions);
}

代码示例来源:origin: kakao/hbase-tools

private NavigableMap getRegionLocations(String tableName, HBaseAdmin admin)
throws IOException {
try (HTable table = new HTable(admin.getConfiguration(), tableName)) {
return table.getRegionLocations();
}
}
};

代码示例来源:origin: co.cask.hbase/hbase

/**
* Gets the starting and ending row keys for every region in the currently
* open table.
*


* This is mainly useful for the MapReduce integration.
* @return Pair of arrays of region starting and ending row keys
* @throws IOException if a remote or network exception occurs
*/
public Pair getStartEndKeys() throws IOException {
NavigableMap regiOns= getRegionLocations();
final List startKeyList = new ArrayList(regions.size());
final List endKeyList = new ArrayList(regions.size());
for (HRegionInfo region : regions.keySet()) {
startKeyList.add(region.getStartKey());
endKeyList.add(region.getEndKey());
}
return new Pair(
startKeyList.toArray(new byte[startKeyList.size()][]),
endKeyList.toArray(new byte[endKeyList.size()][]));
}

代码示例来源:origin: com.moz.fiji.schema/fiji-schema

/**
* Get the Cassandra Fiji Partitions for the given cluster.
*
* @param htable An open connection to the HBase table.
* @return The collection of Fiji partitions.
* @throws IOException if a remote or network exception occurs.
*/
public static Collection getPartitions(
final HTable htable
) throws IOException {
final ImmutableList.Builder partitiOns= ImmutableList.builder();
NavigableMap regiOnLocations= htable.getRegionLocations();
for (Map.Entry regionLocation : regionLocations.entrySet()) {
partitions.add(
new HBaseFijiPartition(
InetAddress.getByName(regionLocation.getValue().getHostname()),
regionLocation.getKey().getStartKey(),
regionLocation.getKey().getEndKey()));
}
return partitions.build();
}
}

代码示例来源:origin: co.cask.hbase/hbase

/**
* Gets all the regions and their address for this table.
* @return A map of HRegionInfo with it's server address
* @throws IOException if a remote or network exception occurs
* @deprecated Use {@link #getRegionLocations()} or {@link #getStartEndKeys()}
*/
public Map getRegionsInfo() throws IOException {
final Map regiOnMap=
new TreeMap();
final Map regiOnLocations= getRegionLocations();
for (Map.Entry entry : regionLocations.entrySet()) {
HServerAddress server = new HServerAddress();
ServerName serverName = entry.getValue();
if (serverName != null && serverName.getHostAndPort() != null) {
server = new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(
serverName.getHostAndPort()));
}
regionMap.put(entry.getKey(), server);
}
return regionMap;
}

代码示例来源:origin: kakao/hbase-tools

private NavigableMap getRegionLocations(String table) throws IOException {
long startTimestamp = System.currentTimeMillis();
Util.printVerboseMessage(args, Util.getMethodName() + " - start");
NavigableMap result = regionLocations.get(table);
if (result == null) {
try (HTable htable = new HTable(admin.getConfiguration(), table)) {
result = htable.getRegionLocations();
regionLocations.put(table, result);
}
}
Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
return result;
}

代码示例来源:origin: kakao/hbase-tools

public static boolean isMoved(HBaseAdmin admin, String tableName, String regionName, String serverNameTarget) {
try (HTable table = new HTable(admin.getConfiguration(), tableName)) {
NavigableMap regiOnLocations= table.getRegionLocations();
for (Map.Entry regionLocation : regionLocations.entrySet()) {
if (regionLocation.getKey().getEncodedName().equals(regionName)) {
return regionLocation.getValue().getServerName().equals(serverNameTarget);
}
}
if (!existsRegion(regionName, regionLocations.keySet()))
return true; // skip moving
} catch (IOException e) {
return false;
}
return false;
}

代码示例来源:origin: apache/incubator-atlas

@Override
public List getLocalKeyPartition() throws BackendException {
List result = new LinkedList<>();
TableMask table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = cnx.getTable(tableName);
HTable hTable = (HTable)table.getTableObject();
Map normed =
normalizeKeyBounds(hTable.getRegionLocations());
for (Map.Entry e : normed.entrySet()) {
if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
result.add(e.getKey());
logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
} else {
logger.debug("Discarding remote {}", e.getValue());
}
}
} catch (MasterNotRunningException e) {
logger.warn("Unexpected MasterNotRunningException", e);
} catch (ZooKeeperConnectionException e) {
logger.warn("Unexpected ZooKeeperConnectionException", e);
} catch (IOException e) {
logger.warn("Unexpected IOException", e);
} finally {
IOUtils.closeQuietly(table);
}
return result;
}

代码示例来源:origin: org.apache.atlas/atlas-titan

@Override
public List getLocalKeyPartition() throws BackendException {
List result = new LinkedList();
TableMask table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = cnx.getTable(tableName);
HTable hTable = (HTable)table.getTableObject();
Map normed =
normalizeKeyBounds(hTable.getRegionLocations());
for (Map.Entry e : normed.entrySet()) {
if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
result.add(e.getKey());
logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
} else {
logger.debug("Discarding remote {}", e.getValue());
}
}
} catch (MasterNotRunningException e) {
logger.warn("Unexpected MasterNotRunningException", e);
} catch (ZooKeeperConnectionException e) {
logger.warn("Unexpected ZooKeeperConnectionException", e);
} catch (IOException e) {
logger.warn("Unexpected IOException", e);
} finally {
IOUtils.closeQuietly(table);
}
return result;
}

代码示例来源:origin: kakao/hbase-tools

protected ArrayList getRegionInfoList(String tableName) throws IOException {
Set hRegiOnInfoSet= new TreeSet<>();
try (HTable table = (HTable) hConnection.getTable(tableName)) {
hRegionInfoSet.addAll(table.getRegionLocations().keySet());
}
return new ArrayList<>(hRegionInfoSet);
}

代码示例来源:origin: kakao/hbase-tools

private long getWriteRequestCountActual(String tableName) throws IOException {
long writeRequestCountActual;
try (HTable table = (HTable) hConnection.getTable(tableName)) {
writeRequestCountActual = 0;
NavigableMap regiOnLocations= table.getRegionLocations();
for (Map.Entry entry : regionLocations.entrySet()) {
ServerLoad serverLoad = admin.getClusterStatus().getLoad(entry.getValue());
for (RegionLoad regionLoad : serverLoad.getRegionsLoad().values()) {
if (Arrays.equals(entry.getKey().getRegionName(), regionLoad.getName()))
writeRequestCountActual += regionLoad.getWriteRequestsCount();
}
}
}
return writeRequestCountActual;
}

代码示例来源:origin: kakao/hbase-tools

protected void waitForSplitting(String tableName, int regionCount) throws IOException, InterruptedException {
int regiOnCountActual= 0;
for (int i = 0; i try (HTable table = (HTable) hConnection.getTable(tableName)) {
regiOnCountActual= 0;
NavigableMap regiOnLocations= table.getRegionLocations();
for (Map.Entry entry : regionLocations.entrySet()) {
ServerLoad serverLoad = admin.getClusterStatus().getLoad(entry.getValue());
for (RegionLoad regionLoad : serverLoad.getRegionsLoad().values()) {
if (Arrays.equals(entry.getKey().getRegionName(), regionLoad.getName()))
regionCountActual++;
}
}
if (regiOnCountActual== regionCount) {
return;
}
} catch (Throwable ignore) {
}
Thread.sleep(WAIT_INTERVAL);
}
Assert.assertEquals("TestBase.waitForSplitting - failed - ", regionCount, regionCountActual);
}

代码示例来源:origin: kakao/hbase-tools

private long getWriteRequestCountActual(String tableName, ServerName serverName) throws IOException {
long writeRequestCountActual;
try (HTable table = (HTable) hConnection.getTable(tableName)) {
writeRequestCountActual = 0;
NavigableMap regiOnLocations= table.getRegionLocations();
for (Map.Entry entry : regionLocations.entrySet()) {
if (serverName.equals(entry.getValue())) {
ServerLoad serverLoad = admin.getClusterStatus().getLoad(entry.getValue());
for (RegionLoad regionLoad : serverLoad.getRegionsLoad().values()) {
if (Arrays.equals(entry.getKey().getRegionName(), regionLoad.getName()))
writeRequestCountActual += regionLoad.getWriteRequestsCount();
}
}
}
}
Long aLOng= getWriteRequestMetric(tableName, serverName);
return writeRequestCountActual - aLong;
}

推荐阅读
author-avatar
eea1051113
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有