/** * Send dropped partition notifications. Subscribers can receive these notifications for a * particular table by listening on a topic named "dbName.tableName" with message selector * string {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_EVENT} = * {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_DROP_PARTITION_EVENT}. * </br> * TODO: DataNucleus 2.0.3, currently used by the HiveMetaStore for persistence, has been * found to throw NPE when serializing objects that contain null. For this reason we override * some fields in the StorageDescriptor of this notification. This should be fixed after * HIVE-2084 "Upgrade datanucleus from 2.0.3 to 3.0.1" is resolved. */ @Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (partitionEvent.getStatus()) { String topicName = getTopicName(partitionEvent.getTable()); if (topicName != null && !topicName.equals("")) { send(messageFactory.buildDropPartitionMessage(partitionEvent.getTable(), partitionEvent.getPartitionIterator()), topicName); } else { LOG.info("Topic name not found in metastore. Suppressing HCatalog notification for " + partitionEvent.getTable().getDbName() + "." + partitionEvent.getTable().getTableName() + " To enable notifications for this table, please do alter table set properties (" + HCatConstants.HCAT_MSGBUS_TOPIC_NAME + "=<dbname>.<tablename>) or whatever you want topic name to be."); } } }
MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.DROP_PARTITION, new DropPartitionEvent(tbl, part, true, deleteData, this), envContext); MetaStoreListenerNotifier.notifyEvent(listeners, EventType.DROP_PARTITION, new DropPartitionEvent(tbl, part, success, deleteData, this), envContext, transactionalListenerResponses, ms);
@Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (TxnUtils.isTransactionalTable(partitionEvent.getTable())) { txnHandler = getTxnHandler(); txnHandler.cleanupRecords(HiveObjectType.PARTITION, null, partitionEvent.getTable(), partitionEvent.getPartitionIterator()); } }
assertEquals(notifyList.size(), listSize); DropPartitionEvent dropPartEvent = (DropPartitionEvent)notifyList.get(listSize - 1); assert dropPartEvent.getStatus(); assertEquals(envContext, dropPartEvent.getEnvironmentContext()); assertEquals(notifyList.size(), listSize); DropPartitionEvent dropPartByNameEvent = (DropPartitionEvent)notifyList.get(listSize - 1); assert dropPartByNameEvent.getStatus(); assertEquals(envContext, dropPartByNameEvent.getEnvironmentContext());
DropPartitionEvent dropPartitionEvent = new DropPartitionEvent(tbl, part, success, this); dropPartitionEvent.setEnvironmentContext(envContext); listener.onDropPartition(dropPartitionEvent);
@Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { // don't sync path if the operation has failed if (!partitionEvent.getStatus()) { LOGGER.debug("Skip syncing path with Sentry server for onDropPartition event," + " since the operation failed. \n"); return; } String authzObj = partitionEvent.getTable().getDbName() + "." + partitionEvent.getTable().getTableName(); String path = partitionEvent.getPartition().getSd().getLocation(); for (SentryMetastoreListenerPlugin plugin : sentryPlugins) { plugin.removePath(authzObj, path); } super.onDropPartition(partitionEvent); }
/** * Listener which fires when a partition is dropped. * * <p>For auditing purposes the read/write differential is the existence and * non-existence of the dropped partition respectively.</p> * * @param event The drop partition event */ @Override public void onDropPartition(DropPartitionEvent event) throws MetaException { try { Set<ReadEntity> readEntities = new HashSet<>(); readEntities.add( new ReadEntity( new Partition(new Table(event.getTable()), event.getPartition()) ) ); Set<WriteEntity> writeEntities = new HashSet<>(); run(readEntities, writeEntities, HiveOperation.THRIFT_DROP_PARTITION); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @param partitionEvent partition event * @throws MetaException */ @Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { Table t = partitionEvent.getTable(); DropPartitionMessage msg = MessageBuilder.getInstance() .buildDropPartitionMessage(t, partitionEvent.getPartitionIterator()); NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_PARTITION.toString(), msgEncoder.getSerializer().serialize(msg)); event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME); event.setDbName(t.getDbName()); event.setTableName(t.getTableName()); process(event, partitionEvent); }
new DropPartitionEvent(tbl, part, success, deleteData, this); dropPartitionEvent.setEnvironmentContext(envContext); listener.onDropPartition(dropPartitionEvent);
/** * Listener which fires when a partition is dropped. * * <p>For auditing purposes the read/write differential is the existence and * non-existence of the dropped partition respectively.</p> * * @param event The drop partition event */ @Override public void onDropPartition(DropPartitionEvent event) throws MetaException { try { Set<ReadEntity> readEntities = new HashSet<>(); readEntities.add( new ReadEntity( new Partition(new Table(event.getTable()), event.getPartition()) ) ); Set<WriteEntity> writeEntities = new HashSet<>(); run(readEntities, writeEntities, HiveOperation.THRIFT_DROP_PARTITION); } catch (Exception e) { throw new RuntimeException(e); } }
Assert.assertTrue(dropPart.getStatus()); validateDropPartition(Collections.singletonList(part).iterator(), dropPart.getPartitionIterator()); validateTableInDropPartition(tbl, dropPart.getTable());
/** * @param partitionEvent partition event * @throws MetaException */ public void onDropPartition (DropPartitionEvent partitionEvent) throws MetaException { Table t = partitionEvent.getTable(); NotificationEvent event = new NotificationEvent(0, now(), HCatConstants.HCAT_DROP_PARTITION_EVENT, msgFactory.buildDropPartitionMessage(t, partitionEvent.getPartitionIterator()).toString()); event.setDbName(t.getDbName()); event.setTableName(t.getTableName()); enqueue(event); }
for (MetaStoreEventListener listener : listeners) { DropPartitionEvent dropPartitionEvent = new DropPartitionEvent(tbl, part, success, deleteData, this); dropPartitionEvent.setEnvironmentContext(envContext); listener.onDropPartition(dropPartitionEvent);
MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.DROP_PARTITION, new DropPartitionEvent(tbl, part, true, deleteData, this), envContext)); new DropPartitionEvent(tbl, part, success, deleteData, this), envContext, parameters, ms);
/** * Send dropped partition notifications. Subscribers can receive these notifications for a * particular table by listening on a topic named "dbName.tableName" with message selector * string {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_EVENT} = * {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_DROP_PARTITION_EVENT}. * </br> * TODO: DataNucleus 2.0.3, currently used by the HiveMetaStore for persistence, has been * found to throw NPE when serializing objects that contain null. For this reason we override * some fields in the StorageDescriptor of this notification. This should be fixed after * HIVE-2084 "Upgrade datanucleus from 2.0.3 to 3.0.1" is resolved. */ @Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (partitionEvent.getStatus()) { String topicName = getTopicName(partitionEvent.getTable()); if (topicName != null && !topicName.equals("")) { send(messageFactory.buildDropPartitionMessage(partitionEvent.getTable(), partitionEvent.getPartitionIterator()), topicName); } else { LOG.info("Topic name not found in metastore. Suppressing HCatalog notification for " + partitionEvent.getTable().getDbName() + "." + partitionEvent.getTable().getTableName() + " To enable notifications for this table, please do alter table set properties (" + HCatConstants.HCAT_MSGBUS_TOPIC_NAME + "=<dbname>.<tablename>) or whatever you want topic name to be."); } } }
/** * @param partitionEvent partition event * @throws MetaException */ public void onDropPartition (DropPartitionEvent partitionEvent) throws MetaException { Table t = partitionEvent.getTable(); NotificationEvent event = new NotificationEvent(0, now(), HCatConstants.HCAT_DROP_PARTITION_EVENT, msgFactory.buildDropPartitionMessage(t, partitionEvent.getPartitionIterator()).toString()); event.setDbName(t.getDbName()); event.setTableName(t.getTableName()); enqueue(event); }
for (MetaStoreEventListener listener : listeners) { DropPartitionEvent dropPartitionEvent = new DropPartitionEvent(tbl, part, success, deleteData, this); dropPartitionEvent.setEnvironmentContext(envContext); listener.onDropPartition(dropPartitionEvent);
new DropPartitionEvent(sourceTable, partition, true, true, this); transactionalListenerResponsesForDropPartition.add( MetaStoreListenerNotifier.notifyEvent(transactionalListeners, for (Partition partition : partitionsToExchange) { DropPartitionEvent dropPartitionEvent = new DropPartitionEvent(sourceTable, partition, success, true, this); Map<String, String> parameters = (transactionalListenerResponsesForDropPartition.size() > i)
/** * Send dropped partition notifications. Subscribers can receive these notifications for a * particular table by listening on a topic named "dbName.tableName" with message selector * string {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_EVENT} = * {@value org.apache.hive.hcatalog.common.HCatConstants#HCAT_DROP_PARTITION_EVENT}. * </br> * TODO: DataNucleus 2.0.3, currently used by the HiveMetaStore for persistence, has been * found to throw NPE when serializing objects that contain null. For this reason we override * some fields in the StorageDescriptor of this notification. This should be fixed after * HIVE-2084 "Upgrade datanucleus from 2.0.3 to 3.0.1" is resolved. */ @Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (partitionEvent.getStatus()) { String topicName = getTopicName(partitionEvent.getTable()); if (topicName != null && !topicName.equals("")) { send(messageFactory.buildDropPartitionMessage(partitionEvent.getTable(), partitionEvent.getPartitionIterator()), topicName); } else { LOG.info("Topic name not found in metastore. Suppressing HCatalog notification for " + partitionEvent.getTable().getDbName() + "." + partitionEvent.getTable().getTableName() + " To enable notifications for this table, please do alter table set properties (" + HCatConstants.HCAT_MSGBUS_TOPIC_NAME + "=<dbname>.<tablename>) or whatever you want topic name to be."); } } }
/** * @param partitionEvent partition event * @throws MetaException */ @Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { Table t = partitionEvent.getTable(); NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_PARTITION.toString(), msgFactory .buildDropPartitionMessage(t, partitionEvent.getPartitionIterator()).toString()); event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME); event.setDbName(t.getDbName()); event.setTableName(t.getTableName()); process(event, partitionEvent); }