本文整理了Java中org.apache.hadoop.hbase.client.HTable.getRegionLocations()
方法的一些代码示例,展示了HTable.getRegionLocations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTable.getRegionLocations()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.HTable
类名称: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
List
HTable table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = new HTable(hconf, tableName);
Map
normalizeKeyBounds(table.getRegionLocations());
for (Map.Entry
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
Set
代码示例来源: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
if (regionCountPrev
} 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
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
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
NavigableMap
final List
final List
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
final HTable htable
) throws IOException {
final ImmutableList.Builder
NavigableMap
for (Map.Entry
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
final Map
new TreeMap
final Map
for (Map.Entry
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
long startTimestamp = System.currentTimeMillis();
Util.printVerboseMessage(args, Util.getMethodName() + " - start");
NavigableMap
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
for (Map.Entry
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
List
TableMask table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = cnx.getTable(tableName);
HTable hTable = (HTable)table.getTableObject();
Map
normalizeKeyBounds(hTable.getRegionLocations());
for (Map.Entry
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
List
TableMask table = null;
try {
ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
table = cnx.getTable(tableName);
HTable hTable = (HTable)table.getTableObject();
Map
normalizeKeyBounds(hTable.getRegionLocations());
for (Map.Entry
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
Set
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
for (Map.Entry
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
regiOnCountActual= 0;
NavigableMap
for (Map.Entry
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
for (Map.Entry
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;
}