public class NotificationListener extends MetaStoreEventListener
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.| Modifier and Type | Field and Description |
|---|---|
protected javax.jms.Connection |
conn |
static int |
NUM_RETRIES |
protected java.lang.ThreadLocal<javax.jms.Session> |
session |
| Constructor and Description |
|---|
NotificationListener(Configuration conf)
Create message bus connection and session in constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected javax.jms.Connection |
createConnection()
Create the JMS connection
|
protected javax.jms.MessageProducer |
createProducer(javax.jms.Destination topic)
Create a JMS producer
|
protected javax.jms.Session |
createSession()
Creates a JMS session
|
protected javax.jms.Topic |
createTopic(java.lang.String topicName)
Get the topic object for the topicName
|
protected void |
finalize() |
protected boolean |
isConnectionHealthy()
Send a dummy message to probe if the JMS connection is healthy
|
void |
onAddPartition(AddPartitionEvent partitionEvent) |
void |
onAlterPartition(AlterPartitionEvent ape) |
void |
onAlterTable(AlterTableEvent ate) |
void |
onCreateDatabase(CreateDatabaseEvent dbEvent) |
void |
onCreateTable(CreateTableEvent tableEvent) |
void |
onDropDatabase(DropDatabaseEvent dbEvent) |
void |
onDropPartition(DropPartitionEvent partitionEvent)
Send dropped partition notifications.
|
void |
onDropTable(DropTableEvent tableEvent)
Send dropped table notifications.
|
void |
onLoadPartitionDone(LoadPartitionDoneEvent lpde) |
protected void |
send(HCatEventMessage hCatEventMessage,
java.lang.String topicName) |
protected void |
send(HCatEventMessage hCatEventMessage,
java.lang.String topicName,
int retries) |
protected void |
testAndCreateConnection()
Does a health check on the connection by sending a dummy message.
|
getConf, setConfprotected javax.jms.Connection conn
public static final int NUM_RETRIES
protected final java.lang.ThreadLocal<javax.jms.Session> session
public NotificationListener(Configuration conf)
public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException
onAddPartition in class MetaStoreEventListenerMetaExceptionpublic void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException
onDropPartition in class MetaStoreEventListenerpartitionEvent - partition eventMetaExceptionpublic void onCreateDatabase(CreateDatabaseEvent dbEvent) throws MetaException
onCreateDatabase in class MetaStoreEventListenerdbEvent - database eventMetaExceptionpublic void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException
onDropDatabase in class MetaStoreEventListenerdbEvent - database eventMetaExceptionpublic void onCreateTable(CreateTableEvent tableEvent) throws MetaException
onCreateTable in class MetaStoreEventListenertableEvent - table event.MetaExceptionpublic void onDropTable(DropTableEvent tableEvent) throws MetaException
onDropTable in class MetaStoreEventListenertableEvent - table event.MetaExceptionprotected void send(HCatEventMessage hCatEventMessage, java.lang.String topicName)
hCatEventMessage - The HCatEventMessage being sent over JMS.topicName - is the name on message broker on which message is sent.protected void send(HCatEventMessage hCatEventMessage, java.lang.String topicName, int retries)
hCatEventMessage - The HCatEventMessage being sent over JMS, this method is threadsafetopicName - is the name on message broker on which message is sent.retries - the number of retry attemptsprotected javax.jms.Topic createTopic(java.lang.String topicName)
throws javax.jms.JMSException
topicName - The String identifying the message-topic.Topic object corresponding to the specified topicName.javax.jms.JMSExceptionprotected void testAndCreateConnection()
protected javax.jms.Connection createConnection()
protected boolean isConnectionHealthy()
protected javax.jms.Session createSession()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected javax.jms.MessageProducer createProducer(javax.jms.Destination topic)
throws javax.jms.JMSException
topic - javax.jms.JMSExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void onLoadPartitionDone(LoadPartitionDoneEvent lpde) throws MetaException
onLoadPartitionDone in class MetaStoreEventListenerMetaExceptionpublic void onAlterPartition(AlterPartitionEvent ape) throws MetaException
onAlterPartition in class MetaStoreEventListenerape - partition eventMetaExceptionpublic void onAlterTable(AlterTableEvent ate) throws MetaException
onAlterTable in class MetaStoreEventListenerate - alter table eventMetaExceptionCopyright © 2012 The Apache Software Foundation