Search in sources :

Example 1 with OpenTxnMessage

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

Example 2 with OpenTxnMessage

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

Aggregations

OpenTxnMessage (org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage)2 SQLException (java.sql.SQLException)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)1 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)1 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)1 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)1 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1 ReplTxnWork (org.apache.hadoop.hive.ql.plan.ReplTxnWork)1