@Test public void testToString() throws Exception { assertEquals("MasterDatastoreImpl\n", database.toString()); database.addBindings(mergeBindings(getBinding("1.1.1.1/32", 100, "10.10.10.10"), getBinding("2.2.2.2/32", 2000, "20.20.20.20"), getBinding("0:0:0:0:0:0:0:A/32", 15, "0.10.10.10"), getBinding("2.2.2.20/32", 2000, "200.200.200.200"))); StringBuilder value = new StringBuilder(); Arrays.asList(database.toString().split("\n")).stream().sorted().forEach(l -> value.append(l).append("\n")); assertEquals("\t100 1.1.1.1/32\n" + "\t15 0:0:0:0:0:0:0:A/32\n" + "\t2000 2.2.2.2/32\n" + "\t2000 2.2.2.20/32\n" + "MasterDatastoreImpl\n", value.toString()); }
@Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null || bindings.isEmpty()) { return added; } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); Map<IpPrefix, MasterDatabaseBinding> databaseMap; if (database != null && database.getMasterDatabaseBinding() != null && !database.getMasterDatabaseBinding().isEmpty()) { databaseMap = database.getMasterDatabaseBinding() .stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); } else { databaseMap = new HashMap<>(); } added.addAll(MasterDatabase.filterIncomingBindings(bindings, databaseMap::get, p -> datastoreAccess.checkAndDelete(getIdentifierBuilder(p).build(), LogicalDatastoreType.OPERATIONAL)).values()); if (!added.isEmpty()) { datastoreAccess.merge(getIdentifierBuilder().build(), new MasterDatabaseBuilder().setMasterDatabaseBinding(added).build(), LogicalDatastoreType.OPERATIONAL); } dbListener.onBindingsAdded(added); return added; }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null || bindings.isEmpty()) { return added; } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); Map<IpPrefix, MasterDatabaseBinding> databaseMap; if (database != null && database.getMasterDatabaseBinding() != null && !database.getMasterDatabaseBinding().isEmpty()) { databaseMap = database.getMasterDatabaseBinding() .stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); } else { databaseMap = new HashMap<>(); } added.addAll(MasterDatabase.filterIncomingBindings(bindings, databaseMap::get, p -> datastoreAccess.checkAndDelete(getIdentifierBuilder(p).build(), LogicalDatastoreType.OPERATIONAL)).values()); if (!added.isEmpty()) { datastoreAccess.merge(getIdentifierBuilder().build(), new MasterDatabaseBuilder().setMasterDatabaseBinding(added).build(), LogicalDatastoreType.OPERATIONAL); } dbListener.onBindingsAdded(added); return added; } }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null || bindings.isEmpty()) { return added; } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); Map<IpPrefix, MasterDatabaseBinding> databaseMap; if (database != null && database.getMasterDatabaseBinding() != null && !database.getMasterDatabaseBinding().isEmpty()) { databaseMap = database.getMasterDatabaseBinding() .stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); } else { databaseMap = new HashMap<>(); } added.addAll(MasterDatabase.filterIncomingBindings(bindings, databaseMap::get, p -> datastoreAccess.checkAndDelete(getIdentifierBuilder(p).build(), LogicalDatastoreType.OPERATIONAL)).values()); if (!added.isEmpty()) { datastoreAccess.merge(getIdentifierBuilder().build(), new MasterDatabaseBuilder().setMasterDatabaseBinding(added).build(), LogicalDatastoreType.OPERATIONAL); } dbListener.onBindingsAdded(added); return added; } MasterDatastoreImpl(DatastoreAccess datastoreAccess, String nodeId, String domain); }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null || bindings.isEmpty()) { return added; } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); Map<IpPrefix, MasterDatabaseBinding> databaseMap; if (database != null && database.getMasterDatabaseBinding() != null && !database.getMasterDatabaseBinding().isEmpty()) { databaseMap = database.getMasterDatabaseBinding() .stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); } else { databaseMap = new HashMap<>(); } added.addAll(MasterDatabase.filterIncomingBindings(bindings, databaseMap::get, p -> datastoreAccess.checkAndDelete(getIdentifierBuilder(p).build(), LogicalDatastoreType.OPERATIONAL)).values()); if (!added.isEmpty()) { datastoreAccess.merge(getIdentifierBuilder().build(), new MasterDatabaseBuilder().setMasterDatabaseBinding(added).build(), LogicalDatastoreType.OPERATIONAL); } dbListener.onBindingsAdded(added); return added; } MasterDatastoreImpl(DatastoreAccess datastoreAccess, String nodeId, String domain); @Override void initDBPropagatingListener(BindingDispatcher dispatcher, org.opendaylight.sxp.core.SxpDomain domain); DatastoreAccess getDatastoreAccess(); @Override synchronized List<MasterDatabaseBinding> addBindings(List<T> bindings); @Override synchronized List<MasterDatabaseBinding> getBindings(); @Override synchronized List<MasterDatabaseBinding> getBindings(OriginType origin); @Override synchronized List<MasterDatabaseBinding> deleteBindings(List<T> bindings); @Override void close(); }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null || bindings.isEmpty()) { return added; } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); Map<IpPrefix, MasterDatabaseBinding> databaseMap; if (database != null && database.getMasterDatabaseBinding() != null && !database.getMasterDatabaseBinding().isEmpty()) { databaseMap = database.getMasterDatabaseBinding() .stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); } else { databaseMap = new HashMap<>(); } added.addAll(MasterDatabase.filterIncomingBindings(bindings, databaseMap::get, p -> datastoreAccess.checkAndDelete(getIdentifierBuilder(p).build(), LogicalDatastoreType.OPERATIONAL)).values()); if (!added.isEmpty()) { datastoreAccess.merge(getIdentifierBuilder().build(), new MasterDatabaseBuilder().setMasterDatabaseBinding(added).build(), LogicalDatastoreType.OPERATIONAL); } dbListener.onBindingsAdded(added); return added; } MasterDatastoreImpl(DatastoreAccess datastoreAccess, String nodeId, String domain); @Override void initDBPropagatingListener(BindingDispatcher dispatcher, org.opendaylight.sxp.core.SxpDomain domain); DatastoreAccess getDatastoreAccess(); @Override synchronized List<MasterDatabaseBinding> addBindings(List<T> bindings); @Override synchronized List<MasterDatabaseBinding> getBindings(); @Override synchronized List<MasterDatabaseBinding> getBindings(OriginType origin); @Override synchronized List<MasterDatabaseBinding> deleteBindings(List<T> bindings); @Override void close();  }