*/
package org.opendaylight.controller.remote.rpc.registry;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
*/
public class ActionRegistry extends BucketStoreActor<ActionRoutingTable> {
private final ActorRef rpcRegistrar;
- private final RemoteActionRegistryMXBeanImpl mxBean;
+
+ private RemoteActionRegistryMXBeanImpl mxBean;
public ActionRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker,
final ActorRef rpcRegistrar) {
super(config, config.getRpcRegistryPersistenceId(), new ActionRoutingTable(rpcInvoker, ImmutableSet.of()));
- this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar);
- this.mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
- config.getAskDuration()), config.getAskDuration());
+ this.rpcRegistrar = requireNonNull(rpcRegistrar);
}
/**
}
@Override
- public void postStop() {
+ public void preStart() {
+ super.preStart();
+ mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
+ getConfig().getAskDuration()), getConfig().getAskDuration());
+ }
+
+ @Override
+ public void postStop() throws Exception {
+ if (mxBean != null) {
+ mxBean.unregister();
+ mxBean = null;
+ }
super.postStop();
- this.mxBean.unregister();
}
@Override
protected void handleCommand(final Object message) throws Exception {
- if (message instanceof ActionRegistry.Messages.UpdateActions) {
+ if (message instanceof ActionRegistry.Messages.UpdateActions updateActions) {
LOG.debug("handling updatesActionRoutes message");
- updatesActionRoutes((Messages.UpdateActions) message);
+ updatesActionRoutes(updateActions);
} else {
super.handleCommand(message);
}
@VisibleForTesting
public RemoteActionEndpoint(final ActorRef router, final Collection<DOMActionInstance> actions) {
- this.router = Preconditions.checkNotNull(router);
+ this.router = requireNonNull(router);
this.actions = ImmutableSet.copyOf(actions);
}
}
Collection<DOMActionInstance> getAddedActions() {
- return this.addedActions;
+ return addedActions;
}
Collection<DOMActionInstance> getRemovedActions() {
- return this.removedActions;
+ return removedActions;
}