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 akka.util.Timeout;
14 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
15 import org.opendaylight.controller.sal.core.api.Broker;
16 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService;
17 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider;
18 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
19 import org.opendaylight.netconf.topology.singleton.api.NetconfDOMTransaction;
20 import org.opendaylight.netconf.topology.singleton.impl.tx.NetconfProxyDOMTransaction;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class SlaveSalFacade {
27 private static final Logger LOG = LoggerFactory.getLogger(SlaveSalFacade.class);
29 private final RemoteDeviceId id;
30 private final NetconfDeviceSalProvider salProvider;
32 private final ActorSystem actorSystem;
33 private final Timeout actorResponseWaitTime;
35 public SlaveSalFacade(final RemoteDeviceId id,
36 final Broker domBroker,
37 final ActorSystem actorSystem,
38 final Timeout actorResponseWaitTime) {
40 this.salProvider = new NetconfDeviceSalProvider(id);
41 this.actorSystem = actorSystem;
42 this.actorResponseWaitTime = actorResponseWaitTime;
44 registerToSal(domBroker);
47 private void registerToSal(final Broker domRegistryDependency) {
48 domRegistryDependency.registerProvider(salProvider);
52 public void registerSlaveMountPoint(final SchemaContext remoteSchemaContext, final DOMRpcService deviceRpc,
53 final ActorRef masterActorRef) {
54 final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
56 final NetconfDOMTransaction proxyDOMTransactions =
57 new NetconfProxyDOMTransaction(id, actorSystem, masterActorRef, actorResponseWaitTime);
59 final NetconfDOMDataBroker netconfDeviceDataBroker =
60 new NetconfDOMDataBroker(actorSystem, id, proxyDOMTransactions);
62 salProvider.getMountInstance().onTopologyDeviceConnected(remoteSchemaContext, netconfDeviceDataBroker,
63 deviceRpc, notificationService);
65 LOG.info("{}: Slave mount point registered.", id);
68 public void unregisterSlaveMountPoint() {
69 salProvider.getMountInstance().onTopologyDeviceDisconnected();
73 unregisterSlaveMountPoint();
75 salProvider.getMountInstance().close();
76 } catch (final Exception exception) {
77 LOG.warn("{}: Exception in closing slave sal facade: {}", id, exception);