2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.topology.singleton.impl;
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
14 import org.opendaylight.controller.sal.core.api.Broker;
15 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService;
16 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider;
17 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
18 import org.opendaylight.netconf.topology.singleton.api.NetconfDOMTransaction;
19 import org.opendaylight.netconf.topology.singleton.impl.tx.NetconfProxyDOMTransaction;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class SlaveSalFacade {
26 private static final Logger LOG = LoggerFactory.getLogger(SlaveSalFacade.class);
28 private final RemoteDeviceId id;
29 private final NetconfDeviceSalProvider salProvider;
31 private final ActorSystem actorSystem;
33 public SlaveSalFacade(final RemoteDeviceId id,
34 final Broker domBroker,
35 final ActorSystem actorSystem) {
37 this.salProvider = new NetconfDeviceSalProvider(id);
38 this.actorSystem = actorSystem;
40 registerToSal(domBroker);
43 private void registerToSal(final Broker domRegistryDependency) {
44 domRegistryDependency.registerProvider(salProvider);
48 public void registerSlaveMountPoint(final SchemaContext remoteSchemaContext, final DOMRpcService deviceRpc,
49 final ActorRef masterActorRef) {
50 final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
52 final NetconfDOMTransaction proxyDOMTransactions =
53 new NetconfProxyDOMTransaction(actorSystem, masterActorRef);
55 final NetconfDOMDataBroker netconfDeviceDataBroker =
56 new NetconfDOMDataBroker(actorSystem, id, proxyDOMTransactions);
58 salProvider.getMountInstance().onTopologyDeviceConnected(remoteSchemaContext, netconfDeviceDataBroker,
59 deviceRpc, notificationService);
61 LOG.info("{}: Slave mount point registered.", id);
64 public void unregisterSlaveMountPoint() {
65 salProvider.getMountInstance().onTopologyDeviceDisconnected();
69 unregisterSlaveMountPoint();
71 salProvider.getMountInstance().close();
72 } catch (Exception exception) {
73 LOG.warn("{}: Exception in closing slave sal facade: {}", id, exception);