Search in sources :

Example 6 with NotificationEventResponse

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());
}
Also used : NotificationEventResponse(org.apache.hadoop.hive.metastore.api.NotificationEventResponse) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) Test(org.junit.Test)

Example 7 with NotificationEventResponse

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());
}
Also used : NotificationEventResponse(org.apache.hadoop.hive.metastore.api.NotificationEventResponse) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) Test(org.junit.Test)

Example 8 with NotificationEventResponse

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());
}
Also used : NotificationEventResponse(org.apache.hadoop.hive.metastore.api.NotificationEventResponse) Database(org.apache.hadoop.hive.metastore.api.Database) Test(org.junit.Test)

Example 9 with NotificationEventResponse

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);
}
Also used : NotificationEventResponse(org.apache.hadoop.hive.metastore.api.NotificationEventResponse) Test(org.junit.Test)

Example 10 with NotificationEventResponse

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());
}
Also used : NotificationEventResponse(org.apache.hadoop.hive.metastore.api.NotificationEventResponse) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) Test(org.junit.Test)

Aggregations

NotificationEventResponse (org.apache.hadoop.hive.metastore.api.NotificationEventResponse)44 Test (org.junit.Test)42 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)34 ArrayList (java.util.ArrayList)15 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)12 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)11 SerDeInfo (org.apache.hadoop.hive.metastore.api.SerDeInfo)11 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)11 Table (org.apache.hadoop.hive.metastore.api.Table)11 Database (org.apache.hadoop.hive.metastore.api.Database)9 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)5 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)5 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)5 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)5 HashMap (java.util.HashMap)4 Nullable (javax.annotation.Nullable)4 CurrentNotificationEventId (org.apache.hadoop.hive.metastore.api.CurrentNotificationEventId)4 LinkedHashMap (java.util.LinkedHashMap)3 Path (org.apache.hadoop.fs.Path)3 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)3