本文整理了Java中org.apache.hadoop.hbase.client.Admin.getConfiguration()
方法的一些代码示例,展示了Admin.getConfiguration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.getConfiguration()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:getConfiguration
暂无
代码示例来源:origin: apache/hbase
@VisibleForTesting
HRegionFileSystem getFileSystem(Connection connection) throws IOException {
Admin admin = connection.getAdmin();
return HRegionFileSystem.openRegionFromFileSystem(admin.getConfiguration(),
FSUtils.getCurrentFileSystem(admin.getConfiguration()),
FSUtils.getTableDir(FSUtils.getRootDir(admin.getConfiguration()), region.getTable()),
region, true);
}
代码示例来源:origin: apache/hbase
long timeoutInSeconds = regionsToMove.size() * admin.getConfiguration()
.getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds);
代码示例来源:origin: apache/hbase
private ServerName getTargetServer() throws Exception {
ServerName server = null;
int maxWaitInSeconds =
admin.getConfiguration().getInt(SERVERSTART_WAIT_MAX_KEY, DEFAULT_SERVERSTART_WAIT_MAX);
long maxWait = EnvironmentEdgeManager.currentTime() + maxWaitInSeconds * 1000;
while (EnvironmentEdgeManager.currentTime() < maxWait) {
try {
List<ServerName> regionServers = new ArrayList<>();
regionServers.addAll(
admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics()
.keySet());
// Remove the host Region server from target Region Servers list
server = stripServer(regionServers, hostname, port);
if (server != null) {
break;
} else {
LOG.warn("Server " + hostname + ":" + port + " is not up yet, waiting");
}
} catch (IOException e) {
LOG.warn("Could not get list of region servers", e);
}
Thread.sleep(500);
}
if (server == null) {
LOG.error("Server " + hostname + ":" + port + " is not up. Giving up.");
throw new Exception("Server " + hostname + ":" + port + " to load regions not online");
}
return server;
}
代码示例来源:origin: apache/hbase
@Override
public Admin getAdmin() throws IOException {
Admin admin = Mockito.mock(Admin.class);
Mockito.when(admin.getConfiguration()).thenReturn(getConfiguration());
return admin;
}
代码示例来源:origin: apache/hbase
public static void waitUntilAssigned(Admin admin,
RegionInfo region) throws IOException, InterruptedException {
long timeout = admin.getConfiguration().getLong("hbase.hbck.assign.timeout", 120000);
long expiration = timeout + EnvironmentEdgeManager.currentTime();
while (EnvironmentEdgeManager.currentTime() < expiration) {
try {
boolean inTransition = false;
for (RegionState rs : admin.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
.getRegionStatesInTransition()) {
if (RegionInfo.COMPARATOR.compare(rs.getRegion(), region) == 0) {
inTransition = true;
break;
}
}
if (!inTransition) {
// yay! no longer RIT
return;
}
// still in rit
LOG.info("Region still in transition, waiting for "
+ "it to become assigned: " + region);
} catch (IOException e) {
LOG.warn("Exception when waiting for region to become assigned,"
+ " retrying", e);
}
Thread.sleep(1000);
}
throw new IOException("Region " + region + " failed to move out of " +
"transition within timeout " + timeout + "ms");
}
代码示例来源:origin: apache/hbase
long timeoutInSeconds = regionsToMove.size() * admin.getConfiguration()
.getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds);
代码示例来源:origin: apache/hbase
/**
* Creates mock returning RegionLoad info about given servers.
*/
private Admin mockAdmin(RegionMetrics... regionLoadArray) throws Exception {
Admin mockAdmin = Mockito.mock(Admin.class);
List<RegionMetrics> regionLoads = new ArrayList<>();
for (RegionMetrics regionLoad : regionLoadArray) {
regionLoads.add(regionLoad);
}
when(mockAdmin.getConfiguration()).thenReturn(configuration);
when(mockAdmin.getRegionMetrics(sn, TableName.valueOf("sizeTestTable")))
.thenReturn(regionLoads);
return mockAdmin;
}
代码示例来源:origin: apache/hbase
boolean moved = false;
int count = 0;
int retries = admin.getConfiguration().getInt(MOVE_RETRIES_MAX_KEY, DEFAULT_MOVE_RETRIES_MAX);
int maxWaitInSeconds =
admin.getConfiguration().getInt(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
long startTime = EnvironmentEdgeManager.currentTime();
boolean sameServer = true;
代码示例来源:origin: apache/hbase
private void init(RegionLocator regionLocator, Admin admin)
throws IOException {
if (!enabled(admin.getConfiguration())) {
LOG.info("Region size calculation disabled.");
return;
}
if (regionLocator.getName().isSystemTable()) {
LOG.info("Region size calculation disabled for system tables.");
return;
}
LOG.info("Calculating region sizes for table \"" + regionLocator.getName() + "\".");
// Get the servers which host regions of the table
Set<ServerName> tableServers = getRegionServersOfTable(regionLocator);
for (ServerName tableServerName : tableServers) {
for (RegionMetrics regionLoad : admin.getRegionMetrics(
tableServerName,regionLocator.getName())) {
byte[] regionId = regionLoad.getRegionName();
long regionSizeBytes
= ((long) regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE)) * MEGABYTE;
sizeMap.put(regionId, regionSizeBytes);
if (LOG.isDebugEnabled()) {
LOG.debug("Region " + regionLoad.getNameAsString() + " has size " + regionSizeBytes);
}
}
}
LOG.debug("Region sizes calculated");
}
代码示例来源:origin: apache/hbase
private void verifyFetchableViaAPI(Admin admin, ThrottleType type, long limit, TimeUnit tu)
throws Exception {
// Verify we can retrieve the new quota via the QuotaRetriever API
try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) {
assertRPCQuota(type, limit, tu, Iterables.getOnlyElement(quotaScanner));
}
}
代码示例来源:origin: apache/hbase
private void verifyNotFetchableViaAPI(Admin admin) throws Exception {
// Verify that we can also not fetch it via the API
try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) {
assertNull("Did not expect to find a quota entry", quotaScanner.next());
}
}
代码示例来源:origin: apache/hbase
@Override
public TimingResult call() throws Exception {
PerformanceEvaluation.TestOptions opts = PerformanceEvaluation.parseOpts(argv);
PerformanceEvaluation.checkTable(admin, opts);
PerformanceEvaluation.RunResult results[] = null;
long numRows = opts.totalRows;
long elapsedTime = 0;
if (opts.nomapred) {
results = PerformanceEvaluation.doLocalClients(opts, admin.getConfiguration());
for (PerformanceEvaluation.RunResult r : results) {
elapsedTime = Math.max(elapsedTime, r.duration);
}
} else {
Job job = PerformanceEvaluation.doMapReduce(opts, admin.getConfiguration());
Counters counters = job.getCounters();
numRows = counters.findCounter(PerformanceEvaluation.Counter.ROWS).getValue();
elapsedTime = counters.findCounter(PerformanceEvaluation.Counter.ELAPSED_TIME).getValue();
}
return new TimingResult(numRows, elapsedTime, results);
}
}
代码示例来源:origin: apache/hbase
List<byte[]> nonEmptyTestFamilies, List<byte[]> emptyTestFamilies,
Path rootDir, Admin admin, FileSystem fs) throws IOException {
final Configuration conf = admin.getConfiguration();
代码示例来源:origin: apache/hbase
/**
* Naive test to check that Connection#getAdmin returns a properly constructed HBaseAdmin object
* @throws IOException Unable to construct admin
*/
@Test
public void testAdminFactory() throws IOException {
Connection con1 = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
Admin admin = con1.getAdmin();
assertTrue(admin.getConnection() == con1);
assertTrue(admin.getConfiguration() == TEST_UTIL.getConfiguration());
con1.close();
}
代码示例来源:origin: apache/hbase
QuotaRetriever scanner = QuotaRetriever.open(admin.getConfiguration());
try {
assertSpaceQuota(sizeLimit, violationPolicy, Iterables.getOnlyElement(scanner));
scanner = QuotaRetriever.open(admin.getConfiguration());
try {
assertNull("Did not expect to find a quota entry", scanner.next());
代码示例来源:origin: apache/hbase
QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration());
try {
assertSpaceQuota(originalSizeLimit, violationPolicy, Iterables.getOnlyElement(quotaScanner));
quotaScanner = QuotaRetriever.open(admin.getConfiguration());
try {
assertSpaceQuota(newSizeLimit, newViolationPolicy, Iterables.getOnlyElement(quotaScanner));
quotaScanner = QuotaRetriever.open(admin.getConfiguration());
try {
assertNull("Did not expect to find a quota entry", quotaScanner.next());
代码示例来源:origin: apache/phoenix
@Test
public void testLocalIndexTableRegionSplitPolicyAndSplitKeys() throws Exception {
String tableName = schemaName + "." + generateUniqueName();
String indexName = "IDX_" + generateUniqueName();
TableName physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(), isNamespaceMapped);
String indexPhysicalTableName = physicalTableName.getNameAsString();
createBaseTable(tableName, null,"('e','i','o')");
Connection conn1 = getConnection();
Connection conn2 = getConnection();
conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + " ON " + tableName + "(v1)");
conn2.createStatement().executeQuery("SELECT * FROM " + tableName).next();
Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin();
TableDescriptor htd = admin
.getDescriptor(TableName.valueOf(indexPhysicalTableName));
assertEquals(IndexRegionSplitPolicy.class.getName(), htd.getValue(TableDescriptorBuilder.SPLIT_POLICY));
try(org.apache.hadoop.hbase.client.Connection c = ConnectionFactory.createConnection(admin.getConfiguration())) {
try (RegionLocator userTable= c.getRegionLocator(SchemaUtil.getPhysicalTableName(tableName.getBytes(), isNamespaceMapped))) {
try (RegionLocator indxTable = c.getRegionLocator(TableName.valueOf(indexPhysicalTableName))) {
assertArrayEquals("Both user table and index table should have same split keys.",
userTable.getStartKeys(), indxTable.getStartKeys());
}
}
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
private void verifyFetchableViaAPI(Admin admin, ThrottleType type, long limit, TimeUnit tu)
throws Exception {
// Verify we can retrieve the new quota via the QuotaRetriever API
try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) {
assertRPCQuota(type, limit, tu, Iterables.getOnlyElement(quotaScanner));
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
private void verifyNotFetchableViaAPI(Admin admin) throws Exception {
// Verify that we can also not fetch it via the API
try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) {
assertNull("Did not expect to find a quota entry", quotaScanner.next());
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
/**
* Naive test to check that Connection#getAdmin returns a properly constructed HBaseAdmin object
* @throws IOException Unable to construct admin
*/
@Test
public void testAdminFactory() throws IOException {
Connection con1 = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
Admin admin = con1.getAdmin();
assertTrue(admin.getConnection() == con1);
assertTrue(admin.getConfiguration() == TEST_UTIL.getConfiguration());
con1.close();
}
内容来源于网络,如有侵权,请联系作者删除!