当前位置: 首页>>代码示例>>Java>>正文


Java RegionLocator类代码示例

本文整理汇总了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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestAccessController.java

示例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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestAccessController.java

示例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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestAccessController.java

示例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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestAccessController.java

示例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();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestZKBasedOpenCloseRegion.java

示例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));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestHFileOutputFormat2.java

示例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());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:TestRegionSizeCalculator.java

示例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()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestRegionSizeCalculator.java

示例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());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestRegionSizeCalculator.java

示例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));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestServerCustomProtocol.java

示例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());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:DistributedHBaseCluster.java

示例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;
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:HBaseIO.java

示例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);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:TestAccessController.java

示例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);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:21,代码来源:TestAccessController.java

示例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);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:21,代码来源:TestAccessController.java


注:本文中的org.apache.hadoop.hbase.client.RegionLocator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。