BGPCEP-726: Migrate PCEP Tunnel config
[bgpcep.git] / pcep / tunnel / tunnel-provider / src / main / java / org / opendaylight / bgpcep / pcep / tunnel / provider / TunnelProgramming.java
index 6de9d4d98cd6f6b890cedc64fa48e3ad76ba4fcf..d0d1233ba35cf2cbda294e95010e6dddd9e9bba4 100644 (file)
@@ -11,11 +11,10 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
 import org.opendaylight.bgpcep.pcep.topology.spi.AbstractInstructionExecutor;
 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.NetworkTopologyPcepService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepCreateP2pTunnelInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepCreateP2pTunnelOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepCreateP2pTunnelOutputBuilder;
@@ -32,39 +31,48 @@ import org.slf4j.LoggerFactory;
 
 public final class TunnelProgramming implements TopologyTunnelPcepProgrammingService, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(TunnelProgramming.class);
-    private final NetworkTopologyPcepService topologyService;
-    private final DataBroker dataProvider;
     private final InstructionScheduler scheduler;
+    private final TunnelProviderDependencies dependencies;
 
-    public TunnelProgramming(final InstructionScheduler scheduler, final DataBroker dataProvider, final NetworkTopologyPcepService topologyService) {
+    TunnelProgramming(
+            @Nonnull final InstructionScheduler scheduler,
+            @Nonnull final TunnelProviderDependencies dependencies) {
         this.scheduler = requireNonNull(scheduler);
-        this.dataProvider = requireNonNull(dataProvider);
-        this.topologyService = requireNonNull(topologyService);
+        this.dependencies = requireNonNull(dependencies);
     }
 
     @Override
-    public ListenableFuture<RpcResult<PcepCreateP2pTunnelOutput>> pcepCreateP2pTunnel(final PcepCreateP2pTunnelInput p2pTunnelInput) {
+    public ListenableFuture<RpcResult<PcepCreateP2pTunnelOutput>> pcepCreateP2pTunnel(
+            final PcepCreateP2pTunnelInput p2pTunnelInput) {
         final PcepCreateP2pTunnelOutputBuilder b = new PcepCreateP2pTunnelOutputBuilder();
-        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new CreateTunnelInstructionExecutor(p2pTunnelInput,
-            TunnelProgramming.this.dataProvider, this.topologyService)));
+        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler,
+                new CreateTunnelInstructionExecutor(p2pTunnelInput,
+                        TunnelProgramming.this.dependencies.getDataBroker(),
+                        TunnelProgramming.this.dependencies.getNtps())));
         final RpcResult<PcepCreateP2pTunnelOutput> res = SuccessfulRpcResult.create(b.build());
         return Futures.immediateFuture(res);
     }
 
     @Override
-    public ListenableFuture<RpcResult<PcepDestroyTunnelOutput>> pcepDestroyTunnel(final PcepDestroyTunnelInput destroyTunnelInput) {
+    public ListenableFuture<RpcResult<PcepDestroyTunnelOutput>> pcepDestroyTunnel(
+            final PcepDestroyTunnelInput destroyTunnelInput) {
         final PcepDestroyTunnelOutputBuilder b = new PcepDestroyTunnelOutputBuilder();
-        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new DestroyTunnelInstructionExecutor(destroyTunnelInput,
-            TunnelProgramming.this.dataProvider, this.topologyService)));
+        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler,
+                new DestroyTunnelInstructionExecutor(destroyTunnelInput,
+                        TunnelProgramming.this.dependencies.getDataBroker(),
+                        TunnelProgramming.this.dependencies.getNtps())));
         final RpcResult<PcepDestroyTunnelOutput> res = SuccessfulRpcResult.create(b.build());
         return Futures.immediateFuture(res);
     }
 
     @Override
-    public ListenableFuture<RpcResult<PcepUpdateTunnelOutput>> pcepUpdateTunnel(final PcepUpdateTunnelInput updateTunnelInput) {
+    public ListenableFuture<RpcResult<PcepUpdateTunnelOutput>> pcepUpdateTunnel(
+            final PcepUpdateTunnelInput updateTunnelInput) {
         final PcepUpdateTunnelOutputBuilder b = new PcepUpdateTunnelOutputBuilder();
-        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new UpdateTunnelInstructionExecutor(updateTunnelInput,
-            TunnelProgramming.this.dataProvider, this.topologyService)));
+        b.setResult(AbstractInstructionExecutor.schedule(this.scheduler,
+                new UpdateTunnelInstructionExecutor(updateTunnelInput,
+                        TunnelProgramming.this.dependencies.getDataBroker(),
+                        TunnelProgramming.this.dependencies.getNtps())));
 
         final RpcResult<PcepUpdateTunnelOutput> res = SuccessfulRpcResult.create(b.build());
         return Futures.immediateFuture(res);