// Populate RM transaction in OutputJobInfo
// In case of bulk mode, populate intermediate output location
Map<String, String> tableJobProperties = tableDesc.getJobProperties();
String jobString = tableJobProperties.get(HCatConstants.HCAT_KEY_OUTPUT_INFO);
try {
OutputJobInfo outputJobInfo = (OutputJobInfo) HCatUtil.deserialize(jobString);
HCatTableInfo tableInfo = outputJobInfo.getTableInfo();
String qualifiedTableName = HBaseHCatStorageHandler.getFullyQualifiedHBaseTableName(tableInfo);
jobProperties.put(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY, qualifiedTableName);
jobProperties.put(TableOutputFormat.OUTPUT_TABLE, qualifiedTableName);
Configuration jobConf = getJobConf();
addResources(jobConf, jobProperties);
Configuration copyOfConf = new Configuration(jobConf);
HBaseConfiguration.addHbaseResources(copyOfConf);
String txnString = outputJobInfo.getProperties().getProperty(
HBaseConstants.PROPERTY_WRITE_TXN_KEY);
Transaction txn = null;
if (txnString == null) {
txn = HBaseRevisionManagerUtil.beginWriteTransaction(qualifiedTableName, tableInfo,
RevisionManagerConfiguration.create(copyOfConf));
String serializedTxn = HCatUtil.serialize(txn);
outputJobInfo.getProperties().setProperty(HBaseConstants.PROPERTY_WRITE_TXN_KEY,
serializedTxn);
} else {
txn = (Transaction) HCatUtil.deserialize(txnString);
}
if (isBulkMode(outputJobInfo)) {
String tableLocation = tableInfo.getTableLocation();
String location = new Path(tableLocation, "REVISION_" + txn.getRevisionNumber())
.toString();
outputJobInfo.getProperties().setProperty(PROPERTY_INT_OUTPUT_LOCATION, location);
// We are writing out an intermediate sequenceFile hence
// location is not passed in OutputJobInfo.getLocation()
// TODO replace this with a mapreduce constant when available
jobProperties.put("mapred.output.dir", location);
jobProperties.put("mapred.output.committer.class", HBaseBulkOutputCommitter.class.getName());