public class OpennmsKafkaProducer extends Object implements AlarmLifecycleListener, EventListener
Modifier and Type | Field and Description |
---|---|
static String |
KAFKA_CLIENT_PID |
Constructor and Description |
---|
OpennmsKafkaProducer(ProtobufMapper protobufMapper,
NodeCache nodeCache,
org.osgi.service.cm.ConfigurationAdmin configAdmin,
EventSubscriptionService eventSubscriptionService) |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
AlarmCallbackStateTracker |
getAlarmCallbackStateTracker() |
CountDownLatch |
getAlarmForwardedLatch() |
CountDownLatch |
getEventForwardedLatch() |
String |
getName()
Return the id of the listener
|
CountDownLatch |
getNodeForwardedLatch() |
void |
handleAlarmSnapshot(List<OnmsAlarm> alarms)
Called periodically with a complete set of alarms as present in the database
at the given timestamp.
|
void |
handleDeletedAlarm(int alarmId,
String reductionKey)
Called when an alarm has been deleted.
|
void |
handleNewOrUpdatedAlarm(OnmsAlarm alarm)
Called when an alarm has been created or updated.
|
void |
init() |
boolean |
isForwardingAlarms() |
void |
onEvent(Event event)
Process a sent event.
|
void |
postHandleAlarmSnapshot()
Called after
AlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>) has been called on all the listeners, and
after the session & transaction used to perform the snapshot has been closed. |
void |
preHandleAlarmSnapshot()
Called before the transaction is opened and the alarms are read for subsequent
calls to
AlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>) . |
void |
setAlarmFilter(String alarmFilter) |
void |
setAlarmTopic(String alarmTopic) |
OpennmsKafkaProducer |
setDataSync(KafkaAlarmDataSync dataSync) |
void |
setEventFilter(String eventFilter) |
void |
setEventTopic(String eventTopic) |
void |
setKafkaSendQueueCapacity(int kafkaSendQueueCapacity) |
void |
setNodeTopic(String nodeTopic) |
void |
setSuppressIncrementalAlarms(boolean suppressIncrementalAlarms) |
boolean |
shouldForwardAlarm(OnmsAlarm alarm) |
public static final String KAFKA_CLIENT_PID
public OpennmsKafkaProducer(ProtobufMapper protobufMapper, NodeCache nodeCache, org.osgi.service.cm.ConfigurationAdmin configAdmin, EventSubscriptionService eventSubscriptionService)
public void init() throws IOException
IOException
public void destroy()
public boolean shouldForwardAlarm(OnmsAlarm alarm)
public void handleAlarmSnapshot(List<OnmsAlarm> alarms)
AlarmLifecycleListener
handleAlarmSnapshot
in interface AlarmLifecycleListener
alarms
- canonical set of alarms in the databasepublic void preHandleAlarmSnapshot()
AlarmLifecycleListener
AlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
.
This can be used to trigger any necessary state tracking to accurately handle
the snapshot results.preHandleAlarmSnapshot
in interface AlarmLifecycleListener
public void postHandleAlarmSnapshot()
AlarmLifecycleListener
AlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
has been called on all the listeners, and
after the session & transaction used to perform the snapshot has been closed.
This can be used to trigger any necessary post-processing of the results once
the related session has been closed.
This function may be called immediately after a call to AlarmLifecycleListener.preHandleAlarmSnapshot()
if
an error occurred while preparing the snapshot i.e. when opening the transaction.postHandleAlarmSnapshot
in interface AlarmLifecycleListener
public void handleNewOrUpdatedAlarm(OnmsAlarm alarm)
AlarmLifecycleListener
handleNewOrUpdatedAlarm
in interface AlarmLifecycleListener
alarm
- a newly created or updated alarmpublic void handleDeletedAlarm(int alarmId, String reductionKey)
AlarmLifecycleListener
handleDeletedAlarm
in interface AlarmLifecycleListener
alarmId
- id of the alarm that was deletedreductionKey
- reduction key of the alarm that was deletedpublic String getName()
EventListener
getName
in interface EventListener
String
object.public void onEvent(Event event)
EventListener
onEvent
in interface EventListener
event
- a Event
object.public void setEventTopic(String eventTopic)
public void setAlarmTopic(String alarmTopic)
public void setNodeTopic(String nodeTopic)
public void setEventFilter(String eventFilter)
public void setAlarmFilter(String alarmFilter)
public OpennmsKafkaProducer setDataSync(KafkaAlarmDataSync dataSync)
public boolean isForwardingAlarms()
public CountDownLatch getEventForwardedLatch()
public CountDownLatch getAlarmForwardedLatch()
public CountDownLatch getNodeForwardedLatch()
public void setSuppressIncrementalAlarms(boolean suppressIncrementalAlarms)
public AlarmCallbackStateTracker getAlarmCallbackStateTracker()
public void setKafkaSendQueueCapacity(int kafkaSendQueueCapacity)
Copyright © 2019. All rights reserved.