HBASE-1391 NPE in TableInputFormatBase.restart if zoo.cfg is wrong or missing on tasktrackers
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@773825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58e206e9c8
commit
62b33ba910
|
@ -123,6 +123,8 @@ Release 0.20.0 - Unreleased
|
|||
Purtell)
|
||||
HBASE-1311 ZooKeeperWrapper: Failed to set watcher on ZNode /hbase/master
|
||||
(Nitay Joffe via Stack)
|
||||
HBASE-1391 NPE in TableInputFormatBase$TableRecordReader.restart if zoo.cfg
|
||||
is wrong or missing on task trackers
|
||||
|
||||
IMPROVEMENTS
|
||||
HBASE-1089 Add count of regions on filesystem to master UI; add percentage
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.apache.hadoop.mapred.FileInputFormat;
|
||||
import org.apache.hadoop.mapred.JobConf;
|
||||
import org.apache.hadoop.mapred.JobConfigurable;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Convert HBase tabular data into a format that is consumable by Map/Reduce.
|
||||
|
@ -58,7 +59,7 @@ public class TableInputFormat extends TableInputFormatBase implements
|
|||
try {
|
||||
setHTable(new HTable(new HBaseConfiguration(job), tableNames[0].getName()));
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
LOG.error(StringUtils.stringifyException(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +70,12 @@ public class TableInputFormat extends TableInputFormatBase implements
|
|||
throw new IOException("expecting one table name");
|
||||
}
|
||||
|
||||
// connected to table?
|
||||
if (getHTable() == null) {
|
||||
throw new IOException("could not connect to table '" +
|
||||
tableNames[0].getName() + "'");
|
||||
}
|
||||
|
||||
// expecting at least one column
|
||||
String colArg = job.get(COLUMN_LIST);
|
||||
if (colArg == null || colArg.length() == 0) {
|
||||
|
|
|
@ -304,6 +304,13 @@ implements InputFormat<ImmutableBytesWritable, RowResult> {
|
|||
this.inputColumns = inputColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows subclasses to get the {@link HTable}.
|
||||
*/
|
||||
protected HTable getHTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows subclasses to set the {@link HTable}.
|
||||
*
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package org.apache.hadoop.hbase.zookeeper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
@ -32,6 +34,7 @@ import org.apache.hadoop.hbase.HConstants;
|
|||
import org.apache.hadoop.hbase.HServerAddress;
|
||||
import org.apache.hadoop.hbase.HServerInfo;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.Watcher;
|
||||
|
@ -158,6 +161,7 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
|
||||
// The clientPort option may come after the server.X hosts, so we need to
|
||||
// grab everything and then create the final host:port comma separated list.
|
||||
boolean anyValid = false;
|
||||
for (Entry<Object,Object> property : properties.entrySet()) {
|
||||
String key = property.getKey().toString().trim();
|
||||
String value = property.getValue().toString().trim();
|
||||
|
@ -167,9 +171,20 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
else if (key.startsWith("server.")) {
|
||||
String host = value.substring(0, value.indexOf(':'));
|
||||
servers.add(host);
|
||||
try {
|
||||
InetAddress.getByName(host);
|
||||
anyValid = true;
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.warn(StringUtils.stringifyException(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyValid) {
|
||||
LOG.error("no valid quorum servers found in " + ZOOKEEPER_CONFIG_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clientPort == null) {
|
||||
LOG.error("no clientPort found in " + ZOOKEEPER_CONFIG_NAME);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue