org.apache.hadoop.hbase.HBaseTestingUtility.createMultiRegionTable()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(115)

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

HBaseTestingUtility.createMultiRegionTable介绍

[英]Create a table with multiple regions.
[中]创建具有多个区域的表。

代码示例

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 try {
  createWithFavoredNode = DistributedFileSystem.class.getDeclaredMethod("create", Path.class,
   FsPermission.class, boolean.class, int.class, short.class, long.class,
   Progressable.class, InetSocketAddress[].class);
 } catch (NoSuchMethodException nm) {
  return;
 }
 TEST_UTIL.startMiniCluster(REGION_SERVERS);
 table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, COLUMN_FAMILY);
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 UTIL.startMiniCluster(3);
 // Create 3 rows in the table, with rowkeys starting with "zzz*" so that
 // scan are forced to hit all the regions.
 try (Table table = UTIL.createMultiRegionTable(TABLE_NAME, CF)) {
  table.put(Arrays.asList(new Put(Bytes.toBytes("zzz1")).addColumn(CF, CQ, VALUE),
   new Put(Bytes.toBytes("zzz2")).addColumn(CF, CQ, VALUE),
   new Put(Bytes.toBytes("zzz3")).addColumn(CF, CQ, VALUE)));
 }
 CONN = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
 NUM_REGIONS = UTIL.getHBaseCluster().getRegions(TABLE_NAME).size();
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 UTIL.startMiniCluster(3);
 UTIL.createMultiRegionTable(NAME, CF);
 UTIL.waitTableAvailable(NAME);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 // switch TIF to log at DEBUG level
 TEST_UTIL.enableDebug(MultiTableInputFormatBase.class);
 // start mini hbase cluster
 TEST_UTIL.startMiniCluster(3);
 // create and fill table
 for (String tableName : TABLES) {
  try (Table table =
    TEST_UTIL.createMultiRegionTable(TableName.valueOf(tableName),
     INPUT_FAMILY, 4)) {
   TEST_UTIL.loadTable(table, INPUT_FAMILY, false);
  }
 }
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 TEST_UTIL.startMiniCluster(1);
 TEST_UTIL.createTable(TABLE_NAME, CF);
 TEST_UTIL.createMultiRegionTable(MULTI_REGION_TABLE_NAME, CF);
 CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();
 ThreadLocalRandom.current().nextBytes(VALUE);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void beforeClass() throws Exception {
 // Up the handlers; this test needs more than usual.
 UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
 UTIL.startMiniCluster();
 Table table =
   UTIL.createMultiRegionTable(MULTI_REGION_TABLE_NAME, new byte[][] { INPUT_FAMILY,
     OUTPUT_FAMILY });
 UTIL.loadTable(table, INPUT_FAMILY, false);
 UTIL.waitUntilAllRegionsAssigned(MULTI_REGION_TABLE_NAME);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void beforeClass() throws Exception {
 UTIL.startMiniCluster();
 Table table =
   UTIL.createMultiRegionTable(MULTI_REGION_TABLE_NAME, new byte[][] { INPUT_FAMILY,
     OUTPUT_FAMILY });
 UTIL.loadTable(table, INPUT_FAMILY, false);
 UTIL.createTable(TABLE_FOR_NEGATIVE_TESTS, new byte[][] { INPUT_FAMILY, OUTPUT_FAMILY });
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 TEST_UTIL.startMiniCluster(3);
 TEST_UTIL.createMultiRegionTable(TABLE_NAME, Bytes.toBytes("family1"), 5);
 procExec = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
 ASYNC_CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 TEST_UTIL.getConfiguration().setInt(AsyncNonMetaRegionLocator.LOCATE_PREFETCH_LIMIT, 100);
 TEST_UTIL.startMiniCluster(3);
 TEST_UTIL.createMultiRegionTable(TABLE_NAME, FAMILY);
 TEST_UTIL.waitTableAvailable(TABLE_NAME);
 CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();
 LOCATOR = new AsyncNonMetaRegionLocator((AsyncConnectionImpl) CONN);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 // test intermittently fails under hadoop2 (2.0.2-alpha) if shortcircuit-read (scr) is on.
 // this turns it off for this test.  TODO: Figure out why scr breaks recovery.
 System.setProperty("hbase.tests.use.shortcircuit.reads", "false");
 // switch TIF to log at DEBUG level
 TEST_UTIL.enableDebug(TableInputFormat.class);
 TEST_UTIL.enableDebug(TableInputFormatBase.class);
 // start mini hbase cluster
 TEST_UTIL.startMiniCluster(3);
 // create and fill table
 table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, INPUT_FAMILYS);
 TEST_UTIL.loadTable(table, INPUT_FAMILYS, null, false);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void beforeClass() throws Exception {
 // Uncomment the following lines if more verbosity is needed for
 // debugging (see HBASE-12285 for details).
 //((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL);
 //((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL);
 //((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
 UTIL.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
   KeyValueCodec.class.getCanonicalName());
 // Disable table on master for now as the feature is broken
 //UTIL.getConfiguration().setBoolean(LoadBalancer.TABLES_ON_MASTER, true);
 // We used to ask for system tables on Master exclusively but not needed by test and doesn't
 // work anyways -- so commented out.
 // UTIL.getConfiguration().setBoolean(LoadBalancer.SYSTEM_TABLES_ON_MASTER, true);
 UTIL.getConfiguration()
   .set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyMasterObserver.class.getName());
 UTIL.startMiniCluster(slaves);
 Table t = UTIL.createMultiRegionTable(TEST_TABLE, Bytes.toBytes(FAMILY));
 UTIL.waitTableEnabled(TEST_TABLE);
 t.close();
 CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration());
 assertTrue(MyMasterObserver.start.get());
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws Exception {
 Configuration c = TEST_UTIL.getConfiguration();
 c.setBoolean("dfs.support.append", true);
 TEST_UTIL.startMiniCluster(1);
 table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, FAMILY);
 TEST_UTIL.loadTable(table, FAMILY);
 // setup the hdfssnapshots
 client = new DFSClient(TEST_UTIL.getDFSCluster().getURI(), TEST_UTIL.getConfiguration());
 String fullUrIPath = TEST_UTIL.getDefaultRootDirPath().toString();
 String uriString = TEST_UTIL.getTestFileSystem().getUri().toString();
 baseDir = StringUtils.removeStart(fullUrIPath, uriString);
 client.allowSnapshot(baseDir);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void beforeClass() throws Exception {
 // Make servers report eagerly. This test is about looking at the cluster status reported.
 // Make it so we don't have to wait around too long to see change.
 UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", MSG_INTERVAL);
 UTIL.startMiniCluster(4);
 admin = UTIL.getAdmin();
 admin.balancerSwitch(false, true);
 byte[] FAMILY = Bytes.toBytes("f");
 for (TableName tableName : tables) {
  Table table = UTIL.createMultiRegionTable(tableName, FAMILY, 16);
  UTIL.waitTableAvailable(tableName);
  UTIL.loadTable(table, FAMILY);
 }
}

