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:
Andrew Kyle Purtell 2009-05-12 08:54:05 +00:00
parent 58e206e9c8
commit 62b33ba910
4 changed files with 32 additions and 1 deletions

View File

@ -123,6 +123,8 @@ Release 0.20.0 - Unreleased
Purtell) Purtell)
HBASE-1311 ZooKeeperWrapper: Failed to set watcher on ZNode /hbase/master HBASE-1311 ZooKeeperWrapper: Failed to set watcher on ZNode /hbase/master
(Nitay Joffe via Stack) (Nitay Joffe via Stack)
HBASE-1391 NPE in TableInputFormatBase$TableRecordReader.restart if zoo.cfg
is wrong or missing on task trackers
IMPROVEMENTS IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapred.FileInputFormat; import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.JobConfigurable; 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. * Convert HBase tabular data into a format that is consumable by Map/Reduce.
@ -58,7 +59,7 @@ public class TableInputFormat extends TableInputFormatBase implements
try { try {
setHTable(new HTable(new HBaseConfiguration(job), tableNames[0].getName())); setHTable(new HTable(new HBaseConfiguration(job), tableNames[0].getName()));
} catch (Exception e) { } 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"); 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 // expecting at least one column
String colArg = job.get(COLUMN_LIST); String colArg = job.get(COLUMN_LIST);
if (colArg == null || colArg.length() == 0) { if (colArg == null || colArg.length() == 0) {

View File

@ -304,6 +304,13 @@ implements InputFormat<ImmutableBytesWritable, RowResult> {
this.inputColumns = inputColumns; this.inputColumns = inputColumns;
} }
/**
* Allows subclasses to get the {@link HTable}.
*/
protected HTable getHTable() {
return this.table;
}
/** /**
* Allows subclasses to set the {@link HTable}. * Allows subclasses to set the {@link HTable}.
* *

View File

@ -20,6 +20,8 @@
package org.apache.hadoop.hbase.zookeeper; package org.apache.hadoop.hbase.zookeeper;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; 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.HServerAddress;
import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.StringUtils;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Watcher; 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 // 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. // grab everything and then create the final host:port comma separated list.
boolean anyValid = false;
for (Entry<Object,Object> property : properties.entrySet()) { for (Entry<Object,Object> property : properties.entrySet()) {
String key = property.getKey().toString().trim(); String key = property.getKey().toString().trim();
String value = property.getValue().toString().trim(); String value = property.getValue().toString().trim();
@ -167,8 +171,19 @@ public class ZooKeeperWrapper implements HConstants {
else if (key.startsWith("server.")) { else if (key.startsWith("server.")) {
String host = value.substring(0, value.indexOf(':')); String host = value.substring(0, value.indexOf(':'));
servers.add(host); 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) { if (clientPort == null) {
LOG.error("no clientPort found in " + ZOOKEEPER_CONFIG_NAME); LOG.error("no clientPort found in " + ZOOKEEPER_CONFIG_NAME);