7963d440f0793c5c237cff45ca91af4e6ebe6f20
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologySetup.java
1 /*
2  * Copyright (c) 2017 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 package org.opendaylight.netconf.topology.singleton.impl.utils;
9
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;
23
24 public class NetconfTopologySetup {
25
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;
42
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();
60     }
61
62     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
63         return clusterSingletonServiceProvider;
64     }
65
66     public DOMRpcProviderService getRpcProviderRegistry() {
67         return rpcProviderRegistry;
68     }
69
70     public DataBroker getDataBroker() {
71         return dataBroker;
72     }
73
74     public InstanceIdentifier<Node> getInstanceIdentifier() {
75         return instanceIdentifier;
76     }
77
78     public Node getNode() {
79         return node;
80     }
81
82     public ListeningExecutorService getProcessingExecutor() {
83         return processingExecutor;
84     }
85
86     public ScheduledExecutorService getKeepaliveExecutor() {
87         return keepaliveExecutor;
88     }
89
90     public ActorSystem getActorSystem() {
91         return actorSystem;
92     }
93
94     public EventExecutor getEventExecutor() {
95         return eventExecutor;
96     }
97
98     public String getTopologyId() {
99         return topologyId;
100     }
101
102     public NetconfClientDispatcher getNetconfClientDispatcher() {
103         return netconfClientDispatcher;
104     }
105
106     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
107         return schemaResourceDTO;
108     }
109
110     public Duration getIdleTimeout() {
111         return idleTimeout;
112     }
113
114     public String getPrivateKeyPath() {
115         return privateKeyPath;
116     }
117
118     public String getPrivateKeyPassphrase() {
119         return privateKeyPassphrase;
120     }
121
122     public AAAEncryptionService getEncryptionService() {
123         return encryptionService;
124     }
125
126     public static class NetconfTopologySetupBuilder {
127
128         private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
129         private DOMRpcProviderService rpcProviderRegistry;
130         private DataBroker dataBroker;
131         private InstanceIdentifier<Node> instanceIdentifier;
132         private Node node;
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;
144
145         public NetconfTopologySetupBuilder() {
146         }
147
148         private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
149             return clusterSingletonServiceProvider;
150         }
151
152         public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
153                 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
154             this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
155             return this;
156         }
157
158         private DOMRpcProviderService getRpcProviderRegistry() {
159             return rpcProviderRegistry;
160         }
161
162         public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
163             this.rpcProviderRegistry = rpcProviderRegistry;
164             return this;
165         }
166
167         private DataBroker getDataBroker() {
168             return dataBroker;
169         }
170
171         public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
172             this.dataBroker = dataBroker;
173             return this;
174         }
175
176         private InstanceIdentifier<Node> getInstanceIdentifier() {
177             return instanceIdentifier;
178         }
179
180         public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
181             this.instanceIdentifier = instanceIdentifier;
182             return this;
183         }
184
185         public Node getNode() {
186             return node;
187         }
188
189         public NetconfTopologySetupBuilder setNode(final Node node) {
190             this.node = node;
191             return this;
192         }
193
194         public NetconfTopologySetup build() {
195             return new NetconfTopologySetup(this);
196         }
197
198         private ScheduledExecutorService getKeepaliveExecutor() {
199             return keepaliveExecutor;
200         }
201
202         public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
203             this.keepaliveExecutor = keepaliveExecutor;
204             return this;
205         }
206
207         private ListeningExecutorService getProcessingExecutor() {
208             return processingExecutor;
209         }
210
211         public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
212             this.processingExecutor = processingExecutor;
213             return this;
214         }
215
216         private ActorSystem getActorSystem() {
217             return actorSystem;
218         }
219
220         public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
221             this.actorSystem = actorSystem;
222             return this;
223         }
224
225         private EventExecutor getEventExecutor() {
226             return eventExecutor;
227         }
228
229         public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
230             this.eventExecutor = eventExecutor;
231             return this;
232         }
233
234         private String getTopologyId() {
235             return topologyId;
236         }
237
238         public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
239             this.topologyId = topologyId;
240             return this;
241         }
242
243         private NetconfClientDispatcher getNetconfClientDispatcher() {
244             return netconfClientDispatcher;
245         }
246
247         public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
248             this.netconfClientDispatcher = clientDispatcher;
249             return this;
250         }
251
252         public NetconfTopologySetupBuilder setSchemaResourceDTO(
253                 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
254             this.schemaResourceDTO = schemaResourceDTO;
255             return this;
256         }
257
258         private NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
259             return schemaResourceDTO;
260         }
261
262         public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
263             this.idleTimeout = idleTimeout;
264             return this;
265         }
266
267         private Duration getIdleTimeout() {
268             return idleTimeout;
269         }
270
271         public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
272             this.privateKeyPath = privateKeyPath;
273             return this;
274         }
275
276         public String getPrivateKeyPath() {
277             return this.privateKeyPath;
278         }
279
280         public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
281             this.privateKeyPassphrase = privateKeyPassphrase;
282             return this;
283         }
284
285         public String getPrivateKeyPassphrase() {
286             return this.privateKeyPassphrase;
287         }
288
289         private AAAEncryptionService getEncryptionService() {
290             return this.encryptionService;
291         }
292
293         public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
294             this.encryptionService = encryptionService;
295             return this;
296         }
297
298         public static NetconfTopologySetupBuilder create() {
299             return new NetconfTopologySetupBuilder();
300         }
301     }
302
303
304 }