use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class ConnectedGraphServer method removeFromDataStore.
/**
* Remove Graph or Graph components to the Data Store.
*
* @param <T> As a generic method, T must be a Graph, Vertex, Edge or Prefix.
* @param id Instance Identifier of the Data Object
* @param info Information to be logged
*/
private synchronized <T extends DataObject> void removeFromDataStore(final InstanceIdentifier<T> id, final String info) {
final ReadWriteTransaction trans = this.chain.newReadWriteTransaction();
trans.delete(LogicalDatastoreType.OPERATIONAL, id);
trans.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.info("GraphModel: {} has been deleted in operational datastore ", info);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("GraphModel: Cannot delete {} to the operational datastore (transaction: {})", info, trans.getIdentifier());
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class ConnectedGraphServer method destroyOperationalGraphModel.
/**
* Destroy the current operational topology data. Note a valid transaction must be provided.
*/
private synchronized FluentFuture<? extends CommitInfo> destroyOperationalGraphModel() {
requireNonNull(this.chain, "A valid transaction chain must be provided.");
final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
trans.delete(LogicalDatastoreType.OPERATIONAL, GRAPH_TOPOLOGY_IDENTIFIER);
trans.delete(LogicalDatastoreType.CONFIGURATION, GRAPH_TOPOLOGY_IDENTIFIER);
final FluentFuture<? extends CommitInfo> future = trans.commit();
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Operational GraphModel removed {}", GRAPH_TOPOLOGY_IDENTIFIER);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Unable to reset operational GraphModel {} (transaction {})", GRAPH_TOPOLOGY_IDENTIFIER, trans.getIdentifier(), throwable);
}
}, MoreExecutors.directExecutor());
/* Clear Connected Graph */
for (ConnectedGraph graph : graphs.values()) {
((ConnectedGraphImpl) graph).clear();
}
return future;
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class AdjRibInWriter method removeRoutes.
void removeRoutes(final MpUnreachNlri nlri) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
LOG.trace("Removing routes {}", nlri);
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
ctx.removeRoutes(tx, nlri);
final FluentFuture<? extends CommitInfo> future = tx.commit();
this.submitted = future;
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Removing routes {}, succeed", nlri);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Removing routes failed", throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class AdjRibInWriter method transform.
AdjRibInWriter transform(final PeerId newPeerId, final YangInstanceIdentifier peerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
createEmptyPeerStructure(newPeerId, peerPath, tx);
final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(peerPath, registry, tableTypes, addPathTablesType, tx);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
if (registerAppPeerListener != null) {
LOG.trace("Application Peer Listener registered");
registerAppPeerListener.register();
}
}
@Override
public void onFailure(final Throwable throwable) {
if (registerAppPeerListener != null) {
LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
} else {
LOG.error("Failed to create Empty Structure", throwable);
}
}
}, MoreExecutors.directExecutor());
return new AdjRibInWriter(this.ribPath, this.chain, this.role, tb);
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class AdjRibInWriter method markTableUptodate.
void markTableUptodate(final TablesKey tableTypes) {
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
final TableContext ctx = this.tables.get(tableTypes);
tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().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("Write Attributes uptodate, succeed");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Write Attributes uptodate failed", throwable);
}
}, MoreExecutors.directExecutor());
}
Aggregations