2 * Copyright (c) 2013 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.bgpcep.pcep.topology.provider;
10 import io.netty.channel.Channel;
11 import io.netty.channel.ChannelFuture;
13 import java.net.InetSocketAddress;
14 import java.util.concurrent.ExecutionException;
16 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
17 import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
18 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
19 import org.opendaylight.protocol.pcep.PCEPDispatcher;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import com.google.common.base.Preconditions;
25 public final class PCEPTopologyProvider extends DefaultTopologyReference implements AutoCloseable {
26 private final ServerSessionManager manager;
27 private final TopologyProgramming network;
28 private final TopologyRPCs element;
29 private final Channel channel;
31 private PCEPTopologyProvider(final Channel channel, final InstanceIdentifier<Topology> topology, final ServerSessionManager manager,
32 final TopologyRPCs element, final TopologyProgramming network) {
34 this.channel = Preconditions.checkNotNull(channel);
35 this.manager = Preconditions.checkNotNull(manager);
36 this.element = Preconditions.checkNotNull(element);
37 this.network = Preconditions.checkNotNull(network);
40 public static PCEPTopologyProvider create(final PCEPDispatcher dispatcher, final InetSocketAddress address,
41 final InstructionScheduler scheduler, final DataProviderService dataService, final InstanceIdentifier<Topology> topology)
42 throws InterruptedException, ExecutionException {
44 final ServerSessionManager manager = new ServerSessionManager(dataService, topology);
45 final TopologyRPCs element = new TopologyRPCs(manager);
46 final TopologyProgramming network = new TopologyProgramming(scheduler, manager);
47 final ChannelFuture f = dispatcher.createServer(address, manager);
49 return new PCEPTopologyProvider(f.channel(), topology, manager, element, network);
53 public void close() throws Exception {
55 // FIXME: BUG-193: close other stuff