efb102caba154fe7e5021ae3aecec5783e79280a
[bgpcep.git] / pcep / topology / topology-provider / src / main / java / org / opendaylight / bgpcep / pcep / topology / provider / config / PCEPTopologyConfiguration.java
1 /*
2  * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.bgpcep.pcep.topology.provider.config;
9
10 import static java.util.Objects.requireNonNull;
11
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;
22
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;
30
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();
41     }
42
43     public @NonNull TopologyId getTopologyId() {
44         return this.topologyId;
45     }
46
47     public @NonNull InstanceIdentifier<Topology> getTopology() {
48         return this.topology;
49     }
50
51     public short getRpcTimeout() {
52         return this.rpcTimeout;
53     }
54
55     public @NonNull InetSocketAddress getAddress() {
56         return this.address;
57     }
58
59     public @NonNull KeyMapping getKeys() {
60         return this.keys;
61     }
62
63     public @NonNull SpeakerIdMapping getSpeakerIds() {
64         return this.speakerIds;
65     }
66 }