2 * Copyright (c) 2017 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
8 package org.opendaylight.netconf.topology.singleton.impl.utils;
10 import akka.actor.ActorSystem;
11 import com.google.common.util.concurrent.ListeningExecutorService;
12 import io.netty.util.concurrent.EventExecutor;
13 import java.util.concurrent.ScheduledExecutorService;
14 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
17 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
18 import org.opendaylight.netconf.client.NetconfClientDispatcher;
19 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import scala.concurrent.duration.Duration;
24 public class NetconfTopologySetup {
26 private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
27 private final DOMRpcProviderService rpcProviderRegistry;
28 private final DataBroker dataBroker;
29 private final InstanceIdentifier<Node> instanceIdentifier;
30 private final Node node;
31 private final ScheduledExecutorService keepaliveExecutor;
32 private final ListeningExecutorService processingExecutor;
33 private final ActorSystem actorSystem;
34 private final EventExecutor eventExecutor;
35 private final NetconfClientDispatcher netconfClientDispatcher;
36 private final String topologyId;
37 private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
38 private final Duration idleTimeout;
39 private final String privateKeyPath;
40 private final String privateKeyPassphrase;
41 private final AAAEncryptionService encryptionService;
43 NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
44 this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
45 this.rpcProviderRegistry = builder.getRpcProviderRegistry();
46 this.dataBroker = builder.getDataBroker();
47 this.instanceIdentifier = builder.getInstanceIdentifier();
48 this.node = builder.getNode();
49 this.keepaliveExecutor = builder.getKeepaliveExecutor();
50 this.processingExecutor = builder.getProcessingExecutor();
51 this.actorSystem = builder.getActorSystem();
52 this.eventExecutor = builder.getEventExecutor();
53 this.netconfClientDispatcher = builder.getNetconfClientDispatcher();
54 this.topologyId = builder.getTopologyId();
55 this.schemaResourceDTO = builder.getSchemaResourceDTO();
56 this.idleTimeout = builder.getIdleTimeout();
57 this.privateKeyPath = builder.getPrivateKeyPath();
58 this.privateKeyPassphrase = builder.getPrivateKeyPassphrase();
59 this.encryptionService = builder.getEncryptionService();
62 public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
63 return clusterSingletonServiceProvider;
66 public DOMRpcProviderService getRpcProviderRegistry() {
67 return rpcProviderRegistry;
70 public DataBroker getDataBroker() {
74 public InstanceIdentifier<Node> getInstanceIdentifier() {
75 return instanceIdentifier;
78 public Node getNode() {
82 public ListeningExecutorService getProcessingExecutor() {
83 return processingExecutor;
86 public ScheduledExecutorService getKeepaliveExecutor() {
87 return keepaliveExecutor;
90 public ActorSystem getActorSystem() {
94 public EventExecutor getEventExecutor() {
98 public String getTopologyId() {
102 public NetconfClientDispatcher getNetconfClientDispatcher() {
103 return netconfClientDispatcher;
106 public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
107 return schemaResourceDTO;
110 public Duration getIdleTimeout() {
114 public String getPrivateKeyPath() {
115 return privateKeyPath;
118 public String getPrivateKeyPassphrase() {
119 return privateKeyPassphrase;
122 public AAAEncryptionService getEncryptionService() {
123 return encryptionService;
126 public static class NetconfTopologySetupBuilder {
128 private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
129 private DOMRpcProviderService rpcProviderRegistry;
130 private DataBroker dataBroker;
131 private InstanceIdentifier<Node> instanceIdentifier;
133 private ScheduledExecutorService keepaliveExecutor;
134 private ListeningExecutorService processingExecutor;
135 private ActorSystem actorSystem;
136 private EventExecutor eventExecutor;
137 private String topologyId;
138 private NetconfClientDispatcher netconfClientDispatcher;
139 private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
140 private Duration idleTimeout;
141 private String privateKeyPath;
142 private String privateKeyPassphrase;
143 private AAAEncryptionService encryptionService;
145 public NetconfTopologySetupBuilder() {
148 private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
149 return clusterSingletonServiceProvider;
152 public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
153 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
154 this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
158 private DOMRpcProviderService getRpcProviderRegistry() {
159 return rpcProviderRegistry;
162 public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
163 this.rpcProviderRegistry = rpcProviderRegistry;
167 private DataBroker getDataBroker() {
171 public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
172 this.dataBroker = dataBroker;
176 private InstanceIdentifier<Node> getInstanceIdentifier() {
177 return instanceIdentifier;
180 public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
181 this.instanceIdentifier = instanceIdentifier;
185 public Node getNode() {
189 public NetconfTopologySetupBuilder setNode(final Node node) {
194 public NetconfTopologySetup build() {
195 return new NetconfTopologySetup(this);
198 private ScheduledExecutorService getKeepaliveExecutor() {
199 return keepaliveExecutor;
202 public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
203 this.keepaliveExecutor = keepaliveExecutor;
207 private ListeningExecutorService getProcessingExecutor() {
208 return processingExecutor;
211 public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
212 this.processingExecutor = processingExecutor;
216 private ActorSystem getActorSystem() {
220 public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
221 this.actorSystem = actorSystem;
225 private EventExecutor getEventExecutor() {
226 return eventExecutor;
229 public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
230 this.eventExecutor = eventExecutor;
234 private String getTopologyId() {
238 public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
239 this.topologyId = topologyId;
243 private NetconfClientDispatcher getNetconfClientDispatcher() {
244 return netconfClientDispatcher;
247 public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
248 this.netconfClientDispatcher = clientDispatcher;
252 public NetconfTopologySetupBuilder setSchemaResourceDTO(
253 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
254 this.schemaResourceDTO = schemaResourceDTO;
258 private NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
259 return schemaResourceDTO;
262 public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
263 this.idleTimeout = idleTimeout;
267 private Duration getIdleTimeout() {
271 public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
272 this.privateKeyPath = privateKeyPath;
276 public String getPrivateKeyPath() {
277 return this.privateKeyPath;
280 public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
281 this.privateKeyPassphrase = privateKeyPassphrase;
285 public String getPrivateKeyPassphrase() {
286 return this.privateKeyPassphrase;
289 private AAAEncryptionService getEncryptionService() {
290 return this.encryptionService;
293 public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
294 this.encryptionService = encryptionService;
298 public static NetconfTopologySetupBuilder create() {
299 return new NetconfTopologySetupBuilder();