getPrintStream().println("Parsing table layout: " + mLayout);
final Path path = new Path(mLayout);
final FileSystem fs =
fileSystemSpecified(path) ? path.getFileSystem(getConf()) : FileSystem.getLocal(getConf());
final FSDataInputStream inputStream = fs.open(path);
final TableLayoutDesc tableLayout = KijiTableLayout.readTableLayoutDescFromJSON(inputStream);
final String tableName = tableLayout.getName();
Preconditions.checkArgument(
(mTableURI.getTable() == null) || tableName.equals(mTableURI.getTable()),
"Table name '%s' does not match URI %s", tableName, mTableURI);
// For large numbers of initial regions, table creation may take a long time as we wait for
// the new regions to come online. Increase the hbase RPC timeout to compensate.
int hbaseTimeout = getConf().getInt("hbase.rpc.timeout", 60000);
hbaseTimeout = hbaseTimeout * 10;
getConf().setInt("hbase.rpc.timeout", hbaseTimeout);
getPrintStream().println("Creating Kiji table " + mTableURI);
if (mNumRegions >= 1) {
// Create a table with an initial number of evenly split regions.
mKiji.createTable(tableLayout, mNumRegions);
} else if (!mSplitKeyFilePath.isEmpty()) {
switch (KijiTableLayout.getEncoding(tableLayout.getKeysFormat())) {
case HASH:
case HASH_PREFIX:
throw new IllegalArgumentException(
"Row key hashing is enabled for the table. Use --num-regions=N instead.");
case RAW:
break;
case FORMATTED:
// TODO Support pre-splitting tables for FORMATTED RKF
// (https://jira.kiji.org/browse/SCHEMA-172)
throw new RuntimeException("CLI support for FORMATTED row keys is not yet available");
default:
throw new RuntimeException(
"Unexpected row key encoding: "
+ KijiTableLayout.getEncoding(tableLayout.getKeysFormat()));
}
// Open the split key file.
final Path splitKeyFilePath = new Path(mSplitKeyFilePath);
final FileSystem splitKeyPathFs = fileSystemSpecified(splitKeyFilePath)
? splitKeyFilePath.getFileSystem(getConf())