Index: conf/hive-default.xml
===================================================================
--- conf/hive-default.xml (revision 1096112)
+++ conf/hive-default.xml (working copy)
@@ -227,6 +227,12 @@
+ hive.metastore.event.listeners
+
+ list of comma seperated listeners for metastore events.
+
+
+
hive.metastore.connect.retries
5
Number of retries while opening a connection to metastore
Index: metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java
===================================================================
--- metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java (revision 0)
+++ metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java (revision 0)
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
+import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+import org.apache.hadoop.hive.metastore.events.ListenerEvent;
+
+/** A dummy implementation for
+ * {@link org.apache.hadoop.hive.metastore.hadooorg.apache.hadoop.hive.metastore.MetaStoreEventListener}
+ * for testing purposes.
+ */
+public class DummyListener extends MetaStoreEventListener{
+
+ public static final List notifyList = new ArrayList();
+
+ public DummyListener(Configuration config) {
+ super(config);
+ }
+
+ @Override
+ public void onAddPartition(AddPartitionEvent partition) throws MetaException {
+ notifyList.add(partition);
+ }
+
+ @Override
+ public void onCreateDatabase(CreateDatabaseEvent db) throws MetaException {
+ notifyList.add(db);
+ }
+
+ @Override
+ public void onCreateTable(CreateTableEvent table) throws MetaException {
+ notifyList.add(table);
+ }
+
+ @Override
+ public void onDropDatabase(DropDatabaseEvent db) throws MetaException {
+ notifyList.add(db);
+ }
+
+ @Override
+ public void onDropPartition(DropPartitionEvent partition) throws MetaException {
+ notifyList.add(partition);
+ }
+
+ @Override
+ public void onDropTable(DropTableEvent table) throws MetaException {
+ notifyList.add(table);
+ }
+}
Index: metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java
===================================================================
--- metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (revision 0)
+++ metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (revision 0)
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.hadoop.hive.cli.CliSessionState;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
+import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+import org.apache.hadoop.hive.metastore.events.ListenerEvent;
+import org.apache.hadoop.hive.ql.Driver;
+import org.apache.hadoop.hive.ql.session.SessionState;
+
+/**
+ * TestMetaStoreEventListener. Test case for
+ * {@link org.apache.hadoop.hive.metastore.hadooorg.apache.hadoop.hive.metastore.MetaStoreEventListener}
+ */
+public class TestMetaStoreEventListener extends TestCase {
+
+ private static final String msPort = "20001";
+ private HiveConf hiveConf;
+ private HiveMetaStoreClient msc;
+ private Driver driver;
+
+ private static class RunMS implements Runnable {
+
+ @Override
+ public void run() {
+ HiveMetaStore.main(new String[]{msPort});
+ }
+
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+
+ super.setUp();
+ System.setProperty(ConfVars.METASTORE_EVENT_LISTENERS.varname,
+ DummyListener.class.getName());
+ Thread t = new Thread(new RunMS());
+ t.start();
+ Thread.sleep(40000);
+ hiveConf = new HiveConf(this.getClass());
+ hiveConf.set("hive.metastore.local", "false");
+ hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + msPort);
+ hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTRETRIES, 3);
+ hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
+ hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
+ hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
+ SessionState.start(new CliSessionState(hiveConf));
+ msc = new HiveMetaStoreClient(hiveConf, null);
+ driver = new Driver(hiveConf);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testListener() throws Exception {
+
+ List notifyList = DummyListener.notifyList;
+ assertEquals(notifyList.size(), 0);
+
+ driver.run("create database tmpdb");
+ Database db = msc.getDatabase("tmpdb");
+ assertEquals(1, notifyList.size());
+ CreateDatabaseEvent dbEvent = (CreateDatabaseEvent)(notifyList.get(0));
+ assert dbEvent.getStatus();
+ assertEquals(db.getName(), dbEvent.getDatabase().getName());
+ assertEquals(db.getLocationUri(), dbEvent.getDatabase().getLocationUri());
+
+ driver.run("use tmpdb");
+ driver.run("create table tmptbl (a string) partitioned by (b string)");
+ Table tbl = msc.getTable("tmpdb", "tmptbl");
+ assertEquals(notifyList.size(), 2);
+ CreateTableEvent tblEvent = (CreateTableEvent)(notifyList.get(1));
+ assert tblEvent.getStatus();
+ assertEquals(tbl.getTableName(), tblEvent.getTable().getTableName());
+ assertEquals(tbl.getDbName(), tblEvent.getTable().getDbName());
+ assertEquals(tbl.getSd().getLocation(), tblEvent.getTable().getSd().getLocation());
+
+ driver.run("alter table tmptbl add partition (b='2011')");
+ Partition part = msc.getPartition("tmpdb", "tmptbl", "b=2011");
+ assertEquals(notifyList.size(), 3);
+ AddPartitionEvent partEvent = (AddPartitionEvent)(notifyList.get(2));
+ assert partEvent.getStatus();
+ assertEquals(part, partEvent.getPartition());
+
+ driver.run("alter table tmptbl drop partition (b='2011')");
+ assertEquals(notifyList.size(), 4);
+ DropPartitionEvent dropPart = (DropPartitionEvent)notifyList.get(3);
+ assert dropPart.getStatus();
+ assertEquals(part.getValues(), dropPart.getPartition().getValues());
+ assertEquals(part.getDbName(), dropPart.getPartition().getDbName());
+ assertEquals(part.getTableName(), dropPart.getPartition().getTableName());
+
+ driver.run("drop table tmptbl");
+ assertEquals(notifyList.size(), 5);
+ DropTableEvent dropTbl = (DropTableEvent)notifyList.get(4);
+ assert dropTbl.getStatus();
+ assertEquals(tbl.getTableName(), dropTbl.getTable().getTableName());
+ assertEquals(tbl.getDbName(), dropTbl.getTable().getDbName());
+ assertEquals(tbl.getSd().getLocation(), dropTbl.getTable().getSd().getLocation());
+
+
+ driver.run("drop database tmpdb");
+ assertEquals(notifyList.size(), 6);
+ DropDatabaseEvent dropDB = (DropDatabaseEvent)notifyList.get(5);
+ assert dropDB.getStatus();
+ assertEquals(db, dropDB.getDatabase());
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java (revision 0)
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore;
+
+import org.apache.hadoop.conf.Configurable;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
+import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+
+/**
+ * This abstract class needs to be extended to provide implementation of actions that needs
+ * to be performed when a particular event occurs on a metastore. These methods
+ * are called whenever an event occurs on metastore. Status of the event whether
+ * it was successful or not is contained in container event object.
+ */
+
+public abstract class MetaStoreEventListener implements Configurable {
+
+ private Configuration conf;
+
+ MetaStoreEventListener(Configuration config){
+ this.conf = config;
+ }
+ /**
+ * @param create table event.
+ * @throws MetaException
+ */
+ public abstract void onCreateTable (CreateTableEvent tableEvent) throws MetaException;
+
+ /**
+ * @param drop table event.
+ * @throws MetaException
+ */
+ public abstract void onDropTable (DropTableEvent tableEvent) throws MetaException;
+
+ /**
+ * @param add partition event
+ * @throws MetaException
+ */
+ public abstract void onAddPartition (AddPartitionEvent partitionEvent) throws MetaException;
+
+ /**
+ * @param drop partition event
+ * @throws MetaException
+ */
+ public abstract void onDropPartition (DropPartitionEvent partitionEvent) throws MetaException;
+
+ /**
+ * @param create database event
+ * @throws MetaException
+ */
+ public abstract void onCreateDatabase (CreateDatabaseEvent dbEvent) throws MetaException;
+
+ /**
+ * @param drop database event
+ * @throws MetaException
+ */
+ public abstract void onDropDatabase (DropDatabaseEvent dbEvent) throws MetaException;
+
+ @Override
+ public Configuration getConf() {
+ return this.conf;
+ }
+
+ @Override
+ public void setConf(Configuration config) {
+ this.conf = config;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1096112)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy)
@@ -65,6 +65,12 @@
import org.apache.hadoop.hive.metastore.api.Type;
import org.apache.hadoop.hive.metastore.api.UnknownDBException;
import org.apache.hadoop.hive.metastore.api.UnknownTableException;
+import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
+import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.DropTableEvent;
import org.apache.hadoop.hive.metastore.hooks.JDOConnectionURLHook;
import org.apache.hadoop.hive.metastore.model.MDBPrivilege;
import org.apache.hadoop.hive.metastore.model.MGlobalPrivilege;
@@ -201,6 +207,8 @@
private ClassLoader classLoader;
private AlterHandler alterHandler;
+ private List listeners;
+
{
classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
@@ -240,6 +248,7 @@
}
}
+ listeners = MetaStoreUtils.getMetaStoreListener(hiveConf);
return true;
}
@@ -546,8 +555,11 @@
} else {
wh.mkdirs(new Path(db.getLocationUri()));
}
+ for (MetaStoreEventListener listener : listeners) {
+ listener.onCreateDatabase(new CreateDatabaseEvent(db, success));
}
}
+ }
public void create_database(final Database db)
throws AlreadyExistsException, InvalidObjectException, MetaException {
@@ -660,8 +672,11 @@
wh.deleteDir(new Path(db.getLocationUri()), true);
// it is not a terrible thing even if the data is not deleted
}
+ for (MetaStoreEventListener listener : listeners) {
+ listener.onDropDatabase(new DropDatabaseEvent(db, success));
}
}
+ }
public void drop_database(final String dbName, final boolean deleteData)
throws NoSuchObjectException, InvalidOperationException, MetaException {
@@ -935,8 +950,11 @@
wh.deleteDir(tblPath, true);
}
}
+ for (MetaStoreEventListener listener : listeners) {
+ listener.onCreateTable(new CreateTableEvent(tbl, success));
}
}
+ }
public void create_table(final Table tbl) throws AlreadyExistsException,
MetaException, InvalidObjectException {
@@ -1022,7 +1040,6 @@
if (!ms.dropTable(dbname, name)) {
throw new MetaException("Unable to drop table");
}
- tbl = null; // table collections disappear after dropping
success = ms.commitTransaction();
} finally {
if (!success) {
@@ -1031,8 +1048,11 @@
wh.deleteDir(tblPath, true);
// ok even if the data is not deleted
}
+ for(MetaStoreEventListener listener : listeners){
+ listener.onDropTable(new DropTableEvent(tbl, success));
}
}
+ }
public void drop_table(final String dbname, final String name, final boolean deleteData)
throws NoSuchObjectException, MetaException {
@@ -1340,7 +1360,10 @@
wh.deleteDir(partLocation, true);
}
}
+ for(MetaStoreEventListener listener : listeners){
+ listener.onAddPartition(new AddPartitionEvent(part, success));
}
+ }
return part;
}
@@ -1431,7 +1454,10 @@
// ok even if the data is not deleted
}
}
+ for(MetaStoreEventListener listener : listeners){
+ listener.onDropPartition(new DropPartitionEvent(part, success));
}
+ }
return true;
}
public boolean drop_partition(final String db_name, final String tbl_name,
Index: metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (revision 1096112)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (working copy)
@@ -26,9 +26,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.Map.Entry;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -86,9 +86,9 @@
import org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege;
import org.apache.hadoop.hive.metastore.model.MTablePrivilege;
import org.apache.hadoop.hive.metastore.model.MType;
-import org.apache.hadoop.hive.metastore.parser.ExpressionTree.ANTLRNoCaseStringStream;
import org.apache.hadoop.hive.metastore.parser.FilterLexer;
import org.apache.hadoop.hive.metastore.parser.FilterParser;
+import org.apache.hadoop.hive.metastore.parser.ExpressionTree.ANTLRNoCaseStringStream;
import org.apache.hadoop.util.StringUtils;
/**
@@ -1000,6 +1000,7 @@
throw new NoSuchObjectException("partition values="
+ part_vals.toString());
}
+ part.setValues(part_vals);
return part;
}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (revision 1096112)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (working copy)
@@ -37,6 +37,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.JavaUtils;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.api.Constants;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
@@ -944,4 +945,37 @@
}
return filter.toString();
}
+
+ /**
+ * create listener instances as per the configuration.
+ * @param conf
+ * @return
+ * @throws MetaException
+ */
+ static List getMetaStoreListener (HiveConf conf)
+ throws MetaException {
+
+ List listeners = new ArrayList();
+ String listenerImplList = conf.getVar(HiveConf.ConfVars.METASTORE_EVENT_LISTENERS);
+ listenerImplList = listenerImplList.trim();
+ if (listenerImplList.equals("")) {
+ return listeners;
}
+
+ String[] listenerImpls = listenerImplList.split(",");
+ for (String listenerImpl : listenerImpls) {
+ try {
+ MetaStoreEventListener listener = (MetaStoreEventListener) Class.forName(
+ listenerImpl.trim(), true, JavaUtils.getClassLoader()).getConstructor(
+ Configuration.class).newInstance(conf);
+ listener.setConf(conf);
+ listeners.add(listener);
+ } catch (Exception e) {
+ throw new MetaException("Failed to instantiate listener named: "+
+ listenerImpl + e.toString());
+ }
+ }
+
+ return listeners;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java (revision 0)
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+
+public class DropPartitionEvent extends ListenerEvent {
+
+ private final Partition partition;
+
+ public DropPartitionEvent (Partition partition, boolean status) {
+
+ super (status);
+ this.partition = partition;
+ }
+
+ /**
+ * @return the partition
+ */
+ public Partition getPartition() {
+
+ return partition;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java (revision 0)
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+
+public class AddPartitionEvent extends ListenerEvent {
+
+ private final Partition partition;
+
+ public AddPartitionEvent (Partition partition, boolean status) {
+
+ super (status);
+ this.partition = partition;
+ }
+
+ /**
+ * @return the partition
+ */
+ public Partition getPartition() {
+ return partition;
+ }
+}
\ No newline at end of file
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java (revision 0)
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+/**
+ * Base class for all the events which are defined for metastore.
+ */
+
+public abstract class ListenerEvent {
+
+ /**
+ * status of the event, whether event was successful or not.
+ */
+ private final boolean status;
+
+ public ListenerEvent(boolean status) {
+ super();
+ this.status = status;
+ }
+
+ /**
+ * @return the status of event.
+ */
+ public boolean getStatus() {
+ return status;
+ }
+
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateDatabaseEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateDatabaseEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateDatabaseEvent.java (revision 0)
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Database;
+
+public class CreateDatabaseEvent extends ListenerEvent {
+
+ private final Database db;
+
+ public CreateDatabaseEvent (Database db, boolean status) {
+ super(status);
+ this.db = db;
+ }
+
+ /**
+ * @return the db
+ */
+ public Database getDatabase () {
+ return db;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/DropDatabaseEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/DropDatabaseEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/DropDatabaseEvent.java (revision 0)
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Database;
+
+public class DropDatabaseEvent extends ListenerEvent {
+
+ private final Database db;
+
+ public DropDatabaseEvent(Database db, boolean status) {
+ super(status);
+ this.db = db;
+ }
+
+ /**
+ * @return the db
+ */
+ public Database getDatabase() {
+ return db;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateTableEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateTableEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/CreateTableEvent.java (revision 0)
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public class CreateTableEvent extends ListenerEvent {
+
+ private final Table table;
+
+ public CreateTableEvent (Table table, boolean status) {
+
+ super (status);
+ this.table = table;
+ }
+
+ /**
+ * @return the table
+ */
+ public Table getTable () {
+ return table;
+ }
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/DropTableEvent.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/events/DropTableEvent.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/events/DropTableEvent.java (revision 0)
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public class DropTableEvent extends ListenerEvent{
+
+ private final Table table;
+
+ public DropTableEvent (Table table, boolean status) {
+
+ super (status);
+ this.table = table;
+ }
+
+ /**
+ * @return the table
+ */
+ public Table getTable () {
+ return table;
+ }
+}
Index: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (revision 1096112)
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (working copy)
@@ -215,6 +215,7 @@
METASTORE_IDENTIFIER_FACTORY("datanucleus.identifierFactory", "datanucleus"),
METASTORE_PLUGIN_REGISTRY_BUNDLE_CHECK("datanucleus.plugin.pluginRegistryBundleCheck", "LOG"),
METASTORE_BATCH_RETRIEVE_MAX("hive.metastore.batch.retrieve.max", 300),
+ METASTORE_EVENT_LISTENERS("hive.metastore.event.listeners", ""),
// should we do checks against the storage (usually hdfs) for operations like drop_partition
METASTORE_AUTHORIZATION_STORAGE_AUTH_CHECKS("hive.metastore.authorization.storage.checks", false),