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 java.util.concurrent.atomic.AtomicBoolean;
31 import javax.annotation.concurrent.GuardedBy;
32 import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl;
33 import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.TopologySessionStats;
34 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
35 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
36 import org.opendaylight.mdsal.common.api.CommitInfo;
37 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
38 import org.opendaylight.protocol.pcep.PCEPSession;
39 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
40 import org.opendaylight.protocol.pcep.TerminationReason;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.LspObject;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MessageHeader;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.LspId;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1Builder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.PccSyncState;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TearDownSessionInput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.lsp.metadata.Metadata;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClient;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path;
62 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
63 import org.opendaylight.yangtools.yang.binding.DataContainer;
64 import org.opendaylight.yangtools.yang.binding.DataObject;
65 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
66 import org.opendaylight.yangtools.yang.common.RpcResult;
67 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
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, TopologySessionStats {
80 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 static final String MISSING_XML_TAG = "Mandatory XML tags are missing.";
94 private static final Logger LOG = LoggerFactory.getLogger(AbstractTopologySessionListener.class);
96 final Map<L, String> lsps = new HashMap<>();
98 final SessionStateImpl listenerState;
100 private final Map<S, PCEPRequest> requests = new HashMap<>();
102 private final Map<String, ReportedLsp> lspData = new HashMap<>();
103 private final ServerSessionManager serverSessionManager;
104 private InstanceIdentifier<PathComputationClient> pccIdentifier;
106 private TopologyNodeState nodeState;
107 private AtomicBoolean synced = new AtomicBoolean(false);
109 private PCEPSession session;
111 private SyncOptimization syncOptimization;
113 private boolean triggeredResyncInProcess;
115 AbstractTopologySessionListener(final ServerSessionManager serverSessionManager) {
116 this.serverSessionManager = requireNonNull(serverSessionManager);
117 this.listenerState = new SessionStateImpl(this);
121 public final synchronized void onSessionUp(final PCEPSession psession) {
123 * The session went up. Look up the router in Inventory model,
124 * create it if it is not there (marking that fact for later
125 * deletion), and mark it as synchronizing. Also create it in
126 * the topology model, with empty LSP list.
128 final InetAddress peerAddress = psession.getRemoteAddress();
130 this.syncOptimization = new SyncOptimization(psession);
132 final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress,
133 this, isLspDbRetreived());
135 // takeNodeState(..) may fail when the server session manager is being restarted due to configuration change
137 LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", psession);
138 psession.close(TerminationReason.UNKNOWN);
139 this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
143 if (this.session != null || this.nodeState != null) {
144 LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(), psession);
145 psession.close(TerminationReason.UNKNOWN);
146 this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
149 this.session = psession;
150 this.nodeState = state;
151 this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
153 LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
155 // Our augmentation in the topology node
156 final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
158 onSessionUp(psession, pccBuilder);
159 this.synced.set(isSynchronized());
161 pccBuilder.setIpAddress(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
162 final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
163 this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
164 final Node initialNodeState = state.getInitialNodeState();
165 final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
167 loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
168 pccBuilder.setReportedLsp(initialNodeState.getAugmentation(Node1.class)
169 .getPathComputationClient().getReportedLsp());
171 state.storeNode(topologyAugment,
172 new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
173 this.listenerState.init(psession);
174 LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
177 synchronized void updatePccState(final PccSyncState pccSyncState) {
178 if (this.nodeState == null) {
179 LOG.info("Server Session Manager is closed.");
180 AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
183 final MessageContext ctx = new MessageContext(this.nodeState.getChain().newWriteOnlyTransaction());
184 updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(pccSyncState).build());
185 if (pccSyncState != PccSyncState.Synchronized) {
186 this.synced.set(false);
187 this.triggeredResyncInProcess = true;
189 // All set, commit the modifications
190 ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
192 public void onSuccess(final CommitInfo result) {
193 LOG.trace("Pcc Internal state for session {} updated successfully",
194 AbstractTopologySessionListener.this.session);
198 public void onFailure(final Throwable throwable) {
199 LOG.error("Failed to update Pcc internal state for session {}",
200 AbstractTopologySessionListener.this.session, throwable);
201 AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
203 }, MoreExecutors.directExecutor());
206 synchronized boolean isTriggeredSyncInProcess() {
207 return this.triggeredResyncInProcess;
211 * Tear down the given PCEP session. It's OK to call this method even after the session
212 * is already down. It always clear up the current session status.
215 @SuppressWarnings("checkstyle:IllegalCatch")
216 private synchronized void tearDown(final PCEPSession psession) {
218 requireNonNull(psession);
219 this.serverSessionManager.releaseNodeState(this.nodeState, psession, isLspDbPersisted());
223 if (this.session != null) {
224 this.session.close();
227 } catch (final Exception e) {
228 LOG.error("Session {} cannot be closed.", psession, e);
231 this.syncOptimization = null;
233 // Clear all requests we know about
234 for (final Entry<S, PCEPRequest> e : this.requests.entrySet()) {
235 final PCEPRequest r = e.getValue();
236 switch (r.getState()) {
238 // Done is done, nothing to do
239 LOG.trace("Request {} was done when session went down.", e.getKey());
242 // Peer has not acked: results in failure
243 LOG.info("Request {} was incomplete when session went down, failing the instruction", e.getKey());
244 r.done(OperationResults.NOACK);
247 // Peer has not been sent to the peer: results in cancellation
248 LOG.debug("Request {} was not sent when session went down, cancelling the instruction", e.getKey());
249 r.done(OperationResults.UNSENT);
255 this.requests.clear();
259 public final synchronized void onSessionDown(final PCEPSession psession, final Exception exception) {
260 LOG.warn("Session {} went down unexpectedly", psession, exception);
265 public final synchronized void onSessionTerminated(final PCEPSession psession, final PCEPTerminationReason reason) {
266 LOG.info("Session {} terminated by peer with reason {}", psession, reason);
271 public final synchronized void onMessage(final PCEPSession psession, final Message message) {
272 if (this.nodeState == null) {
273 LOG.warn("Topology node state is null. Unhandled message {} on session {}", message, psession);
274 psession.close(TerminationReason.UNKNOWN);
277 final MessageContext ctx = new MessageContext(this.nodeState.getChain().newWriteOnlyTransaction());
279 if (onMessage(ctx, message)) {
280 LOG.warn("Unhandled message {} on session {}", message, psession);
281 //cancel not supported, submit empty transaction
282 ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
284 public void onSuccess(final CommitInfo result) {
285 LOG.trace("Successful commit");
289 public void onFailure(final Throwable trw) {
290 LOG.error("Failed commit", trw);
292 }, MoreExecutors.directExecutor());
296 ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
298 public void onSuccess(final CommitInfo result) {
299 LOG.trace("Internal state for session {} updated successfully", psession);
300 ctx.notifyRequests();
305 public void onFailure(final Throwable throwable) {
306 LOG.error("Failed to update internal state for session {}, closing it", psession, throwable);
307 ctx.notifyRequests();
308 psession.close(TerminationReason.UNKNOWN);
310 }, MoreExecutors.directExecutor());
314 public synchronized void close() {
316 if (this.session != null) {
317 LOG.info("Closing session {}", session);
318 this.session.close(TerminationReason.UNKNOWN);
322 private synchronized void clearNodeState() {
323 if (this.nodeState != null) {
324 this.serverSessionManager.unbind(this.nodeState.getNodeId());
325 this.nodeState = null;
329 final synchronized PCEPRequest removeRequest(final S id) {
330 final PCEPRequest ret = this.requests.remove(id);
332 this.listenerState.processRequestStats(ret.getElapsedMillis());
334 LOG.trace("Removed request {} object {}", id, ret);
338 final synchronized ListenableFuture<OperationResult> sendMessage(final Message message, final S requestId,
339 final Metadata metadata) {
340 final io.netty.util.concurrent.Future<Void> f = this.session.sendMessage(message);
341 this.listenerState.updateStatefulSentMsg(message);
342 final PCEPRequest req = new PCEPRequest(metadata);
343 this.requests.put(requestId, req);
344 final short rpcTimeout = this.serverSessionManager.getRpcTimeout();
345 LOG.trace("RPC response timeout value is {} seconds", rpcTimeout);
346 if (rpcTimeout > 0) {
347 setupTimeoutHandler(requestId, req, rpcTimeout);
350 f.addListener((FutureListener<Void>) future -> {
351 if (!future.isSuccess()) {
352 synchronized (AbstractTopologySessionListener.this) {
353 AbstractTopologySessionListener.this.requests.remove(requestId);
355 req.done(OperationResults.UNSENT);
356 LOG.info("Failed to send request {}, instruction cancelled", requestId, future.cause());
359 LOG.trace("Request {} sent to peer (object {})", requestId, req);
363 return req.getFuture();
366 private void setupTimeoutHandler(final S requestId, final PCEPRequest req, final short timeout) {
367 final Timer timer = req.getTimer();
368 timer.schedule(new TimerTask() {
371 synchronized (AbstractTopologySessionListener.this) {
372 AbstractTopologySessionListener.this.requests.remove(requestId);
375 LOG.info("Request {} timed-out waiting for response", requestId);
377 }, TimeUnit.SECONDS.toMillis(timeout));
378 LOG.trace("Set up response timeout handler for request {}", requestId);
382 * Update an LSP in the data store.
384 * @param ctx Message context
385 * @param id Revision-specific LSP identifier
386 * @param lspName LSP name
387 * @param rlb Reported LSP builder
388 * @param solicited True if the update was solicited
389 * @param remove True if this is an LSP path removal
391 protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName,
392 final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
395 if (lspName == null) {
396 name = this.lsps.get(id);
398 LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
405 LOG.debug("Saved LSP {} with name {}", id, name);
406 this.lsps.put(id, name);
409 final ReportedLsp previous = this.lspData.get(name);
410 // if no previous report about the lsp exist, just proceed
411 if (previous != null) {
412 final List<Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
413 // if all paths or the last path were deleted, delete whole tunnel
414 if (updatedPaths.isEmpty()) {
415 LOG.debug("All paths were removed, removing LSP with {}.", id);
419 rlb.setPath(updatedPaths);
421 rlb.setKey(new ReportedLspKey(name));
424 // If this is an unsolicited update. We need to make sure we retain the metadata already present
426 this.nodeState.setLspMetadata(name, rlb.getMetadata());
428 rlb.setMetadata(this.nodeState.getLspMetadata(name));
431 final ReportedLsp rl = rlb.build();
432 ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.getKey()), rl);
433 LOG.debug("LSP {} updated to MD-SAL", name);
435 this.lspData.put(name, rl);
438 private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name,
439 final boolean remove) {
440 // just one path should be reported
441 Preconditions.checkState(rlb.getPath().size() == 1);
442 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId =
443 rlb.getPath().get(0).getLspId();
444 final List<Path> updatedPaths;
445 //lspId = 0 and remove = false -> tunnel is down, still exists but no path is signaled
446 //remove existing tunnel's paths now, as explicit path remove will not come
447 if (!remove && reportedLspId.getValue() == 0) {
448 updatedPaths = new ArrayList<>();
449 LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
451 // check previous report for existing paths
452 updatedPaths = new ArrayList<>(previous.getPath());
453 LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
454 for (final Path path : previous.getPath()) {
455 //we found reported path in previous reports
456 if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
457 LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
458 // path that was reported previously and does have the same lsp-id, path will be updated
459 final boolean r = updatedPaths.remove(path);
460 LOG.trace("Request removed? {}", r);
464 // if the path does not exist in previous report, add it to path list, it's a new ERO
465 // only one path will be added
466 //lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
467 LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
468 updatedPaths.addAll(rlb.getPath());
470 if (reportedLspId.getValue() == 0) {
471 // if lsp-id also 0, remove all paths
472 LOG.debug("Removing all paths.");
473 updatedPaths.clear();
475 // path is marked to be removed
476 LOG.debug("Removing path {} from {}", rlb.getPath(), updatedPaths);
477 final boolean r = updatedPaths.removeAll(rlb.getPath());
478 LOG.trace("Request removed? {}", r);
481 LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
486 * Indicate that the peer has completed state synchronization.
488 * @param ctx Message context
490 protected final synchronized void stateSynchronizationAchieved(final MessageContext ctx) {
491 if (this.synced.getAndSet(true)) {
492 LOG.debug("State synchronization achieved while synchronizing, not updating state");
495 if (this.triggeredResyncInProcess) {
496 this.triggeredResyncInProcess = false;
498 updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).build());
500 // The node has completed synchronization, cleanup metadata no longer reported back
501 this.nodeState.cleanupExcept(this.lsps.values());
502 LOG.debug("Session {} achieved synchronized state", this.session);
505 protected final synchronized void updatePccNode(final MessageContext ctx, final PathComputationClient pcc) {
506 ctx.trans.merge(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier, pcc);
509 protected final InstanceIdentifier<ReportedLsp> lspIdentifier(final String name) {
510 return this.pccIdentifier.child(ReportedLsp.class, new ReportedLspKey(name));
514 * Remove LSP from the database.
516 * @param ctx Message Context
517 * @param id Revision-specific LSP identifier
519 protected final synchronized void removeLsp(final MessageContext ctx, final L id) {
520 final String name = this.lsps.remove(id);
521 LOG.debug("LSP {} removed", name);
522 ctx.trans.delete(LogicalDatastoreType.OPERATIONAL, lspIdentifier(name));
523 this.lspData.remove(name);
526 @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
527 protected abstract void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder);
530 * Perform revision-specific message processing when a message arrives.
532 * @param ctx Message processing context
533 * @param message Protocol message
534 * @return True if the message type is not handle.
536 @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
537 protected abstract boolean onMessage(MessageContext ctx, Message message);
539 final String lookupLspName(final L id) {
540 requireNonNull(id, "ID parameter null.");
541 return this.lsps.get(id);
545 * Reads operational data on this node. Doesn't attempt to read the data,
546 * if the node does not exist. In this case returns null.
548 * @param id InstanceIdentifier of the node
549 * @return null if the node does not exists, or operational data
551 final synchronized <T extends DataObject> ListenableFuture<Optional<T>>
552 readOperationalData(final InstanceIdentifier<T> id) {
553 if (this.nodeState == null) {
556 return this.nodeState.readOperationalData(id);
559 protected abstract Object validateReportedLsp(Optional<ReportedLsp> rep, LspId input);
561 protected abstract void loadLspData(Node node, Map<String, ReportedLsp> lspData, Map<L, String> lsps,
562 boolean incrementalSynchro);
564 final boolean isLspDbPersisted() {
565 return this.syncOptimization != null && this.syncOptimization.isSyncAvoidanceEnabled();
568 final boolean isLspDbRetreived() {
569 return this.syncOptimization != null && this.syncOptimization.isDbVersionPresent();
573 * Is Incremental synchronization if LSP-DB-VERSION are included,
574 * LSP-DB-VERSION TLV values doesnt match, and LSP-SYNC-CAPABILITY is enabled.
576 final synchronized boolean isIncrementalSynchro() {
577 return this.syncOptimization != null && this.syncOptimization.isSyncAvoidanceEnabled()
578 && this.syncOptimization.isDeltaSyncEnabled();
581 final synchronized boolean isTriggeredInitialSynchro() {
582 return this.syncOptimization != null && this.syncOptimization.isTriggeredInitSyncEnabled();
585 final synchronized boolean isTriggeredReSyncEnabled() {
586 return this.syncOptimization != null && this.syncOptimization.isTriggeredReSyncEnabled();
589 protected final synchronized boolean isSynchronized() {
590 return this.syncOptimization != null && this.syncOptimization.doesLspDbMatch();
594 public synchronized int getDelegatedLspsCount() {
595 return Math.toIntExact(this.lspData.values().stream()
596 .map(ReportedLsp::getPath).filter(Objects::nonNull).filter(pathList -> !pathList.isEmpty())
597 // pick the first path, as delegate status should be same in each path
598 .map(pathList -> pathList.get(0))
599 .map(path -> path.getAugmentation(Path1.class)).filter(Objects::nonNull)
600 .map(LspObject::getLsp).filter(Objects::nonNull)
601 .filter(Lsp::isDelegate)
606 public boolean isSessionSynchronized() {
607 return this.synced.get();
611 public synchronized ListenableFuture<RpcResult<Void>> tearDownSession(final TearDownSessionInput input) {
613 return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
616 static final class MessageContext {
617 private final Collection<PCEPRequest> requests = new ArrayList<>();
618 private final WriteTransaction trans;
620 private MessageContext(final WriteTransaction trans) {
621 this.trans = requireNonNull(trans);
624 void resolveRequest(final PCEPRequest req) {
625 this.requests.add(req);
628 private void notifyRequests() {
629 for (final PCEPRequest r : this.requests) {
630 r.done(OperationResults.SUCCESS);