本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchColumnFamilyException类的具体用法?Java NoSuchColumnFamilyException怎么用?Java NoSuchColumnFamilyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchColumnFamilyException类属于org.apache.hadoop.hbase.regionserver包,在下文中一共展示了NoSuchColumnFamilyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleHBaseException
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
public static void handleHBaseException(
Throwable t,
Iterator<Record> records,
ErrorRecordHandler errorRecordHandler
) throws StageException {
Throwable cause = t;
// Drill down to root cause
while((cause instanceof UncheckedExecutionException || cause instanceof UndeclaredThrowableException ||
cause instanceof ExecutionException) && cause.getCause() != null) {
cause = cause.getCause();
}
// Column is null or No such Column Family exception
if(cause instanceof NullPointerException || cause instanceof NoSuchColumnFamilyException) {
while(records.hasNext()) {
Record record = records.next();
errorRecordHandler.onError(new OnRecordErrorException(record, Errors.HBASE_37, cause));
}
} else {
LOG.error(Errors.HBASE_36.getMessage(), cause.toString(), cause);
throw new StageException(Errors.HBASE_36, cause.toString(), cause);
}
}
示例2: testPutNoCF
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@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(Bytes.toBytes("testPutNoCF"), FAMILY);
boolean caughtNSCFE = false;
try {
Put p = new Put(ROW);
p.add(BAD_FAM, QUALIFIER, VAL);
table.put(p);
} catch (RetriesExhaustedWithDetailsException e) {
caughtNSCFE = e.getCause(0) instanceof NoSuchColumnFamilyException;
}
assertTrue("Should throw NoSuchColumnFamilyException", caughtNSCFE);
}
示例3: testPutNoCF
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testPutNoCF() throws IOException {
final byte[] BAD_FAM = Bytes.toBytes("BAD_CF");
final byte[] VAL = Bytes.toBytes(100);
HTable table = TEST_UTIL.createTable(Bytes.toBytes("testPutNoCF"), new byte[][]{FAMILY});
boolean caughtNSCFE = false;
try {
Put p = new Put(ROW);
p.add(BAD_FAM, QUALIFIER, VAL);
table.put(p);
} catch (RetriesExhaustedWithDetailsException e) {
caughtNSCFE = e.getCause(0) instanceof NoSuchColumnFamilyException;
}
assertTrue("Should throw NoSuchColumnFamilyException", caughtNSCFE);
}
示例4: testPutNoCF
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@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);
}
示例5: classifyExs
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
public static Map<String, Integer> classifyExs(List<Throwable> ths) {
Map<String, Integer> cls = new HashMap<String, Integer>();
for (Throwable t : ths) {
if (t == null) continue;
String name = "";
if (t instanceof NoSuchColumnFamilyException) {
name = t.getMessage();
} else {
name = t.getClass().getSimpleName();
}
Integer i = cls.get(name);
if (i == null) {
i = 0;
}
i += 1;
cls.put(name, i);
}
return cls;
}
示例6: processPutStatus
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Override
public boolean processPutStatus(MutationStatus operationStatus) throws IOException{
OperationStatus opStat = ((HMutationStatus)operationStatus).unwrapDelegate();
switch (opStat.getOperationStatusCode()) {
case NOT_RUN:
throw new IOException("Could not acquire Lock");
case BAD_FAMILY:
throw new NoSuchColumnFamilyException(opStat.getExceptionMsg());
case SANITY_CHECK_FAILURE:
throw new IOException("Sanity Check failure:" + opStat.getExceptionMsg());
case FAILURE:
throw new IOException(opStat.getExceptionMsg());
default:
return true;
}
}
示例7: testAtomicPut
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
@Category(KnownGap.class)
public void testAtomicPut() throws Exception {
Table table = getConnection().getTable(TABLE_NAME);
byte[] rowKey = Bytes.toBytes("testrow-" + RandomStringUtils.randomAlphanumeric(8));
byte[] goodQual = Bytes.toBytes("testQualifier-" + RandomStringUtils.randomAlphanumeric(8));
byte[] goodValue = Bytes.toBytes("testValue-" + RandomStringUtils.randomAlphanumeric(8));
byte[] badQual = Bytes.toBytes("testQualifier-" + RandomStringUtils.randomAlphanumeric(8));
byte[] badValue = Bytes.toBytes("testValue-" + RandomStringUtils.randomAlphanumeric(8));
byte[] badfamily = Bytes.toBytes("badcolumnfamily-" + RandomStringUtils.randomAlphanumeric(8));
Put put = new Put(rowKey);
put.addColumn(COLUMN_FAMILY, goodQual, goodValue);
put.addColumn(badfamily, badQual, badValue);
RetriesExhaustedWithDetailsException thrownException = null;
try {
table.put(put);
} catch (RetriesExhaustedWithDetailsException e) {
thrownException = e;
}
Assert.assertNotNull("Exception should have been thrown", thrownException);
Assert.assertEquals("Expecting one exception", 1, thrownException.getNumExceptions());
Assert.assertArrayEquals("Row key", rowKey, thrownException.getRow(0).getRow());
Assert.assertTrue("Cause: NoSuchColumnFamilyException",
thrownException.getCause(0) instanceof NoSuchColumnFamilyException);
Get get = new Get(rowKey);
Result result = table.get(get);
Assert.assertEquals("Atomic behavior means there should be nothing here", 0, result.size());
table.close();
}
示例8: testScanWrongColumnFamily
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testScanWrongColumnFamily() throws Exception {
try {
doScan(createScan().addFamily(Bytes.toBytes("WrongColumnFamily")));
} catch (Exception e) {
assertTrue(e instanceof NoSuchColumnFamilyException ||
e.getCause() instanceof NoSuchColumnFamilyException);
}
}
示例9: testCheckAndMutate
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testCheckAndMutate() throws Throwable {
try (Table table = createTable()) {
// put one row
putOneRow(table);
// get row back and assert the values
getOneRowAndAssertAllExist(table);
// put the same row again with C column deleted
RowMutations rm = makeRowMutationsWithColumnCDeleted();
boolean res = table.checkAndMutate(ROWKEY, FAMILY).qualifier(Bytes.toBytes("A"))
.ifEquals(Bytes.toBytes("a")).thenMutate(rm);
assertTrue(res);
// get row back and assert the values
getOneRowAndAssertAllButCExist(table);
//Test that we get a region level exception
try {
rm = getBogusRowMutations();
table.checkAndMutate(ROWKEY, FAMILY).qualifier(Bytes.toBytes("A"))
.ifEquals(Bytes.toBytes("a")).thenMutate(rm);
fail("Expected NoSuchColumnFamilyException");
} catch (RetriesExhaustedWithDetailsException e) {
try {
throw e.getCause(0);
} catch (NoSuchColumnFamilyException e1) {
// expected
}
}
}
}
示例10: testCheckAndMutateWithBuilder
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testCheckAndMutateWithBuilder() throws Throwable {
try (Table table = createTable()) {
// put one row
putOneRow(table);
// get row back and assert the values
getOneRowAndAssertAllExist(table);
// put the same row again with C column deleted
RowMutations rm = makeRowMutationsWithColumnCDeleted();
boolean res = table.checkAndMutate(ROWKEY, FAMILY).qualifier(Bytes.toBytes("A"))
.ifEquals(Bytes.toBytes("a")).thenMutate(rm);
assertTrue(res);
// get row back and assert the values
getOneRowAndAssertAllButCExist(table);
//Test that we get a region level exception
try {
rm = getBogusRowMutations();
table.checkAndMutate(ROWKEY, FAMILY).qualifier(Bytes.toBytes("A"))
.ifEquals(Bytes.toBytes("a")).thenMutate(rm);
fail("Expected NoSuchColumnFamilyException");
} catch (RetriesExhaustedWithDetailsException e) {
try {
throw e.getCause(0);
} catch (NoSuchColumnFamilyException e1) {
// expected
}
}
}
}
示例11: testRestoreSchemaChange
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testRestoreSchemaChange() throws Exception {
byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");
HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
// Add one column family and put some data in it
admin.disableTable(tableName);
admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
admin.enableTable(tableName);
assertEquals(2, table.getTableDescriptor().getFamilies().size());
HTableDescriptor htd = admin.getTableDescriptor(tableName);
assertEquals(2, htd.getFamilies().size());
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, TEST_FAMILY2);
long snapshot2Rows = snapshot1Rows + 500;
assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
Set<String> fsFamilies = getFamiliesFromFS(tableName);
assertEquals(2, fsFamilies.size());
// Take a snapshot
admin.disableTable(tableName);
admin.snapshot(snapshotName2, tableName);
// Restore the snapshot (without the cf)
admin.restoreSnapshot(snapshotName0);
admin.enableTable(tableName);
assertEquals(1, table.getTableDescriptor().getFamilies().size());
try {
TEST_UTIL.countRows(table, TEST_FAMILY2);
fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
} catch (NoSuchColumnFamilyException e) {
// expected
}
assertEquals(snapshot0Rows, TEST_UTIL.countRows(table));
htd = admin.getTableDescriptor(tableName);
assertEquals(1, htd.getFamilies().size());
fsFamilies = getFamiliesFromFS(tableName);
assertEquals(1, fsFamilies.size());
// Restore back the snapshot (with the cf)
admin.disableTable(tableName);
admin.restoreSnapshot(snapshotName2);
admin.enableTable(tableName);
htd = admin.getTableDescriptor(tableName);
assertEquals(2, htd.getFamilies().size());
assertEquals(2, table.getTableDescriptor().getFamilies().size());
assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
fsFamilies = getFamiliesFromFS(tableName);
assertEquals(2, fsFamilies.size());
table.close();
}
示例12: testRowMutation
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testRowMutation() throws Exception {
LOG.info("Starting testRowMutation");
final TableName TABLENAME = TableName.valueOf("testRowMutation");
Table t = TEST_UTIL.createTable(TABLENAME, FAMILY);
byte [][] QUALIFIERS = new byte [][] {
Bytes.toBytes("a"), Bytes.toBytes("b")
};
RowMutations arm = new RowMutations(ROW);
Put p = new Put(ROW);
p.add(FAMILY, QUALIFIERS[0], VALUE);
arm.add(p);
t.mutateRow(arm);
Get g = new Get(ROW);
Result r = t.get(g);
assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIERS[0])));
arm = new RowMutations(ROW);
p = new Put(ROW);
p.add(FAMILY, QUALIFIERS[1], VALUE);
arm.add(p);
Delete d = new Delete(ROW);
d.deleteColumns(FAMILY, QUALIFIERS[0]);
arm.add(d);
// TODO: Trying mutateRow again. The batch was failing with a one try only.
t.mutateRow(arm);
r = t.get(g);
assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIERS[1])));
assertNull(r.getValue(FAMILY, QUALIFIERS[0]));
//Test that we get a region level exception
try {
arm = new RowMutations(ROW);
p = new Put(ROW);
p.add(new byte[]{'b', 'o', 'g', 'u', 's'}, QUALIFIERS[0], VALUE);
arm.add(p);
t.mutateRow(arm);
fail("Expected NoSuchColumnFamilyException");
} catch(NoSuchColumnFamilyException e) {
}
}
示例13: testCheckAndMutate
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testCheckAndMutate() throws Exception {
final TableName tableName = TableName.valueOf("TestPutWithDelete");
final byte[] rowKey = Bytes.toBytes("12345");
final byte[] family = Bytes.toBytes("cf");
HTable table = TEST_UTIL.createTable(tableName, family);
TEST_UTIL.waitTableAvailable(tableName.getName(), 5000);
try {
// put one row
Put put = new Put(rowKey);
put.add(family, Bytes.toBytes("A"), Bytes.toBytes("a"));
put.add(family, Bytes.toBytes("B"), Bytes.toBytes("b"));
put.add(family, Bytes.toBytes("C"), Bytes.toBytes("c"));
table.put(put);
// get row back and assert the values
Get get = new Get(rowKey);
Result result = table.get(get);
assertTrue("Column A value should be a",
Bytes.toString(result.getValue(family, Bytes.toBytes("A"))).equals("a"));
assertTrue("Column B value should be b",
Bytes.toString(result.getValue(family, Bytes.toBytes("B"))).equals("b"));
assertTrue("Column C value should be c",
Bytes.toString(result.getValue(family, Bytes.toBytes("C"))).equals("c"));
// put the same row again with C column deleted
RowMutations rm = new RowMutations(rowKey);
put = new Put(rowKey);
put.add(family, Bytes.toBytes("A"), Bytes.toBytes("a"));
put.add(family, Bytes.toBytes("B"), Bytes.toBytes("b"));
rm.add(put);
Delete del = new Delete(rowKey);
del.deleteColumn(family, Bytes.toBytes("C"));
rm.add(del);
boolean res = table.checkAndMutate(rowKey, family, Bytes.toBytes("A"), CompareFilter.CompareOp.EQUAL,
Bytes.toBytes("a"), rm);
assertTrue(res);
// get row back and assert the values
get = new Get(rowKey);
result = table.get(get);
assertTrue("Column A value should be a",
Bytes.toString(result.getValue(family, Bytes.toBytes("A"))).equals("a"));
assertTrue("Column B value should be b",
Bytes.toString(result.getValue(family, Bytes.toBytes("B"))).equals("b"));
assertTrue("Column C should not exist",
result.getValue(family, Bytes.toBytes("C")) == null);
//Test that we get a region level exception
try {
Put p = new Put(rowKey);
p.add(new byte[]{'b', 'o', 'g', 'u', 's'}, new byte[]{'A'}, new byte[0]);
rm = new RowMutations(rowKey);
rm.add(p);
table.checkAndMutate(rowKey, family, Bytes.toBytes("A"), CompareFilter.CompareOp.EQUAL,
Bytes.toBytes("a"), rm);
fail("Expected NoSuchColumnFamilyException");
} catch(NoSuchColumnFamilyException e) {
}
} finally {
table.close();
}
}
示例14: processException
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
protected Response processException(Throwable exp) {
Throwable curr = exp;
if(accessDeniedClazz != null) {
//some access denied exceptions are buried
while (curr != null) {
if(accessDeniedClazz.isAssignableFrom(curr.getClass())) {
throw new WebApplicationException(
Response.status(Response.Status.FORBIDDEN)
.type(MIMETYPE_TEXT).entity("Forbidden" + CRLF +
StringUtils.stringifyException(exp) + CRLF)
.build());
}
curr = curr.getCause();
}
}
//TableNotFound may also be buried one level deep
if (exp instanceof TableNotFoundException ||
exp.getCause() instanceof TableNotFoundException) {
throw new WebApplicationException(
Response.status(Response.Status.NOT_FOUND)
.type(MIMETYPE_TEXT).entity("Not found" + CRLF +
StringUtils.stringifyException(exp) + CRLF)
.build());
}
if (exp instanceof NoSuchColumnFamilyException){
throw new WebApplicationException(
Response.status(Response.Status.NOT_FOUND)
.type(MIMETYPE_TEXT).entity("Not found" + CRLF +
StringUtils.stringifyException(exp) + CRLF)
.build());
}
if (exp instanceof RuntimeException) {
throw new WebApplicationException(
Response.status(Response.Status.BAD_REQUEST)
.type(MIMETYPE_TEXT).entity("Bad request" + CRLF +
StringUtils.stringifyException(exp) + CRLF)
.build());
}
if (exp instanceof RetriesExhaustedWithDetailsException) {
RetriesExhaustedWithDetailsException retryException =
(RetriesExhaustedWithDetailsException) exp;
processException(retryException.getCause(0));
}
throw new WebApplicationException(
Response.status(Response.Status.SERVICE_UNAVAILABLE)
.type(MIMETYPE_TEXT).entity("Unavailable" + CRLF +
StringUtils.stringifyException(exp) + CRLF)
.build());
}
示例15: testRestoreSchemaChange
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; //导入依赖的package包/类
@Test
public void testRestoreSchemaChange() throws Exception {
byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");
HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
// Add one column family and put some data in it
admin.disableTable(tableName);
admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
admin.enableTable(tableName);
assertEquals(2, table.getTableDescriptor().getFamilies().size());
HTableDescriptor htd = admin.getTableDescriptor(tableName);
assertEquals(2, htd.getFamilies().size());
SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, TEST_FAMILY2);
long snapshot2Rows = snapshot1Rows + 500;
assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
Set<String> fsFamilies = getFamiliesFromFS(tableName);
assertEquals(2, fsFamilies.size());
table.close();
// Take a snapshot
admin.disableTable(tableName);
admin.snapshot(snapshotName2, tableName);
// Restore the snapshot (without the cf)
admin.restoreSnapshot(snapshotName0);
assertEquals(1, table.getTableDescriptor().getFamilies().size());
admin.enableTable(tableName);
try {
TEST_UTIL.countRows(table, TEST_FAMILY2);
fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
} catch (NoSuchColumnFamilyException e) {
// expected
}
assertEquals(snapshot0Rows, TEST_UTIL.countRows(table));
htd = admin.getTableDescriptor(tableName);
assertEquals(1, htd.getFamilies().size());
fsFamilies = getFamiliesFromFS(tableName);
assertEquals(1, fsFamilies.size());
table.close();
// Restore back the snapshot (with the cf)
admin.disableTable(tableName);
admin.restoreSnapshot(snapshotName2);
admin.enableTable(tableName);
htd = admin.getTableDescriptor(tableName);
assertEquals(2, htd.getFamilies().size());
assertEquals(2, table.getTableDescriptor().getFamilies().size());
assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
fsFamilies = getFamiliesFromFS(tableName);
assertEquals(2, fsFamilies.size());
table.close();
}