HBASE-5472 LoadIncrementalHFiles loops forever if the target table misses a CF -- RE-RE-APPLY
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1471248 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df95e96647
commit
d11a58116c
|
@ -220,6 +220,27 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
Deque<LoadQueueItem> queue = new LinkedList<LoadQueueItem>();
|
||||
try {
|
||||
discoverLoadQueue(queue, hfofDir);
|
||||
// check whether there is invalid family name in HFiles to be bulkloaded
|
||||
Collection<HColumnDescriptor> families = table.getTableDescriptor().getFamilies();
|
||||
ArrayList<String> familyNames = new ArrayList<String>();
|
||||
for (HColumnDescriptor family : families) {
|
||||
familyNames.add(family.getNameAsString());
|
||||
}
|
||||
ArrayList<String> unmatchedFamilies = new ArrayList<String>();
|
||||
for (LoadQueueItem lqi : queue) {
|
||||
String familyNameInHFile = Bytes.toString(lqi.family);
|
||||
if (!familyNames.contains(familyNameInHFile)) {
|
||||
unmatchedFamilies.add(familyNameInHFile);
|
||||
}
|
||||
}
|
||||
if (unmatchedFamilies.size() > 0) {
|
||||
String msg =
|
||||
"Unmatched family names found: unmatched family names in HFiles to be bulkloaded: "
|
||||
+ unmatchedFamilies + "; valid family names of table "
|
||||
+ Bytes.toString(table.getTableName()) + " are: " + familyNames;
|
||||
LOG.error(msg);
|
||||
throw new IOException(msg);
|
||||
}
|
||||
int count = 0;
|
||||
|
||||
if (queue.isEmpty()) {
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.junit.experimental.categories.Category;
|
|||
public class TestLoadIncrementalHFiles {
|
||||
private static final byte[] QUALIFIER = Bytes.toBytes("myqual");
|
||||
private static final byte[] FAMILY = Bytes.toBytes("myfam");
|
||||
private static final String EXPECTED_MSG_FOR_NON_EXISTING_FAMILY = "Unmatched family names found";
|
||||
|
||||
private static final byte[][] SPLIT_KEYS = new byte[][] {
|
||||
Bytes.toBytes("ddd"),
|
||||
|
@ -188,6 +189,11 @@ public class TestLoadIncrementalHFiles {
|
|||
|
||||
HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
|
||||
HTableDescriptor htd = new HTableDescriptor(TABLE);
|
||||
// set real family name to upper case in purpose to simulate the case that
|
||||
// family name in HFiles is invalid
|
||||
HColumnDescriptor family =
|
||||
new HColumnDescriptor(Bytes.toBytes(new String(FAMILY).toUpperCase()));
|
||||
htd.addFamily(family);
|
||||
admin.createTable(htd, SPLIT_KEYS);
|
||||
|
||||
HTable table = new HTable(util.getConfiguration(), TABLE);
|
||||
|
@ -198,6 +204,11 @@ public class TestLoadIncrementalHFiles {
|
|||
assertTrue("Loading into table with non-existent family should have failed", false);
|
||||
} catch (Exception e) {
|
||||
assertTrue("IOException expected", e instanceof IOException);
|
||||
// further check whether the exception message is correct
|
||||
String errMsg = e.getMessage();
|
||||
assertTrue("Incorrect exception message, expected message: ["
|
||||
+ EXPECTED_MSG_FOR_NON_EXISTING_FAMILY + "], current message: [" + errMsg + "]",
|
||||
errMsg.contains(EXPECTED_MSG_FOR_NON_EXISTING_FAMILY));
|
||||
}
|
||||
table.close();
|
||||
admin.close();
|
||||
|
|
Loading…
Reference in New Issue