You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kh...@apache.org on 2015/02/04 20:24:13 UTC

svn commit: r1657387 [1/8] - in /hive/trunk: common/src/java/org/apache/hadoop/hive/conf/ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/ hcatalog/...

Author: khorgath
Date: Wed Feb  4 19:24:12 2015
New Revision: 1657387

URL: http://svn.apache.org/r1657387
Log:
HIVE-9273 : Add option to fire metastore event on insert (Alan Gates via Sushanth Sowmyan)

Added:
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/FireEventRequestData.java
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/FireEventResponse.java
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/InsertEventRequestData.java
Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageDeserializer.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageDeserializer.java
    hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
    hive/trunk/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
    hive/trunk/metastore/if/hive_metastore.thrift
    hive/trunk/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
    hive/trunk/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h
    hive/trunk/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp
    hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
    hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/FireEventRequest.java
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/SkewedInfo.java
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java
    hive/trunk/metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php
    hive/trunk/metastore/src/gen/thrift/gen-php/metastore/Types.php
    hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote
    hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py
    hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
    hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
    hive/trunk/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/events/InsertEvent.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Wed Feb  4 19:24:12 2015
@@ -593,6 +593,8 @@ public class HiveConf extends Configurat
         "* implies all the keys will get inherited."),
     METASTORE_FILTER_HOOK("hive.metastore.filter.hook", "org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl",
         "Metastore hook class for filtering the metadata read results"),
+    FIRE_EVENTS_FOR_DML("hive.metastore.dml.events", false, "If true, the metastore will be asked" +
+        " to fire events for DML operations"),
 
     // Parameters for exporting metadata on table drop (requires the use of the)
     // org.apache.hadoop.hive.ql.parse.MetaDataExportListener preevent listener

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java Wed Feb  4 19:24:12 2015
@@ -29,6 +29,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
 import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
@@ -43,8 +44,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hive.hcatalog.common.HCatConstants;
 import org.apache.hive.hcatalog.messaging.MessageFactory;
 
-import java.util.ArrayDeque;
-import java.util.Queue;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -228,8 +228,8 @@ public class DbNotificationListener exte
   @Override
   public void onInsert(InsertEvent insertEvent) throws MetaException {
     NotificationEvent event = new NotificationEvent(0, now(), HCatConstants.HCAT_INSERT_EVENT,
-        msgFactory.buildInsertMessage(insertEvent.getDb(), insertEvent.getTable(), insertEvent
-            .getPartitions()).toString());
+        msgFactory.buildInsertMessage(insertEvent.getDb(), insertEvent.getTable(),
+            insertEvent.getPartitions(), insertEvent.getFiles()).toString());
     event.setDbName(insertEvent.getDb());
     event.setTableName(insertEvent.getTable());
     enqueue(event);

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java Wed Feb  4 19:24:12 2015
@@ -43,6 +43,12 @@ public abstract class InsertMessage exte
    */
   public abstract List<String> getPartitionValues();
 
