HBASE-15752 ClassNotFoundException is encountered when custom WAL codec is not found in WALPlayer job

This commit is contained in:
tedyu 2016-05-03 01:57:25 -07:00
parent c06a976a98
commit c77a153001
2 changed files with 8 additions and 1 deletions

View File

@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.regionserver.wal.WALCellCodec;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.wal.WALKey;
@ -292,6 +293,12 @@ public class WALPlayer extends Configured implements Tool {
// No reducers.
job.setNumReduceTasks(0);
}
String codecCls = WALCellCodec.getWALCellCodecClass(conf);
try {
TableMapReduceUtil.addDependencyJars(conf, Class.forName(codecCls));
} catch (Exception e) {
throw new IOException("Cannot determine wal codec class " + codecCls, e);
}
return job;
}

View File

@ -82,7 +82,7 @@ public class WALCellCodec implements Codec {
this.compression = compression;
}
static String getWALCellCodecClass(Configuration conf) {
public static String getWALCellCodecClass(Configuration conf) {
return conf.get(WAL_CELL_CODEC_CLASS_KEY, WALCellCodec.class.getName());
}