use of org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage in project hive by apache.
the class DbNotificationListener method onAllocWriteId.
/**
* @param allocWriteIdEvent Alloc write id event
* @throws MetaException
*/
@Override
public void onAllocWriteId(AllocWriteIdEvent allocWriteIdEvent, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
String tableName = allocWriteIdEvent.getTableName();
String dbName = allocWriteIdEvent.getDbName();
AllocWriteIdMessage msg = MessageBuilder.getInstance().buildAllocWriteIdMessage(allocWriteIdEvent.getTxnToWriteIdList(), dbName, tableName);
NotificationEvent event = new NotificationEvent(0, now(), EventType.ALLOC_WRITE_ID.toString(), msgEncoder.getSerializer().serialize(msg));
event.setTableName(tableName);
event.setDbName(dbName);
try {
addNotificationLog(event, allocWriteIdEvent, dbConn, sqlGenerator);
} catch (SQLException e) {
throw new MetaException("Unable to execute direct SQL " + StringUtils.stringifyException(e));
}
}
use of org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage in project hive by apache.
the class AllocWriteIdHandler method handle.
@Override
public List<Task<?>> handle(Context context) throws SemanticException {
if (!AcidUtils.isAcidEnabled(context.hiveConf)) {
context.log.error("Cannot load alloc write id event as acid is not enabled");
throw new SemanticException("Cannot load alloc write id event as acid is not enabled");
}
AllocWriteIdMessage msg = deserializer.getAllocWriteIdMessage(context.dmd.getPayload());
String dbName = (context.dbName != null && !context.dbName.isEmpty() ? context.dbName : msg.getDB());
// We need table name for alloc write id and that is received from source.
String tableName = msg.getTableName();
// Repl policy should be created based on the table name in context.
ReplTxnWork work = new ReplTxnWork(HiveUtils.getReplPolicy(context.dbName), dbName, tableName, ReplTxnWork.OperationType.REPL_ALLOC_WRITE_ID, msg.getTxnToWriteIdList(), context.eventOnlyReplicationSpec(), context.getDumpDirectory(), context.getMetricCollector());
Task<?> allocWriteIdTask = TaskFactory.get(work, context.hiveConf);
context.log.info("Added alloc write id task : {}", allocWriteIdTask.getId());
updatedMetadata.set(context.dmd.getEventTo().toString(), dbName, tableName, null);
return Collections.singletonList(allocWriteIdTask);
}
Aggregations