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.DOMMountPointService;
15 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
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.yangtools.yang.model.api.SchemaContext;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class SlaveSalFacade {
25 private static final Logger LOG = LoggerFactory.getLogger(SlaveSalFacade.class);
27 private final RemoteDeviceId id;
28 private final NetconfDeviceSalProvider salProvider;
29 private final ActorSystem actorSystem;
30 private final Timeout actorResponseWaitTime;
32 public SlaveSalFacade(final RemoteDeviceId id,
33 final ActorSystem actorSystem,
34 final Timeout actorResponseWaitTime,
35 final DOMMountPointService mountPointService) {
37 this.salProvider = new NetconfDeviceSalProvider(id, mountPointService);
38 this.actorSystem = actorSystem;
39 this.actorResponseWaitTime = actorResponseWaitTime;
42 public void registerSlaveMountPoint(final SchemaContext remoteSchemaContext, final DOMRpcService deviceRpc,
43 final ActorRef masterActorRef) {
44 final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
46 final ProxyDOMDataBroker netconfDeviceDataBroker =
47 new ProxyDOMDataBroker(actorSystem, id, masterActorRef, actorResponseWaitTime);
49 salProvider.getMountInstance().onTopologyDeviceConnected(remoteSchemaContext, netconfDeviceDataBroker,
50 deviceRpc, notificationService);
52 LOG.info("{}: Slave mount point registered.", id);
55 public void unregisterSlaveMountPoint() {
56 salProvider.getMountInstance().onTopologyDeviceDisconnected();
60 unregisterSlaveMountPoint();
62 salProvider.getMountInstance().close();
63 } catch (final Exception exception) {
64 LOG.warn("{}: Exception in closing slave sal facade: {}", id, exception);