本文整理汇总了Java中org.apache.hadoop.hbase.index.Constants.INDEX_TABLE_SUFFIX属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.INDEX_TABLE_SUFFIX属性的具体用法?Java Constants.INDEX_TABLE_SUFFIX怎么用?Java Constants.INDEX_TABLE_SUFFIX使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hbase.index.Constants
的用法示例。
在下文中一共展示了Constants.INDEX_TABLE_SUFFIX属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateIndexTableWhenIndexTableAlreadyExist
@Test(timeout = 180000)
public void testCreateIndexTableWhenIndexTableAlreadyExist() throws Exception {
HTableDescriptor iHtd =
TestUtils.createIndexedHTableDescriptor("testCreateIndexTableWhenIndexTableAlreadyExist", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.deleteTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWhenIndexTableAlreadyExist"));
String indexTableName =
"testCreateIndexTableWhenIndexTableAlreadyExist" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index table is not created.", admin.isTableAvailable(indexTableName));
}
示例2: testIndexTableCreationAfterMasterRestart
@Test(timeout = 180000)
public void testIndexTableCreationAfterMasterRestart() throws Exception {
HTableDescriptor iHtd =
TestUtils.createIndexedHTableDescriptor("testIndexTableCreationAfterMasterRestart", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
admin.deleteTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
cluster.abortMaster(0);
cluster.waitOnMaster(0);
// start up a new master
cluster.startMaster();
assertTrue(cluster.waitForActiveAndReadyMaster());
String indexTableName =
"testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例3: testCreateIndexTableWhenIndexTableAlreadyExist
@Test(timeout = 180000)
public void testCreateIndexTableWhenIndexTableAlreadyExist() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
IndexedHTableDescriptor iHtd =
createIndexedHTableDescriptor("testCreateIndexTableWhenIndexTableAlreadyExist", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.deleteTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWhenIndexTableAlreadyExist"));
String indexTableName =
"testCreateIndexTableWhenIndexTableAlreadyExist" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index table is not created.", admin.isTableAvailable(indexTableName));
}
示例4: testCreateIndexTableWithOutIndexDetails
@Test(timeout = 180000)
public void testCreateIndexTableWithOutIndexDetails() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
IndexedHTableDescriptor iHtd =
new IndexedHTableDescriptor("testCreateIndexTableWithOutIndexDetails");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWithOutIndexDetails"));
String indexTableName =
"testCreateIndexTableWithOutIndexDetails" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例5: testIndexTableCreationAfterMasterRestart
@Test(timeout = 180000)
public void testIndexTableCreationAfterMasterRestart() throws Exception {
HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
IndexedHTableDescriptor iHtd =
createIndexedHTableDescriptor("testIndexTableCreationAfterMasterRestart", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
admin.deleteTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
cluster.abortMaster(0);
cluster.waitOnMaster(0);
HMaster master = cluster.startMaster().getMaster();
cluster.waitForActiveAndReadyMaster();
String indexTableName =
"testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例6: checkEndsWithIndexSuffix
private void checkEndsWithIndexSuffix(TableName tableName) throws IOException {
if (IndexUtils.isIndexTable(tableName)) {
String message =
"User table name should not be ends with " + Constants.INDEX_TABLE_SUFFIX + '.';
LOG.error(message);
throw new DoNotRetryIOException(new IllegalArgumentException(message));
}
}
示例7: testCreateIndexTableWithOutIndexDetails
@Test(timeout = 180000)
public void testCreateIndexTableWithOutIndexDetails() throws Exception {
HTableDescriptor iHtd =
new HTableDescriptor(TableName.valueOf("testCreateIndexTableWithOutIndexDetails"));
TableIndices indices = new TableIndices();
iHtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWithOutIndexDetails"));
String indexTableName =
"testCreateIndexTableWithOutIndexDetails" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例8: checkEndsWithIndexSuffix
private void checkEndsWithIndexSuffix(String tableName) throws IOException {
if (tableName.endsWith(Constants.INDEX_TABLE_SUFFIX)) {
String message =
"User table name should not be ends with " + Constants.INDEX_TABLE_SUFFIX + '.';
LOG.error(message);
IllegalArgumentException ie = new IllegalArgumentException(message);
throw new IOException(ie);
}
}
示例9: testCreateIndexTableWhenExistedIndexTableDisabled
@Test(timeout = 180000)
public void testCreateIndexTableWhenExistedIndexTableDisabled() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
IndexedHTableDescriptor iHtd =
createIndexedHTableDescriptor("testCreateIndexTableWhenExistedIndexTableDisabled", "cf",
"index_name", "cf", "cq");
char c = 'A';
byte[][] split = new byte[20][];
for (int i = 0; i < 20; i++) {
byte[] b = { (byte) c };
split[i] = b;
c++;
}
admin.createTable(iHtd, split);
admin.disableTable("testCreateIndexTableWhenExistedIndexTableDisabled");
admin.deleteTable("testCreateIndexTableWhenExistedIndexTableDisabled");
iHtd =
createIndexedHTableDescriptor("testCreateIndexTableWhenExistedIndexTableDisabled", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWhenExistedIndexTableDisabled"));
String indexTableName =
"testCreateIndexTableWhenExistedIndexTableDisabled" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例10: getIndexTableName
/**
* Utility method to get the name of the index table when given the name of the actual table.
* @param tableName
* @return index table name
*/
public static String getIndexTableName(String tableName) {
// TODO The suffix for the index table is fixed now. Do we allow to make this configurable?
// We can handle things in byte[] way?
return tableName + Constants.INDEX_TABLE_SUFFIX;
}
示例11: testCheckAndPutFor1PutShouldHav2PutsInIndexTableAndShouldReplaceWithNewValue
@Test(timeout = 180000)
public void testCheckAndPutFor1PutShouldHav2PutsInIndexTableAndShouldReplaceWithNewValue()
throws Exception {
Configuration conf = UTIL.getConfiguration();
String userTableName = "testCheckAndPutContainingTheIndexedColumn";
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
ihtd.addFamily(hcd);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec);
ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
admin.createTable(ihtd);
String idxTableName = userTableName + Constants.INDEX_TABLE_SUFFIX;
HTable table = new HTable(conf, userTableName);
// test put with the indexed column
Put p = new Put("row1".getBytes());
p.add("col".getBytes(), "q1".getBytes(), "myValue".getBytes());
table.put(p);
int usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxtableCount);
// Test check and put
Put p1 = new Put("row1".getBytes());
p1.add("col".getBytes(), "q1".getBytes(), "myNewValue".getBytes());
Assert.assertTrue(table.checkAndPut("row1".getBytes(), "col".getBytes(), "q1".getBytes(),
"myValue".getBytes(), p1));
usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(2, idxtableCount);
Get get = new Get("row1".getBytes());
get.addColumn(Bytes.toBytes("col"), Bytes.toBytes("q1"));
Result result = table.get(get);
byte[] val = result.getValue(Bytes.toBytes("col"), Bytes.toBytes("q1"));
Assert.assertEquals("myNewValue", Bytes.toString(val));
}
示例12: testCheckAndDeleteShudDeleteTheRowSuccessfullyInBothIndexAndMainTable
@Test(timeout = 180000)
public void testCheckAndDeleteShudDeleteTheRowSuccessfullyInBothIndexAndMainTable()
throws Exception {
Configuration conf = UTIL.getConfiguration();
String userTableName = "testCheckAndDeleteContainingTheIndexedColumn";
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
ihtd.addFamily(hcd);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec);
ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
admin.createTable(ihtd);
String idxTableName = userTableName + Constants.INDEX_TABLE_SUFFIX;
HTable table = new HTable(conf, userTableName);
// test put with the indexed column
Put p = new Put("row1".getBytes());
p.add("col".getBytes(), "q1".getBytes(), "myValue".getBytes());
table.put(p);
int usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxtableCount);
Delete delete = new Delete("row1".getBytes());
delete.deleteFamily("col".getBytes());
// CheckandDelete
Assert.assertTrue(table.checkAndDelete("row1".getBytes(), "col".getBytes(), "q1".getBytes(),
"myValue".getBytes(), delete));
Get get = new Get("row1".getBytes());
get.addFamily("col".getBytes());
Result r = table.get(get);
Assert.assertEquals(0, r.size());
usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(0, usertableCount);
idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(0, idxtableCount);
}
示例13: testCheckAndPutFor1PutShouldHav2PutsInIndexTableAndShouldReplaceWithNewValue
@Test(timeout = 180000)
public void testCheckAndPutFor1PutShouldHav2PutsInIndexTableAndShouldReplaceWithNewValue()
throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
Configuration conf = UTIL.getConfiguration();
String userTableName = "testCheckAndPutContainingTheIndexedColumn";
IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
ihtd.addFamily(hcd);
ihtd.addIndex(iSpec);
admin.createTable(ihtd);
ZKAssign.blockUntilNoRIT(zkw);
String idxTableName = userTableName + Constants.INDEX_TABLE_SUFFIX;
HTable table = new HTable(conf, userTableName);
// test put with the indexed column
Put p = new Put("row1".getBytes());
p.add("col".getBytes(), "q1".getBytes(), "myValue".getBytes());
table.put(p);
int usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxtableCount);
// Test check and put
Put p1 = new Put("row1".getBytes());
p1.add("col".getBytes(), "q1".getBytes(), "myNewValue".getBytes());
Assert.assertTrue(table.checkAndPut("row1".getBytes(), "col".getBytes(), "q1".getBytes(),
"myValue".getBytes(), p1));
usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(2, idxtableCount);
Get get = new Get("row1".getBytes());
get.addColumn(Bytes.toBytes("col"), Bytes.toBytes("q1"));
Result result = table.get(get);
byte[] val = result.getValue(Bytes.toBytes("col"), Bytes.toBytes("q1"));
Assert.assertEquals("myNewValue", Bytes.toString(val));
}
示例14: testCheckAndDeleteShudDeleteTheRowSuccessfullyInBothIndexAndMainTable
@Test(timeout = 180000)
public void testCheckAndDeleteShudDeleteTheRowSuccessfullyInBothIndexAndMainTable()
throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
Configuration conf = UTIL.getConfiguration();
String userTableName = "testCheckAndDeleteContainingTheIndexedColumn";
IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
ihtd.addFamily(hcd);
ihtd.addIndex(iSpec);
admin.createTable(ihtd);
ZKAssign.blockUntilNoRIT(zkw);
String idxTableName = userTableName + Constants.INDEX_TABLE_SUFFIX;
HTable table = new HTable(conf, userTableName);
// test put with the indexed column
Put p = new Put("row1".getBytes());
p.add("col".getBytes(), "q1".getBytes(), "myValue".getBytes());
table.put(p);
int usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxtableCount);
Delete delete = new Delete("row1".getBytes());
delete.deleteFamily("col".getBytes());
// CheckandDelete
Assert.assertTrue(table.checkAndDelete("row1".getBytes(), "col".getBytes(), "q1".getBytes(),
"myValue".getBytes(), delete));
Get get = new Get("row1".getBytes());
get.addFamily("col".getBytes());
Result r = table.get(get);
Assert.assertEquals(0, r.size());
usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(0, usertableCount);
idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(0, idxtableCount);
}
示例15: testRowMutations
@Test(timeout = 180000)
public void testRowMutations() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
Configuration conf = UTIL.getConfiguration();
String userTableName = "testMutateRows";
IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10);
iSpec.addIndexColumn(hcd, "q2", ValueType.String, 10);
ihtd.addFamily(hcd);
ihtd.addIndex(iSpec);
admin.createTable(ihtd);
ZKAssign.blockUntilNoRIT(zkw);
String idxTableName = userTableName + Constants.INDEX_TABLE_SUFFIX;
HTable table = new HTable(conf, userTableName);
HTable idxtable = new HTable(conf, idxTableName);
byte[] row = Bytes.toBytes("rowA");
Put put = new Put(row);
put.add("col".getBytes(), "q2".getBytes(), "delValue".getBytes());
table.put(put);
int usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxtableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxtableCount);
RowMutations rm = new RowMutations(row);
Put p = new Put(row);
p.add("col".getBytes(), "q1".getBytes(), "q1value".getBytes());
rm.add(p);
Delete d = new Delete(row);
d.deleteColumns("col".getBytes(), "q2".getBytes());
rm.add(d);
// Mutate rows
table.mutateRow(rm);
admin.flush(userTableName);
admin.majorCompact(userTableName);
// Now after one put and one delete it shud be 1
usertableCount = countNumberOfRows(userTableName);
Assert.assertEquals(1, usertableCount);
int idxTableCount = countNumberOfRows(idxTableName);
Assert.assertEquals(1, idxTableCount);
Get get = new Get(row);
get.addFamily("col".getBytes());
Result r = table.get(get);
Assert.assertEquals(1, r.size());
String del = Bytes.toString(r.getValue("col".getBytes(), "q2".getBytes()));
Assert.assertNull(del);
String putval = Bytes.toString(r.getValue("col".getBytes(), "q1".getBytes()));
Assert.assertEquals("q1value", putval);
// Result of index table shud contain one keyvalue for "q1value" put only
Scan s = new Scan();
ResultScanner scanner = idxtable.getScanner(s);
Result result = scanner.next();
Assert.assertEquals(1, result.size());
String idxRow = Bytes.toString(result.getRow());
int len = IndexUtils.getMaxIndexNameLength() + "q1value".length();
String value = idxRow.substring(IndexUtils.getMaxIndexNameLength() + 1, len + 1);
// asserting value in idx table is for the put which has the value "q1value"
Assert.assertEquals("q1value", value);
}