代码示例来源:origin: apache/hbase

@Test
 public void testKillMiniHBaseCluster() throws Exception {

  HBaseTestingUtility htu = new HBaseTestingUtility();
  htu.startMiniZKCluster();

  try {
   htu.startMiniHBaseCluster();

   TableName tableName;
   byte[] FAM_NAME;

   for(int i = 0; i < NUMTABLES; i++) {
    tableName = TableName.valueOf(name.getMethodName() + i);
    FAM_NAME = Bytes.toBytes("fam" + i);

    try (Table table = htu.createMultiRegionTable(tableName, FAM_NAME, NUMREGIONS)) {
     htu.loadRandomRows(table, FAM_NAME, 100, NUMROWS);
    }
   }
  } finally {
   htu.killMiniHBaseCluster();
   htu.shutdownMiniZKCluster();
  }
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testGetRegionLocation() throws Exception {
 RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin();
 TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY);
 AsyncTableRegionLocator locator = ASYNC_CONN.getRegionLocator(tableName);
 HRegionLocation regionLocation = locator.getRegionLocation(Bytes.toBytes("mmm")).get();
 RegionInfo region = regionLocation.getRegion();
 byte[] regionName = regionLocation.getRegion().getRegionName();
 HRegionLocation location = rawAdmin.getRegionLocation(regionName).get();
 assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName()));
 location = rawAdmin.getRegionLocation(region.getEncodedNameAsBytes()).get();
 assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName()));
}

代码示例来源:origin: apache/hbase

