Class ElasticAlarmHistoryRepository
- java.lang.Object
-
- org.opennms.features.alarms.history.elastic.ElasticAlarmHistoryRepository
-
- All Implemented Interfaces:
AlarmHistoryRepository
public class ElasticAlarmHistoryRepository extends java.lang.Object implements AlarmHistoryRepository
Queries alarm history stored in Elasticsearch.
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_LOOKBACK_PERIOD_MS
-
Constructor Summary
Constructors Constructor Description ElasticAlarmHistoryRepository(io.searchbox.client.JestClient client, IndexStrategy indexStrategy, IndexSettings indexSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<AlarmState>getActiveAlarmsAt(long time)Retrieves the last known state of alarms which were active (and not yet deleted) at the given time.java.util.List<AlarmState>getActiveAlarmsNow()Retrieves the last known state of alarms which are currently active (and not yet deleted).java.util.Optional<AlarmState>getAlarmWithDbIdAt(long id, long time)Retrieves the last known state of the alarm with the given database id, at or before the given time.java.util.Optional<AlarmState>getAlarmWithReductionKeyIdAt(java.lang.String reductionKey, long time)Similar toAlarmHistoryRepository.getAlarmWithDbIdAt(long, long), except the lookup is performed using the reduction key.java.util.List<AlarmState>getLastStateOfAllAlarms(long start, long end)Retrieves the last known state of all alarms which were recorded in the given time period.longgetNumActiveAlarmsAt(long time)Retrieves the number of alarms which were active at the given time.longgetNumActiveAlarmsNow()Retrieves the number of alarms which are currently active.java.util.List<AlarmState>getStatesForAlarmWithDbId(long id)Retrieves all the known states for the alarm with the given database id.java.util.List<AlarmState>getStatesForAlarmWithReductionKey(java.lang.String reductionKey)Retrieves all the known states for the alarm with the given database reduction key.voidsetLookbackPeriodMs(long lookbackPeriodMs)
-
-
-
Constructor Detail
-
ElasticAlarmHistoryRepository
public ElasticAlarmHistoryRepository(io.searchbox.client.JestClient client, IndexStrategy indexStrategy, IndexSettings indexSettings)
-
-
Method Detail
-
getAlarmWithDbIdAt
public java.util.Optional<AlarmState> getAlarmWithDbIdAt(long id, long time)
Description copied from interface:AlarmHistoryRepositoryRetrieves the last known state of the alarm with the given database id, at or before the given time. If the alarm was deleted at (or before) this time, the returned document will only include minimal information. To retrieve the complete state prior to the delete you can perform another call to this this function with a time less thanAlarmState.getDeletedTime().- Specified by:
getAlarmWithDbIdAtin interfaceAlarmHistoryRepository- Parameters:
id- database id of the alarm to querytime- timestamps in milliseconds- Returns:
- the last known state of the alarm, or an empty
Optionalif none was found
-
getAlarmWithReductionKeyIdAt
public java.util.Optional<AlarmState> getAlarmWithReductionKeyIdAt(java.lang.String reductionKey, long time)
Description copied from interface:AlarmHistoryRepositorySimilar toAlarmHistoryRepository.getAlarmWithDbIdAt(long, long), except the lookup is performed using the reduction key.- Specified by:
getAlarmWithReductionKeyIdAtin interfaceAlarmHistoryRepository- Parameters:
reductionKey- reduction key of the alarm to querytime- timestamps in milliseconds- Returns:
- the last known state of the alarm, or an empty
Optionalif none was found
-
getStatesForAlarmWithDbId
public java.util.List<AlarmState> getStatesForAlarmWithDbId(long id)
Description copied from interface:AlarmHistoryRepositoryRetrieves all the known states for the alarm with the given database id.- Specified by:
getStatesForAlarmWithDbIdin interfaceAlarmHistoryRepository- Parameters:
id- database id of the alarm to query- Returns:
- all the known states for the alarm, or an empty list if none were found
-
getStatesForAlarmWithReductionKey
public java.util.List<AlarmState> getStatesForAlarmWithReductionKey(java.lang.String reductionKey)
Description copied from interface:AlarmHistoryRepositoryRetrieves all the known states for the alarm with the given database reduction key.- Specified by:
getStatesForAlarmWithReductionKeyin interfaceAlarmHistoryRepository- Parameters:
reductionKey- reduction key of the alarm to query- Returns:
- all the known states for the alarm, or an empty list if none were found
-
getActiveAlarmsAt
public java.util.List<AlarmState> getActiveAlarmsAt(long time)
Description copied from interface:AlarmHistoryRepositoryRetrieves the last known state of alarms which were active (and not yet deleted) at the given time.- Specified by:
getActiveAlarmsAtin interfaceAlarmHistoryRepository- Parameters:
time- timestamp in milliseconds- Returns:
- list of alarms
-
getLastStateOfAllAlarms
public java.util.List<AlarmState> getLastStateOfAllAlarms(long start, long end)
Description copied from interface:AlarmHistoryRepositoryRetrieves the last known state of all alarms which were recorded in the given time period.- Specified by:
getLastStateOfAllAlarmsin interfaceAlarmHistoryRepository- Parameters:
start- timestamp in milliseconds (inclusive)end- timestamp in milliseconds (inclusive)- Returns:
- list of alarms
-
getNumActiveAlarmsAt
public long getNumActiveAlarmsAt(long time)
Description copied from interface:AlarmHistoryRepositoryRetrieves the number of alarms which were active at the given time.- Specified by:
getNumActiveAlarmsAtin interfaceAlarmHistoryRepository- Parameters:
time- timestamp in milliseconds- Returns:
- number of active alarms
-
getActiveAlarmsNow
public java.util.List<AlarmState> getActiveAlarmsNow()
Description copied from interface:AlarmHistoryRepositoryRetrieves the last known state of alarms which are currently active (and not yet deleted).- Specified by:
getActiveAlarmsNowin interfaceAlarmHistoryRepository- Returns:
- list of alarms
-
getNumActiveAlarmsNow
public long getNumActiveAlarmsNow()
Description copied from interface:AlarmHistoryRepositoryRetrieves the number of alarms which are currently active.- Specified by:
getNumActiveAlarmsNowin interfaceAlarmHistoryRepository- Returns:
- number of active alarms
-
setLookbackPeriodMs
public void setLookbackPeriodMs(long lookbackPeriodMs)
-
-