/** * Creates an alarm identifier from the specified device id and * unique identifier provided representation. * * @param id device id * @param uniqueIdentifier per device unique identifier of the alarm * @return alarm identifier */ public static AlarmId alarmId(DeviceId id, String uniqueIdentifier) { return new AlarmId(id, uniqueIdentifier); }
@Override public boolean cleared() { return severity.equals(SeverityLevel.CLEARED); }
/** * Constructs a Builder to create a Default Alarm based on another alarm. * * @param alarm the other alarm */ public Builder(final Alarm alarm) { this(alarm.id(), alarm.deviceId(), alarm.description(), alarm.severity(), alarm.timeRaised()); this.source = alarm.source(); this.timeUpdated = alarm.timeUpdated(); this.timeCleared = alarm.timeCleared(); this.isServiceAffecting = alarm.serviceAffecting(); this.isAcknowledged = alarm.acknowledged(); this.isManuallyClearable = alarm.manuallyClearable(); this.assignedUser = alarm.assignedUser(); }
private void populateRow(TableModel.Row row, Alarm alarm) { log.debug("populate table Row row={} item ={}", row, alarm); row.cell(ID, alarm.id().fingerprint()) .cell(DEVICE_ID_STR, alarm.deviceId()) .cell(DESCRIPTION, alarm.description()) .cell(SOURCE, alarm.source()) .cell(TIME_RAISED, new DateTime(alarm.timeRaised())) .cell(SEVERITY, alarm.severity()); } }
@Override public Alarm updateBookkeepingFields(AlarmId id, boolean isAcknowledged, String assignedUser) { Alarm found = store.getAlarm(id); if (found == null) { throw new ItemNotFoundException("Alarm with id " + id + " found"); } Alarm updated = new DefaultAlarm.Builder(found) .withId(found.id()) .withAcknowledged(isAcknowledged) .withAssignedUser(assignedUser).build(); store.setAlarm(updated); return updated; }
@Override public DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId) { return new DefaultAlarm.Builder( deviceId, "SNMP alarm retrieval failed", Alarm.SeverityLevel.CRITICAL, System.currentTimeMillis()).build(); } }
/** * Returns all of the ACTIVE alarms for a specific device. Recently cleared alarms excluded. * * @param deviceId the device to use when searching alarms. * @return set of alarms; empty set if no alarms */ default Set<Alarm> getActiveAlarms(DeviceId deviceId) { return getActiveAlarms().stream() .filter(a -> deviceId.equals(a.deviceId())) .collect(Collectors.toSet()); }
@Override public void setAlarm(Alarm alarm) { alarms.put(alarm.id(), alarm); }
public static long getEventTime(Document doc) throws UnsupportedOperationException, IllegalArgumentException { String dateTime = getEventTimeNode(doc).getTextContent(); return getEventTime(dateTime); }
/** * Clears the alarm that is being created. * * @return self for chaining */ public Builder clear() { this.severity = SeverityLevel.CLEARED; final long now = System.currentTimeMillis(); return withTimeCleared(now).withTimeUpdated(now); }
public static AlarmEntityId alarmEntityId(final String string) { return alarmEntityId(URI.create(string)); }
private AlarmId generateAlarmId() { return AlarmId.alarmId(alarmIdGenerator.incrementAndGet()); }
static Set<Alarm> lookUpAlarms(DeviceId deviceId) { return alarmService().getAlarms(deviceId); }
static Map<Alarm.SeverityLevel, Long> lookUpAlarmCounts() { return alarmService().getAlarmCounts(); }
private void consumeAlarms(Device device) { if (device.is(AlarmConsumer.class)) { providerService.updateAlarmList(device.id(), device.as(AlarmConsumer.class).consumeAlarms()); } else { log.info("Device {} does not support alarm consumer behaviour", device.id()); } }
public static Node getDescriptionNode(Document doc) { return getEventTimeNode(doc).getNextSibling(); }
/** * Builds the alarm. * * @return self for chaining */ public DefaultAlarm build() { checkNotNull(id, "Must specify an alarm id"); checkNotNull(deviceId, "Must specify a device"); checkNotNull(description, "Must specify a description"); checkNotNull(severity, "Must specify a severity"); return new DefaultAlarm(id, deviceId, description, source, timeRaised, timeUpdated, timeCleared, severity, isServiceAffecting, isAcknowledged, isManuallyClearable, assignedUser); } }
static Alarm lookupAlarm(AlarmId alarmId) { return alarmService().getAlarm(alarmId); }
private static DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId) { return new DefaultAlarm.Builder( deviceId, "SNMP alarm retrieval failed", Alarm.SeverityLevel.CRITICAL, System.currentTimeMillis()).build(); }
/** * Creates an alarm identifier from the specified globally unique identifier. * * @param globallyUniqueIdentifier the globally unique identifier of the Alarm, * device Id + local unique identifier on the device * @return alarm identifier */ public static AlarmId alarmId(String globallyUniqueIdentifier) { return new AlarmId(globallyUniqueIdentifier); }