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 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.NetconfClientFactory;
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;
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 NetconfClientFactory netconfClientFactory;
35 private final String topologyId;
36 private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
37 private final Duration idleTimeout;
38 private final BaseNetconfSchemas baseSchemas;
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 netconfClientFactory = builder.getNetconfClientFactory();
50 topologyId = builder.getTopologyId();
51 schemaResourceDTO = builder.getSchemaResourceDTO();
52 idleTimeout = builder.getIdleTimeout();
53 baseSchemas = builder.getBaseSchemas();
56 public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
57 return clusterSingletonServiceProvider;
60 public DataBroker getDataBroker() {
64 public InstanceIdentifier<Node> getInstanceIdentifier() {
65 return instanceIdentifier;
68 public Node getNode() {
72 public Executor getProcessingExecutor() {
73 return processingExecutor;
76 public ScheduledExecutorService getKeepaliveExecutor() {
77 return keepaliveExecutor;
80 public ActorSystem getActorSystem() {
84 public EventExecutor getEventExecutor() {
88 public String getTopologyId() {
92 public NetconfClientFactory getNetconfClientFactory() {
93 return netconfClientFactory;
96 public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
97 return schemaResourceDTO;
100 public Duration getIdleTimeout() {
104 public BaseNetconfSchemas getBaseSchemas() {
108 public static class NetconfTopologySetupBuilder {
109 private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
110 private DataBroker dataBroker;
111 private InstanceIdentifier<Node> instanceIdentifier;
113 private ScheduledExecutorService keepaliveExecutor;
114 private Executor processingExecutor;
115 private ActorSystem actorSystem;
116 private EventExecutor eventExecutor;
117 private String topologyId;
118 private NetconfClientFactory netconfClientFactory;
119 private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
120 private Duration idleTimeout;
121 private BaseNetconfSchemas baseSchemas;
123 public NetconfTopologySetupBuilder() {
127 BaseNetconfSchemas getBaseSchemas() {
128 return requireNonNull(baseSchemas, "BaseSchemas not initialized");
131 public NetconfTopologySetupBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
132 this.baseSchemas = requireNonNull(baseSchemas);
136 ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
137 return clusterSingletonServiceProvider;
140 public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
141 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
142 this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
146 DataBroker getDataBroker() {
150 public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
151 this.dataBroker = dataBroker;
155 InstanceIdentifier<Node> getInstanceIdentifier() {
156 return instanceIdentifier;
159 public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
160 this.instanceIdentifier = instanceIdentifier;
164 public Node getNode() {
168 public NetconfTopologySetupBuilder setNode(final Node node) {
173 public NetconfTopologySetup build() {
174 return new NetconfTopologySetup(this);
177 ScheduledExecutorService getKeepaliveExecutor() {
178 return keepaliveExecutor;
181 public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
182 this.keepaliveExecutor = keepaliveExecutor;
186 Executor getProcessingExecutor() {
187 return processingExecutor;
190 public NetconfTopologySetupBuilder setProcessingExecutor(final Executor processingExecutor) {
191 this.processingExecutor = processingExecutor;
195 ActorSystem getActorSystem() {
199 public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
200 this.actorSystem = actorSystem;
204 EventExecutor getEventExecutor() {
205 return eventExecutor;
208 public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
209 this.eventExecutor = eventExecutor;
213 String getTopologyId() {
217 public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
218 this.topologyId = topologyId;
222 NetconfClientFactory getNetconfClientFactory() {
223 return netconfClientFactory;
226 public NetconfTopologySetupBuilder setNetconfClientFactory(final NetconfClientFactory clientFactory) {
227 netconfClientFactory = clientFactory;
231 public NetconfTopologySetupBuilder setSchemaResourceDTO(
232 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
233 this.schemaResourceDTO = schemaResourceDTO;
237 NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
238 return schemaResourceDTO;
241 public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
242 this.idleTimeout = idleTimeout;
246 Duration getIdleTimeout() {
250 public static NetconfTopologySetupBuilder create() {
251 return new NetconfTopologySetupBuilder();