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, setConf
protected 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 MetaStoreEventListener
MetaException
public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException
onDropPartition
in class MetaStoreEventListener
partitionEvent
- partition eventMetaException
public void onCreateDatabase(CreateDatabaseEvent dbEvent) throws MetaException
onCreateDatabase
in class MetaStoreEventListener
dbEvent
- database eventMetaException
public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException
onDropDatabase
in class MetaStoreEventListener
dbEvent
- database eventMetaException
public void onCreateTable(CreateTableEvent tableEvent) throws MetaException
onCreateTable
in class MetaStoreEventListener
tableEvent
- table event.MetaException
public void onDropTable(DropTableEvent tableEvent) throws MetaException
onDropTable
in class MetaStoreEventListener
tableEvent
- table event.MetaException
protected 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.JMSException
protected void testAndCreateConnection()
protected javax.jms.Connection createConnection()
protected boolean isConnectionHealthy()
protected javax.jms.Session createSession() throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.MessageProducer createProducer(javax.jms.Destination topic) throws javax.jms.JMSException
topic
- javax.jms.JMSException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void onLoadPartitionDone(LoadPartitionDoneEvent lpde) throws MetaException
onLoadPartitionDone
in class MetaStoreEventListener
MetaException
public void onAlterPartition(AlterPartitionEvent ape) throws MetaException
onAlterPartition
in class MetaStoreEventListener
ape
- partition eventMetaException
public void onAlterTable(AlterTableEvent ate) throws MetaException
onAlterTable
in class MetaStoreEventListener
ate
- alter table eventMetaException
Copyright © 2012 The Apache Software Foundation