use of org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage in project hive by apache.
the class OpenTxnHandler 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");
}
OpenTxnMessage msg = deserializer.getOpenTxnMessage(context.dmd.getPayload());
Task<ReplTxnWork> openTxnTask = TaskFactory.get(new ReplTxnWork(HiveUtils.getReplPolicy(context.dbName), context.dbName, null, msg.getTxnIds(), ReplTxnWork.OperationType.REPL_OPEN_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 Open txn task : {}", openTxnTask.getId());
return Collections.singletonList(openTxnTask);
}
use of org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage in project hive by apache.
the class DbNotificationListener method onOpenTxn.
@Override
public void onOpenTxn(OpenTxnEvent openTxnEvent, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
if (openTxnEvent.getTxnType() == TxnType.READ_ONLY) {
return;
}
int lastTxnIdx = openTxnEvent.getTxnIds().size() - 1;
OpenTxnMessage msg = MessageBuilder.getInstance().buildOpenTxnMessage(openTxnEvent.getTxnIds().get(0), openTxnEvent.getTxnIds().get(lastTxnIdx));
NotificationEvent event = new NotificationEvent(0, now(), EventType.OPEN_TXN.toString(), msgEncoder.getSerializer().serialize(msg));
try {
addNotificationLog(event, openTxnEvent, dbConn, sqlGenerator);
} catch (SQLException e) {
throw new MetaException("Unable to execute direct SQL " + StringUtils.stringifyException(e));
}
}
Aggregations