use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class EffectiveRibInWriter method onDataTreeChanged.
@Override
public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
if (this.chain == null) {
LOG.trace("Chain closed. Ignoring Changes : {}", changes);
return;
}
LOG.trace("Data changed called to effective RIB. Change : {}", changes);
DOMDataTreeWriteTransaction tx = null;
for (final DataTreeCandidate tc : changes) {
final YangInstanceIdentifier rootPath = tc.getRootPath();
final DataTreeCandidateNode root = tc.getRootNode();
for (final DataTreeCandidateNode table : root.getChildNodes()) {
if (tx == null) {
tx = this.chain.newWriteOnlyTransaction();
}
changeDataTree(tx, rootPath, root, table);
}
}
if (tx != null) {
final FluentFuture<? extends CommitInfo> future = tx.commit();
this.submitted = future;
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
}
// Refresh VPN Table if RT Memberships were updated
if (this.rtMembershipsUpdated) {
this.vpnTableRefresher.refreshTable(IVP4_VPN_TABLE_KEY, this.peerImportParameters.getFromPeerId());
this.vpnTableRefresher.refreshTable(IVP6_VPN_TABLE_KEY, this.peerImportParameters.getFromPeerId());
this.rtMembershipsUpdated = false;
}
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class LocRibWriter method init.
private synchronized void init() {
final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.node(ATTRIBUTES_NID).node(UPTODATE_NID), RIBNormalizedNodes.ATTRIBUTES_UPTODATE_TRUE);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
this.reg = this.dataBroker.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, ribIId.node(PEER_NID).node(PEER_NID).node(EFFRIBIN_NID).node(TABLES_NID).node(locRibTableIID.getLastPathArgument())), this);
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class LocRibWriter method onDataTreeChanged.
/**
* We use two-stage processing here in hopes that we avoid duplicate
* calculations when multiple peers have changed a particular entry.
*
* @param changes on supported table
*/
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
if (this.chain == null) {
LOG.trace("Chain closed, ignoring received data change {} to LocRib {}", changes, this);
return;
}
LOG.trace("Received data change {} to LocRib {}", changes, this);
final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
try {
final Map<RouteUpdateKey, RouteEntry<C, S>> toUpdate = update(tx, changes);
if (!toUpdate.isEmpty()) {
walkThrough(tx, toUpdate.entrySet());
}
} catch (final Exception e) {
LOG.error("Failed to completely propagate updates {}, state is undefined", changes, e);
} finally {
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
}
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class TopologyDataChangeCounter method putCount.
private void putCount(final long totalCount) {
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
final Counter counter = new CounterBuilder().setId(this.counterId).setCount(Uint32.valueOf(totalCount)).build();
wTx.put(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId, counter);
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Data change count update stored");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed to store Data change count");
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class StateProviderImpl method close.
@Deactivate
@PreDestroy
@Override
public synchronized void close() {
if (closed.compareAndSet(false, true)) {
this.scheduleTask.cancel(true);
if (!this.instanceIdentifiersCache.isEmpty()) {
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
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) {
LOG.trace("Successfully operational stats removed.");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to clean up operational stats", throwable);
}
}, MoreExecutors.directExecutor());
}
this.transactionChain.close();
this.scheduler.shutdown();
}
}
Aggregations