use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class ClientNotifForwarder method removeNotificationListener.
public synchronized Integer[] removeNotificationListener(ObjectName name, NotificationListener listener) throws ListenerNotFoundException, IOException {
beforeRemove();
if (logger.traceOn()) {
logger.trace("removeNotificationListener", "Remove the listener " + listener + " from " + name);
}
List<Integer> ids = new ArrayList<Integer>();
List<ClientListenerInfo> values = new ArrayList<ClientListenerInfo>(infoList.values());
for (int i = values.size() - 1; i >= 0; i--) {
ClientListenerInfo li = values.get(i);
if (li.sameAs(name, listener)) {
ids.add(li.getListenerID());
infoList.remove(li.getListenerID());
}
}
if (ids.isEmpty())
throw new ListenerNotFoundException("Listener not found");
return ids.toArray(new Integer[0]);
}
use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class ClientNotifForwarder method removeNotificationListener.
public synchronized Integer removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException, IOException {
if (logger.traceOn()) {
logger.trace("removeNotificationListener", "Remove the listener " + listener + " from " + name);
}
beforeRemove();
Integer id = null;
List<ClientListenerInfo> values = new ArrayList<ClientListenerInfo>(infoList.values());
for (int i = values.size() - 1; i >= 0; i--) {
ClientListenerInfo li = values.get(i);
if (li.sameAs(name, listener, filter, handback)) {
id = li.getListenerID();
infoList.remove(id);
break;
}
}
if (id == null)
throw new ListenerNotFoundException("Listener not found");
return id;
}
use of javax.management.ListenerNotFoundException in project intellij-community by JetBrains.
the class PerformanceWatcher method watchCodeCache.
private void watchCodeCache(final MemoryPoolMXBean bean) {
final long threshold = bean.getUsage().getMax() - 5 * 1024 * 1024;
if (!bean.isUsageThresholdSupported() || threshold <= 0)
return;
bean.setUsageThreshold(threshold);
final NotificationEmitter emitter = (NotificationEmitter) ManagementFactory.getMemoryMXBean();
emitter.addNotificationListener(new NotificationListener() {
@Override
public void handleNotification(Notification n, Object hb) {
if (bean.getUsage().getUsed() > threshold) {
LOG.info("Code Cache is almost full");
dumpThreads("codeCacheFull", true);
try {
emitter.removeNotificationListener(this);
} catch (ListenerNotFoundException e) {
LOG.error(e);
}
}
}
}, null, null);
}
use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class ServerNotifForwarder method removeNotificationListener.
public void removeNotificationListener(ObjectName name, Integer listenerID) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
if (logger.traceOn()) {
logger.trace("removeNotificationListener", "Remove the listener " + listenerID + " from " + name);
}
checkState();
if (name != null && !name.isPattern()) {
if (!mbeanServer.isRegistered(name)) {
throw new InstanceNotFoundException("The MBean " + name + " is not registered.");
}
}
synchronized (listenerMap) {
// Tread carefully because if set.size() == 1 it may be a
// Collections.singleton, which is unmodifiable.
Set<IdAndFilter> set = listenerMap.get(name);
IdAndFilter idaf = new IdAndFilter(listenerID, null);
if (set == null || !set.contains(idaf))
throw new ListenerNotFoundException("Listener not found");
if (set.size() == 1)
listenerMap.remove(name);
else
set.remove(idaf);
}
}
use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method getListener.
private NotificationListener getListener(ObjectName listener) throws ListenerNotFoundException {
// ----------------
// Get listener object
// ----------------
DynamicMBean instance;
try {
instance = getMBean(listener);
} catch (InstanceNotFoundException e) {
throw EnvHelp.initCause(new ListenerNotFoundException(e.getMessage()), e);
}
Object resource = getResource(instance);
if (!(resource instanceof NotificationListener)) {
final RuntimeException exc = new IllegalArgumentException(listener.getCanonicalName());
final String msg = "MBean " + listener.getCanonicalName() + " does not " + "implement " + NotificationListener.class.getName();
throw new RuntimeOperationsException(exc, msg);
}
return (NotificationListener) resource;
}
Aggregations