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 long
DEFAULT_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.long
getNumActiveAlarmsAt(long time)
Retrieves the number of alarms which were active at the given time.long
getNumActiveAlarmsNow()
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.void
setLookbackPeriodMs(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:AlarmHistoryRepository
Retrieves 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:
getAlarmWithDbIdAt
in interfaceAlarmHistoryRepository
- Parameters:
id
- database id of the alarm to querytime
- timestamps in milliseconds- Returns:
- the last known state of the alarm, or an empty
Optional
if none was found
-
getAlarmWithReductionKeyIdAt
public java.util.Optional<AlarmState> getAlarmWithReductionKeyIdAt(java.lang.String reductionKey, long time)
Description copied from interface:AlarmHistoryRepository
Similar toAlarmHistoryRepository.getAlarmWithDbIdAt(long, long)
, except the lookup is performed using the reduction key.- Specified by:
getAlarmWithReductionKeyIdAt
in interfaceAlarmHistoryRepository
- Parameters:
reductionKey
- reduction key of the alarm to querytime
- timestamps in milliseconds- Returns:
- the last known state of the alarm, or an empty
Optional
if none was found
-
getStatesForAlarmWithDbId
public java.util.List<AlarmState> getStatesForAlarmWithDbId(long id)
Description copied from interface:AlarmHistoryRepository
Retrieves all the known states for the alarm with the given database id.- Specified by:
getStatesForAlarmWithDbId
in 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:AlarmHistoryRepository
Retrieves all the known states for the alarm with the given database reduction key.- Specified by:
getStatesForAlarmWithReductionKey
in 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:AlarmHistoryRepository
Retrieves the last known state of alarms which were active (and not yet deleted) at the given time.- Specified by:
getActiveAlarmsAt
in 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:AlarmHistoryRepository
Retrieves the last known state of all alarms which were recorded in the given time period.- Specified by:
getLastStateOfAllAlarms
in 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:AlarmHistoryRepository
Retrieves the number of alarms which were active at the given time.- Specified by:
getNumActiveAlarmsAt
in interfaceAlarmHistoryRepository
- Parameters:
time
- timestamp in milliseconds- Returns:
- number of active alarms
-
getActiveAlarmsNow
public java.util.List<AlarmState> getActiveAlarmsNow()
Description copied from interface:AlarmHistoryRepository
Retrieves the last known state of alarms which are currently active (and not yet deleted).- Specified by:
getActiveAlarmsNow
in interfaceAlarmHistoryRepository
- Returns:
- list of alarms
-
getNumActiveAlarmsNow
public long getNumActiveAlarmsNow()
Description copied from interface:AlarmHistoryRepository
Retrieves the number of alarms which are currently active.- Specified by:
getNumActiveAlarmsNow
in interfaceAlarmHistoryRepository
- Returns:
- number of active alarms
-
setLookbackPeriodMs
public void setLookbackPeriodMs(long lookbackPeriodMs)
-
-