private void snoopOnUnregister(NotificationResult nr) { Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME); if (delegateSet == null || delegateSet.isEmpty()) { return; } for (TargetedNotification tn : nr.getTargetedNotifications()) { Integer id = tn.getListenerID(); for (IdAndFilter idaf : delegateSet) { if (idaf.id == id) { // This is a notification from the MBeanServerDelegate. Notification n = tn.getNotification(); if (n instanceof MBeanServerNotification && n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { MBeanServerNotification mbsn = (MBeanServerNotification) n; ObjectName gone = mbsn.getMBeanName(); synchronized (listenerMap) { listenerMap.remove(gone); } } } } } }
private NotificationResult fetchNotifs() { try { NotificationResult nr = ClientNotifForwarder.this. fetchNotifs(clientSequenceNumber,maxNotifications, timeout); if (logger.traceOn()) { logger.trace("NotifFetcher-run", "Got notifications from the server: "+nr); } return nr; } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) { logger.trace("NotifFetcher.fetchNotifs", e); return fetchOneNotif(); } catch (IOException ioe) { if (!shouldStop()) { logger.error("NotifFetcher-run", "Failed to fetch notification, " + "stopping thread. Error is: " + ioe, ioe); logger.debug("NotifFetcher-run",ioe); } // no more fetching return null; } }
private void snoopOnUnregister(NotificationResult nr) { List<IdAndFilter> copy = null; synchronized (listenerMap) { Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME); if (delegateSet == null || delegateSet.isEmpty()) { return; } copy = new ArrayList<>(delegateSet); } for (TargetedNotification tn : nr.getTargetedNotifications()) { Integer id = tn.getListenerID(); for (IdAndFilter idaf : copy) { if (idaf.id == id) { // This is a notification from the MBeanServerDelegate. Notification n = tn.getNotification(); if (n instanceof MBeanServerNotification && n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { MBeanServerNotification mbsn = (MBeanServerNotification) n; ObjectName gone = mbsn.getMBeanName(); synchronized (listenerMap) { listenerMap.remove(gone); } } } } } }
public NotificationResult fetchNotifications(NotificationBufferFilter filter, long startSequenceNumber, long timeout, int maxNotifications) throws InterruptedException { NotificationBuffer buf = ArrayNotificationBuffer.this; return buf.fetchNotifications(filter, startSequenceNumber, timeout, maxNotifications); }
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // return new NotificationResult(0L, 0L, new TargetedNotification[0]); } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
private NotificationResult fetchNotifs() { try { NotificationResult nr = ClientNotifForwarder.this. fetchNotifs(clientSequenceNumber,maxNotifications, timeout); if (logger.traceOn()) { logger.trace("NotifFetcher-run", "Got notifications from the server: "+nr); } return nr; } catch (ClassNotFoundException | NotSerializableException e) { logger.trace("NotifFetcher.fetchNotifs", e); return fetchOneNotif(); } catch (IOException ioe) { if (!shouldStop()) { logger.error("NotifFetcher-run", "Failed to fetch notification, " + "stopping thread. Error is: " + ioe, ioe); logger.debug("NotifFetcher-run",ioe); } // no more fetching return null; } }