import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+// FIXME: remove this class and promote MountInstance to a top-level construct
+// Non-final for mocking
public class NetconfDeviceSalProvider implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSalProvider.class);
private final RemoteDeviceId id;
private final MountInstance mountInstance;
- private volatile NetconfDeviceTopologyAdapter topologyDatastoreAdapter;
-
public NetconfDeviceSalProvider(final RemoteDeviceId deviceId, final DOMMountPointService mountService) {
- this(deviceId, mountService, null);
- }
-
- // FIXME: NETCONF-918: remove this method
- public NetconfDeviceSalProvider(final RemoteDeviceId deviceId, final DOMMountPointService mountService,
- final DataBroker dataBroker) {
- id = deviceId;
+ id = requireNonNull(deviceId);
mountInstance = new MountInstance(mountService, id);
- if (dataBroker != null) {
- topologyDatastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, id);
- }
}
public MountInstance getMountInstance() {
return mountInstance;
}
- public NetconfDeviceTopologyAdapter getTopologyDatastoreAdapter() {
- final NetconfDeviceTopologyAdapter local = topologyDatastoreAdapter;
- checkState(local != null,
- "%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id, this);
- return local;
- }
-
@Override
public void close() {
mountInstance.close();
- if (topologyDatastoreAdapter != null) {
- topologyDatastoreAdapter.close();
- topologyDatastoreAdapter = null;
- }
}
public static class MountInstance implements AutoCloseable {