本文整理了Java中org.apache.hadoop.hbase.HBaseTestingUtility.createTable()
方法的一些代码示例,展示了HBaseTestingUtility.createTable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseTestingUtility.createTable()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.HBaseTestingUtility
类名称:HBaseTestingUtility
方法名:createTable
[英]Create a table.
[中]创建一个表。
代码示例来源:origin: apache/hbase
private Table createTable(boolean multiRegions) throws IOException {
if (multiRegions) {
return UTIL.createTable(NAME, CF, new byte[][] { Bytes.toBytes(1) });
} else {
return UTIL.createTable(NAME, CF);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testCreateMultiRegion() throws IOException {
byte[] end = { 1, 3, 5, 7, 9 };
byte[] start = { 0, 2, 4, 6, 8 };
byte[][] f = { Bytes.toBytes("f") };
TEST_UTIL.createTable(tableName, f, 1, start, end, 10);
}
代码示例来源:origin: apache/hbase
/**
* For HADOOP-2579
* @throws IOException
*/
@Test (expected=TableExistsException.class)
public void testTableExistsExceptionWithATable() throws IOException {
final TableName name = TableName.valueOf(this.name.getMethodName());
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
}
代码示例来源:origin: apache/hbase
@Test
public void testMROnTableWithTimestamp() throws Exception {
util.createTable(tn, FAMILY);
args.put(ImportTsv.COLUMNS_CONF_KEY, "HBASE_ROW_KEY,HBASE_TS_KEY,FAM:A,FAM:B");
args.put(ImportTsv.SEPARATOR_CONF_KEY, ",");
String data = "KEY,1234,VALUE1,VALUE2\n";
doMROnTableTest(data, 1);
util.deleteTable(tn);
}
代码示例来源:origin: apache/hbase
private void setQuotaAndThenDropTable(SpaceViolationPolicy policy) throws Exception {
Put put = new Put(Bytes.toBytes("to_reject"));
put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
Bytes.toBytes("reject"));
// Do puts until we violate space policy
final TableName tn = writeUntilViolationAndVerifyViolation(policy, put);
// Now, drop the table
TEST_UTIL.deleteTable(tn);
LOG.debug("Successfully deleted table ", tn);
// Now re-create the table
TEST_UTIL.createTable(tn, Bytes.toBytes(SpaceQuotaHelperForTests.F1));
LOG.debug("Successfully re-created table ", tn);
// Put some rows now: should not violate as table/quota was dropped
verifyNoViolation(policy, tn, put);
}
代码示例来源:origin: apache/hbase
@Before
public void setup() throws Exception {
tableName = TableName.valueOf(name.getMethodName().replaceAll("[^a-zA-Z0-9]", "_"));
LOG.info("Creating table " + tableName);
table = TEST_UTIL.createTable(tableName, fam);
}
代码示例来源:origin: apache/hbase
@Before
public void setup() throws Exception {
TEST_UTIL.getConfiguration().setInt("hbase.regionserver.logroll.period", logRollPeriod);
TEST_UTIL.startMiniCluster(1);
TableName name = TableName.valueOf("Test");
TEST_UTIL.createTable(name, Bytes.toBytes("cf"));
TEST_UTIL.waitTableAvailable(name);
}
代码示例来源:origin: apache/hbase
@Before
public void before() throws Exception {
table = util.createTable(TEST_TABLE, TEST_FAMILY);
Put puta = new Put(ROW_A);
puta.addColumn(TEST_FAMILY, qualifierCol1, bytes1);
table.put(puta);
Put putb = new Put(ROW_B);
putb.addColumn(TEST_FAMILY, qualifierCol1, bytes2);
table.put(putb);
Put putc = new Put(ROW_C);
putc.addColumn(TEST_FAMILY, qualifierCol1, bytes3);
table.put(putc);
}
代码示例来源:origin: apache/hbase
@Before
public void before() throws IOException {
this.tableName = TableName.valueOf(this.name.getMethodName());
// Create a table. Has one region at least.
TEST_UTIL.createTable(this.tableName, Bytes.toBytes("cf"));
}
代码示例来源:origin: apache/hbase
@Test
public void testMROnTableWithCustomMapper()
throws Exception {
util.createTable(tn, FAMILY);
args.put(ImportTsv.MAPPER_CONF_KEY,
"org.apache.hadoop.hbase.mapreduce.TsvImporterCustomTestMapper");
doMROnTableTest(null, 3);
util.deleteTable(tn);
}
代码示例来源:origin: apache/hbase
@Test
public void testCreateAndDrop() throws Exception {
TEST_UTIL.createTable(tableName, Bytes.toBytes("cf"));
// wait for created table to be assigned
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return getTableRegionMap().get(tableName) != null;
}
});
TEST_UTIL.deleteTable(tableName);
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUp() throws Exception {
UTIL.startMiniCluster(1);
UTIL.createTable(TABLE_NAME, FAMILY);
CONN = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
TABLE = CONN.getTable(TABLE_NAME);
TABLE.putAll(IntStream.range(0, ROW_COUNT).mapToObj(i -> {
Put put = new Put(Bytes.toBytes(i));
IntStream.range(0, CQS.length)
.forEach(j -> put.addColumn(FAMILY, CQS[j], Bytes.toBytes((j + 1) * i)));
return put;
}).collect(Collectors.toList())).get();
}
代码示例来源:origin: apache/hbase
@Before
public void setUp() throws IOException, InterruptedException {
tableName = TableName.valueOf(testName.getMethodName().replaceAll("[^0-9a-zA-Z]", "_"));
UTIL.createTable(tableName, CF);
UTIL.waitTableAvailable(tableName);
}
代码示例来源:origin: apache/hbase
private static void createTables() throws IOException, InterruptedException {
byte[][] FAMILIES = new byte [][] {Bytes.toBytes("f")};
for (TableName tableName : tables) {
Table table =
UTIL.createTable(tableName, FAMILIES, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
UTIL.waitTableAvailable(tableName);
UTIL.loadTable(table, FAMILIES[0]);
}
}
代码示例来源:origin: apache/hbase
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster();
Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME), Bytes.toBytes(COL_FAM));
writeRows(table, TOTAL_ROWS, ROWS_WITH_ONE_COL);
table.close();
}
代码示例来源:origin: apache/hbase
@Test
public void testPutNoCF() throws IOException {
final byte[] BAD_FAM = Bytes.toBytes("BAD_CF");
final byte[] VAL = Bytes.toBytes(100);
Table table = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()), FAMILY);
boolean caughtNSCFE = false;
try {
Put p = new Put(ROW);
p.addColumn(BAD_FAM, QUALIFIER, VAL);
table.put(p);
} catch (Exception e) {
caughtNSCFE = e instanceof NoSuchColumnFamilyException;
}
assertTrue("Should throw NoSuchColumnFamilyException", caughtNSCFE);
}
代码示例来源:origin: apache/hbase
@Test
public void testDryModeWithoutBulkOutputAndTableExists() throws Exception {
util.createTable(tn, FAMILY);
args.put(ImportTsv.DRY_RUN_CONF_KEY, "true");
doMROnTableTest(null, 1);
// Dry mode should not delete an existing table. If it's not present,
// this will throw TableNotFoundException.
util.deleteTable(tn);
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUp() throws Exception {
TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD,
SCANNER_LEASE_TIMEOUT_PERIOD_MS);
TEST_UTIL.startMiniCluster(1);
TEST_UTIL.createTable(TABLE_NAME, FAMILY);
CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();
TABLE = CONN.getTable(TABLE_NAME);
TABLE.putAll(IntStream.range(0, 10).mapToObj(
i -> new Put(Bytes.toBytes(String.format("%02d", i))).addColumn(FAMILY, CQ, Bytes.toBytes(i)))
.collect(Collectors.toList())).get();
}
代码示例来源:origin: apache/hbase
private Table createTable()
throws IOException, InterruptedException {
final TableName tableName = TableName.valueOf(name.getMethodName());
Table table = TEST_UTIL.createTable(tableName, FAMILY);
TEST_UTIL.waitTableAvailable(tableName.getName(), 5000);
return table;
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(1);
// create a table with 4 region: (-oo, b),[b,c),[c,d),[d,+oo)
byte[] bytes = Bytes.toBytes("bcd");
byte[][] splitKeys = new byte[bytes.length][];
for (int i = 0; i < bytes.length; i++) {
splitKeys[i] = new byte[] { bytes[i] };
}
htable = TEST_UTIL.createTable(TABLE_NAME, COLUMN_FAMILY, splitKeys);
}
内容来源于网络,如有侵权,请联系作者删除!