use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class BmpRouterImpl method createRouterEntry.
private synchronized void createRouterEntry() {
Preconditions.checkState(isDatastoreWritable());
final DOMDataTreeWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)).withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, this.routerIp)).withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN)).withChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).build());
wTx.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 ProgrammingServiceImpl method instantiateServiceInstance.
@Override
public synchronized void instantiateServiceInstance() {
LOG.info("Instruction Queue service {} instantiated", this.sgi.getName());
this.reg = this.rpcProviderRegistry.registerRpcImplementation(ProgrammingService.class, this);
final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
wt.put(LogicalDatastoreType.OPERATIONAL, this.qid, new InstructionsQueueBuilder().withKey(new InstructionsQueueKey(this.instructionId)).setInstruction(Map.of()).build());
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Instruction Queue {} added", ProgrammingServiceImpl.this.qid);
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed to add Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class ProgrammingServiceImpl method closeServiceInstance.
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
LOG.info("Closing Instruction Queue service {}", this.sgi.getName());
if (this.reg != null) {
this.reg.close();
this.reg = null;
}
for (final InstructionImpl instruction : this.insns.values()) {
instruction.tryCancel(null);
}
// Workaround for BUG-2283
final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
wt.delete(LogicalDatastoreType.OPERATIONAL, this.qid);
final FluentFuture<? extends CommitInfo> future = wt.commit();
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed to shutdown Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
}
}, MoreExecutors.directExecutor());
return future;
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class AppPeerBenchmark method processRoutes.
private long processRoutes(final Ipv4Prefix ipv4Prefix, final Uint32 count, final Uint32 batch, final Attributes attributes) {
WriteTransaction wt = this.txChain.newWriteOnlyTransaction();
String address = getAdddressFromPrefix(ipv4Prefix);
final long countLong = count.longValue();
final long batchLong = batch.longValue();
final Stopwatch stopwatch = Stopwatch.createStarted();
for (int i = 1; i <= countLong; i++) {
final Ipv4RouteKey routeKey = new Ipv4RouteKey(NON_PATH_ID, createKey(address));
final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIId = this.routesIId.child(Ipv4Route.class, routeKey);
if (attributes != null) {
final Ipv4RouteBuilder ipv4RouteBuilder = new Ipv4RouteBuilder();
ipv4RouteBuilder.setRouteKey(routeKey.getRouteKey());
ipv4RouteBuilder.setPrefix(new Ipv4Prefix(routeKey.getRouteKey()));
ipv4RouteBuilder.withKey(routeKey);
ipv4RouteBuilder.setAttributes(attributes);
final Ipv4Route ipv4Route = ipv4RouteBuilder.build();
wt.put(LogicalDatastoreType.CONFIGURATION, routeIId, ipv4Route);
} else {
wt.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
}
if (i % batchLong == 0) {
wt.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());
wt = this.txChain.newWriteOnlyTransaction();
}
address = increasePrefix(address);
}
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Route batch stored.");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to store route batch.", throwable);
}
}, MoreExecutors.directExecutor());
return stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
}
use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.
the class AppPeerBenchmark method start.
public void start() {
LOG.debug("Instantiating App Peer Benchmark : {}", this.appRibId);
final ApplicationRib appRib = new ApplicationRibBuilder().setId(new ApplicationRibId(new ApplicationRibId(this.appRibId))).setTables(EMPTY_TABLES).build();
final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.CONFIGURATION, this.appIID, appRib);
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.info("Empty Structure created for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId, throwable);
}
}, MoreExecutors.directExecutor());
}
Aggregations