tx.delete(LogicalDatastoreType.OPERATIONAL, ribOutTarget);
}
- final synchronized void releaseBindingChain() {
- if (this.submitted != null) {
- try {
- this.submitted.get();
- } catch (final InterruptedException | ExecutionException throwable) {
- LOG.error("Write routes failed", throwable);
+ final synchronized void releaseBindingChain(final boolean isWaitForSubmitted) {
+ if (isWaitForSubmitted) {
+ if (this.submitted != null) {
+ try {
+ this.submitted.get();
+ } catch (final InterruptedException | ExecutionException throwable) {
+ LOG.error("Write routes failed", throwable);
+ }
}
}
closeBindingChain();
import java.util.stream.Collectors;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.checkerframework.checker.lock.qual.Holding;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
@Override
public synchronized FluentFuture<? extends CommitInfo> close() {
- final FluentFuture<? extends CommitInfo> future = releaseConnection();
+ final FluentFuture<? extends CommitInfo> future = releaseConnection(true);
closeDomChain();
setActive(false);
return future;
@Override
public synchronized FluentFuture<? extends CommitInfo> releaseConnection() {
+ return releaseConnection(true);
+ }
+
+ /**
+ * On transaction chain failure, we don't want to wait for future.
+ *
+ * @param isWaitForSubmitted if true, wait for submitted future before closing binding chain. if false, don't wait.
+ */
+ @Holding("this")
+ private @NonNull FluentFuture<? extends CommitInfo> releaseConnection(final boolean isWaitForSubmitted) {
LOG.info("Closing session with peer");
this.sessionUp = false;
this.adjRibOutListenerSet.values().forEach(AdjRibOutListener::close);
handleRestartTimer();
}
}
- releaseBindingChain();
+ releaseBindingChain(isWaitForSubmitted);
closeSession();
return future;
TimeUnit.NANOSECONDS);
}
+ @Holding("this")
private void releaseConnectionGracefully() {
if (getPeerRestartTime() > 0) {
setRestartingState();
}
- releaseConnection();
+ releaseConnection(true);
}
@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
@Override
public boolean supportsTable(final TablesKey tableKey) {
- return this.sessionUp && getAfiSafisAdvertized().contains(tableKey);
+ return this.sessionUp && getAfiSafisAdvertized().contains(tableKey) && this.tables.contains(tableKey);
}
@Override
public synchronized void onTransactionChainFailed(final DOMTransactionChain chain,
final DOMDataTreeTransaction transaction, final Throwable cause) {
LOG.error("Transaction domChain failed.", cause);
- releaseConnection();
+ releaseConnection(true);
}
@Override
public synchronized void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
final Throwable cause) {
LOG.error("Transaction domChain failed.", cause);
- releaseConnection();
+ releaseConnection(false);
}
@Override
setGracefulPreferences(true, tablesToPreserve);
this.currentSelectionDeferralTimerSeconds = selectionDeferralTimerSeconds;
setLocalRestartingState(true);
- return releaseConnection();
+ return releaseConnection(true);
}
@Override
newRoutes.addAll(entry.newBestPaths(this.ribSupport, e.getKey().getRouteId()));
}
updateLocRib(newRoutes, staleRoutes, tx);
- this.peerTracker.getNonInternalPeers().parallelStream().forEach(
- toPeer -> toPeer.refreshRibOut(this.entryDep, staleRoutes, newRoutes));
+ this.peerTracker.getNonInternalPeers().parallelStream()
+ .filter(toPeer -> toPeer.supportsTable(this.entryDep.getLocalTablesKey()))
+ .forEach(toPeer -> toPeer.refreshRibOut(this.entryDep, staleRoutes, newRoutes));
}
private void updateLocRib(final List<AdvertizedRoute<C, S, R, I>> newRoutes,
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.LongAdder;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.eclipse.jdt.annotation.NonNull;
private final LongAdder notificationReceivedCounter = new LongAdder();
private final LongAdder erroneousUpdate = new LongAdder();
private final String groupId;
- @GuardedBy("this")
- private boolean active;
+ private AtomicBoolean active = new AtomicBoolean(false);
@GuardedBy("this")
private final Map<TablesKey, PrefixesSentCounters> prefixesSent = new HashMap<>();
}
@Override
- public final synchronized boolean isActive() {
- return this.active;
+ public final boolean isActive() {
+ return this.active.get();
}
- protected final synchronized void setActive(final boolean active) {
- this.active = active;
+ protected final void setActive(final boolean active) {
+ this.active.set(active);
}
@Override