use of org.apache.hadoop.hive.metastore.api.NotificationEventResponse in project hive by apache.
the class TestDbNotificationListener method commitTxn.
@Test
public void commitTxn() throws Exception {
long txnId1 = msClient.openTxn("me", TxnType.READ_ONLY);
long txnId2 = msClient.openTxn("me", TxnType.DEFAULT);
NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
assertEquals(1, rsp.getEventsSize());
msClient.commitTxn(txnId1);
rsp = msClient.getNextNotification(firstEventId + 1, 0, null);
assertEquals(0, rsp.getEventsSize());
msClient.commitTxn(txnId2);
rsp = msClient.getNextNotification(firstEventId + 1, 0, null);
assertEquals(1, rsp.getEventsSize());
NotificationEvent event = rsp.getEvents().get(0);
assertEquals(firstEventId + 2, event.getEventId());
assertTrue(event.getEventTime() >= startTime);
assertEquals(EventType.COMMIT_TXN.toString(), event.getEventType());
}
use of org.apache.hadoop.hive.metastore.api.NotificationEventResponse in project hive by apache.
the class TestDbNotificationListener method abortTxn.
@Test
public void abortTxn() throws Exception {
long txnId1 = msClient.openTxn("me", TxnType.READ_ONLY);
long txnId2 = msClient.openTxn("me", TxnType.DEFAULT);
NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
assertEquals(1, rsp.getEventsSize());
msClient.abortTxns(Collections.singletonList(txnId1));
rsp = msClient.getNextNotification(firstEventId + 1, 0, null);
assertEquals(0, rsp.getEventsSize());
msClient.abortTxns(Collections.singletonList(txnId2));
rsp = msClient.getNextNotification(firstEventId + 1, 0, null);
assertEquals(1, rsp.getEventsSize());
NotificationEvent event = rsp.getEvents().get(0);
assertEquals(firstEventId + 2, event.getEventId());
assertTrue(event.getEventTime() >= startTime);
assertEquals(EventType.ABORT_TXN.toString(), event.getEventType());
}
use of org.apache.hadoop.hive.metastore.api.NotificationEventResponse in project hive by apache.
the class TestDbNotificationListener method cleanupNotifs.
@Test
public void cleanupNotifs() throws Exception {
Database db = new Database("cleanup1", "no description", testTempDir, emptyParameters);
msClient.createDatabase(db);
msClient.dropDatabase("cleanup1");
LOG.info("Pulling events immediately after createDatabase/dropDatabase");
NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
assertEquals(2, rsp.getEventsSize());
// sleep for expiry time, and then fetch again
// sleep twice the TTL interval - things should have been cleaned by then.
Thread.sleep(EVENTS_TTL * 2 * 1000);
LOG.info("Pulling events again after cleanup");
NotificationEventResponse rsp2 = msClient.getNextNotification(firstEventId, 0, null);
LOG.info("second trigger done");
assertEquals(0, rsp2.getEventsSize());
}
use of org.apache.hadoop.hive.metastore.api.NotificationEventResponse in project hive by apache.
the class TestDbNotificationListener method sqlTempTable.
@Test
public void sqlTempTable() throws Exception {
String defaultDbName = "default";
String tempTblName = "sqltemptbl";
driver.run("create temporary table " + tempTblName + " (c int)");
driver.run("insert into table " + tempTblName + " values (1)");
// Get notifications from metastore
NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
assertEquals(0, rsp.getEventsSize());
testEventCounts(defaultDbName, firstEventId, null, null, 0);
}
use of org.apache.hadoop.hive.metastore.api.NotificationEventResponse in project hive by apache.
the class TestDbNotificationListener method sqlDb.
@Test
public void sqlDb() throws Exception {
String dbName = "sqldb";
// Event 1
driver.run("create database " + dbName);
// Event 2
driver.run("drop database " + dbName);
// Get notifications from metastore
NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
assertEquals(2, rsp.getEventsSize());
NotificationEvent event = rsp.getEvents().get(0);
assertEquals(firstEventId + 1, event.getEventId());
assertEquals(EventType.CREATE_DATABASE.toString(), event.getEventType());
event = rsp.getEvents().get(1);
assertEquals(firstEventId + 2, event.getEventId());
assertEquals(EventType.DROP_DATABASE.toString(), event.getEventType());
}
Aggregations