import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
-import java.util.stream.Collectors;
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.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
+import org.opendaylight.netconf.sal.connect.netconf.sal.AbstractNetconfDataTreeService;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceDataBroker;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
-class MasterSalFacade implements AutoCloseable, RemoteDeviceHandler<NetconfSessionPreferences> {
-
+class MasterSalFacade implements RemoteDeviceHandler, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(MasterSalFacade.class);
private final RemoteDeviceId id;
private NetconfSessionPreferences netconfSessionPreferences = null;
private DOMRpcService deviceRpc = null;
private DOMDataBroker deviceDataBroker = null;
+ private NetconfDataTreeService netconfService = null;
private DOMActionService deviceAction = null;
MasterSalFacade(final RemoteDeviceId id,
final DOMMountPointService mountService,
final DataBroker dataBroker) {
this.id = id;
- this.salProvider = new NetconfDeviceSalProvider(id, mountService, dataBroker);
+ salProvider = new NetconfDeviceSalProvider(id, mountService, dataBroker);
this.actorSystem = actorSystem;
this.masterActorRef = masterActorRef;
this.actorResponseWaitTime = actorResponseWaitTime;
public void onDeviceConnected(final MountPointContext mountContext,
final NetconfSessionPreferences sessionPreferences,
final DOMRpcService domRpcService, final DOMActionService domActionService) {
- this.deviceAction = domActionService;
+ deviceAction = domActionService;
LOG.debug("{}: YANG 1.1 actions are supported in clustered netconf topology, "
+ "DOMActionService exposed for the device", id);
onDeviceConnected(mountContext, sessionPreferences, domRpcService);
public void onDeviceConnected(final MountPointContext mountContext,
final NetconfSessionPreferences sessionPreferences,
final DOMRpcService domRpcService) {
- this.currentMountContext = mountContext;
- this.netconfSessionPreferences = sessionPreferences;
- this.deviceRpc = domRpcService;
+ currentMountContext = mountContext;
+ netconfSessionPreferences = sessionPreferences;
+ deviceRpc = domRpcService;
LOG.info("Device {} connected - registering master mount point", id);
final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
deviceDataBroker = newDeviceDataBroker();
+ netconfService = newNetconfDataTreeService();
// We need to create ProxyDOMDataBroker so accessing mountpoint
// on leader node would be same as on follower node
final ProxyDOMDataBroker proxyDataBroker = new ProxyDOMDataBroker(id, masterActorRef, actorSystem.dispatcher(),
actorResponseWaitTime);
+ final NetconfDataTreeService proxyNetconfService = new ProxyNetconfDataTreeService(id, masterActorRef,
+ actorSystem.dispatcher(), actorResponseWaitTime);
salProvider.getMountInstance().onTopologyDeviceConnected(currentMountContext.getEffectiveModelContext(),
- proxyDataBroker, deviceRpc, notificationService, deviceAction);
+ proxyDataBroker, proxyNetconfService, deviceRpc, notificationService, deviceAction);
}
protected DOMDataBroker newDeviceDataBroker() {
return new NetconfDeviceDataBroker(id, currentMountContext, deviceRpc, netconfSessionPreferences);
}
+ protected NetconfDataTreeService newNetconfDataTreeService() {
+ return AbstractNetconfDataTreeService.of(id, currentMountContext, deviceRpc, netconfSessionPreferences);
+ }
+
private Future<Object> sendInitialDataToActor() {
- final List<SourceIdentifier> sourceIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(
- currentMountContext.getEffectiveModelContext()).stream()
- .map(mi -> RevisionSourceIdentifier.create(mi.getName(), mi.getRevision()))
- .collect(Collectors.toList());
+ final List<SourceIdentifier> sourceIdentifiers = List.copyOf(SchemaContextUtil.getConstituentModuleIdentifiers(
+ currentMountContext.getEffectiveModelContext()));
LOG.debug("{}: Sending CreateInitialMasterActorData with sourceIdentifiers {} to {}", id, sourceIdentifiers,
masterActorRef);
// send initial data to master actor
- return Patterns.ask(masterActorRef, new CreateInitialMasterActorData(deviceDataBroker, sourceIdentifiers,
- deviceRpc, deviceAction), actorResponseWaitTime);
+ return Patterns.ask(masterActorRef, new CreateInitialMasterActorData(deviceDataBroker, netconfService,
+ sourceIdentifiers, deviceRpc, deviceAction), actorResponseWaitTime);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void updateDeviceData() {
final String masterAddress = Cluster.get(actorSystem).selfAddress().toString();
LOG.debug("{}: updateDeviceData with master address {}", id, masterAddress);