2 * Copyright (c) 2020 Orange. 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
9 package org.opendaylight.bgpcep.pcep.server.provider;
11 import com.google.common.base.Preconditions;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.algo.PathComputationProvider;
14 import org.opendaylight.bgpcep.pcep.server.PceServerProvider;
15 import org.opendaylight.graph.ConnectedGraph;
16 import org.opendaylight.graph.ConnectedGraphProvider;
18 public class PceServerFactory implements PceServerProvider {
20 private final ConnectedGraphProvider graphProvider;
21 private final PathComputationProvider algoProvider;
22 private ConnectedGraph tedGraph = null;
24 public PceServerFactory(ConnectedGraphProvider graphProvider, PathComputationProvider pathComputationProvider) {
25 Preconditions.checkArgument(graphProvider != null);
26 this.graphProvider = graphProvider;
27 this.algoProvider = pathComputationProvider;
32 * Set Traffic Engineering Graph. This method is necessary as the TedGraph could be available
33 * after the PathComputationFactory start e.g. manual insertion of a ted Graph, or late tedGraph fulfillment
34 * from BGP Link State.
36 private void setTedGraph() {
37 for (ConnectedGraph cgraph : this.graphProvider.getConnectedGraphs()) {
38 if (cgraph.getGraph().getName().startsWith("ted://")) {
39 this.tedGraph = cgraph;
46 public PathComputationImpl getPathComputation() {
47 /* Leave a change to get a valid Graph */
48 if (tedGraph == null) {
51 return new PathComputationImpl(tedGraph, algoProvider);
55 public @Nullable ConnectedGraph getTedGraph() {
56 /* Leave a change to get a valid Graph in case of late fulfillment */
57 if (tedGraph == null) {