+  /**
+   * Get the list of files created as a result of this DML operation.  May be null.
+   * @return List of new files, or null.
+   */
+  public abstract List<String> getFiles();
+
   @Override
   public HCatEventMessage checkValid() {
     if (getTable() == null)

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageDeserializer.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageDeserializer.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageDeserializer.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageDeserializer.java Wed Feb  4 19:24:12 2015
@@ -46,6 +46,8 @@ public abstract class MessageDeserialize
       return getAlterPartitionMessage(messageBody);
     case DROP_PARTITION:
       return getDropPartitionMessage(messageBody);
+    case INSERT:
+      return getInsertMessage(messageBody);
 
     default:
       throw new IllegalArgumentException("Unsupported event-type: " + eventTypeString);
@@ -96,6 +98,13 @@ public abstract class MessageDeserialize
    */
   public abstract DropPartitionMessage getDropPartitionMessage(String messageBody);
 
+  /**
+   * Method to deserialize InsertMessage
+   * @param messageBody the message in serialized form
+   * @return message in object form
+   */
+  public abstract InsertMessage getInsertMessage(String messageBody);
+
   // Protection against construction.
   protected MessageDeserializer() {}
 }

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java Wed Feb  4 19:24:12 2015
@@ -171,5 +171,15 @@ public abstract class MessageFactory {
    */
   public abstract DropPartitionMessage buildDropPartitionMessage(Table table, Partition partition);
 
-  public abstract InsertMessage buildInsertMessage(String db, String table, List<String> partVals);
+  /**
+   * Factory method for building insert message
+   * @param db Name of the database the insert occurred in
+   * @param table Name of the table the insert occurred in
+   * @param partVals Partition values for the partition that the insert occurred in, may be null
+   *                 if the insert was done into a non-partitioned table
+   * @param files List of files created as a result of the insert, may be null.
+   * @return instance of InsertMessage
+   */
+  public abstract InsertMessage buildInsertMessage(String db, String table,
+                                                   List<String> partVals, List<String> files);
 }

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java Wed Feb  4 19:24:12 2015
@@ -37,7 +37,7 @@ public class JSONInsertMessage extends I
   Long timestamp;
 
   @JsonProperty
-  List<String> partitionValues;
+  List<String> partitionValues, files;
 
   /**
    * Default constructor, needed for Jackson.
@@ -45,13 +45,14 @@ public class JSONInsertMessage extends I
   public JSONInsertMessage() {}
 
   public JSONInsertMessage(String server, String servicePrincipal, String db, String table,
-                           List<String> partVals, Long timestamp) {
+                           List<String> partVals, List<String> files, Long timestamp) {
     this.server = server;
     this.servicePrincipal = servicePrincipal;
     this.db = db;
     this.table = table;
     this.timestamp = timestamp;
     partitionValues = partVals;
+    this.files = files;
     checkValid();
   }
 
@@ -68,6 +69,11 @@ public class JSONInsertMessage extends I
   }
 
   @Override
+  public List<String> getFiles() {
+    return files;
+  }
+
+  @Override
   public String getServicePrincipal() { return servicePrincipal; }
 
   @Override

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageDeserializer.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageDeserializer.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageDeserializer.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageDeserializer.java Wed Feb  4 19:24:12 2015
@@ -28,6 +28,7 @@ import org.apache.hive.hcatalog.messagin
 import org.apache.hive.hcatalog.messaging.DropDatabaseMessage;
 import org.apache.hive.hcatalog.messaging.DropPartitionMessage;
 import org.apache.hive.hcatalog.messaging.DropTableMessage;
+import org.apache.hive.hcatalog.messaging.InsertMessage;
 import org.apache.hive.hcatalog.messaging.MessageDeserializer;
 import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.ObjectMapper;
@@ -122,4 +123,13 @@ public class JSONMessageDeserializer ext
       throw new IllegalArgumentException("Could not construct DropPartitionMessage.", exception);
     }
   }
+
+  @Override
+  public InsertMessage getInsertMessage(String messageBody) {
+    try {
+      return mapper.readValue(messageBody, JSONInsertMessage.class);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Could not construct InsertMessage", e);
+    }
+  }
 }

Modified: hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java (original)
+++ hive/trunk/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java Wed Feb  4 19:24:12 2015
@@ -124,9 +124,10 @@ public class JSONMessageFactory extends
   }
 
   @Override
-  public InsertMessage buildInsertMessage(String db, String table, List<String> partVals) {
+  public InsertMessage buildInsertMessage(String db, String table, List<String> partVals,
+                                          List<String> files) {
     return new JSONInsertMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, db, table, partVals,
-        now());
+        files, now());
   }
 
   private long now() {

Modified: hive/trunk/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java (original)
+++ hive/trunk/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java Wed Feb  4 19:24:12 2015
@@ -23,9 +23,9 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertTrue;
 import static junit.framework.Assert.fail;
 
-import junit.framework.Assert;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.cli.CliSessionState;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.IMetaStoreClient;
@@ -33,17 +33,17 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.EventRequestType;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.FireEventRequest;
+import org.apache.hadoop.hive.metastore.api.FireEventRequestData;
+import org.apache.hadoop.hive.metastore.api.InsertEventRequestData;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 import org.apache.hadoop.hive.metastore.api.NotificationEventResponse;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.ql.Driver;
+import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hive.hcatalog.common.HCatConstants;
-import org.apache.hive.hcatalog.data.schema.HCatFieldSchema;
-import org.apache.hive.hcatalog.listener.DbNotificationListener;
-import org.apache.hive.hcatalog.messaging.HCatEventMessage;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -59,6 +59,7 @@ public class TestDbNotificationListener
   private static final Log LOG = LogFactory.getLog(TestDbNotificationListener.class.getName());
   private static Map<String, String> emptyParameters = new HashMap<String, String>();
   private static IMetaStoreClient msClient;
+  private static Driver driver;
   private int startTime;
   private long firstEventId;
 
@@ -67,7 +68,12 @@ public class TestDbNotificationListener
     HiveConf conf = new HiveConf();
     conf.setVar(HiveConf.ConfVars.METASTORE_EVENT_LISTENERS,
         DbNotificationListener.class.getName());
+    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
+    conf.setBoolVar(HiveConf.ConfVars.FIRE_EVENTS_FOR_DML, true);
+    conf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+    SessionState.start(new CliSessionState(conf));
     msClient = new HiveMetaStoreClient(conf);
+    driver = new Driver(conf);
   }
 
   @Before
@@ -151,7 +157,8 @@ public class TestDbNotificationListener
         new ArrayList<FieldSchema>(), emptyParameters, null, null, null);
     msClient.createTable(table);
 
-    table = new Table("alttable", "default", "me", startTime, startTime + 1, 0, sd,
+    cols.add(new FieldSchema("col2", "int", ""));
+    table = new Table("alttable", "default", "me", startTime, startTime, 0, sd,
         new ArrayList<FieldSchema>(), emptyParameters, null, null, null);
     msClient.alter_table("default", "alttable", table);
 
@@ -296,9 +303,14 @@ public class TestDbNotificationListener
 
   @Test
   public void insertTable() throws Exception {
-    FireEventRequest rqst = new FireEventRequest(EventRequestType.INSERT, "mydb", true);
+    FireEventRequestData data = new FireEventRequestData();
+    InsertEventRequestData insertData = new InsertEventRequestData();
+    data.setInsertData(insertData);
+    insertData.addToFilesAdded("/warehouse/mytable/b1");
+    FireEventRequest rqst = new FireEventRequest(true, data);
+    rqst.setDbName("mydb");
     rqst.setTableName("mytable");
-    msClient.fireNotificationEvent(rqst);
+    msClient.fireListenerEvent(rqst);
 
     NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(1, rsp.getEventsSize());
@@ -309,18 +321,23 @@ public class TestDbNotificationListener
     assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
     assertEquals("mydb", event.getDbName());
     assertEquals("mytable", event.getTableName());
-    System.out.println(event.getMessage());
     assertTrue(event.getMessage().matches("\\{\"eventType\":\"INSERT\",\"server\":\"\"," +
         "\"servicePrincipal\":\"\",\"db\":\"mydb\",\"table\":" +
-        "\"mytable\",\"timestamp\":[0-9]+,\"partitionValues\":null}"));
+        "\"mytable\",\"timestamp\":[0-9]+,\"partitionValues\":null," +
+        "\"files\":\\[\"/warehouse/mytable/b1\"]}"));
   }
 
   @Test
   public void insertPartition() throws Exception {
-    FireEventRequest rqst = new FireEventRequest(EventRequestType.INSERT, "mydb", true);
+    FireEventRequestData data = new FireEventRequestData();
+    InsertEventRequestData insertData = new InsertEventRequestData();
+    data.setInsertData(insertData);
+    insertData.addToFilesAdded("/warehouse/mytable/today/b1");
+    FireEventRequest rqst = new FireEventRequest(true, data);
+    rqst.setDbName("mydb");
     rqst.setTableName("mytable");
     rqst.setPartitionVals(Arrays.asList("today"));
-    msClient.fireNotificationEvent(rqst);
+    msClient.fireListenerEvent(rqst);
 
     NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(1, rsp.getEventsSize());
@@ -331,10 +348,10 @@ public class TestDbNotificationListener
     assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
     assertEquals("mydb", event.getDbName());
     assertEquals("mytable", event.getTableName());
-    System.out.println(event.getMessage());
     assertTrue(event.getMessage().matches("\\{\"eventType\":\"INSERT\",\"server\":\"\"," +
         "\"servicePrincipal\":\"\",\"db\":\"mydb\",\"table\":" +
-        "\"mytable\",\"timestamp\":[0-9]+,\"partitionValues\":\\[\"today\"]}"));
+        "\"mytable\",\"timestamp\":[0-9]+,\"partitionValues\":\\[\"today\"]," +
+        "\"files\":\\[\"/warehouse/mytable/today/b1\"]}"));
   }
 
   @Test
@@ -391,4 +408,99 @@ public class TestDbNotificationListener
     assertEquals(1, rsp.getEventsSize());
     assertEquals(firstEventId + 1, rsp.getEvents().get(0).getEventId());
   }
+
+  @Test
+  public void sqlInsertTable() throws Exception {
+
+    driver.run("create table sit (c int)");
+    driver.run("insert into table sit values (1)");
+    driver.run("alter table sit add columns (c2 int)");
+    driver.run("drop table sit");
+
+    NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
+    // For reasons not clear to me there's an alter after the create table and one after the
+    // insert.  I think the one after the insert is a stats calculation.
+    assertEquals(6, rsp.getEventsSize());
+    NotificationEvent event = rsp.getEvents().get(0);
+    assertEquals(firstEventId + 1, event.getEventId());
+    assertEquals(HCatConstants.HCAT_CREATE_TABLE_EVENT, event.getEventType());
+    event = rsp.getEvents().get(2);
+    assertEquals(firstEventId + 3, event.getEventId());
+    assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
+    // Make sure the files are listed in the insert
+    assertTrue(event.getMessage().matches(".*\"files\":\\[\"pfile.*"));
+    event = rsp.getEvents().get(4);
+    assertEquals(firstEventId + 5, event.getEventId());
+    assertEquals(HCatConstants.HCAT_ALTER_TABLE_EVENT, event.getEventType());
+    event = rsp.getEvents().get(5);
+    assertEquals(firstEventId + 6, event.getEventId());
+    assertEquals(HCatConstants.HCAT_DROP_TABLE_EVENT, event.getEventType());
+  }
+
+  @Test
+  public void sqlDb() throws Exception {
+
+    driver.run("create database sd");
+    driver.run("drop database sd");
+
+    NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
+    assertEquals(2, rsp.getEventsSize());
+    NotificationEvent event = rsp.getEvents().get(0);
+    assertEquals(firstEventId + 1, event.getEventId());
+    assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT, event.getEventType());
+    event = rsp.getEvents().get(1);
+    assertEquals(firstEventId + 2, event.getEventId());
+    assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT, event.getEventType());
+  }
+
+  @Test
+  public void sqlInsertPartition() throws Exception {
+
+    driver.run("create table sip (c int) partitioned by (ds string)");
+    driver.run("insert into table sip partition (ds = 'today') values (1)");
+    driver.run("insert into table sip partition (ds = 'today') values (2)");
+    driver.run("insert into table sip partition (ds) values (3, 'today')");
+    driver.run("alter table sip add partition (ds = 'yesterday')");
+    driver.run("insert into table sip partition (ds = 'yesterday') values (2)");
+
+    driver.run("insert into table sip partition (ds) values (3, 'yesterday')");
+    driver.run("insert into table sip partition (ds) values (3, 'tomorrow')");
+    driver.run("alter table sip drop partition (ds = 'tomorrow')");
+
+    NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
+
+    for (NotificationEvent ne : rsp.getEvents()) LOG.debug("EVENT: " + ne.getMessage());
+    // For reasons not clear to me there's one or more alter partitions after add partition and
+    // insert.
+    assertEquals(19, rsp.getEventsSize());
+    NotificationEvent event = rsp.getEvents().get(1);
+    assertEquals(firstEventId + 2, event.getEventId());
+    assertEquals(HCatConstants.HCAT_ADD_PARTITION_EVENT, event.getEventType());
+    event = rsp.getEvents().get(4);
+    assertEquals(firstEventId + 5, event.getEventId());
+    assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
+    // Make sure the files are listed in the insert
+    assertTrue(event.getMessage().matches(".*\"files\":\\[\"pfile.*"));
+    event = rsp.getEvents().get(7);
+    assertEquals(firstEventId + 8, event.getEventId());
+    assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
+    assertTrue(event.getMessage().matches(".*\"files\":\\[\"pfile.*"));
+    event = rsp.getEvents().get(9);
+    assertEquals(firstEventId + 10, event.getEventId());
+    assertEquals(HCatConstants.HCAT_ADD_PARTITION_EVENT, event.getEventType());
+    event = rsp.getEvents().get(11);
+    assertEquals(firstEventId + 12, event.getEventId());
+    assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
+    assertTrue(event.getMessage().matches(".*\"files\":\\[\"pfile.*"));
+    event = rsp.getEvents().get(14);
+    assertEquals(firstEventId + 15, event.getEventId());
+    assertEquals(HCatConstants.HCAT_INSERT_EVENT, event.getEventType());
+    assertTrue(event.getMessage().matches(".*\"files\":\\[\"pfile.*"));
+    event = rsp.getEvents().get(16);
+    assertEquals(firstEventId + 17, event.getEventId());
+    assertEquals(HCatConstants.HCAT_ADD_PARTITION_EVENT, event.getEventType());
+    event = rsp.getEvents().get(18);
+    assertEquals(firstEventId + 19, event.getEventId());
+    assertEquals(HCatConstants.HCAT_DROP_PARTITION_EVENT, event.getEventType());
+  }
 }
\ No newline at end of file

Modified: hive/trunk/metastore/if/hive_metastore.thrift
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/if/hive_metastore.thrift?rev=1657387&r1=1657386&r2=1657387&view=diff
==============================================================================
--- hive/trunk/metastore/if/hive_metastore.thrift (original)
+++ hive/trunk/metastore/if/hive_metastore.thrift Wed Feb  4 19:24:12 2015
@@ -673,13 +673,28 @@ struct CurrentNotificationEventId {
     1: required i64 eventId,
 }
 
+struct InsertEventRequestData {
+    1: required list<string> filesAdded
+}
+
+union FireEventRequestData {
+    1: InsertEventRequestData insertData
+}
+
 struct FireEventRequest {
-    1: required EventRequestType eventType,
-    2: required string dbName,
-    3: required bool successful,
+    1: required bool successful,
+    2: required FireEventRequestData data
+    // dbname, tablename, and partition vals are included as optional in the top level event rather than placed in each type of
+    // subevent as I assume they'll be used across most event types.
+    3: optional string dbName,
     4: optional string tableName,
-    5: optional list<string> partitionVals
+    5: optional list<string> partitionVals,
+}
+
+struct FireEventResponse {
+    // NOP for now, this is just a place holder for future responses
 }
+    
 
 
 exception MetaException {
@@ -1151,7 +1166,7 @@ service ThriftHiveMetastore extends fb30
   // Notification logging calls
   NotificationEventResponse get_next_notification(1:NotificationEventRequest rqst) 
   CurrentNotificationEventId get_current_notificationEventId()
-  void fire_notification_event(1:FireEventRequest rqst)
+  FireEventResponse fire_listener_event(1:FireEventRequest rqst)
 }
 
 // * Note about the DDL_TIME: When creating or altering a table or a partition,