@Override public void run() { int ntfOk = 0; int ntfError = 0; for (int i = 0; i < this.iterations; i++) { try { this.publishService.putNotification(this.ntf); ntfOk++; } catch (final Exception e) { ntfError++; } } this.ntfOk = ntfOk; this.ntfError = ntfError; } }
@Override public void run() { int ntfOk = 0; int ntfError = 0; for (int i = 0; i < this.iterations; i++) { try { this.publishService.putNotification(this.ntf); ntfOk++; } catch (final Exception e) { ntfError++; } } this.ntfOk = ntfOk; this.ntfError = ntfError; } }
@Override public void publish(final Notification notification, final ExecutorService executor) { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { LOG.error("Notification publication was interupted: " + e); } }
@Override public void publish(final Notification notification) { try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { LOG.error("Notification publication was interupted: " + e); } }
/** * Publish the given notification. * * @param n A {@link Notification} instance. */ public void publish(Notification n) { if (serviceAvailable) { try { publishService.putNotification(n); } catch (InterruptedException e) { LOG.error("Interrupted.", e); } } }
private void sendNotificationIfPossible(final Notification notification) throws InterruptedException { if (notificationPublishService != null) { notificationPublishService.putNotification(notification); LOG.trace("{} was published.", notification.getClass()); } else { LOG.warn("Notification Provider is null!"); } }
@Override public void onNotification(@Nonnull final Notification notification) { LOG.debug("Notification: {} pushed into collector", notification.getClass().getSimpleName()); LOG.trace("Notification: {} pushed into collector", notification); try { bindingDOMNotificationPublishServiceAdapter.putNotification(notification); } catch (InterruptedException e) { LOG.warn("Interrupted", e); Thread.currentThread().interrupt(); } }
private void checkAndPublishRouterAssociatedtoVpnNotification(Uuid routerId, Uuid vpnId) throws InterruptedException { RouterAssociatedToVpn routerAssociatedToVpn = new RouterAssociatedToVpnBuilder().setRouterId(routerId) .setVpnId(vpnId).build(); LOG.info("publishing notification upon association of router to VPN"); notificationPublishService.putNotification(routerAssociatedToVpn); }
private void checkAndPublishRouterDisassociatedFromVpnNotification(Uuid routerId, Uuid vpnId) throws InterruptedException { RouterDisassociatedFromVpn routerDisassociatedFromVpn = new RouterDisassociatedFromVpnBuilder().setRouterId (routerId).setVpnId(vpnId).build(); LOG.info("publishing notification upon disassociation of router from VPN"); notificationPublishService.putNotification(routerDisassociatedFromVpn); }
private void checkAndFireMacChangedNotification(String interfaceName, InetAddress inetAddr, byte[] macAddressBytes) throws InterruptedException { IpAddress ip = new IpAddress(inetAddr.getHostAddress().toCharArray()); String macAddress = NWUtil.toStringMacAddress(macAddressBytes); PhysAddress mac = new PhysAddress(macAddress); if (!macAddress.equals(macsDB.get(interfaceName + "-" + inetAddr.getHostAddress()))) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("mac address changed for " + inetAddr); } MacChangedBuilder builder = new MacChangedBuilder(); builder.setInterface(interfaceName); builder.setIpaddress(ip); builder.setMacaddress(mac); notificationPublishService.putNotification(builder.build()); } }
@SuppressWarnings("checkstyle:IllegalCatch") private void handleMapReply(ByteBuffer buffer) { try { MapReply reply = MapReplySerializer.getInstance().deserialize(buffer); XtrReplyMappingBuilder replyMappingBuilder = new XtrReplyMappingBuilder(); replyMappingBuilder.setMapReply(LispNotificationHelper.convertMapReply(reply)); if (notificationPublishService != null) { notificationPublishService.putNotification(replyMappingBuilder.build()); LOG.trace("MapReply was published!"); } else { LOG.warn("Notification Provider is null!"); } } catch (RuntimeException re) { throw new LispMalformedPacketException( "Couldn't deserialize Map-Reply (len=" + buffer.capacity() + ")", re); } catch (InterruptedException e) { LOG.warn("Notification publication interrupted!"); } }
private void checkAndPublishPortRemoveNotification(String subnetIp, Uuid subnetId, Uuid portId, Long elanTag) throws InterruptedException { PortRemovedFromSubnetBuilder builder = new PortRemovedFromSubnetBuilder(); LOG.info("publish notification called"); builder.setPortId(portId); builder.setSubnetIp(subnetIp); builder.setSubnetId(subnetId); builder.setElanTag(elanTag); notificationPublishService.putNotification(builder.build()); }
private void checkAndPublishPortAddNotification(String subnetIp, Uuid subnetId, Uuid portId, Long elanTag) throws InterruptedException { PortAddedToSubnetBuilder builder = new PortAddedToSubnetBuilder(); LOG.info("publish notification called"); builder.setSubnetIp(subnetIp); builder.setSubnetId(subnetId); builder.setPortId(portId); builder.setElanTag(elanTag); notificationPublishService.putNotification(builder.build()); }
private void checkAndPublishSubnetDelNotification(Uuid subnetId, String subnetIp, String vpnName, Boolean isExternalvpn, Long elanTag) throws InterruptedException { SubnetDeletedFromVpnBuilder builder = new SubnetDeletedFromVpnBuilder(); LOG.info("publish notification called"); builder.setSubnetId(subnetId); builder.setSubnetIp(subnetIp); builder.setVpnName(vpnName); builder.setExternalVpn(isExternalvpn); builder.setElanTag(elanTag); notificationPublishService.putNotification(builder.build()); }
private void checkAndPublishSubnetUpdNotification(Uuid subnetId, String subnetIp, String vpnName, Boolean isExternalvpn, Long elanTag) throws InterruptedException { SubnetUpdatedInVpnBuilder builder = new SubnetUpdatedInVpnBuilder(); LOG.info("publish notification called"); builder.setSubnetId(subnetId); builder.setSubnetIp(subnetIp); builder.setVpnName(vpnName); builder.setExternalVpn(isExternalvpn); builder.setElanTag(elanTag); notificationPublishService.putNotification(builder.build()); }
private void checkAndPublishSubnetAddNotification(Uuid subnetId, String subnetIp, String vpnName, Boolean isExternalvpn, Long elanTag) throws InterruptedException { SubnetAddedToVpnBuilder builder = new SubnetAddedToVpnBuilder(); LOG.info("publish notification called"); builder.setSubnetId(subnetId); builder.setSubnetIp(subnetIp); builder.setVpnName(vpnName); builder.setExternalVpn(isExternalvpn); builder.setElanTag(elanTag); notificationPublishService.putNotification(builder.build()); }
private void fireArpReqRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMac, InetAddress dstInetAddr, int tableId, BigInteger metadata) throws InterruptedException { String macAddress = NWUtil.toStringMacAddress(srcMac); ArpRequestReceivedBuilder builder = new ArpRequestReceivedBuilder(); builder.setInterface(interfaceName); builder.setOfTableId((long) tableId); builder.setSrcIpaddress(new IpAddress(srcInetAddr.getHostAddress() .toCharArray())); builder.setDstIpaddress(new IpAddress(dstInetAddr.getHostAddress() .toCharArray())); builder.setSrcMac(new PhysAddress(macAddress)); builder.setMetadata(metadata); notificationPublishService.putNotification(builder.build()); }
private void fireArpRespRecvdNotification(String interfaceName, InetAddress inetAddr, byte[] macAddressBytes, int tableId, BigInteger metadata) throws InterruptedException { IpAddress ip = new IpAddress(inetAddr.getHostAddress().toCharArray()); String macAddress = NWUtil.toStringMacAddress(macAddressBytes); PhysAddress mac = new PhysAddress(macAddress); ArpResponseReceivedBuilder builder = new ArpResponseReceivedBuilder(); builder.setInterface(interfaceName); builder.setIpaddress(ip); builder.setOfTableId((long) tableId); builder.setMacaddress(mac); builder.setMetadata(metadata); notificationPublishService.putNotification(builder.build()); }
public static void sendSubscriptionDeletedNotification(JSONObject subsJsonObjec, String subscriptionResourceId) { String uri = subsJsonObjec.optString(ResourceSubscription.SUBSCRIBER_URI, null); if (uri == null) { return; } NotificationPrimitive onem2mNotification = new NotificationPrimitive(); onem2mNotification.setPrimitiveMany(NotificationPrimitive.URI, uri); JSONObject notification = new JSONObject(); String name = Onem2mDb.getInstance().getHierarchicalNameForResource(subscriptionResourceId); JsonUtils.put(notification, SUBSCRIPTION_DELETION, true); JsonUtils.put(notification, SUBSCRIPTION_REFERENCE, name); onem2mNotification.setPrimitive(NotificationPrimitive.CONTENT, notification.toString()); SubscriptionDeleted sd = new SubscriptionDeletedBuilder() .setOnem2mPrimitive(onem2mNotification.getPrimitivesList()) .build(); // now that we have a NotificationPrimitive, we need to send it to the Notifier try { Onem2mCoreProvider.getNotifier().putNotification(sd); } catch (Exception e){ LOG.error("cannot send notification"); } }
@SuppressWarnings("checkstyle:IllegalCatch") private void handleMapNotify(ByteBuffer inBuffer, InetAddress sourceAddress, int port) { try { MapNotify mapNotify = MapNotifySerializer.getInstance().deserialize(inBuffer); GotMapNotifyBuilder gotMapNotifyBuilder = new GotMapNotifyBuilder(); gotMapNotifyBuilder.setMapNotify(LispNotificationHelper.convertMapNotify(mapNotify)); TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder(); transportAddressBuilder.setIpAddress(LispNotificationHelper .getIpAddressBinaryFromInetAddress(sourceAddress)); transportAddressBuilder.setPort(new PortNumber(port)); gotMapNotifyBuilder.setTransportAddress(transportAddressBuilder.build()); if (notificationPublishService != null) { notificationPublishService.putNotification(gotMapNotifyBuilder.build()); LOG.trace("MapNotify was published!"); } else { LOG.warn("Notification Provider is null!"); } } catch (RuntimeException re) { throw new LispMalformedPacketException("Couldn't deserialize Map-Notify (len=" + inBuffer.capacity() + ")", re); } catch (InterruptedException e) { LOG.warn("Notification publication interrupted!"); } }