}
}
- 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");
- }
+ 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());
+ @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) {
return;
}
- final RIBSupport<?, ?, ?, ?> ribSupport = ribContext.getRibSupport();
final YangInstanceIdentifier effectiveTablePath = effectiveTablePath(tableKey);
final ModificationType modificationType = root.getModificationType();
+ LOG.debug("Effective table {} modification type {}", effectiveTablePath, modificationType);
switch (modificationType) {
case DISAPPEARED:
case DELETE:
- processTableChildren(tx, ribSupport, effectiveTablePath, table.getChildNodes());
- LOG.debug("Delete Effective Table {} modification type {}, ", effectiveTablePath, modificationType);
- tx.delete(LogicalDatastoreType.OPERATIONAL, effectiveTablePath);
+ deleteTable(tx, ribContext, effectiveTablePath, table);
break;
case APPEARED:
case WRITE:
- LOG.trace("Create Empty table {}", ribSupport.getTablesKey());
- ribContext.createEmptyTableStructure(tx, effectiveTablePath);
- processTableChildren(tx, ribSupport, effectiveTablePath, table.getChildNodes());
+ writeTable(tx, ribContext, effectiveTablePath, table);
break;
case SUBTREE_MODIFIED:
- processTableChildren(tx, ribSupport, effectiveTablePath, table.getChildNodes());
+ modifyTable(tx, ribContext, effectiveTablePath, table);
break;
case UNMODIFIED:
LOG.info("Ignoring spurious notification on {} data {}", rootPath, table);
}
}
+ private void deleteTable(final DOMDataWriteTransaction tx, final RIBSupportContext ribContext,
+ final YangInstanceIdentifier effectiveTablePath, final DataTreeCandidateNode table) {
+ processTableChildren(tx, ribContext.getRibSupport(), effectiveTablePath, table.getChildNodes());
+ LOG.debug("Delete Effective Table {}", effectiveTablePath);
+ tx.delete(LogicalDatastoreType.OPERATIONAL, effectiveTablePath);
+ }
+
+ private void modifyTable(final DOMDataWriteTransaction tx, final RIBSupportContext ribContext,
+ final YangInstanceIdentifier effectiveTablePath, final DataTreeCandidateNode table) {
+ LOG.debug("Modify Effective Table {}", effectiveTablePath);
+ processTableChildren(tx, ribContext.getRibSupport(), effectiveTablePath, table.getChildNodes());
+ }
+
+ private void writeTable(final DOMDataWriteTransaction tx, final RIBSupportContext ribContext,
+ final YangInstanceIdentifier effectiveTablePath, final DataTreeCandidateNode table) {
+ LOG.debug("Write Effective Table {}", effectiveTablePath);
+ ribContext.createEmptyTableStructure(tx, effectiveTablePath);
+ processTableChildren(tx, ribContext.getRibSupport(), effectiveTablePath, table.getChildNodes());
+ }
+
private void processTableChildren(final DOMDataWriteTransaction tx, final RIBSupport<?, ?, ?, ?> ribSupport,
final YangInstanceIdentifier effectiveTablePath, final Collection<DataTreeCandidateNode> children) {
for (final DataTreeCandidateNode child : children) {
final PathArgument childIdentifier = child.getIdentifier();
+ final ModificationType childModType = child.getModificationType();
final Optional<NormalizedNode<?, ?>> childDataAfter = child.getDataAfter();
- LOG.debug("Process table {} type {}, dataAfter {}, dataBefore {}", childIdentifier, child
- .getModificationType(), childDataAfter, child.getDataBefore());
+ LOG.debug("Process table {} type {}, dataAfter {}, dataBefore {}", childIdentifier, childModType,
+ childDataAfter, child.getDataBefore());
final YangInstanceIdentifier routesPath = effectiveTablePath.node(childIdentifier);
- switch (child.getModificationType()) {
+ switch (childModType) {
case DELETE:
- LOG.debug("Route deleted. routeId={}", routesPath);
- processTableChildrenDelete(child, childIdentifier, tx, ribSupport, routesPath);
- break;
case DISAPPEARED:
- LOG.debug("Route disappeared. routeId={}", routesPath);
processTableChildrenDelete(child, childIdentifier, tx, ribSupport, routesPath);
break;
case UNMODIFIED:
final DOMDataWriteTransaction tx, final RIBSupport<?, ?, ?, ?> ribSupport,
final YangInstanceIdentifier routesPath) {
if (ROUTES.equals(childIdentifier)) {
- final Collection<DataTreeCandidateNode> changedRoutes = ribSupport.changedRoutes(child);
- if (!changedRoutes.isEmpty()) {
- for (final DataTreeCandidateNode route : changedRoutes) {
- final NormalizedNode<?, ?> routeBefore = route.getDataBefore().orElse(null);
- if (routeBefore != null) {
- final YangInstanceIdentifier routePath = ribSupport.routePath(routesPath, route.getIdentifier());
- handleRouteTarget(ModificationType.DELETE, ribSupport, routePath, routeBefore);
- final TablesKey tablesKey = ribSupport.getTablesKey();
- CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey);
- }
+ for (final DataTreeCandidateNode route : ribSupport.changedRoutes(child)) {
+ final Optional<NormalizedNode<?, ?>> routeBefore = route.getDataBefore();
+ if (routeBefore.isPresent()) {
+ final YangInstanceIdentifier routePath = ribSupport.routePath(routesPath, route.getIdentifier());
+ handleRouteTarget(ModificationType.DELETE, ribSupport, routePath, routeBefore.get());
+ final TablesKey tablesKey = ribSupport.getTablesKey();
+ CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey);
}
}
}
final DOMDataWriteTransaction tx, final RIBSupport<?, ?, ?, ?> ribSupport,
final YangInstanceIdentifier routesPath, final Optional<NormalizedNode<?, ?>> childDataAfter) {
if (ROUTES.equals(childIdentifier)) {
- final Collection<DataTreeCandidateNode> changedRoutes = ribSupport.changedRoutes(child);
- if (!changedRoutes.isEmpty()) {
- for (final DataTreeCandidateNode route : changedRoutes) {
- processRoute(tx, ribSupport, routesPath.getParent(), route);
- }
+ for (final DataTreeCandidateNode route : ribSupport.changedRoutes(child)) {
+ processRoute(tx, ribSupport, routesPath.getParent(), route);
}
} else {
tx.put(LogicalDatastoreType.OPERATIONAL, routesPath, childDataAfter.get());