HBASE-2897 RowResultGenerator should handle NoSuchColumnFamilyException

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@983493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2010-08-08 23:29:53 +00:00
parent f4ed3cd699
commit 0530905854
4 changed files with 27 additions and 1 deletions

View File

@ -471,6 +471,7 @@ Release 0.21.0 - Unreleased
HBASE-2901 HBASE-2461 broke build HBASE-2901 HBASE-2461 broke build
HBASE-2823 Entire Row Deletes not stored in Row+Col Bloom HBASE-2823 Entire Row Deletes not stored in Row+Col Bloom
(Alexander Georgiev via Stack) (Alexander Georgiev via Stack)
HBASE-2897 RowResultGenerator should handle NoSuchColumnFamilyException
IMPROVEMENTS IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -24,6 +24,9 @@ import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Get;
@ -31,8 +34,11 @@ import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool; import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
public class RowResultGenerator extends ResultGenerator { public class RowResultGenerator extends ResultGenerator {
private static final Log LOG = LogFactory.getLog(RowResultGenerator.class);
private Iterator<KeyValue> valuesI; private Iterator<KeyValue> valuesI;
private KeyValue cache; private KeyValue cache;
@ -67,6 +73,14 @@ public class RowResultGenerator extends ResultGenerator {
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
valuesI = result.list().iterator(); valuesI = result.list().iterator();
} }
} catch (NoSuchColumnFamilyException e) {
// Warn here because Stargate will return 404 in the case if multiple
// column families were specified but one did not exist -- currently
// HBase will fail the whole Get.
// Specifying multiple columns in a URI should be uncommon usage but
// help to avoid confusion by leaving a record of what happened here in
// the log.
LOG.warn(StringUtils.stringifyException(e));
} finally { } finally {
pool.putTable(table); pool.putTable(table);
} }

View File

@ -143,7 +143,7 @@ public class Client {
int code = httpClient.executeMethod(method); int code = httpClient.executeMethod(method);
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug(method.getName() + " " + uri + ": " + code + " " + LOG.debug(method.getName() + " " + uri + " " + code + " " +
method.getStatusText() + " in " + (endTime - startTime) + " ms"); method.getStatusText() + " in " + (endTime - startTime) + " ms");
} }
return code; return code;

View File

@ -312,6 +312,17 @@ public class TestRowResource extends HBaseRESTClusterTestBase {
checkValueXML(TABLE, encodedKey, COLUMN_2, VALUE_2); checkValueXML(TABLE, encodedKey, COLUMN_2, VALUE_2);
} }
public void testNoSuchCF() throws IOException, JAXBException {
final String goodPath = "/" + TABLE + "/" + ROW_1 + "/" + CFA;
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
Response response = client.post(goodPath, MIMETYPE_BINARY,
Bytes.toBytes(VALUE_1));
assertEquals(response.getCode(), 200);
assertEquals(client.get(goodPath, MIMETYPE_BINARY).getCode(), 200);
assertEquals(client.get(badPath, MIMETYPE_BINARY).getCode(), 404);
assertEquals(client.get(goodPath, MIMETYPE_BINARY).getCode(), 200);
}
void doTestMultiCellGetPutXML() throws IOException, JAXBException { void doTestMultiCellGetPutXML() throws IOException, JAXBException {
String path = "/" + TABLE + "/fakerow"; // deliberate nonexistent row String path = "/" + TABLE + "/fakerow"; // deliberate nonexistent row