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.ChannelFuture;
11 import io.netty.channel.nio.NioEventLoopGroup;
12 import io.netty.util.HashedWheelTimer;
14 import java.net.InetSocketAddress;
15 import java.util.concurrent.ExecutionException;
17 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
19 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
20 import org.opendaylight.protocol.pcep.PCEPDispatcher;
21 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
22 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
23 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
24 import org.opendaylight.protocol.pcep.impl.PCEPSessionProposalFactoryImpl;
25 import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
27 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 import com.google.common.base.Preconditions;
34 public final class BundleActivator extends AbstractBindingAwareProvider {
35 private static final Logger LOG = LoggerFactory.getLogger(BundleActivator.class);
38 public void onSessionInitiated(final ProviderContext session) {
39 final DataProviderService dps = Preconditions.checkNotNull(session.getSALService(DataProviderService.class));
41 // FIXME: integration with config subsystem should allow this to be injected as a service
42 final InetSocketAddress address = new InetSocketAddress("0.0.0.0", 4189);
43 final PCEPSessionProposalFactory spf = new PCEPSessionProposalFactoryImpl(30, 10, true, true, true, true, 0);
44 final Open prefs = spf.getSessionProposal(address, 0);
45 final PCEPDispatcher dispatcher = new PCEPDispatcherImpl(PCEPExtensionProviderContextImpl
46 .getSingletonInstance().getMessageHandlerRegistry(), new DefaultPCEPSessionNegotiatorFactory(
47 new HashedWheelTimer(), prefs, 5), new NioEventLoopGroup(), new NioEventLoopGroup());
49 final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder().node(Topology.class).toInstance();
51 final PCEPTopologyProvider exp = new PCEPTopologyProvider(dispatcher, null, dps, topology);
52 final ChannelFuture s = exp.startServer(address);
55 } catch (InterruptedException | ExecutionException e) {
56 LOG.error("Failed to instantiate server", e);