@Test
public void testGetRegion() throws Exception {
 // We use actual HBaseAdmin instance instead of going via Admin interface in
 // here because makes use of an internal HBA method (TODO: Fix.).
 HBaseAdmin rawAdmin = TEST_UTIL.getHBaseAdmin();
 final TableName tableName = TableName.valueOf(name.getMethodName());
 LOG.info("Started " + tableName);
 Table t = TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY);
 try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
  HRegionLocation regionLocation = locator.getRegionLocation(Bytes.toBytes("mmm"));
  RegionInfo region = regionLocation.getRegionInfo();
  byte[] regionName = region.getRegionName();
  Pair<RegionInfo, ServerName> pair = rawAdmin.getRegion(regionName);
  assertTrue(Bytes.equals(regionName, pair.getFirst().getRegionName()));
  pair = rawAdmin.getRegion(region.getEncodedNameAsBytes());
  assertTrue(Bytes.equals(regionName, pair.getFirst().getRegionName()));
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testDisabledTableMove() throws Exception {
 final byte[] familyNameBytes = Bytes.toBytes("f");
 String newGroupName = getGroupName(name.getMethodName());
 final RSGroupInfo newGroup = addGroup(newGroupName, 2);
 TEST_UTIL.createMultiRegionTable(tableName, familyNameBytes, 5);
 TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
  @Override
  public boolean evaluate() throws Exception {
   List<String> regions = getTableRegionMap().get(tableName);
   if (regions == null) {
    return false;
   }
   return getTableRegionMap().get(tableName).size() >= 5;
  }
 });
 RSGroupInfo tableGrp = rsGroupAdmin.getRSGroupInfoOfTable(tableName);
 assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP));
 // test disable table
 admin.disableTable(tableName);
 // change table's group
 LOG.info("Moving table " + tableName + " to " + newGroup.getName());
 rsGroupAdmin.moveTables(Sets.newHashSet(tableName), newGroup.getName());
 // verify group change
 Assert.assertEquals(newGroup.getName(),
  rsGroupAdmin.getRSGroupInfoOfTable(tableName).getName());
}

代码示例来源:origin: apache/hbase

@Test
public void testMisplacedRegions() throws Exception {
 final TableName tableName = TableName.valueOf(tablePrefix + "_testMisplacedRegions");
 LOG.info("testMisplacedRegions");
 final RSGroupInfo RSGroupInfo = addGroup("testMisplacedRegions", 1);
 TEST_UTIL.createMultiRegionTable(tableName, new byte[] { 'f' }, 15);
 TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
 rsGroupAdminEndpoint.getGroupInfoManager().moveTables(Sets.newHashSet(tableName),
  RSGroupInfo.getName());
 admin.balancerSwitch(true, true);
 assertTrue(rsGroupAdmin.balanceRSGroup(RSGroupInfo.getName()));
 admin.balancerSwitch(false, true);
 assertTrue(observer.preBalanceRSGroupCalled);
 assertTrue(observer.postBalanceRSGroupCalled);
 TEST_UTIL.waitFor(60000, new Predicate<Exception>() {
  @Override
  public boolean evaluate() throws Exception {
   ServerName serverName =
    ServerName.valueOf(RSGroupInfo.getServers().iterator().next().toString(), 1);
   return admin.getConnection().getAdmin().getRegions(serverName).size() == 15;
  }
 });
}

代码示例来源:origin: apache/hbase

/**
 * Start up a mini cluster and put a small table of many empty regions into it.
 * @throws Exception
 */
@BeforeClass public static void beforeAllTests() throws Exception {
 TEST_UTIL.startMiniCluster(2);
 // Create a table of three families.  This will assign a region.
 TEST_UTIL.createMultiRegionTable(TABLENAME, FAMILIES);
 Table t = TEST_UTIL.getConnection().getTable(TABLENAME);
 int countOfRegions = -1;
 try (RegionLocator r = TEST_UTIL.getConnection().getRegionLocator(TABLENAME)) {
  countOfRegions = r.getStartKeys().length;
 }
 TEST_UTIL.waitUntilAllRegionsAssigned(TABLENAME);
 addToEachStartKey(countOfRegions);
 t.close();
}

代码示例来源:origin: apache/hbase

Table table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, FAMILY);

相关文章

HBaseTestingUtility类方法