本文整理汇总了Java中org.apache.hadoop.hbase.client.RegionLocator类的典型用法代码示例。如果您正苦于以下问题:Java RegionLocator类的具体用法?Java RegionLocator怎么用?Java RegionLocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegionLocator类属于org.apache.hadoop.hbase.client包,在下文中一共展示了RegionLocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMove
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test (timeout=180000)
public void testMove() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
final ServerName server = location.getServerName();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV, null),
hri, server, server);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
USER_GROUP_WRITE, USER_GROUP_CREATE);
}
示例2: testAssign
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test (timeout=180000)
public void testAssign() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV, null), hri);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
USER_GROUP_WRITE, USER_GROUP_CREATE);
}
示例3: testUnassign
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test (timeout=180000)
public void testUnassign() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV, null), hri, false);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
USER_GROUP_WRITE, USER_GROUP_CREATE);
}
示例4: testRegionOffline
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test (timeout=180000)
public void testRegionOffline() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRegionOffline(ObserverContext.createAndPrepare(CP_ENV, null), hri);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
USER_GROUP_WRITE, USER_GROUP_CREATE);
}
示例5: beforeAllTests
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@BeforeClass public static void beforeAllTests() throws Exception {
Configuration c = TEST_UTIL.getConfiguration();
c.setBoolean("hbase.assignment.usezk", true);
c.setBoolean("dfs.support.append", true);
c.setInt("hbase.regionserver.info.port", 0);
TEST_UTIL.startMiniCluster(2);
TEST_UTIL.createMultiRegionTable(TABLENAME, FAMILIES);
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
countOfRegions = -1;
try (RegionLocator r = t.getRegionLocator()) {
countOfRegions = r.getStartKeys().length;
}
waitUntilAllRegionsAssigned();
addToEachStartKey(countOfRegions);
t.close();
TEST_UTIL.getHBaseCluster().getMaster().assignmentManager.initializeHandlerTrackers();
}
示例6: runIncrementalPELoad
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
private void runIncrementalPELoad(Configuration conf, HTableDescriptor tableDescriptor,
RegionLocator regionLocator, Path outDir) throws IOException, UnsupportedEncodingException,
InterruptedException, ClassNotFoundException {
Job job = new Job(conf, "testLocalMRIncrementalLoad");
job.setWorkingDirectory(util.getDataTestDirOnTestFS("runIncrementalPELoad"));
job.getConfiguration().setStrings("io.serializations", conf.get("io.serializations"),
MutationSerialization.class.getName(), ResultSerialization.class.getName(),
KeyValueSerialization.class.getName());
setupRandomGeneratorMapper(job);
HFileOutputFormat2.configureIncrementalLoad(job, tableDescriptor, regionLocator);
FileOutputFormat.setOutputPath(job, outDir);
assertFalse(util.getTestFileSystem().exists(outDir)) ;
assertEquals(regionLocator.getAllRegionLocations().size(), job.getNumReduceTasks());
assertTrue(job.waitForCompletion(true));
}
示例7: testSimpleTestCase
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test
public void testSimpleTestCase() throws Exception {
RegionLocator regionLocator = mockRegionLocator("region1", "region2", "region3");
Admin admin = mockAdmin(
mockServer(
mockRegion("region1", 123),
mockRegion("region3", 1232)
),
mockServer(
mockRegion("region2", 54321),
mockRegion("otherTableRegion", 110)
)
);
RegionSizeCalculator calculator = new RegionSizeCalculator(regionLocator, admin);
assertEquals(123 * megabyte, calculator.getRegionSize("region1".getBytes()));
assertEquals(54321 * megabyte, calculator.getRegionSize("region2".getBytes()));
assertEquals(1232 * megabyte, calculator.getRegionSize("region3".getBytes()));
// if region is not inside our table, it should return 0
assertEquals(0 * megabyte, calculator.getRegionSize("otherTableRegion".getBytes()));
assertEquals(3, calculator.getRegionSizeMap().size());
}
示例8: testLargeRegion
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
/**
* When size of region in megabytes is larger than largest possible integer there could be
* error caused by lost of precision.
* */
@Test
public void testLargeRegion() throws Exception {
RegionLocator regionLocator = mockRegionLocator("largeRegion");
Admin admin = mockAdmin(
mockServer(
mockRegion("largeRegion", Integer.MAX_VALUE)
)
);
RegionSizeCalculator calculator = new RegionSizeCalculator(regionLocator, admin);
assertEquals(((long) Integer.MAX_VALUE) * megabyte, calculator.getRegionSize("largeRegion".getBytes()));
}
示例9: testDisabled
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
/** When calculator is disabled, it should return 0 for each request.*/
@Test
public void testDisabled() throws Exception {
String regionName = "cz.goout:/index.html";
RegionLocator table = mockRegionLocator(regionName);
Admin admin = mockAdmin(
mockServer(
mockRegion(regionName, 999)
)
);
//first request on enabled calculator
RegionSizeCalculator calculator = new RegionSizeCalculator(table, admin);
assertEquals(999 * megabyte, calculator.getRegionSize(regionName.getBytes()));
//then disabled calculator.
configuration.setBoolean(RegionSizeCalculator.ENABLE_REGIONSIZECALCULATOR, false);
RegionSizeCalculator disabledCalculator = new RegionSizeCalculator(table, admin);
assertEquals(0 * megabyte, disabledCalculator.getRegionSize(regionName.getBytes()));
assertEquals(0, disabledCalculator.getRegionSizeMap().size());
}
示例10: verifyRegionResults
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
private void verifyRegionResults(RegionLocator regionLocator,
Map<byte[], String> results, String expected, byte[] row)
throws Exception {
for (Map.Entry<byte [], String> e: results.entrySet()) {
LOG.info("row=" + Bytes.toString(row) + ", expected=" + expected +
", result key=" + Bytes.toString(e.getKey()) +
", value=" + e.getValue());
}
HRegionLocation loc = regionLocator.getRegionLocation(row, true);
byte[] region = loc.getRegionInfo().getRegionName();
assertTrue("Results should contain region " +
Bytes.toStringBinary(region) + " for row '" + Bytes.toStringBinary(row)+ "'",
results.containsKey(region));
assertEquals("Invalid result for row '"+Bytes.toStringBinary(row)+"'",
expected, results.get(region));
}
示例11: getServerHoldingRegion
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Override
public ServerName getServerHoldingRegion(TableName tn, byte[] regionName) throws IOException {
HRegionLocation regionLoc = null;
try (RegionLocator locator = connection.getRegionLocator(tn)) {
regionLoc = locator.getRegionLocation(regionName);
}
if (regionLoc == null) {
LOG.warn("Cannot find region server holding region " + Bytes.toString(regionName) +
", start key [" + Bytes.toString(HRegionInfo.getStartKey(regionName)) + "]");
return null;
}
AdminProtos.AdminService.BlockingInterface client =
((ClusterConnection)this.connection).getAdmin(regionLoc.getServerName());
ServerInfo info = ProtobufUtil.getServerInfo(null, client);
return ProtobufUtil.toServerName(info.getServerName());
}
示例12: getRegionLocations
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
private List<HRegionLocation> getRegionLocations(Connection connection) throws Exception {
final Scan scan = read.serializableScan.get();
byte[] startRow = scan.getStartRow();
byte[] stopRow = scan.getStopRow();
final List<HRegionLocation> regionLocations = new ArrayList<>();
final boolean scanWithNoLowerBound = startRow.length == 0;
final boolean scanWithNoUpperBound = stopRow.length == 0;
TableName tableName = TableName.valueOf(read.tableId);
RegionLocator regionLocator = connection.getRegionLocator(tableName);
List<HRegionLocation> tableRegionInfos = regionLocator.getAllRegionLocations();
for (HRegionLocation regionLocation : tableRegionInfos) {
final byte[] startKey = regionLocation.getRegionInfo().getStartKey();
final byte[] endKey = regionLocation.getRegionInfo().getEndKey();
boolean isLastRegion = endKey.length == 0;
// filters regions who are part of the scan
if ((scanWithNoLowerBound || isLastRegion || Bytes.compareTo(startRow, endKey) < 0)
&& (scanWithNoUpperBound || Bytes.compareTo(stopRow, startKey) > 0)) {
regionLocations.add(regionLocation);
}
}
return regionLocations;
}
示例13: testMove
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test
public void testMove() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator =
TEST_UTIL.getConnection().getRegionLocator(TEST_TABLE.getTableName())) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
final ServerName server = location.getServerName();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV, null),
hri, server, server);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE);
}
示例14: testAssign
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test
public void testAssign() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator =
TEST_UTIL.getConnection().getRegionLocator(TEST_TABLE.getTableName())) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV, null), hri);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE);
}
示例15: testUnassign
import org.apache.hadoop.hbase.client.RegionLocator; //导入依赖的package包/类
@Test
public void testUnassign() throws Exception {
List<HRegionLocation> regions;
try (RegionLocator locator =
TEST_UTIL.getConnection().getRegionLocator(TEST_TABLE.getTableName())) {
regions = locator.getAllRegionLocations();
}
HRegionLocation location = regions.get(0);
final HRegionInfo hri = location.getRegionInfo();
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV, null), hri, false);
return null;
}
};
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER);
verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE);
}