/** * 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); } }
@Test public void testAlterTable() throws IOException { Table t = new Table(); t.setDbName("testdb"); t.setTableName("testtable"); NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_ALTER_TABLE_EVENT, msgFactory.buildAlterTableMessage(t, t, t.getWriteId()).toString()); event.setDbName(t.getDbName()); event.setTableName(t.getTableName()); HCatNotificationEvent hev = new HCatNotificationEvent(event); ReplicationTask rtask = ReplicationTask.create(client,hev); assertEquals(hev.toString(), rtask.getEvent().toString()); verifyAlterTableReplicationTask(rtask); }
/** * @param tableEvent alter table event * @throws MetaException */ public void onAlterTable (AlterTableEvent tableEvent) throws MetaException { Table before = tableEvent.getOldTable(); Table after = tableEvent.getNewTable(); NotificationEvent event = new NotificationEvent(0, now(), HCatConstants.HCAT_ALTER_TABLE_EVENT, msgFactory.buildAlterTableMessage(before, after).toString()); event.setDbName(after.getDbName()); event.setTableName(after.getTableName()); enqueue(event); }
/** * @param tableEvent alter table event * @throws MetaException */ public void onAlterTable (AlterTableEvent tableEvent) throws MetaException { Table before = tableEvent.getOldTable(); Table after = tableEvent.getNewTable(); NotificationEvent event = new NotificationEvent(0, now(), HCatConstants.HCAT_ALTER_TABLE_EVENT, msgFactory.buildAlterTableMessage(before, after).toString()); event.setDbName(after.getDbName()); event.setTableName(after.getTableName()); enqueue(event); }
/** * 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.getHandler().getHiveConf()) + "." + after.getDbName().toLowerCase(); send(messageFactory.buildAlterTableMessage(before, after), topicName); } }
/** * 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), topicName); } }
/** * 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.getHandler().getHiveConf()) + "." + after.getDbName().toLowerCase(); send(messageFactory.buildAlterTableMessage(before, after), topicName); } }