public class ElasticAlarmIndexer extends Object implements AlarmLifecycleListener, Runnable
AlarmLifecycleListener
.
In order to avoid blocking the callbacks issued via the AlarmLifecycleListener
interface while we communicate
with ES, the callbacks create tasks which are added to a queue. Tasks on this queue are then handled by a worker thread
and processed in the same order as which they were added.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TASK_QUEUE_CAPACITY |
static String |
INDEX_NAME |
Constructor and Description |
---|
ElasticAlarmIndexer(com.codahale.metrics.MetricRegistry metrics,
io.searchbox.client.JestClient client,
TemplateInitializer templateInitializer) |
ElasticAlarmIndexer(com.codahale.metrics.MetricRegistry metrics,
io.searchbox.client.JestClient client,
TemplateInitializer templateInitializer,
CacheConfig nodeCacheConfig,
int taskQueueCapacity,
IndexStrategy indexStrategy,
IndexSettings indexSettings) |
Modifier and Type | Method and Description |
---|---|
void |
bulkInsert(List<AlarmDocumentDTO> alarmDocuments) |
void |
destroy() |
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() |
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 |
run() |
void |
setAlarmReindexDurationMs(long alarmReindexDurationMs) |
void |
setBatchSize(int batchSize) |
void |
setBulkRetryCount(int bulkRetryCount) |
void |
setIndexAllUpdates(boolean indexAllUpdates) |
void |
setLookbackPeriodMs(long lookbackPeriodMs) |
void |
setUsePseudoClock(boolean usePseudoClock) |
public static final int DEFAULT_TASK_QUEUE_CAPACITY
public static final String INDEX_NAME
public ElasticAlarmIndexer(com.codahale.metrics.MetricRegistry metrics, io.searchbox.client.JestClient client, TemplateInitializer templateInitializer)
public ElasticAlarmIndexer(com.codahale.metrics.MetricRegistry metrics, io.searchbox.client.JestClient client, TemplateInitializer templateInitializer, CacheConfig nodeCacheConfig, int taskQueueCapacity, IndexStrategy indexStrategy, IndexSettings indexSettings)
public void init()
public void destroy()
public void bulkInsert(List<AlarmDocumentDTO> alarmDocuments) throws PersistenceException, IOException
PersistenceException
IOException
public 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 handleAlarmSnapshot(List<OnmsAlarm> alarms)
AlarmLifecycleListener
handleAlarmSnapshot
in interface AlarmLifecycleListener
alarms
- canonical set of alarms in the databasepublic 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 void setBulkRetryCount(int bulkRetryCount)
public void setBatchSize(int batchSize)
public void setAlarmReindexDurationMs(long alarmReindexDurationMs)
public void setLookbackPeriodMs(long lookbackPeriodMs)
public void setUsePseudoClock(boolean usePseudoClock)
public void setIndexAllUpdates(boolean indexAllUpdates)
Copyright © 2021. All rights reserved.