Search in sources :

Example 1 with AbortTxnMessage

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);
}
Also used : AbortTxnMessage(org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage) ReplTxnWork(org.apache.hadoop.hive.ql.plan.ReplTxnWork) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Example 2 with AbortTxnMessage

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));
    }
}
Also used : SQLException(java.sql.SQLException) AbortTxnMessage(org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

AbortTxnMessage (org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage)2 SQLException (java.sql.SQLException)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1 ReplTxnWork (org.apache.hadoop.hive.ql.plan.ReplTxnWork)1