Migrated usage of RpcService to Rpc<?,?> for pcep-server-provider.
JIRA: BGPCEP-1027
Change-Id: I143557b91d0d8f6a131cd2ec4a34136d5490bbbc
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev220720.graph.topology.GraphKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.NetworkTopologyPcepService;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
closeListenerAndManager(topoKey);
/* Then create Path Manger */
- final NetworkTopologyPcepService ntps = rpcRegistry.getRpcService(NetworkTopologyPcepService.class);
- PathManagerProvider pathManager = new PathManagerProvider(dataBroker, topology, ntps, this);
+ PathManagerProvider pathManager = new PathManagerProvider(dataBroker, topology, rpcRegistry, this);
/* And Listener */
PathManagerListener pathListener = new PathManagerListener(dataBroker, topology, pathManager);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.NetworkTopologyPcepService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.Node1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspOutput;
/**
* Call add-lsp RPC to enforce the LSP into the PCC. This action will trigger a PcInitiate message to the PCC.
*
- * @param ntps Network Topology PCEP Service
+ * @param addLsp Add Lsp RPC
*
* @return Add LSP Output to convey the RPC result
*/
- public ListenableFuture<RpcResult<AddLspOutput>> addPath(final NetworkTopologyPcepService ntps) {
+ public ListenableFuture<RpcResult<AddLspOutput>> addPath(final AddLsp addLsp) {
/* Check if we could add this path */
if ((type != PathType.Initiated) || !teNode.isSync()) {
return null;
}
sent = true;
- final ListenableFuture<RpcResult<AddLspOutput>> enforce = ntps.addLsp(getAddLspInput());
- LOG.info("Call Add LSP to {} with {}", ntps, enforce);
+ final ListenableFuture<RpcResult<AddLspOutput>> enforce = addLsp.invoke(getAddLspInput());
+ LOG.info("Call Add LSP to {} with {}", addLsp, enforce);
Futures.addCallback(enforce, new FutureCallback<RpcResult<AddLspOutput>>() {
@Override
public void onSuccess(final RpcResult<AddLspOutput> result) {
/**
* Call update-lsp RPC to enforce the LSP into the PCC. This action will trigger a PcUpdate message to the PCC.
*
- * @param ntps Network Topology PCEP Service
+ * @param updateLsp Update LSP RPC
*
* @return Update LSP Output to convey the RPC result
*/
- public ListenableFuture<RpcResult<UpdateLspOutput>> updatePath(final NetworkTopologyPcepService ntps) {
+ public ListenableFuture<RpcResult<UpdateLspOutput>> updatePath(final UpdateLsp updateLsp) {
/* Check if we could update this path */
if ((type != PathType.Initiated && type != PathType.Delegated) || !teNode.isSync()) {
sent = true;
final NodeId id = teNode.getId();
- final ListenableFuture<RpcResult<UpdateLspOutput>> enforce = ntps.updateLsp(getUpdateLspInput());
- LOG.info("Call Update LSP to {} with {}", ntps, enforce);
+ final ListenableFuture<RpcResult<UpdateLspOutput>> enforce = updateLsp.invoke(getUpdateLspInput());
+ LOG.info("Call Update LSP to {} with {}", updateLsp, enforce);
Futures.addCallback(enforce, new FutureCallback<RpcResult<UpdateLspOutput>>() {
@Override
public void onSuccess(final RpcResult<UpdateLspOutput> result) {
* Call remove-lsp RPC to remove the LSP from the PCC. This action will trigger a PcInitiate message to the PCC
* with 'R' bit set.
*
- * @param ntps Network Topology PCEP Service
+ * @param removeLsp Remove Lsp RPC
*
* @return Remove LSP Output to convey the RPC result
*/
- public ListenableFuture<RpcResult<RemoveLspOutput>> removePath(final NetworkTopologyPcepService ntps) {
+ public ListenableFuture<RpcResult<RemoveLspOutput>> removePath(final RemoveLsp removeLsp) {
/* Check if we could remove this path */
if ((type != PathType.Initiated) || !teNode.isSync() || cfgLsp.getPathStatus() != PathStatus.Sync) {
.setName(cfgLsp.getName())
.setNetworkTopologyRef(new NetworkTopologyRef(pcepTopology))
.build();
- final ListenableFuture<RpcResult<RemoveLspOutput>> enforce = ntps.removeLsp(rli);
- LOG.info("Call Remove LSP to {} with {}", ntps, enforce);
+ final ListenableFuture<RpcResult<RemoveLspOutput>> enforce = removeLsp.invoke(rli);
+ LOG.info("Call Remove LSP to {} with {}", removeLsp, enforce);
Futures.addCallback(enforce, new FutureCallback<RpcResult<RemoveLspOutput>>() {
@Override
public void onSuccess(final RpcResult<RemoveLspOutput> result) {
import org.opendaylight.graph.ConnectedVertex;
import org.opendaylight.graph.ConnectedVertexTrigger;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.server.rev220321.pcc.configured.lsp.configured.lsp.IntendedPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.server.rev220321.pcc.configured.lsp.configured.lsp.IntendedPathBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.server.rev220321.pcc.configured.lsp.configured.lsp.intended.path.ConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.NetworkTopologyPcepService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLsp;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
private final InstanceIdentifier<Topology> pcepTopology;
private final DataBroker dataBroker;
private final DefaultPceServerProvider pceServerProvider;
- private final NetworkTopologyPcepService ntps;
+ private final AddLsp addLsp;
+ private final UpdateLsp updateLsp;
+ private final RemoveLsp removeLsp;
private TransactionChain chain = null;
private ConnectedGraph tedGraph = null;
private final Map<NodeId, ManagedTeNode> mngNodes = new HashMap<NodeId, ManagedTeNode>();
public PathManagerProvider(final DataBroker dataBroker, KeyedInstanceIdentifier<Topology, TopologyKey> topology,
- final NetworkTopologyPcepService ntps, final DefaultPceServerProvider pceServerProvider) {
+ final RpcConsumerRegistry rpcRegistry, final DefaultPceServerProvider pceServerProvider) {
this.dataBroker = requireNonNull(dataBroker);
this.pceServerProvider = requireNonNull(pceServerProvider);
- this.ntps = requireNonNull(ntps);
+ this.addLsp = rpcRegistry.getRpc(AddLsp.class);
+ this.updateLsp = rpcRegistry.getRpc(UpdateLsp.class);
+ this.removeLsp = rpcRegistry.getRpc(RemoveLsp.class);
this.pcepTopology = requireNonNull(topology);
initTransactionChain();
tedGraph = getGraph();
/* Then, setup Path on PCC if it is synchronized */
if (teNode.isSync()) {
- mngLsp.addPath(ntps);
+ mngLsp.addPath(addLsp);
}
LOG.debug("Added new Managed LSP: {}", mngLsp);
/* Finally, update Path on PCC if it is synchronized and we computed a valid path */
if (teNode.isSync()) {
- mngPath.updatePath(ntps);
+ mngPath.updatePath(updateLsp);
}
LOG.debug("Updated Managed Paths: {}", mngPath);
/* Finally, update Path on PCC if it is synchronized and computed path is valid */
if (teNode.isSync()) {
if (add) {
- mngPath.addPath(ntps);
+ mngPath.addPath(addLsp);
} else {
- mngPath.updatePath(ntps);
+ mngPath.updatePath(updateLsp);
}
} else {
mngPath.unSetTriggerFlag();
*/
if (teNode.isSync() && mngPath.getType() == PathType.Initiated
&& mngPath.getLsp().getPathStatus() == PathStatus.Sync) {
- mngPath.removePath(ntps);
+ mngPath.removePath(removeLsp);
}
/*
.build());
/* and update Path on PCC if it is synchronized */
if (teNode.isSync()) {
- newPath.updatePath(ntps);
+ newPath.updatePath(updateLsp);
}
} else {
/* Mark this TE Path as Synchronous and add it to the Managed TE Path */
/* Check if we need to update the TE Path */
if (teNode.isSync() && newStatus == PathStatus.Updated) {
- curPath.updatePath(ntps);
+ curPath.updatePath(updateLsp);
LOG.debug("Updated Managed TE Path {} on NodeId {}", curPath, id);
return curPath;
}
if (mngPath.getLsp().getComputedPath().getComputationStatus() != ComputationStatus.Completed) {
updateComputedPath(mngPath, false);
} else {
- mngPath.updatePath(ntps);
+ mngPath.updatePath(updateLsp);
}
break;
case Configured:
if (mngPath.getLsp().getComputedPath().getComputationStatus() != ComputationStatus.Completed) {
updateComputedPath(mngPath, true);
} else {
- mngPath.addPath(ntps);
+ mngPath.addPath(addLsp);
}
break;
default: