/** * Send altered table notifications. Subscribers can receive these notifications for * dropped tables by listening on topic "HCAT" with message selector string * {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_EVENT} = * {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_ALTER_TABLE_EVENT} */ @Override public void onAlterTable(AlterTableEvent tableEvent) throws MetaException { if (tableEvent.getStatus()) { Table before = tableEvent.getOldTable(); Table after = tableEvent.getNewTable(); // onCreateTable alters the table to add the topic name. Since this class is generating // that alter, we don't want to notify on that alter. So take a quick look and see if // that's what this this alter is, and if so swallow it. if (after.getParameters() != null && after.getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME) != null && (before.getParameters() == null || before.getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME) == null)) { return; } // I think this is wrong, the alter table statement should come on the table topic not the // DB topic - Alan. String topicName = getTopicPrefix(tableEvent.getIHMSHandler().getConf()) + "." + after.getDbName().toLowerCase(); send(messageFactory.buildAlterTableMessage(before, after, tableEvent.getWriteId()), topicName); } }
/** * @param tableEvent alter table event * @throws MetaException */ @Override public void onAlterTable(AlterTableEvent tableEvent) throws MetaException { Table before = tableEvent.getOldTable(); Table after = tableEvent.getNewTable(); AlterTableMessage msg = MessageBuilder.getInstance() .buildAlterTableMessage(before, after, tableEvent.getIsTruncateOp(), tableEvent.getWriteId()); NotificationEvent event = new NotificationEvent(0, now(), EventType.ALTER_TABLE.toString(), msgEncoder.getSerializer().serialize(msg) ); event.setCatName(after.isSetCatName() ? after.getCatName() : DEFAULT_CATALOG_NAME); event.setDbName(after.getDbName()); event.setTableName(after.getTableName()); process(event, tableEvent); }