this.scheduleTask.cancel(true);
if (!this.instanceIdentifiersCache.keySet().isEmpty()) {
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
- this.instanceIdentifiersCache.keySet().iterator()
- .forEachRemaining(ribId -> removeStoredOperationalState(ribId, wTx));
+ this.instanceIdentifiersCache.values()
+ .forEach(bgpIID -> wTx.delete(LogicalDatastoreType.OPERATIONAL, bgpIID));
+ this.instanceIdentifiersCache.clear();
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
private final ServiceGroupIdentifier serviceGroupIdentifier;
private final AtomicBoolean instantiated = new AtomicBoolean(false);
private final PeerGroupConfigLoader peerGroupLoader;
+ @GuardedBy("this")
private RibImpl ribImpl;
Futures.addCallback(futureResult, new FutureCallback<List<? extends CommitInfo>>() {
@Override
public void onSuccess(final List<? extends CommitInfo> result) {
- done.setFuture(Futures.transform(BGPClusterSingletonService.this.ribImpl.closeServiceInstance(),
- input -> null, MoreExecutors.directExecutor()));
+ synchronized (BGPClusterSingletonService.this) {
+ if (BGPClusterSingletonService.this.ribImpl != null) {
+ done.setFuture(Futures.transform(BGPClusterSingletonService.this.ribImpl.closeServiceInstance(),
+ input -> null, MoreExecutors.directExecutor()));
+ } else {
+ done.setFuture(Futures.transform(CommitInfo.emptyFluentFuture(),
+ input -> null, MoreExecutors.directExecutor()));
+ }
+ }
}
@Override
LOG.debug("RIB instance created: {}", this.ribImpl);
}
+ @Holding("this")
@SuppressWarnings("checkstyle:illegalCatch")
private void closeRibService() {
try {
}
@Override
- public void close() {
+ public synchronized void close() {
LOG.info("BGPClusterSingletonService {} close", this.serviceGroupIdentifier.getName());
this.peers.values().iterator().forEachRemaining(PeerBean::close);
this.ribImpl.close();