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 ThreadLocal<javax.jms.Session> |
session |
Constructor and Description |
---|
NotificationListener(org.apache.hadoop.conf.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(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 tableEvent)
Send altered table notifications.
|
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,
String topicName) |
protected void |
send(HCatEventMessage hCatEventMessage,
String topicName,
int retries) |
protected void |
testAndCreateConnection()
Does a health check on the connection by sending a dummy message.
|
getConf, onAddIndex, onAlterIndex, onConfigChange, onDropIndex, onInsert, setConf
protected javax.jms.Connection conn
public static final int NUM_RETRIES
protected final ThreadLocal<javax.jms.Session> session
public NotificationListener(org.apache.hadoop.conf.Configuration conf)
public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException
onAddPartition
in class MetaStoreEventListener
MetaException
public void onAlterPartition(AlterPartitionEvent ape) throws MetaException
onAlterPartition
in class MetaStoreEventListener
ape
- partition eventMetaException
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 onAlterTable(AlterTableEvent tableEvent) throws MetaException
onAlterTable
in class MetaStoreEventListener
tableEvent
- alter table eventMetaException
public void onDropTable(DropTableEvent tableEvent) throws MetaException
onDropTable
in class MetaStoreEventListener
tableEvent
- table event.MetaException
protected void send(HCatEventMessage hCatEventMessage, 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, 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(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 Throwable
public void onLoadPartitionDone(LoadPartitionDoneEvent lpde) throws MetaException
onLoadPartitionDone
in class MetaStoreEventListener
MetaException
Copyright © 2016 The Apache Software Foundation. All rights reserved.