org.apache.hcatalog.listener
Class NotificationListener

java.lang.Object
  extended by org.apache.hadoop.hive.metastore.MetaStoreEventListener
      extended by org.apache.hcatalog.listener.NotificationListener
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable

public class NotificationListener
extends org.apache.hadoop.hive.metastore.MetaStoreEventListener

Implementation of MetaStoreEventListener It sends message on two type of topics. One has name of form dbName.tblName On this topic, two kind of messages are sent: add/drop partition and finalize_partition message. Second topic has name "HCAT" and messages sent on it are: add/drop database and add/drop table. All messages also has a property named "HCAT_EVENT" set on them whose value can be used to configure message selector on subscriber side.


Field Summary
protected  javax.jms.Connection conn
           
protected  javax.jms.Session session
           
 
Constructor Summary
NotificationListener(org.apache.hadoop.conf.Configuration conf)
          Create message bus connection and session in constructor.
 
Method Summary
protected  void createConnection()
           
protected  void finalize()
           
 void onAddPartition(org.apache.hadoop.hive.metastore.events.AddPartitionEvent partitionEvent)
           
 void onAlterPartition(org.apache.hadoop.hive.metastore.events.AlterPartitionEvent ape)
           
 void onAlterTable(org.apache.hadoop.hive.metastore.events.AlterTableEvent ate)
           
 void onCreateDatabase(org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent dbEvent)
           
 void onCreateTable(org.apache.hadoop.hive.metastore.events.CreateTableEvent tableEvent)
           
 void onDropDatabase(org.apache.hadoop.hive.metastore.events.DropDatabaseEvent dbEvent)
           
 void onDropPartition(org.apache.hadoop.hive.metastore.events.DropPartitionEvent partitionEvent)
           
 void onDropTable(org.apache.hadoop.hive.metastore.events.DropTableEvent tableEvent)
           
 void onLoadPartitionDone(org.apache.hadoop.hive.metastore.events.LoadPartitionDoneEvent lpde)
           
protected  void send(java.lang.Object msgBody, java.lang.String topicName, java.lang.String event)
           
 
Methods inherited from class org.apache.hadoop.hive.metastore.MetaStoreEventListener
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected javax.jms.Session session

conn

protected javax.jms.Connection conn
Constructor Detail

NotificationListener

public NotificationListener(org.apache.hadoop.conf.Configuration conf)
Create message bus connection and session in constructor.

Method Detail

onAddPartition

public void onAddPartition(org.apache.hadoop.hive.metastore.events.AddPartitionEvent partitionEvent)
                    throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onAddPartition in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onDropPartition

public void onDropPartition(org.apache.hadoop.hive.metastore.events.DropPartitionEvent partitionEvent)
                     throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onDropPartition in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onCreateDatabase

public void onCreateDatabase(org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent dbEvent)
                      throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onCreateDatabase in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onDropDatabase

public void onDropDatabase(org.apache.hadoop.hive.metastore.events.DropDatabaseEvent dbEvent)
                    throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onDropDatabase in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onCreateTable

public void onCreateTable(org.apache.hadoop.hive.metastore.events.CreateTableEvent tableEvent)
                   throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onCreateTable in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onDropTable

public void onDropTable(org.apache.hadoop.hive.metastore.events.DropTableEvent tableEvent)
                 throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onDropTable in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

send

protected void send(java.lang.Object msgBody,
                    java.lang.String topicName,
                    java.lang.String event)
Parameters:
msgBody - is the metastore object. It is sent in full such that if subscriber is really interested in details, it can reconstruct it fully. In case of finalize_partition message this will be string specification of the partition.
topicName - is the name on message broker on which message is sent.
event - is the value of HCAT_EVENT property in message. It can be used to select messages in client side.

createConnection

protected void createConnection()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

onLoadPartitionDone

public void onLoadPartitionDone(org.apache.hadoop.hive.metastore.events.LoadPartitionDoneEvent lpde)
                         throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onLoadPartitionDone in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onAlterPartition

public void onAlterPartition(org.apache.hadoop.hive.metastore.events.AlterPartitionEvent ape)
                      throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onAlterPartition in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

onAlterTable

public void onAlterTable(org.apache.hadoop.hive.metastore.events.AlterTableEvent ate)
                  throws org.apache.hadoop.hive.metastore.api.MetaException
Specified by:
onAlterTable in class org.apache.hadoop.hive.metastore.MetaStoreEventListener
Throws:
org.apache.hadoop.hive.metastore.api.MetaException