Bug 6714 - Use singleton service in clustered netconf topology
[netconf.git] / netconf / abstract-topology / src / main / java / org / opendaylight / netconf / topology / example / ExampleTopology.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netconf.topology.example;
10
11 import akka.actor.ActorSystem;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
14 import org.opendaylight.netconf.topology.NodeManagerCallback;
15 import org.opendaylight.netconf.topology.NodeManagerCallback.NodeManagerCallbackFactory;
16 import org.opendaylight.netconf.topology.TopologyManagerCallback;
17 import org.opendaylight.netconf.topology.TopologyManagerCallback.TopologyManagerCallbackFactory;
18 import org.opendaylight.netconf.topology.util.BaseTopologyManager;
19
20 public class ExampleTopology {
21
22     private static final String TOPOLOGY_NETCONF = "topology-netconf";
23     private BaseTopologyManager netconfNodeBaseTopologyManager;
24     private final DataBroker dataBroker;
25
26     public ExampleTopology(final EntityOwnershipService entityOwnershipService, final DataBroker dataBroker) {
27         final ActorSystem actorSystem = ActorSystem.create("netconf-cluster");
28
29         this.dataBroker = dataBroker;
30
31         final NodeManagerCallbackFactory nodeManagerCallbackFactory = new NodeManagerCallbackFactory() {
32             @Override
33             public NodeManagerCallback create(String nodeId, String topologyId, ActorSystem actorSystem) {
34                 return new ExampleNodeManagerCallback();
35             }
36         };
37
38         final TopologyManagerCallbackFactory topologyManagerCallbackFactory = new TopologyManagerCallbackFactory() {
39             @Override
40             public TopologyManagerCallback create(ActorSystem actorSystem, String topologyId) {
41                 return new ExampleTopologyManagerCallback(actorSystem, dataBroker, topologyId, nodeManagerCallbackFactory);
42             }
43         };
44
45 //        netconfNodeBaseTopologyManager = new BaseTopologyManager<>(dataBroker, TOPOLOGY_NETCONF,
46 //                topologyManagerCallbackFactory,
47 //                new SingleStateAggregator(),
48 //                new SalNodeWriter(dataBroker, TOPOLOGY_NETCONF),
49 //                new TopologyRoleChangeStrategy(dataBroker, entityOwnershipService, "netconf", TOPOLOGY_NETCONF));
50
51     }
52
53 }