import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.Collections;
-import java.util.concurrent.ExecutorService;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.connect.util.RemoteDeviceId;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(NetconfDeviceSalProvider.class);
private final RemoteDeviceId id;
- private final ExecutorService executor;
private volatile NetconfDeviceDatastoreAdapter datastoreAdapter;
private MountInstance mountInstance;
private volatile NetconfDeviceTopologyAdapter topologyDatastoreAdapter;
- public NetconfDeviceSalProvider(final RemoteDeviceId deviceId, final ExecutorService executor) {
+ public NetconfDeviceSalProvider(final RemoteDeviceId deviceId) {
this.id = deviceId;
- this.executor = executor;
}
public MountInstance getMountInstance() {
private DOMMountPointService mountService;
private final RemoteDeviceId id;
private ObjectRegistration<DOMMountPoint> registration;
- private NotificationPublishService notificationSerivce;
+ private NetconfDeviceNotificationService notificationService;
private ObjectRegistration<DOMMountPoint> topologyRegistration;
@Deprecated
synchronized void onDeviceConnected(final SchemaContext initialCtx,
- final DOMDataBroker broker, final RpcProvisionRegistry rpc,
- final NotificationPublishService notificationSerivce) {
+ final DOMDataBroker broker, final DOMRpcService rpc,
+ final NetconfDeviceNotificationService notificationService) {
Preconditions.checkNotNull(mountService, "Closed");
Preconditions.checkState(registration == null, "Already initialized");
mountBuilder.addInitialSchemaContext(initialCtx);
mountBuilder.addService(DOMDataBroker.class, broker);
- mountBuilder.addService(RpcProvisionRegistry.class, rpc);
- this.notificationSerivce = notificationSerivce;
- mountBuilder.addService(NotificationPublishService.class, notificationSerivce);
+ mountBuilder.addService(DOMRpcService.class, rpc);
+ mountBuilder.addService(DOMNotificationService.class, notificationService);
+ this.notificationService = notificationService;
registration = mountBuilder.register();
+ logger.debug("{}: Mountpoint exposed into MD-SAL {}", id, registration);
}
@Deprecated
synchronized void onDeviceDisconnected() {
if(registration == null) {
+ logger.trace("{}: Not removing mountpoint from MD-SAL, mountpoint was not registered yet", id);
return;
}
// Only log and ignore
logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getPath(), e);
} finally {
+ logger.debug("{}: Mountpoint removed from MD-SAL {}", id, registration);
registration = null;
}
}
synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
- final DOMDataBroker broker, final RpcProvisionRegistry rpc,
- final NotificationPublishService notificationSerivce) {
+ final DOMDataBroker broker, final DOMRpcService rpc,
+ final NetconfDeviceNotificationService notificationService) {
Preconditions.checkNotNull(mountService, "Closed");
Preconditions.checkState(topologyRegistration == null, "Already initialized");
mountBuilder.addInitialSchemaContext(initialCtx);
mountBuilder.addService(DOMDataBroker.class, broker);
- mountBuilder.addService(RpcProvisionRegistry.class, rpc);
- this.notificationSerivce = notificationSerivce;
- mountBuilder.addService(NotificationPublishService.class, notificationSerivce);
+ mountBuilder.addService(DOMRpcService.class, rpc);
+ mountBuilder.addService(DOMNotificationService.class, notificationService);
topologyRegistration = mountBuilder.register();
+ logger.debug("{}: TOPOLOGY Mountpoint exposed into MD-SAL {}", id, registration);
+
}
synchronized void onTopologyDeviceDisconnected() {
if(topologyRegistration == null) {
+ logger.trace("{}: Not removing TOPOLOGY mountpoint from MD-SAL, mountpoint was not registered yet", id);
return;
}
// Only log and ignore
logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getTopologyPath(), e);
} finally {
+ logger.debug("{}: TOPOLOGY Mountpoint removed from MD-SAL {}", id, registration);
topologyRegistration = null;
}
}
@Override
synchronized public void close() throws Exception {
- if(registration != null) {
- onDeviceDisconnected();
- onTopologyDeviceDisconnected();
- }
+ onDeviceDisconnected();
+ onTopologyDeviceDisconnected();
mountService = null;
}
- public synchronized void publish(final CompositeNode domNotification) {
- Preconditions.checkNotNull(notificationSerivce, "Device not set up yet, cannot handle notification {}", domNotification);
- notificationSerivce.publish(domNotification);
+ public synchronized void publish(final DOMNotification domNotification) {
+ Preconditions.checkNotNull(notificationService, "Device not set up yet, cannot handle notification {}", domNotification);
+ notificationService.publishNotification(domNotification);
}
}