23376b64501a1fadee9632c1d53f7d51f2ac4b88
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologySetup.java
1 /*
2  * Copyright (c) 2016 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.singleton.impl.utils;
10
11 import akka.actor.ActorSystem;
12 import io.netty.util.concurrent.EventExecutor;
13 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
14 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
15 import org.opendaylight.controller.config.threadpool.ThreadPool;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
18 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
19 import org.opendaylight.netconf.client.NetconfClientDispatcher;
20 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import scala.concurrent.duration.Duration;
24
25 public class NetconfTopologySetup {
26
27     private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
28     private final RpcProviderRegistry rpcProviderRegistry;
29     private final DataBroker dataBroker;
30     private final InstanceIdentifier<Node> instanceIdentifier;
31     private final Node node;
32     private final ScheduledThreadPool keepaliveExecutor;
33     private final ThreadPool processingExecutor;
34     private final ActorSystem actorSystem;
35     private final EventExecutor eventExecutor;
36     private final NetconfClientDispatcher netconfClientDispatcher;
37     private final String topologyId;
38     private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
39     private final Duration idleTimeout;
40     private final AAAEncryptionService encryptionService;
41
42     private NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
43         this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
44         this.rpcProviderRegistry = builder.getRpcProviderRegistry();
45         this.dataBroker = builder.getDataBroker();
46         this.instanceIdentifier = builder.getInstanceIdentifier();
47         this.node = builder.getNode();
48         this.keepaliveExecutor = builder.getKeepaliveExecutor();
49         this.processingExecutor = builder.getProcessingExecutor();
50         this.actorSystem = builder.getActorSystem();
51         this.eventExecutor = builder.getEventExecutor();
52         this.netconfClientDispatcher = builder.getNetconfClientDispatcher();
53         this.topologyId = builder.getTopologyId();
54         this.schemaResourceDTO = builder.getSchemaResourceDTO();
55         this.idleTimeout = builder.getIdleTimeout();
56         this.encryptionService = builder.getEncryptionService();
57     }
58
59     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
60         return clusterSingletonServiceProvider;
61     }
62
63     public RpcProviderRegistry getRpcProviderRegistry() {
64         return rpcProviderRegistry;
65     }
66
67     public DataBroker getDataBroker() {
68         return dataBroker;
69     }
70
71     public InstanceIdentifier<Node> getInstanceIdentifier() {
72         return instanceIdentifier;
73     }
74
75     public Node getNode() {
76         return node;
77     }
78
79     public ThreadPool getProcessingExecutor() {
80         return processingExecutor;
81     }
82
83     public ScheduledThreadPool getKeepaliveExecutor() {
84         return keepaliveExecutor;
85     }
86
87     public ActorSystem getActorSystem() {
88         return actorSystem;
89     }
90
91     public EventExecutor getEventExecutor() {
92         return eventExecutor;
93     }
94
95     public String getTopologyId() {
96         return topologyId;
97     }
98
99     public NetconfClientDispatcher getNetconfClientDispatcher() {
100         return netconfClientDispatcher;
101     }
102
103     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
104         return  schemaResourceDTO;
105     }
106
107     public Duration getIdleTimeout() {
108         return idleTimeout;
109     }
110
111     public AAAEncryptionService getEncryptionService() {
112         return encryptionService;
113     }
114
115     public static class NetconfTopologySetupBuilder {
116
117         private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
118         private RpcProviderRegistry rpcProviderRegistry;
119         private DataBroker dataBroker;
120         private InstanceIdentifier<Node> instanceIdentifier;
121         private Node node;
122         private ScheduledThreadPool keepaliveExecutor;
123         private ThreadPool processingExecutor;
124         private ActorSystem actorSystem;
125         private EventExecutor eventExecutor;
126         private String topologyId;
127         private NetconfClientDispatcher netconfClientDispatcher;
128         private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
129         private Duration idleTimeout;
130         private AAAEncryptionService encryptionService;
131
132         public NetconfTopologySetupBuilder(){
133         }
134
135         private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
136             return clusterSingletonServiceProvider;
137         }
138
139         public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
140                 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
141             this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
142             return this;
143         }
144
145         private RpcProviderRegistry getRpcProviderRegistry() {
146             return rpcProviderRegistry;
147         }
148
149         public NetconfTopologySetupBuilder setRpcProviderRegistry(final RpcProviderRegistry rpcProviderRegistry) {
150             this.rpcProviderRegistry = rpcProviderRegistry;
151             return this;
152         }
153
154         private DataBroker getDataBroker() {
155             return dataBroker;
156         }
157
158         public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
159             this.dataBroker = dataBroker;
160             return this;
161         }
162
163         private InstanceIdentifier<Node> getInstanceIdentifier() {
164             return instanceIdentifier;
165         }
166
167         public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
168             this.instanceIdentifier = instanceIdentifier;
169             return this;
170         }
171
172         public Node getNode() {
173             return node;
174         }
175
176         public NetconfTopologySetupBuilder setNode(final Node node) {
177             this.node = node;
178             return this;
179         }
180
181         public NetconfTopologySetup build() {
182             return new NetconfTopologySetup(this);
183         }
184
185         private ScheduledThreadPool getKeepaliveExecutor() {
186             return keepaliveExecutor;
187         }
188
189         public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledThreadPool keepaliveExecutor) {
190             this.keepaliveExecutor = keepaliveExecutor;
191             return this;
192         }
193
194         private ThreadPool getProcessingExecutor() {
195             return processingExecutor;
196         }
197
198         public NetconfTopologySetupBuilder setProcessingExecutor(final ThreadPool processingExecutor) {
199             this.processingExecutor = processingExecutor;
200             return this;
201         }
202
203         private ActorSystem getActorSystem() {
204             return actorSystem;
205         }
206
207         public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
208             this.actorSystem = actorSystem;
209             return this;
210         }
211
212         private EventExecutor getEventExecutor() {
213             return eventExecutor;
214         }
215
216         public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
217             this.eventExecutor = eventExecutor;
218             return this;
219         }
220
221         private String getTopologyId() {
222             return topologyId;
223         }
224
225         public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
226             this.topologyId = topologyId;
227             return this;
228         }
229
230         private NetconfClientDispatcher getNetconfClientDispatcher() {
231             return netconfClientDispatcher;
232         }
233
234         public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
235             this.netconfClientDispatcher = clientDispatcher;
236             return this;
237         }
238
239         public NetconfTopologySetupBuilder setSchemaResourceDTO(
240                 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
241             this.schemaResourceDTO = schemaResourceDTO;
242             return this;
243         }
244
245         private NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
246             return schemaResourceDTO;
247         }
248
249         public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
250             this.idleTimeout = idleTimeout;
251             return this;
252         }
253
254         private Duration getIdleTimeout() {
255             return idleTimeout;
256         }
257
258         private AAAEncryptionService getEncryptionService() {
259             return this.encryptionService;
260         }
261
262         public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
263             this.encryptionService = encryptionService;
264             return this;
265         }
266
267         public static NetconfTopologySetupBuilder create() {
268             return new NetconfTopologySetupBuilder();
269         }
270     }
271
272
273 }