@Override public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification) { final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers = listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } return tryPublish(notification, subscribers); }
public synchronized void publishNotification(final DOMNotification notification) { for (final DOMNotificationListener domNotificationListener : listeners.get(notification.getType())) { domNotificationListener.onNotification(notification); } }
@Override public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification, final long timeout, final TimeUnit unit) throws InterruptedException { final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers = listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } // Attempt to perform a non-blocking publish first final ListenableFuture<? extends Object> noBlock = tryPublish(notification, subscribers); if (!DOMNotificationPublishService.REJECTED.equals(noBlock)) { return noBlock; } /* * FIXME: we need a background thread, which will watch out for blocking too long. Here * we will arm a tasklet for it and synchronize delivery of interrupt properly. */ throw new UnsupportedOperationException("Not implemented yet"); }
@Override public void onNotification(@Nonnull final DOMNotification notification) { final Notification baNotification = deserialize(notification); final QName notificationQName = notification.getType().getLastComponent(); getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification); }
@Override public ListenableFuture<? extends Object> putNotification(final DOMNotification notification) throws InterruptedException { final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers = listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } final long seq = disruptor.getRingBuffer().next(); return publish(seq, notification, subscribers); }
@Override public void onNotification(final DOMNotification notification) { SchemaPath notificationPath = notification.getType(); Date notificationEventTime = null; if (notification instanceof DOMEvent) { notificationEventTime = ((DOMEvent) notification).getEventTime(); } final String namespace = notification.getType().getLastComponent().getNamespace().toString(); for (NotificationTopicRegistration notifReg : notificationTopicRegistrations.get(namespace)) { notifReg.setLastEventTime(notificationEventTime); Set<TopicId> topicIdsForNotification = notifReg.getTopicsForNotification(notificationPath); for (TopicId topicId : topicIdsForNotification) { publishNotification(notification, topicId); LOG.debug("Notification {} has been published for TopicId {}", notification.getType(), topicId.getValue()); } } }
private Notification deserialize(final DOMNotification notification) { if(notification instanceof LazySerializedDOMNotification) { return ((LazySerializedDOMNotification) notification).getBindingData(); } return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody()); }
private Notification deserialize(final DOMNotification notification) { if(notification instanceof LazySerializedDOMNotification) { return ((LazySerializedDOMNotification) notification).getBindingData(); } return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody()); } }
/** * This method implements on Notification. * When there is a notification received by listener, that should be * parsed for the subscription-id and then processed. */ @Override public void onNotification(DOMNotification notification) { LOG.trace("Notification recieved {}", notification.getBody()); QName qname = PushUpdate.QNAME; SchemaPath schemaPath = SchemaPath.create(true, qname); if (notification.getType().equals(schemaPath)) { ContainerNode conNode = notification.getBody(); //If the subscription-id of notification same as // subscription-id set for this object then proceed. //if (conNode.getChild(subid).get().getValue().toString().equals(subscription_id)){ if (this.subscriptionList.contains(conNode.getChild(subid).get().getValue().toString())) { LOG.trace("Received push-udpate for subscription {}",conNode.getChild(subid).get().getValue().toString() ); try { pushUpdateHandlder(notification); } catch (Exception e) { LOG.warn(e.toString()); } } else { LOG.error("Received subscription-id {} is not valid. Skipping the notification processing", conNode.getChild(subid).get().getValue().toString()); } } }
private AnyXmlNode encapsulate(final DOMNotification body) { // FIXME: Introduce something like YangModeledAnyXmlNode in Yangtools final Document doc = XmlUtil.newDocument(); final Optional<String> namespace = Optional.of(PAYLOAD_ARG.getNodeType().getNamespace().toString()); final Element element = XmlUtil.createElement(doc, "payload", namespace); final DOMResult result = new DOMResult(element); final SchemaContext context = mount.getSchemaContext(); final SchemaPath schemaPath = body.getType(); try { NetconfUtil.writeNormalizedNode(body.getBody(), result, schemaPath, context); return Builders.anyXmlBuilder().withNodeIdentifier(PAYLOAD_ARG).withValue(new DOMSource(element)).build(); } catch (IOException | XMLStreamException e) { LOG.error("Unable to encapsulate notification.", e); throw Throwables.propagate(e); } }