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