Add changed-leaf-nodes-only subscription extension
[netconf.git] / apps / 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 static java.util.Objects.requireNonNull;
11
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;
27
28 public class NetconfTopologySetup {
29
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;
48
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();
68     }
69
70     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
71         return clusterSingletonServiceProvider;
72     }
73
74     public DOMRpcProviderService getRpcProviderRegistry() {
75         return rpcProviderRegistry;
76     }
77
78     public DOMActionProviderService getActionProviderRegistry() {
79         return actionProviderRegistry;
80     }
81
82     public DataBroker getDataBroker() {
83         return dataBroker;
84     }
85
86     public InstanceIdentifier<Node> getInstanceIdentifier() {
87         return instanceIdentifier;
88     }
89
90     public Node getNode() {
91         return node;
92     }
93
94     public ListeningExecutorService getProcessingExecutor() {
95         return processingExecutor;
96     }
97
98     public ScheduledExecutorService getKeepaliveExecutor() {
99         return keepaliveExecutor;
100     }
101
102     public ActorSystem getActorSystem() {
103         return actorSystem;
104     }
105
106     public EventExecutor getEventExecutor() {
107         return eventExecutor;
108     }
109
110     public String getTopologyId() {
111         return topologyId;
112     }
113
114     public NetconfClientDispatcher getNetconfClientDispatcher() {
115         return netconfClientDispatcher;
116     }
117
118     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
119         return schemaResourceDTO;
120     }
121
122     public Duration getIdleTimeout() {
123         return idleTimeout;
124     }
125
126     public String getPrivateKeyPath() {
127         return privateKeyPath;
128     }
129
130     public String getPrivateKeyPassphrase() {
131         return privateKeyPassphrase;
132     }
133
134     public AAAEncryptionService getEncryptionService() {
135         return encryptionService;
136     }
137
138     public BaseNetconfSchemas getBaseSchemas() {
139         return baseSchemas;
140     }
141
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;
148         private Node node;
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;
161
162         public NetconfTopologySetupBuilder() {
163
164         }
165
166         BaseNetconfSchemas getBaseSchemas() {
167             return requireNonNull(baseSchemas, "BaseSchemas not initialized");
168         }
169
170         public NetconfTopologySetupBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
171             this.baseSchemas = requireNonNull(baseSchemas);
172             return this;
173         }
174
175         ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
176             return clusterSingletonServiceProvider;
177         }
178
179         public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
180                 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
181             this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
182             return this;
183         }
184
185         DOMRpcProviderService getRpcProviderRegistry() {
186             return rpcProviderRegistry;
187         }
188
189         public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
190             this.rpcProviderRegistry = rpcProviderRegistry;
191             return this;
192         }
193
194         DOMActionProviderService getActionProviderRegistry() {
195             return actionProviderRegistry;
196         }
197
198         public NetconfTopologySetupBuilder setActionProviderRegistry(
199             final DOMActionProviderService actionProviderRegistry) {
200             this.actionProviderRegistry = actionProviderRegistry;
201             return this;
202         }
203
204         DataBroker getDataBroker() {
205             return dataBroker;
206         }
207
208         public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
209             this.dataBroker = dataBroker;
210             return this;
211         }
212
213         InstanceIdentifier<Node> getInstanceIdentifier() {
214             return instanceIdentifier;
215         }
216
217         public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
218             this.instanceIdentifier = instanceIdentifier;
219             return this;
220         }
221
222         public Node getNode() {
223             return node;
224         }
225
226         public NetconfTopologySetupBuilder setNode(final Node node) {
227             this.node = node;
228             return this;
229         }
230
231         public NetconfTopologySetup build() {
232             return new NetconfTopologySetup(this);
233         }
234
235         ScheduledExecutorService getKeepaliveExecutor() {
236             return keepaliveExecutor;
237         }
238
239         public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
240             this.keepaliveExecutor = keepaliveExecutor;
241             return this;
242         }
243
244         ListeningExecutorService getProcessingExecutor() {
245             return processingExecutor;
246         }
247
248         public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
249             this.processingExecutor = processingExecutor;
250             return this;
251         }
252
253         ActorSystem getActorSystem() {
254             return actorSystem;
255         }
256
257         public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
258             this.actorSystem = actorSystem;
259             return this;
260         }
261
262         EventExecutor getEventExecutor() {
263             return eventExecutor;
264         }
265
266         public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
267             this.eventExecutor = eventExecutor;
268             return this;
269         }
270
271         String getTopologyId() {
272             return topologyId;
273         }
274
275         public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
276             this.topologyId = topologyId;
277             return this;
278         }
279
280         NetconfClientDispatcher getNetconfClientDispatcher() {
281             return netconfClientDispatcher;
282         }
283
284         public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
285             this.netconfClientDispatcher = clientDispatcher;
286             return this;
287         }
288
289         public NetconfTopologySetupBuilder setSchemaResourceDTO(
290                 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
291             this.schemaResourceDTO = schemaResourceDTO;
292             return this;
293         }
294
295         NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
296             return schemaResourceDTO;
297         }
298
299         public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
300             this.idleTimeout = idleTimeout;
301             return this;
302         }
303
304         Duration getIdleTimeout() {
305             return idleTimeout;
306         }
307
308         public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
309             this.privateKeyPath = privateKeyPath;
310             return this;
311         }
312
313         public String getPrivateKeyPath() {
314             return this.privateKeyPath;
315         }
316
317         public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
318             this.privateKeyPassphrase = privateKeyPassphrase;
319             return this;
320         }
321
322         public String getPrivateKeyPassphrase() {
323             return this.privateKeyPassphrase;
324         }
325
326         AAAEncryptionService getEncryptionService() {
327             return this.encryptionService;
328         }
329
330         public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
331             this.encryptionService = encryptionService;
332             return this;
333         }
334
335         public static NetconfTopologySetupBuilder create() {
336             return new NetconfTopologySetupBuilder();
337         }
338     }
339 }