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