use of org.apache.hadoop.hive.metastore.api.NotificationEvent in project hive by apache.
the class DbNotificationListener method onDropDatabase.
/**
* @param dbEvent database event
* @throws MetaException
*/
@Override
public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException {
Database db = dbEvent.getDatabase();
NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_DATABASE.toString(), msgFactory.buildDropDatabaseMessage(db).toString());
event.setDbName(db.getName());
process(event, dbEvent);
}
use of org.apache.hadoop.hive.metastore.api.NotificationEvent in project hive by apache.
the class DbNotificationListener method onDropConstraint.
/**
* @param dropConstraintEvent drop constraint event
* @throws MetaException
*/
@Override
public void onDropConstraint(DropConstraintEvent dropConstraintEvent) throws MetaException {
String dbName = dropConstraintEvent.getDbName();
String tableName = dropConstraintEvent.getTableName();
String constraintName = dropConstraintEvent.getConstraintName();
NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_CONSTRAINT.toString(), msgFactory.buildDropConstraintMessage(dbName, tableName, constraintName).toString());
event.setDbName(dbName);
event.setTableName(tableName);
process(event, dropConstraintEvent);
}
use of org.apache.hadoop.hive.metastore.api.NotificationEvent in project hive by apache.
the class DbNotificationListener method onAddUniqueConstraint.
/**
* @param addUniqueConstraintEvent add unique constraint event
* @throws MetaException
*/
@Override
public void onAddUniqueConstraint(AddUniqueConstraintEvent addUniqueConstraintEvent) throws MetaException {
List<SQLUniqueConstraint> cols = addUniqueConstraintEvent.getUniqueConstraintCols();
if (cols.size() > 0) {
NotificationEvent event = new NotificationEvent(0, now(), EventType.ADD_UNIQUECONSTRAINT.toString(), msgFactory.buildAddUniqueConstraintMessage(addUniqueConstraintEvent.getUniqueConstraintCols()).toString());
event.setDbName(cols.get(0).getTable_db());
event.setTableName(cols.get(0).getTable_name());
process(event, addUniqueConstraintEvent);
}
}
use of org.apache.hadoop.hive.metastore.api.NotificationEvent in project hive by apache.
the class DbNotificationListener method onAddPartition.
/**
* @param partitionEvent partition event
* @throws MetaException
*/
@Override
public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException {
Table t = partitionEvent.getTable();
String msg = msgFactory.buildAddPartitionMessage(t, partitionEvent.getPartitionIterator(), new PartitionFilesIterator(partitionEvent.getPartitionIterator(), t)).toString();
NotificationEvent event = new NotificationEvent(0, now(), EventType.ADD_PARTITION.toString(), msg);
event.setDbName(t.getDbName());
event.setTableName(t.getTableName());
process(event, partitionEvent);
}
use of org.apache.hadoop.hive.metastore.api.NotificationEvent in project hive by apache.
the class TestObjectStore method testNotificationOps.
/**
* Test notification operations
*/
// TODO MS-SPLIT uncomment once we move EventMessage over
@Test
public void testNotificationOps() throws InterruptedException {
final int NO_EVENT_ID = 0;
final int FIRST_EVENT_ID = 1;
final int SECOND_EVENT_ID = 2;
NotificationEvent event = new NotificationEvent(0, 0, EventMessage.EventType.CREATE_DATABASE.toString(), "");
NotificationEventResponse eventResponse;
CurrentNotificationEventId eventId;
// Verify that there is no notifications available yet
eventId = objectStore.getCurrentNotificationEventId();
Assert.assertEquals(NO_EVENT_ID, eventId.getEventId());
// Verify that addNotificationEvent() updates the NotificationEvent with the new event ID
objectStore.addNotificationEvent(event);
Assert.assertEquals(FIRST_EVENT_ID, event.getEventId());
objectStore.addNotificationEvent(event);
Assert.assertEquals(SECOND_EVENT_ID, event.getEventId());
// Verify that objectStore fetches the latest notification event ID
eventId = objectStore.getCurrentNotificationEventId();
Assert.assertEquals(SECOND_EVENT_ID, eventId.getEventId());
// Verify that getNextNotification() returns all events
eventResponse = objectStore.getNextNotification(new NotificationEventRequest());
Assert.assertEquals(2, eventResponse.getEventsSize());
Assert.assertEquals(FIRST_EVENT_ID, eventResponse.getEvents().get(0).getEventId());
Assert.assertEquals(SECOND_EVENT_ID, eventResponse.getEvents().get(1).getEventId());
// Verify that getNextNotification(last) returns events after a specified event
eventResponse = objectStore.getNextNotification(new NotificationEventRequest(FIRST_EVENT_ID));
Assert.assertEquals(1, eventResponse.getEventsSize());
Assert.assertEquals(SECOND_EVENT_ID, eventResponse.getEvents().get(0).getEventId());
// Verify that getNextNotification(last) returns zero events if there are no more notifications available
eventResponse = objectStore.getNextNotification(new NotificationEventRequest(SECOND_EVENT_ID));
Assert.assertEquals(0, eventResponse.getEventsSize());
// Verify that cleanNotificationEvents() cleans up all old notifications
Thread.sleep(1);
objectStore.cleanNotificationEvents(1);
eventResponse = objectStore.getNextNotification(new NotificationEventRequest());
Assert.assertEquals(0, eventResponse.getEventsSize());
}
Aggregations