@Test public void testDeleteBindings() throws Exception { 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("15.15.15.15/24", 15, "0.10.10.10"), getBinding("2.2.2.20/32", 2000, "200.200.200.200"))); assertEquals(0, database.deleteBindings(mergeBindings()).size()); assertEquals(4, database.getBindings().size()); assertBindings(database.deleteBindings(mergeBindings(getBinding("1.1.1.1/32", 100, "10.10.10.10"), getBinding("2.2.2.2/32", 2000, "20.20.20.20"))), mergeBindings(getBinding("1.1.1.1/32", 100, "10.10.10.10"), getBinding("2.2.2.2/32", 2000, "20.20.20.20"))); assertBindings(database.getBindings(), mergeBindings(getBinding("15.15.15.15/24", 15, "0.10.10.10"), getBinding("2.2.2.20/32", 2000, "200.200.200.200"))); assertBindings(database.deleteBindings(mergeBindings(getBinding("15.15.15.15/24", 15, "0.10.10.10"), getBinding("2.2.2.20/32", 2000, "200.200.200.200"))), mergeBindings(getBinding("15.15.15.15/24", 15, "0.10.10.10"), getBinding("2.2.2.20/32", 2000, "200.200.200.200"))); assertEquals(0, database.getBindings().size()); }
@Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> deleteBindings(List<T> bindings) { if (bindings == null || bindings.isEmpty()) { return Collections.emptyList(); } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); if (database == null) { return Collections.emptyList(); } List<MasterDatabaseBinding> databaseBindings = database.getMasterDatabaseBinding(); if (databaseBindings == null || databaseBindings.isEmpty()) { return Collections.emptyList(); } List<MasterDatabaseBinding> removedBindings = new ArrayList<>(databaseBindings); Map<IpPrefix, T> mapBindingsToDelete = bindings.stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); if (databaseBindings.removeIf(bindingIsToBeDeleted(mapBindingsToDelete))) { datastoreAccess.put(getIdentifierBuilder().build(), database, LogicalDatastoreType.OPERATIONAL); removedBindings.removeAll(databaseBindings); dbListener.onBindingsRemoved(removedBindings); return removedBindings; } return Collections.emptyList(); }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> deleteBindings(List<T> bindings) { if (bindings == null || bindings.isEmpty()) { return Collections.emptyList(); } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); if (database == null) { return Collections.emptyList(); } List<MasterDatabaseBinding> databaseBindings = database.getMasterDatabaseBinding(); if (databaseBindings == null || databaseBindings.isEmpty()) { return Collections.emptyList(); } List<MasterDatabaseBinding> removedBindings = new ArrayList<>(databaseBindings); Map<IpPrefix, T> mapBindingsToDelete = bindings.stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); if (databaseBindings.removeIf(bindingIsToBeDeleted(mapBindingsToDelete))) { datastoreAccess.put(getIdentifierBuilder().build(), database, LogicalDatastoreType.OPERATIONAL); removedBindings.removeAll(databaseBindings); dbListener.onBindingsRemoved(removedBindings); return removedBindings; } return Collections.emptyList(); } }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> deleteBindings(List<T> bindings) { if (bindings == null || bindings.isEmpty()) { return Collections.emptyList(); } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); if (database == null) { return Collections.emptyList(); } List<MasterDatabaseBinding> databaseBindings = database.getMasterDatabaseBinding(); if (databaseBindings == null || databaseBindings.isEmpty()) { return Collections.emptyList(); } List<MasterDatabaseBinding> removedBindings = new ArrayList<>(databaseBindings); Map<IpPrefix, T> mapBindingsToDelete = bindings.stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); if (databaseBindings.removeIf(bindingIsToBeDeleted(mapBindingsToDelete))) { datastoreAccess.put(getIdentifierBuilder().build(), database, LogicalDatastoreType.OPERATIONAL); removedBindings.removeAll(databaseBindings); dbListener.onBindingsRemoved(removedBindings); return removedBindings; } return Collections.emptyList(); } MasterDatastoreImpl(DatastoreAccess datastoreAccess, String nodeId, String domain); }
MasterDatastoreImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> deleteBindings(List<T> bindings) { if (bindings == null || bindings.isEmpty()) { return Collections.emptyList(); } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); if (database == null) { return Collections.emptyList(); } List<MasterDatabaseBinding> databaseBindings = database.getMasterDatabaseBinding(); if (databaseBindings == null || databaseBindings.isEmpty()) { return Collections.emptyList(); } List<MasterDatabaseBinding> removedBindings = new ArrayList<>(databaseBindings); Map<IpPrefix, T> mapBindingsToDelete = bindings.stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); if (databaseBindings.removeIf(bindingIsToBeDeleted(mapBindingsToDelete))) { datastoreAccess.put(getIdentifierBuilder().build(), database, LogicalDatastoreType.OPERATIONAL); removedBindings.removeAll(databaseBindings); dbListener.onBindingsRemoved(removedBindings); return removedBindings; } return Collections.emptyList(); } 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> deleteBindings(List<T> bindings) { if (bindings == null || bindings.isEmpty()) { return Collections.emptyList(); } org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.sxp.databases.fields.MasterDatabase database = datastoreAccess.readSynchronous(getIdentifierBuilder().build(), LogicalDatastoreType.OPERATIONAL); if (database == null) { return Collections.emptyList(); } List<MasterDatabaseBinding> databaseBindings = database.getMasterDatabaseBinding(); if (databaseBindings == null || databaseBindings.isEmpty()) { return Collections.emptyList(); } List<MasterDatabaseBinding> removedBindings = new ArrayList<>(databaseBindings); Map<IpPrefix, T> mapBindingsToDelete = bindings.stream() .collect(Collectors.toMap(SxpBindingFields::getIpPrefix, Function.identity())); if (databaseBindings.removeIf(bindingIsToBeDeleted(mapBindingsToDelete))) { datastoreAccess.put(getIdentifierBuilder().build(), database, LogicalDatastoreType.OPERATIONAL); removedBindings.removeAll(databaseBindings); dbListener.onBindingsRemoved(removedBindings); return removedBindings; } return Collections.emptyList(); } 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();  }