use of org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage in project hive by apache.
the class AbortTxnHandler method handle.
@Override
public List<Task<?>> handle(Context context) throws SemanticException {
if (!AcidUtils.isAcidEnabled(context.hiveConf)) {
context.log.error("Cannot load transaction events as acid is not enabled");
throw new SemanticException("Cannot load transaction events as acid is not enabled");
}
AbortTxnMessage msg = deserializer.getAbortTxnMessage(context.dmd.getPayload());
Task<ReplTxnWork> abortTxnTask = TaskFactory.get(new ReplTxnWork(HiveUtils.getReplPolicy(context.dbName), context.dbName, null, msg.getTxnId(), ReplTxnWork.OperationType.REPL_ABORT_TXN, context.eventOnlyReplicationSpec(), context.getDumpDirectory(), context.getMetricCollector()), context.hiveConf);
// Anyways, if this event gets executed again, it is taken care of.
if (!context.isDbNameEmpty()) {
updatedMetadata.set(context.dmd.getEventTo().toString(), context.dbName, null, null);
}
context.log.debug("Added Abort txn task : {}", abortTxnTask.getId());
return Collections.singletonList(abortTxnTask);
}
use of org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage in project hive by apache.
the class DbNotificationListener method onAbortTxn.
@Override
public void onAbortTxn(AbortTxnEvent abortTxnEvent, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
if (abortTxnEvent.getTxnType() == TxnType.READ_ONLY) {
return;
}
AbortTxnMessage msg = MessageBuilder.getInstance().buildAbortTxnMessage(abortTxnEvent.getTxnId());
NotificationEvent event = new NotificationEvent(0, now(), EventType.ABORT_TXN.toString(), msgEncoder.getSerializer().serialize(msg));
try {
addNotificationLog(event, abortTxnEvent, dbConn, sqlGenerator);
} catch (SQLException e) {
throw new MetaException("Unable to execute direct SQL " + StringUtils.stringifyException(e));
}
}
Aggregations