2 * Copyright (c) 2017 AT&T Intellectual Property. 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.config;
10 import static java.util.Objects.requireNonNull;
12 import java.net.InetSocketAddress;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.protocol.concepts.KeyMapping;
15 import org.opendaylight.protocol.pcep.SpeakerIdMapping;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 public final class PCEPTopologyConfiguration {
24 private final InetSocketAddress address;
25 private final KeyMapping keys;
26 private final TopologyId topologyId;
27 private final short rpcTimeout;
28 private final SpeakerIdMapping speakerIds;
29 private final InstanceIdentifier<Topology> topology;
31 public PCEPTopologyConfiguration(final @NonNull SessionConfig config, final @NonNull Topology topology) {
32 requireNonNull(topology);
33 this.address = PCEPTopologyProviderUtil.getInetSocketAddress(requireNonNull(config.getListenAddress()),
34 requireNonNull(config.getListenPort()));
35 this.keys = requireNonNull(PCEPTopologyProviderUtil.contructKeys(topology));
36 this.speakerIds = requireNonNull(PCEPTopologyProviderUtil.contructSpeakersId(topology));
37 this.topologyId = requireNonNull(topology.getTopologyId());
38 this.rpcTimeout = config.getRpcTimeout();
39 this.topology = InstanceIdentifier.builder(NetworkTopology.class)
40 .child(Topology.class, new TopologyKey(this.topologyId)).build();
43 public @NonNull TopologyId getTopologyId() {
44 return this.topologyId;
47 public @NonNull InstanceIdentifier<Topology> getTopology() {
51 public short getRpcTimeout() {
52 return this.rpcTimeout;
55 public @NonNull InetSocketAddress getAddress() {
59 public @NonNull KeyMapping getKeys() {
63 public @NonNull SpeakerIdMapping getSpeakerIds() {
64 return this.speakerIds;