Further rework of base schemas
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologySetup.java
index cee8c0d80774b077665c771a27a36142439872b1..1c96ae323b6efdf6884873ec5c2730a853a791fd 100644 (file)
@@ -1,22 +1,26 @@
 /*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.topology.singleton.impl.utils;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSystem;
+import com.google.common.util.concurrent.ListeningExecutorService;
 import io.netty.util.concurrent.EventExecutor;
-import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
-import org.opendaylight.controller.config.threadpool.ThreadPool;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import java.util.concurrent.ScheduledExecutorService;
+import org.opendaylight.aaa.encrypt.AAAEncryptionService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
+import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import scala.concurrent.duration.Duration;
@@ -24,22 +28,28 @@ import scala.concurrent.duration.Duration;
 public class NetconfTopologySetup {
 
     private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
-    private final RpcProviderRegistry rpcProviderRegistry;
+    private final DOMRpcProviderService rpcProviderRegistry;
+    private final DOMActionProviderService actionProviderRegistry;
     private final DataBroker dataBroker;
     private final InstanceIdentifier<Node> instanceIdentifier;
     private final Node node;
-    private final ScheduledThreadPool keepaliveExecutor;
-    private final ThreadPool processingExecutor;
+    private final ScheduledExecutorService keepaliveExecutor;
+    private final ListeningExecutorService processingExecutor;
     private final ActorSystem actorSystem;
     private final EventExecutor eventExecutor;
     private final NetconfClientDispatcher netconfClientDispatcher;
     private final String topologyId;
     private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
     private final Duration idleTimeout;
+    private final String privateKeyPath;
+    private final String privateKeyPassphrase;
+    private final AAAEncryptionService encryptionService;
+    private final BaseNetconfSchemas baseSchemas;
 
-    private NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
+    NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
         this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
         this.rpcProviderRegistry = builder.getRpcProviderRegistry();
+        this.actionProviderRegistry = builder.getActionProviderRegistry();
         this.dataBroker = builder.getDataBroker();
         this.instanceIdentifier = builder.getInstanceIdentifier();
         this.node = builder.getNode();
@@ -51,16 +61,24 @@ public class NetconfTopologySetup {
         this.topologyId = builder.getTopologyId();
         this.schemaResourceDTO = builder.getSchemaResourceDTO();
         this.idleTimeout = builder.getIdleTimeout();
+        this.privateKeyPath = builder.getPrivateKeyPath();
+        this.privateKeyPassphrase = builder.getPrivateKeyPassphrase();
+        this.encryptionService = builder.getEncryptionService();
+        this.baseSchemas = builder.getBaseSchemas();
     }
 
     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
         return clusterSingletonServiceProvider;
     }
 
-    public RpcProviderRegistry getRpcProviderRegistry() {
+    public DOMRpcProviderService getRpcProviderRegistry() {
         return rpcProviderRegistry;
     }
 
+    public DOMActionProviderService getActionProviderRegistry() {
+        return actionProviderRegistry;
+    }
+
     public DataBroker getDataBroker() {
         return dataBroker;
     }
@@ -73,11 +91,11 @@ public class NetconfTopologySetup {
         return node;
     }
 
-    public ThreadPool getProcessingExecutor() {
+    public ListeningExecutorService getProcessingExecutor() {
         return processingExecutor;
     }
 
-    public ScheduledThreadPool getKeepaliveExecutor() {
+    public ScheduledExecutorService getKeepaliveExecutor() {
         return keepaliveExecutor;
     }
 
@@ -98,33 +116,63 @@ public class NetconfTopologySetup {
     }
 
     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
-        return  schemaResourceDTO;
+        return schemaResourceDTO;
     }
 
     public Duration getIdleTimeout() {
         return idleTimeout;
     }
 
-    public static class NetconfTopologySetupBuilder {
+    public String getPrivateKeyPath() {
+        return privateKeyPath;
+    }
 
+    public String getPrivateKeyPassphrase() {
+        return privateKeyPassphrase;
+    }
+
+    public AAAEncryptionService getEncryptionService() {
+        return encryptionService;
+    }
+
+    public BaseNetconfSchemas getBaseSchemas() {
+        return baseSchemas;
+    }
+
+    public static class NetconfTopologySetupBuilder {
         private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
-        private RpcProviderRegistry rpcProviderRegistry;
+        private DOMRpcProviderService rpcProviderRegistry;
+        private DOMActionProviderService actionProviderRegistry;
         private DataBroker dataBroker;
         private InstanceIdentifier<Node> instanceIdentifier;
         private Node node;
-        private ScheduledThreadPool keepaliveExecutor;
-        private ThreadPool processingExecutor;
+        private ScheduledExecutorService keepaliveExecutor;
+        private ListeningExecutorService processingExecutor;
         private ActorSystem actorSystem;
         private EventExecutor eventExecutor;
         private String topologyId;
         private NetconfClientDispatcher netconfClientDispatcher;
         private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
         private Duration idleTimeout;
+        private String privateKeyPath;
+        private String privateKeyPassphrase;
+        private AAAEncryptionService encryptionService;
+        private BaseNetconfSchemas baseSchemas;
+
+        public NetconfTopologySetupBuilder() {
+
+        }
 
-        public NetconfTopologySetupBuilder(){
+        BaseNetconfSchemas getBaseSchemas() {
+            return requireNonNull(baseSchemas, "BaseSchemas not initialized");
         }
 
-        private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
+        public NetconfTopologySetupBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
+            this.baseSchemas = requireNonNull(baseSchemas);
+            return this;
+        }
+
+        ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
             return clusterSingletonServiceProvider;
         }
 
@@ -134,16 +182,26 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private RpcProviderRegistry getRpcProviderRegistry() {
+        DOMRpcProviderService getRpcProviderRegistry() {
             return rpcProviderRegistry;
         }
 
-        public NetconfTopologySetupBuilder setRpcProviderRegistry(final RpcProviderRegistry rpcProviderRegistry) {
+        public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
             this.rpcProviderRegistry = rpcProviderRegistry;
             return this;
         }
 
-        private DataBroker getDataBroker() {
+        DOMActionProviderService getActionProviderRegistry() {
+            return actionProviderRegistry;
+        }
+
+        public NetconfTopologySetupBuilder setActionProviderRegistry(
+            final DOMActionProviderService actionProviderRegistry) {
+            this.actionProviderRegistry = actionProviderRegistry;
+            return this;
+        }
+
+        DataBroker getDataBroker() {
             return dataBroker;
         }
 
@@ -152,7 +210,7 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private InstanceIdentifier<Node> getInstanceIdentifier() {
+        InstanceIdentifier<Node> getInstanceIdentifier() {
             return instanceIdentifier;
         }
 
@@ -174,25 +232,25 @@ public class NetconfTopologySetup {
             return new NetconfTopologySetup(this);
         }
 
-        private ScheduledThreadPool getKeepaliveExecutor() {
+        ScheduledExecutorService getKeepaliveExecutor() {
             return keepaliveExecutor;
         }
 
-        public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledThreadPool keepaliveExecutor) {
+        public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
             this.keepaliveExecutor = keepaliveExecutor;
             return this;
         }
 
-        private ThreadPool getProcessingExecutor() {
+        ListeningExecutorService getProcessingExecutor() {
             return processingExecutor;
         }
 
-        public NetconfTopologySetupBuilder setProcessingExecutor(final ThreadPool processingExecutor) {
+        public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
             this.processingExecutor = processingExecutor;
             return this;
         }
 
-        private ActorSystem getActorSystem() {
+        ActorSystem getActorSystem() {
             return actorSystem;
         }
 
@@ -201,7 +259,7 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private EventExecutor getEventExecutor() {
+        EventExecutor getEventExecutor() {
             return eventExecutor;
         }
 
@@ -210,7 +268,7 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private String getTopologyId() {
+        String getTopologyId() {
             return topologyId;
         }
 
@@ -219,7 +277,7 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private NetconfClientDispatcher getNetconfClientDispatcher() {
+        NetconfClientDispatcher getNetconfClientDispatcher() {
             return netconfClientDispatcher;
         }
 
@@ -234,7 +292,7 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
+        NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
             return schemaResourceDTO;
         }
 
@@ -243,14 +301,39 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        private Duration getIdleTimeout() {
+        Duration getIdleTimeout() {
             return idleTimeout;
         }
 
+        public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
+            this.privateKeyPath = privateKeyPath;
+            return this;
+        }
+
+        public String getPrivateKeyPath() {
+            return this.privateKeyPath;
+        }
+
+        public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
+            this.privateKeyPassphrase = privateKeyPassphrase;
+            return this;
+        }
+
+        public String getPrivateKeyPassphrase() {
+            return this.privateKeyPassphrase;
+        }
+
+        AAAEncryptionService getEncryptionService() {
+            return this.encryptionService;
+        }
+
+        public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
+            this.encryptionService = encryptionService;
+            return this;
+        }
+
         public static NetconfTopologySetupBuilder create() {
             return new NetconfTopologySetupBuilder();
         }
     }
-
-
-}
+}
\ No newline at end of file