import java.util.List;
import java.util.stream.Collectors;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
}
@Override
- @SuppressWarnings("checkstyle:hiddenField")
public void onDeviceConnected(final SchemaContext remoteSchemaContext,
- final NetconfSessionPreferences netconfSessionPreferences,
- final DOMRpcService deviceRpc) {
+ final NetconfSessionPreferences sessionPreferences,
+ final DOMRpcService domRpcService, final DOMActionService domActionService) {
+ // We do not support actions in clustered topology yet
+ if (domActionService != null) {
+ LOG.warn("{}: YANG 1.1 actions are not supported in clustered netconf topology, "
+ + "DOMActionService will not be exposed for the device");
+ }
+
+ onDeviceConnected(remoteSchemaContext, sessionPreferences, domRpcService);
+ }
+
+ @Override
+ public void onDeviceConnected(final SchemaContext remoteSchemaContext,
+ final NetconfSessionPreferences sessionPreferences,
+ final DOMRpcService domRpcService) {
this.currentSchemaContext = remoteSchemaContext;
- this.netconfSessionPreferences = netconfSessionPreferences;
- this.deviceRpc = deviceRpc;
+ this.netconfSessionPreferences = sessionPreferences;
+ this.deviceRpc = domRpcService;
+
+ LOG.info("Device {} connected - registering master mount point", id);
registerMasterMountPoint();
sendInitialDataToActor().onComplete(new OnComplete<Object>() {
@Override
- public void onComplete(final Throwable failure, final Object success) throws Throwable {
+ public void onComplete(final Throwable failure, final Object success) {
if (failure == null) {
updateDeviceData();
return;
}
- throw failure;
+
+ LOG.error("{}: CreateInitialMasterActorData to {} failed", id, masterActorRef, failure);
}
}, actorSystem.dispatcher());
@Override
public void onDeviceDisconnected() {
+ LOG.info("Device {} disconnected - unregistering master mount point", id);
salProvider.getTopologyDatastoreAdapter().updateDeviceData(false, new NetconfDeviceCapabilities());
unregisterMasterMountPoint();
}
final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
- LOG.info("{}: Creating master data broker for device", id);
+ deviceDataBroker = newDeviceDataBroker();
- deviceDataBroker = new NetconfDeviceDataBroker(id, currentSchemaContext, deviceRpc, netconfSessionPreferences);
// We need to create ProxyDOMDataBroker so accessing mountpoint
// on leader node would be same as on follower node
final ProxyDOMDataBroker proxyDataBroker =
- new ProxyDOMDataBroker(actorSystem, id, masterActorRef, actorResponseWaitTime);
+ new ProxyDOMDataBroker(id, masterActorRef, actorSystem.dispatcher(), actorResponseWaitTime);
salProvider.getMountInstance()
.onTopologyDeviceConnected(currentSchemaContext, proxyDataBroker, deviceRpc, notificationService);
}
+ protected DOMDataBroker newDeviceDataBroker() {
+ return new NetconfDeviceDataBroker(id, currentSchemaContext, deviceRpc, netconfSessionPreferences);
+ }
+
private Future<Object> sendInitialDataToActor() {
final List<SourceIdentifier> sourceIdentifiers =
SchemaContextUtil.getConstituentModuleIdentifiers(currentSchemaContext).stream()
.map(mi -> RevisionSourceIdentifier.create(mi.getName(), mi.getRevision()))
.collect(Collectors.toList());
- // send initial data to master actor and create actor for providing it
+ 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), actorResponseWaitTime);
}
private void updateDeviceData() {
- final Cluster cluster = Cluster.get(actorSystem);
- salProvider.getTopologyDatastoreAdapter().updateClusteredDeviceData(true, cluster.selfAddress().toString(),
+ final String masterAddress = Cluster.get(actorSystem).selfAddress().toString();
+ LOG.debug("{}: updateDeviceData with master address {}", id, masterAddress);
+ salProvider.getTopologyDatastoreAdapter().updateClusteredDeviceData(true, masterAddress,
netconfSessionPreferences.getNetconfDeviceCapabilities());
}