use of org.thingsboard.server.service.telemetry.sub.AlarmSubscriptionUpdate in project thingsboard by thingsboard.
the class DefaultSubscriptionManagerService method onLocalAlarmSubUpdate.
private void onLocalAlarmSubUpdate(EntityId entityId, Function<TbSubscription, TbAlarmsSubscription> castFunction, Predicate<TbAlarmsSubscription> filterFunction, Function<TbAlarmsSubscription, Alarm> processFunction, boolean deleted) {
Set<TbSubscription> entitySubscriptions = subscriptionsByEntityId.get(entityId);
if (entitySubscriptions != null) {
entitySubscriptions.stream().map(castFunction).filter(Objects::nonNull).filter(filterFunction).forEach(s -> {
Alarm alarm = processFunction.apply(s);
if (alarm != null) {
if (serviceId.equals(s.getServiceId())) {
AlarmSubscriptionUpdate update = new AlarmSubscriptionUpdate(s.getSubscriptionId(), alarm, deleted);
localSubscriptionService.onSubscriptionUpdate(s.getSessionId(), update, TbCallback.EMPTY);
} else {
TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_CORE, s.getServiceId());
toCoreNotificationsProducer.send(tpi, toProto(s, alarm, deleted), null);
}
}
});
} else {
log.debug("[{}] No device subscriptions to process!", entityId);
}
}
Aggregations