@Test public void testToString() throws Exception { assertEquals("MasterDatabaseImpl\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" + "MasterDatabaseImpl\n", value.toString()); }
@Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; } }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  @Override void initDBPropagatingListener(BindingDispatcher dispatcher, SxpDomain domain); @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(); }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  @Override void initDBPropagatingListener(BindingDispatcher dispatcher, SxpDomain domain); @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();  }