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 static java.util.Objects.requireNonNull;
12 import akka.actor.ActorSystem;
13 import com.google.common.util.concurrent.ListeningExecutorService;
14 import io.netty.util.concurrent.EventExecutor;
15 import java.time.Duration;
16 import java.util.concurrent.ScheduledExecutorService;
17 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
18 import org.opendaylight.mdsal.binding.api.DataBroker;
19 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
20 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
21 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
22 import org.opendaylight.netconf.client.NetconfClientDispatcher;
23 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
24 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 public class NetconfTopologySetup {
30 private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
31 private final DOMRpcProviderService rpcProviderRegistry;
32 private final DOMActionProviderService actionProviderRegistry;
33 private final DataBroker dataBroker;
34 private final InstanceIdentifier<Node> instanceIdentifier;
35 private final Node node;
36 private final ScheduledExecutorService keepaliveExecutor;
37 private final ListeningExecutorService processingExecutor;
38 private final ActorSystem actorSystem;
39 private final EventExecutor eventExecutor;
40 private final NetconfClientDispatcher netconfClientDispatcher;
41 private final String topologyId;
42 private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
43 private final Duration idleTimeout;
44 private final String privateKeyPath;
45 private final String privateKeyPassphrase;
46 private final AAAEncryptionService encryptionService;
47 private final BaseNetconfSchemas baseSchemas;
49 NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
50 this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
51 this.rpcProviderRegistry = builder.getRpcProviderRegistry();
52 this.actionProviderRegistry = builder.getActionProviderRegistry();
53 this.dataBroker = builder.getDataBroker();
54 this.instanceIdentifier = builder.getInstanceIdentifier();
55 this.node = builder.getNode();
56 this.keepaliveExecutor = builder.getKeepaliveExecutor();
57 this.processingExecutor = builder.getProcessingExecutor();
58 this.actorSystem = builder.getActorSystem();
59 this.eventExecutor = builder.getEventExecutor();
60 this.netconfClientDispatcher = builder.getNetconfClientDispatcher();
61 this.topologyId = builder.getTopologyId();
62 this.schemaResourceDTO = builder.getSchemaResourceDTO();
63 this.idleTimeout = builder.getIdleTimeout();
64 this.privateKeyPath = builder.getPrivateKeyPath();
65 this.privateKeyPassphrase = builder.getPrivateKeyPassphrase();
66 this.encryptionService = builder.getEncryptionService();
67 this.baseSchemas = builder.getBaseSchemas();
70 public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
71 return clusterSingletonServiceProvider;
74 public DOMRpcProviderService getRpcProviderRegistry() {
75 return rpcProviderRegistry;
78 public DOMActionProviderService getActionProviderRegistry() {
79 return actionProviderRegistry;
82 public DataBroker getDataBroker() {
86 public InstanceIdentifier<Node> getInstanceIdentifier() {
87 return instanceIdentifier;
90 public Node getNode() {
94 public ListeningExecutorService getProcessingExecutor() {
95 return processingExecutor;
98 public ScheduledExecutorService getKeepaliveExecutor() {
99 return keepaliveExecutor;
102 public ActorSystem getActorSystem() {
106 public EventExecutor getEventExecutor() {
107 return eventExecutor;
110 public String getTopologyId() {
114 public NetconfClientDispatcher getNetconfClientDispatcher() {
115 return netconfClientDispatcher;
118 public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
119 return schemaResourceDTO;
122 public Duration getIdleTimeout() {
126 public String getPrivateKeyPath() {
127 return privateKeyPath;
130 public String getPrivateKeyPassphrase() {
131 return privateKeyPassphrase;
134 public AAAEncryptionService getEncryptionService() {
135 return encryptionService;
138 public BaseNetconfSchemas getBaseSchemas() {
142 public static class NetconfTopologySetupBuilder {
143 private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
144 private DOMRpcProviderService rpcProviderRegistry;
145 private DOMActionProviderService actionProviderRegistry;
146 private DataBroker dataBroker;
147 private InstanceIdentifier<Node> instanceIdentifier;
149 private ScheduledExecutorService keepaliveExecutor;
150 private ListeningExecutorService processingExecutor;
151 private ActorSystem actorSystem;
152 private EventExecutor eventExecutor;
153 private String topologyId;
154 private NetconfClientDispatcher netconfClientDispatcher;
155 private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
156 private Duration idleTimeout;
157 private String privateKeyPath;
158 private String privateKeyPassphrase;
159 private AAAEncryptionService encryptionService;
160 private BaseNetconfSchemas baseSchemas;
162 public NetconfTopologySetupBuilder() {
166 BaseNetconfSchemas getBaseSchemas() {
167 return requireNonNull(baseSchemas, "BaseSchemas not initialized");
170 public NetconfTopologySetupBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
171 this.baseSchemas = requireNonNull(baseSchemas);
175 ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
176 return clusterSingletonServiceProvider;
179 public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
180 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
181 this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
185 DOMRpcProviderService getRpcProviderRegistry() {
186 return rpcProviderRegistry;
189 public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
190 this.rpcProviderRegistry = rpcProviderRegistry;
194 DOMActionProviderService getActionProviderRegistry() {
195 return actionProviderRegistry;
198 public NetconfTopologySetupBuilder setActionProviderRegistry(
199 final DOMActionProviderService actionProviderRegistry) {
200 this.actionProviderRegistry = actionProviderRegistry;
204 DataBroker getDataBroker() {
208 public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
209 this.dataBroker = dataBroker;
213 InstanceIdentifier<Node> getInstanceIdentifier() {
214 return instanceIdentifier;
217 public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
218 this.instanceIdentifier = instanceIdentifier;
222 public Node getNode() {
226 public NetconfTopologySetupBuilder setNode(final Node node) {
231 public NetconfTopologySetup build() {
232 return new NetconfTopologySetup(this);
235 ScheduledExecutorService getKeepaliveExecutor() {
236 return keepaliveExecutor;
239 public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
240 this.keepaliveExecutor = keepaliveExecutor;
244 ListeningExecutorService getProcessingExecutor() {
245 return processingExecutor;
248 public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
249 this.processingExecutor = processingExecutor;
253 ActorSystem getActorSystem() {
257 public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
258 this.actorSystem = actorSystem;
262 EventExecutor getEventExecutor() {
263 return eventExecutor;
266 public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
267 this.eventExecutor = eventExecutor;
271 String getTopologyId() {
275 public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
276 this.topologyId = topologyId;
280 NetconfClientDispatcher getNetconfClientDispatcher() {
281 return netconfClientDispatcher;
284 public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
285 this.netconfClientDispatcher = clientDispatcher;
289 public NetconfTopologySetupBuilder setSchemaResourceDTO(
290 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
291 this.schemaResourceDTO = schemaResourceDTO;
295 NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
296 return schemaResourceDTO;
299 public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
300 this.idleTimeout = idleTimeout;
304 Duration getIdleTimeout() {
308 public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
309 this.privateKeyPath = privateKeyPath;
313 public String getPrivateKeyPath() {
314 return this.privateKeyPath;
317 public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
318 this.privateKeyPassphrase = privateKeyPassphrase;
322 public String getPrivateKeyPassphrase() {
323 return this.privateKeyPassphrase;
326 AAAEncryptionService getEncryptionService() {
327 return this.encryptionService;
330 public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
331 this.encryptionService = encryptionService;
335 public static NetconfTopologySetupBuilder create() {
336 return new NetconfTopologySetupBuilder();