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 static java.util.Objects.requireNonNull;
12 import com.google.common.base.Optional;
13 import com.google.common.base.Preconditions;
14 import com.google.common.util.concurrent.FutureCallback;
15 import com.google.common.util.concurrent.Futures;
16 import com.google.common.util.concurrent.ListenableFuture;
17 import com.google.common.util.concurrent.MoreExecutors;
18 import io.netty.util.concurrent.FutureListener;
19 import java.net.InetAddress;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.HashMap;
23 import java.util.List;
25 import java.util.Map.Entry;
26 import java.util.Objects;
27 import java.util.Timer;
28 import java.util.TimerTask;
29 import java.util.concurrent.TimeUnit;
30 import javax.annotation.concurrent.GuardedBy;
31 import org.opendaylight.controller.config.yang.pcep.topology.provider.ListenerStateRuntimeMXBean;
32 import org.opendaylight.controller.config.yang.pcep.topology.provider.PeerCapabilities;
33 import org.opendaylight.controller.config.yang.pcep.topology.provider.ReplyTime;
34 import org.opendaylight.controller.config.yang.pcep.topology.provider.SessionState;
35 import org.opendaylight.controller.config.yang.pcep.topology.provider.StatefulMessages;
36 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
37 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
38 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
39 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
40 import org.opendaylight.protocol.pcep.PCEPSession;
41 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
42 import org.opendaylight.protocol.pcep.TerminationReason;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.LspObject;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MessageHeader;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.LspId;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1Builder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.PccSyncState;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TearDownSessionInput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.lsp.metadata.Metadata;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClient;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path;
64 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
65 import org.opendaylight.yangtools.yang.binding.DataContainer;
66 import org.opendaylight.yangtools.yang.binding.DataObject;
67 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
72 * Base class for PCEP topology providers. It handles the common tasks involved in managing a PCEP server (PCE)
73 * endpoint, and exposing a network topology based on it. It needs to be subclassed to form a fully functional block,
74 * where the subclass provides handling of incoming messages.
76 * @param <S> identifier type of requests
77 * @param <L> identifier type for LSPs
79 public abstract class AbstractTopologySessionListener<S, L> implements TopologySessionListener, ListenerStateRuntimeMXBean {
80 protected static final MessageHeader MESSAGE_HEADER = new MessageHeader() {
81 private final ProtocolVersion version = new ProtocolVersion((short) 1);
84 public Class<? extends DataContainer> getImplementedInterface() {
85 return MessageHeader.class;
89 public ProtocolVersion getVersion() {
93 protected static final String MISSING_XML_TAG = "Mandatory XML tags are missing.";
94 private static final Logger LOG = LoggerFactory.getLogger(AbstractTopologySessionListener.class);
96 protected final Map<L, String> lsps = new HashMap<>();
98 private final Map<S, PCEPRequest> requests = new HashMap<>();
101 private final Map<String, ReportedLsp> lspData = new HashMap<>();
102 private final ServerSessionManager serverSessionManager;
104 private final SessionListenerState listenerState;
105 private InstanceIdentifier<PathComputationClient> pccIdentifier;
106 private TopologyNodeState nodeState;
107 private boolean synced = false;
108 private PCEPSession session;
109 private SyncOptimization syncOptimization;
110 private boolean triggeredResyncInProcess;
112 protected AbstractTopologySessionListener(final ServerSessionManager serverSessionManager) {
113 this.serverSessionManager = requireNonNull(serverSessionManager);
114 this.listenerState = new SessionListenerState();
118 public final synchronized void onSessionUp(final PCEPSession session) {
120 * The session went up. Look up the router in Inventory model,
121 * create it if it is not there (marking that fact for later
122 * deletion), and mark it as synchronizing. Also create it in
123 * the topology model, with empty LSP list.
125 final InetAddress peerAddress = session.getRemoteAddress();
127 this.syncOptimization = new SyncOptimization(session);
129 final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
130 // takeNodeState(..) may fail when the server session manager is being restarted due to configuration change
132 LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", session);
133 session.close(TerminationReason.UNKNOWN);
134 this.onSessionTerminated(session, new PCEPCloseTermination(TerminationReason.UNKNOWN));
138 if (this.session != null || this.nodeState != null) {
139 LOG.error("PCEP session is already up with {}. Closing session {}", session.getRemoteAddress(), session);
140 session.close(TerminationReason.UNKNOWN);
141 this.onSessionTerminated(session, new PCEPCloseTermination(TerminationReason.UNKNOWN));
145 this.session = session;
146 this.nodeState = state;
148 LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
150 // Our augmentation in the topology node
151 final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
153 onSessionUp(session, pccBuilder);
154 this.synced = isSynchronized();
156 pccBuilder.setIpAddress(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
157 final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
158 this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
159 final Node initialNodeState = state.getInitialNodeState();
160 final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
162 loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
163 pccBuilder.setReportedLsp(initialNodeState.getAugmentation(Node1.class).getPathComputationClient().getReportedLsp());
165 writeNode(pccBuilder, state, topologyAugment);
166 this.listenerState.init(session);
167 LOG.info("Session with {} attached to topology node {}", session.getRemoteAddress(), state.getNodeId());
170 private void writeNode(final PathComputationClientBuilder pccBuilder, final TopologyNodeState state,
171 final InstanceIdentifier<Node1> topologyAugment) {
172 final Node1 ta = new Node1Builder().setPathComputationClient(pccBuilder.build()).build();
174 final ReadWriteTransaction trans = state.rwTransaction();
175 trans.put(LogicalDatastoreType.OPERATIONAL, topologyAugment, ta);
176 LOG.trace("Peer data {} set to {}", topologyAugment, ta);
178 // All set, commit the modifications
179 Futures.addCallback(trans.submit(), new FutureCallback<Void>() {
181 public void onSuccess(final Void result) {
182 LOG.trace("Internal state for session {} updated successfully", AbstractTopologySessionListener.this.session);
186 public void onFailure(final Throwable t) {
187 LOG.error("Failed to update internal state for session {}, terminating it", AbstractTopologySessionListener.this.session, t);
188 AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
190 }, MoreExecutors.directExecutor());
193 protected void updatePccState(final PccSyncState pccSyncState) {
194 if (this.nodeState == null) {
195 LOG.info("Server Session Manager is closed.");
196 AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
199 final MessageContext ctx = new MessageContext(this.nodeState.beginTransaction());
200 updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(pccSyncState).build());
201 if (pccSyncState != PccSyncState.Synchronized) {
203 this.triggeredResyncInProcess = true;
205 // All set, commit the modifications
206 Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
208 public void onSuccess(final Void result) {
209 LOG.trace("Internal state for session {} updated successfully", AbstractTopologySessionListener.this.session);
213 public void onFailure(final Throwable t) {
214 LOG.error("Failed to update internal state for session {}", AbstractTopologySessionListener.this.session, t);
215 AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
217 }, MoreExecutors.directExecutor());
220 protected boolean isTriggeredSyncInProcess() {
221 return this.triggeredResyncInProcess;
225 * Tear down the given PCEP session. It's OK to call this method even after the session
226 * is already down. It always clear up the current session status.
231 private synchronized void tearDown(final PCEPSession session) {
232 requireNonNull(session);
233 this.serverSessionManager.releaseNodeState(this.nodeState, session, isLspDbPersisted());
234 this.nodeState = null;
236 if (this.session != null) {
237 this.session.close();
240 } catch (Exception e) {
241 LOG.error("Session {} cannot be closed.", session, e);
244 this.syncOptimization = null;
246 // Clear all requests we know about
247 for (final Entry<S, PCEPRequest> e : this.requests.entrySet()) {
248 final PCEPRequest r = e.getValue();
249 switch (r.getState()) {
251 // Done is done, nothing to do
252 LOG.trace("Request {} was done when session went down.", e.getKey());
255 // Peer has not acked: results in failure
256 LOG.info("Request {} was incomplete when session went down, failing the instruction", e.getKey());
257 r.done(OperationResults.NOACK);
260 // Peer has not been sent to the peer: results in cancellation
261 LOG.debug("Request {} was not sent when session went down, cancelling the instruction", e.getKey());
262 r.done(OperationResults.UNSENT);
268 this.requests.clear();
272 public final synchronized void onSessionDown(final PCEPSession session, final Exception e) {
273 LOG.warn("Session {} went down unexpectedly", session, e);
278 public final synchronized void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason reason) {
279 LOG.info("Session {} terminated by peer with reason {}", session, reason);
284 public final synchronized void onMessage(final PCEPSession session, final Message message) {
285 if (this.nodeState == null) {
286 LOG.warn("Topology node state is null. Unhandled message {} on session {}", message, session);
287 session.close(TerminationReason.UNKNOWN);
290 final MessageContext ctx = new MessageContext(this.nodeState.beginTransaction());
292 if (onMessage(ctx, message)) {
293 LOG.warn("Unhandled message {} on session {}", message, session);
294 //cancel not supported, submit empty transaction
299 Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
301 public void onSuccess(final Void result) {
302 LOG.trace("Internal state for session {} updated successfully", session);
303 ctx.notifyRequests();
307 public void onFailure(final Throwable t) {
308 LOG.error("Failed to update internal state for session {}, closing it", session, t);
309 ctx.notifyRequests();
310 session.close(TerminationReason.UNKNOWN);
312 }, MoreExecutors.directExecutor());
316 public void close() {
317 if (this.session != null) {
318 this.session.close(TerminationReason.UNKNOWN);
322 protected final synchronized PCEPRequest removeRequest(final S id) {
323 final PCEPRequest ret = this.requests.remove(id);
325 this.listenerState.processRequestStats(ret.getElapsedMillis());
327 LOG.trace("Removed request {} object {}", id, ret);
331 protected final synchronized ListenableFuture<OperationResult> sendMessage(final Message message, final S requestId,
332 final Metadata metadata) {
333 final io.netty.util.concurrent.Future<Void> f = this.session.sendMessage(message);
334 this.listenerState.updateStatefulSentMsg(message);
335 final PCEPRequest req = new PCEPRequest(metadata);
336 this.requests.put(requestId, req);
337 final short rpcTimeout = this.serverSessionManager.getRpcTimeout();
338 LOG.trace("RPC response timeout value is {} seconds", rpcTimeout);
339 if (rpcTimeout > 0) {
340 setupTimeoutHandler(requestId, req, rpcTimeout);
343 f.addListener((FutureListener<Void>) future -> {
344 if (!future.isSuccess()) {
345 synchronized (AbstractTopologySessionListener.this) {
346 AbstractTopologySessionListener.this.requests.remove(requestId);
348 req.done(OperationResults.UNSENT);
349 LOG.info("Failed to send request {}, instruction cancelled", requestId, future.cause());
352 LOG.trace("Request {} sent to peer (object {})", requestId, req);
356 return req.getFuture();
359 private void setupTimeoutHandler(final S requestId, final PCEPRequest req, final short timeout) {
360 final Timer timer = req.getTimer();
361 timer.schedule(new TimerTask() {
364 synchronized (AbstractTopologySessionListener.this) {
365 AbstractTopologySessionListener.this.requests.remove(requestId);
368 LOG.info("Request {} timed-out waiting for response", requestId);
370 }, TimeUnit.SECONDS.toMillis(timeout));
371 LOG.trace("Set up response timeout handler for request {}", requestId);
375 * Update an LSP in the data store
377 * @param ctx Message context
378 * @param id Revision-specific LSP identifier
379 * @param lspName LSP name
380 * @param rlb Reported LSP builder
381 * @param solicited True if the update was solicited
382 * @param remove True if this is an LSP path removal
384 protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName,
385 final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
388 if (lspName == null) {
389 name = this.lsps.get(id);
391 LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
398 LOG.debug("Saved LSP {} with name {}", id, name);
399 this.lsps.put(id, name);
402 final ReportedLsp previous = this.lspData.get(name);
403 // if no previous report about the lsp exist, just proceed
404 if (previous != null) {
405 final List<Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
406 // if all paths or the last path were deleted, delete whole tunnel
407 if (updatedPaths == null || updatedPaths.isEmpty()) {
408 LOG.debug("All paths were removed, removing LSP with {}.", id);
412 rlb.setPath(updatedPaths);
414 rlb.setKey(new ReportedLspKey(name));
417 // If this is an unsolicited update. We need to make sure we retain the metadata already present
419 this.nodeState.setLspMetadata(name, rlb.getMetadata());
421 rlb.setMetadata(this.nodeState.getLspMetadata(name));
424 final ReportedLsp rl = rlb.build();
425 ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.getKey()), rl);
426 LOG.debug("LSP {} updated to MD-SAL", name);
428 this.lspData.put(name, rl);
431 private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
432 // just one path should be reported
433 Preconditions.checkState(rlb.getPath().size() == 1);
434 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = rlb.getPath().get(0).getLspId();
435 final List<Path> updatedPaths;
436 //lspId = 0 and remove = false -> tunnel is down, still exists but no path is signaled
437 //remove existing tunnel's paths now, as explicit path remove will not come
438 if (!remove && reportedLspId.getValue() == 0) {
439 updatedPaths = new ArrayList<>();
440 LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
442 // check previous report for existing paths
443 updatedPaths = new ArrayList<>(previous.getPath());
444 LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
445 for (final Path path : previous.getPath()) {
446 //we found reported path in previous reports
447 if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
448 LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
449 // path that was reported previously and does have the same lsp-id, path will be updated
450 final boolean r = updatedPaths.remove(path);
451 LOG.trace("Request removed? {}", r);
455 // if the path does not exist in previous report, add it to path list, it's a new ERO
456 // only one path will be added
457 //lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
458 LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
459 updatedPaths.addAll(rlb.getPath());
461 if (reportedLspId.getValue() == 0) {
462 // if lsp-id also 0, remove all paths
463 LOG.debug("Removing all paths.");
464 updatedPaths.clear();
466 // path is marked to be removed
467 LOG.debug("Removing path {} from {}", rlb.getPath(), updatedPaths);
468 final boolean r = updatedPaths.removeAll(rlb.getPath());
469 LOG.trace("Request removed? {}", r);
472 LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
477 * Indicate that the peer has completed state synchronization.
479 * @param ctx Message context
481 protected final synchronized void stateSynchronizationAchieved(final MessageContext ctx) {
483 LOG.debug("State synchronization achieved while synchronized, not updating state");
487 // Update synchronization flag
489 if (this.triggeredResyncInProcess) {
490 this.triggeredResyncInProcess = false;
492 updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).build());
494 // The node has completed synchronization, cleanup metadata no longer reported back
495 this.nodeState.cleanupExcept(this.lsps.values());
496 LOG.debug("Session {} achieved synchronized state", this.session);
499 protected final synchronized void updatePccNode(final MessageContext ctx, final PathComputationClient pcc) {
500 ctx.trans.merge(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier, pcc);
503 protected final InstanceIdentifier<ReportedLsp> lspIdentifier(final String name) {
504 return this.pccIdentifier.child(ReportedLsp.class, new ReportedLspKey(name));
508 * Remove LSP from the database.
510 * @param ctx Message Context
511 * @param id Revision-specific LSP identifier
513 protected final synchronized void removeLsp(final MessageContext ctx, final L id) {
514 final String name = this.lsps.remove(id);
515 LOG.debug("LSP {} removed", name);
516 ctx.trans.delete(LogicalDatastoreType.OPERATIONAL, lspIdentifier(name));
517 this.lspData.remove(name);
520 protected abstract void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder);
523 * Perform revision-specific message processing when a message arrives.
525 * @param ctx Message processing context
526 * @param message Protocol message
527 * @return True if the message type is not handle.
529 protected abstract boolean onMessage(MessageContext ctx, Message message);
531 protected final String lookupLspName(final L id) {
532 requireNonNull(id, "ID parameter null.");
533 return this.lsps.get(id);
537 * Reads operational data on this node. Doesn't attempt to read the data,
538 * if the node does not exist. In this case returns null.
540 * @param id InstanceIdentifier of the node
541 * @return null if the node does not exists, or operational data
543 protected final synchronized <T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) {
544 if (this.nodeState == null) {
547 return this.nodeState.readOperationalData(id);
550 protected abstract Object validateReportedLsp(final Optional<ReportedLsp> rep, final LspId input);
552 protected abstract void loadLspData(final Node node, final Map<String, ReportedLsp> lspData, final Map<L, String> lsps, final boolean incrementalSynchro);
554 protected final boolean isLspDbPersisted() {
555 if (this.syncOptimization != null) {
556 return this.syncOptimization.isSyncAvoidanceEnabled();
561 protected final boolean isLspDbRetreived() {
562 if (this.syncOptimization != null) {
563 return this.syncOptimization.isDbVersionPresent();
569 * Is Incremental synchronization if LSP-DB-VERSION are included,
570 * LSP-DB-VERSION TLV values doesnt match, and LSP-SYNC-CAPABILITY is enabled
574 protected final boolean isIncrementalSynchro() {
575 if (this.syncOptimization != null) {
576 return this.syncOptimization.isSyncAvoidanceEnabled() && this.syncOptimization.isDeltaSyncEnabled();
581 protected final boolean isTriggeredInitialSynchro() {
582 if (this.syncOptimization != null) {
583 return this.syncOptimization.isTriggeredInitSyncEnabled();
588 protected final boolean isTriggeredReSyncEnabled() {
589 if (this.syncOptimization != null) {
590 return this.syncOptimization.isTriggeredReSyncEnabled();
595 protected final boolean isSynchronized() {
596 if (this.syncOptimization != null) {
597 return this.syncOptimization.doesLspDbMatch();
602 protected synchronized SessionListenerState getSessionListenerState() {
603 return this.listenerState;
607 public synchronized Integer getDelegatedLspsCount() {
608 return Math.toIntExact(this.lspData.values().stream()
609 .map(ReportedLsp::getPath).filter(Objects::nonNull).filter(pathList -> !pathList.isEmpty())
610 // pick the first path, as delegate status should be same in each path
611 .map(pathList -> pathList.get(0))
612 .map(path -> path.getAugmentation(Path1.class)).filter(Objects::nonNull)
613 .map(LspObject::getLsp).filter(Objects::nonNull)
614 .filter(Lsp::isDelegate)
619 public Boolean getSynchronized() {
624 public StatefulMessages getStatefulMessages() {
625 return this.listenerState.getStatefulMessages();
629 public synchronized ReplyTime getReplyTime() {
630 return this.listenerState.getReplyTime();
634 public synchronized PeerCapabilities getPeerCapabilities() {
635 return this.listenerState.getPeerCapabilities();
639 public synchronized ListenableFuture<Void> tearDownSession(final TearDownSessionInput input) {
641 return Futures.immediateFuture(null);
645 public synchronized SessionState getSessionState() {
646 return this.listenerState.getSessionState(this.session);
650 public synchronized String getPeerId() {
651 return this.session.getPeerPref().getIpAddress();
654 protected static final class MessageContext {
655 private final Collection<PCEPRequest> requests = new ArrayList<>();
656 private final WriteTransaction trans;
658 private MessageContext(final WriteTransaction trans) {
659 this.trans = requireNonNull(trans);
662 void resolveRequest(final PCEPRequest req) {
663 this.requests.add(req);
666 private void notifyRequests() {
667 for (final PCEPRequest r : this.requests) {
668 r.done(OperationResults.SUCCESS);