Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "BUG-650: Split out CommitCoordinationTask"
[controller.git]
/
opendaylight
/
config
/
config-manager
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
config
/
manager
/
impl
/
jmx
/
InternalJMXRegistrator.java
diff --git
a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
index 5d771560a53b5dd25a3ec2140b5c2bf74f1791c0..85ad8c51340c045cc051150ec9e6159fc7144fbb 100644
(file)
--- a/
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
+++ b/
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
@@
-13,19
+13,20
@@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import javax.annotation.concurrent.GuardedBy;
import javax.management.InstanceAlreadyExistsException;
import javax.annotation.concurrent.GuardedBy;
import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
import javax.management.JMX;
import javax.management.JMX;
+import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.QueryExp;
import javax.management.ObjectName;
import javax.management.QueryExp;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InternalJMXRegistrator implements Closeable {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InternalJMXRegistrator implements Closeable {
- private static final Logger
logger
= LoggerFactory
+ private static final Logger
LOG
= LoggerFactory
.getLogger(InternalJMXRegistrator.class);
private final MBeanServer configMBeanServer;
.getLogger(InternalJMXRegistrator.class);
private final MBeanServer configMBeanServer;
@@
-38,7
+39,7
@@
public class InternalJMXRegistrator implements Closeable {
private final ObjectName on;
InternalJMXRegistration(InternalJMXRegistrator internalJMXRegistrator,
private final ObjectName on;
InternalJMXRegistration(InternalJMXRegistrator internalJMXRegistrator,
- ObjectName on) {
+
ObjectName on) {
this.internalJMXRegistrator = internalJMXRegistrator;
this.on = on;
}
this.internalJMXRegistrator = internalJMXRegistrator;
this.on = on;
}
@@
-51,16
+52,15
@@
public class InternalJMXRegistrator implements Closeable {
@GuardedBy("this")
private final Set<ObjectName> registeredObjectNames = new HashSet<>();
@GuardedBy("this")
private final Set<ObjectName> registeredObjectNames = new HashSet<>();
+ @GuardedBy("this")
private final List<InternalJMXRegistrator> children = new ArrayList<>();
public synchronized InternalJMXRegistration registerMBean(Object object,
private final List<InternalJMXRegistrator> children = new ArrayList<>();
public synchronized InternalJMXRegistration registerMBean(Object object,
- ObjectName on) throws InstanceAlreadyExistsException {
+
ObjectName on) throws InstanceAlreadyExistsException {
try {
configMBeanServer.registerMBean(object, on);
try {
configMBeanServer.registerMBean(object, on);
- } catch (InstanceAlreadyExistsException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (MBeanRegistrationException | NotCompliantMBeanException e) {
+ throw new IllegalStateException(e);
}
registeredObjectNames.add(on);
return new InternalJMXRegistration(this, on);
}
registeredObjectNames.add(on);
return new InternalJMXRegistration(this, on);
@@
-69,20
+69,18
@@
public class InternalJMXRegistrator implements Closeable {
private synchronized void unregisterMBean(ObjectName on) {
// first check that on was registered using this instance
boolean removed = registeredObjectNames.remove(on);
private synchronized void unregisterMBean(ObjectName on) {
// first check that on was registered using this instance
boolean removed = registeredObjectNames.remove(on);
- if (!removed)
- throw new IllegalStateException(
- "Cannot unregister - ObjectName not found in 'registeredObjectNames': "
- + on);
+ if (!removed) {
+ throw new IllegalStateException("Cannot unregister - ObjectName not found in 'registeredObjectNames': " + on);
+ }
try {
configMBeanServer.unregisterMBean(on);
try {
configMBeanServer.unregisterMBean(on);
- } catch (Exception e) {
- throw new
Runtim
eException(e);
+ } catch (
InstanceNotFoundException | MBeanRegistration
Exception e) {
+ throw new
IllegalStat
eException(e);
}
}
}
}
- public InternalJMXRegistrator createChild() {
- InternalJMXRegistrator child = new InternalJMXRegistrator(
- configMBeanServer);
+ public synchronized InternalJMXRegistrator createChild() {
+ InternalJMXRegistrator child = new InternalJMXRegistrator(configMBeanServer);
children.add(child);
return child;
}
children.add(child);
return child;
}
@@
-101,7
+99,7
@@
public class InternalJMXRegistrator implements Closeable {
try {
configMBeanServer.unregisterMBean(on);
} catch (Exception e) {
try {
configMBeanServer.unregisterMBean(on);
} catch (Exception e) {
-
logger
.warn("Ignoring error while unregistering {}", on, e);
+
LOG
.warn("Ignoring error while unregistering {}", on, e);
}
}
registeredObjectNames.clear();
}
}
registeredObjectNames.clear();
@@
-112,7
+110,7
@@
public class InternalJMXRegistrator implements Closeable {
}
public <T> T newMBeanProxy(ObjectName objectName, Class<T> interfaceClass,
}
public <T> T newMBeanProxy(ObjectName objectName, Class<T> interfaceClass,
- boolean notificationBroadcaster) {
+
boolean notificationBroadcaster) {
return JMX.newMBeanProxy(configMBeanServer, objectName, interfaceClass,
notificationBroadcaster);
}
return JMX.newMBeanProxy(configMBeanServer, objectName, interfaceClass,
notificationBroadcaster);
}
@@
-123,7
+121,7
@@
public class InternalJMXRegistrator implements Closeable {
}
public <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass,
}
public <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass,
- boolean notificationBroadcaster) {
+
boolean notificationBroadcaster) {
return JMX.newMXBeanProxy(configMBeanServer, objectName,
interfaceClass, notificationBroadcaster);
}
return JMX.newMXBeanProxy(configMBeanServer, objectName,
interfaceClass, notificationBroadcaster);
}
@@
-138,7
+136,7
@@
public class InternalJMXRegistrator implements Closeable {
return getSameNames(result);
}
return getSameNames(result);
}
- private Set<ObjectName> getSameNames(Set<ObjectName> superSet) {
+ private
synchronized
Set<ObjectName> getSameNames(Set<ObjectName> superSet) {
Set<ObjectName> result = new HashSet<>(superSet);
result.retainAll(registeredObjectNames);
for (InternalJMXRegistrator child : children) {
Set<ObjectName> result = new HashSet<>(superSet);
result.retainAll(registeredObjectNames);
for (InternalJMXRegistrator child : children) {