@Test public void testDeleteFilter() throws Exception { initMasterDatabaseOperations(SxpRpcServiceImplTest.generalAnswer); RpcResult<DeleteFilterOutput> result = service.deleteFilter(new DeleteFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.1")).build()) .get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.deleteFilter(new DeleteFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setPeerGroupName(SxpNode.DEFAULT_DOMAIN) .setFilterType(FilterType.Inbound) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.deleteFilter(new DeleteFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setPeerGroupName(SxpNode.DEFAULT_DOMAIN) .setFilterType(FilterType.Inbound) .setFilterSpecific(FilterSpecific.AccessOrPrefixList) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertTrue(result.getResult().isResult()); }
@Override public ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final DeleteFilterOutputBuilder output = new DeleteFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDeleteFilter event | {}", input.toString()); if (input.getFilterSpecific() == null) { final LogicalDatastoreType datastoreType; SxpPeerGroup group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), LogicalDatastoreType.CONFIGURATION); if (group == null || group.getSxpFilter() == null || group.getSxpFilter().isEmpty()) { datastoreType = LogicalDatastoreType.OPERATIONAL; group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), datastoreType); } else { datastoreType = LogicalDatastoreType.CONFIGURATION; } final List<SxpFilter> filters = group == null || group.getSxpFilter() == null ? new ArrayList<>() : group.getSxpFilter(); filters.forEach(f -> { if (f.getFilterType().equals(input.getFilterType())) output.setResult(datastoreAccess.checkAndDelete(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(f.getFilterSpecific(), f.getFilterType())), datastoreType)); }); } else { final InstanceIdentifier identifier = getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(input.getFilterSpecific(), input.getFilterType())); output.setResult(datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.CONFIGURATION) || datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.OPERATIONAL)); } return RpcResultBuilder.success(output.build()).build(); }); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final DeleteFilterOutputBuilder output = new DeleteFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDeleteFilter event | {}", input.toString()); if (input.getFilterSpecific() == null) { final LogicalDatastoreType datastoreType; SxpPeerGroup group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), LogicalDatastoreType.CONFIGURATION); if (group == null || group.getSxpFilter() == null || group.getSxpFilter().isEmpty()) { datastoreType = LogicalDatastoreType.OPERATIONAL; group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), datastoreType); } else { datastoreType = LogicalDatastoreType.CONFIGURATION; } final List<SxpFilter> filters = group == null || group.getSxpFilter() == null ? new ArrayList<>() : group.getSxpFilter(); filters.forEach(f -> { if (f.getFilterType().equals(input.getFilterType())) output.setResult(datastoreAccess.checkAndDelete(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(f.getFilterSpecific(), f.getFilterType())), datastoreType)); }); } else { final InstanceIdentifier identifier = getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(input.getFilterSpecific(), input.getFilterType())); output.setResult(datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.CONFIGURATION) || datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.OPERATIONAL)); } return RpcResultBuilder.success(output.build()).build(); }); } }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final DeleteFilterOutputBuilder output = new DeleteFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDeleteFilter event | {}", input.toString()); if (input.getFilterSpecific() == null) { final LogicalDatastoreType datastoreType; SxpPeerGroup group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), LogicalDatastoreType.CONFIGURATION); if (group == null || group.getSxpFilter() == null || group.getSxpFilter().isEmpty()) { datastoreType = LogicalDatastoreType.OPERATIONAL; group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), datastoreType); } else { datastoreType = LogicalDatastoreType.CONFIGURATION; } final List<SxpFilter> filters = group == null || group.getSxpFilter() == null ? new ArrayList<>() : group.getSxpFilter(); filters.forEach(f -> { if (f.getFilterType().equals(input.getFilterType())) output.setResult(datastoreAccess.checkAndDelete(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(f.getFilterSpecific(), f.getFilterType())), datastoreType)); }); } else { final InstanceIdentifier identifier = getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(input.getFilterSpecific(), input.getFilterType())); output.setResult(datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.CONFIGURATION) || datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.OPERATIONAL)); } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final DeleteFilterOutputBuilder output = new DeleteFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDeleteFilter event | {}", input.toString()); if (input.getFilterSpecific() == null) { final LogicalDatastoreType datastoreType; SxpPeerGroup group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), LogicalDatastoreType.CONFIGURATION); if (group == null || group.getSxpFilter() == null || group.getSxpFilter().isEmpty()) { datastoreType = LogicalDatastoreType.OPERATIONAL; group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), datastoreType); } else { datastoreType = LogicalDatastoreType.CONFIGURATION; } final List<SxpFilter> filters = group == null || group.getSxpFilter() == null ? new ArrayList<>() : group.getSxpFilter(); filters.forEach(f -> { if (f.getFilterType().equals(input.getFilterType())) output.setResult(datastoreAccess.checkAndDelete(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(f.getFilterSpecific(), f.getFilterType())), datastoreType)); }); } else { final InstanceIdentifier identifier = getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(input.getFilterSpecific(), input.getFilterType())); output.setResult(datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.CONFIGURATION) || datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.OPERATIONAL)); } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); @Override ListenableFuture<RpcResult<AddConnectionOutput>> addConnection(final AddConnectionInput input); @Override ListenableFuture<RpcResult<DeleteDomainFilterOutput>> deleteDomainFilter(final DeleteDomainFilterInput input); @Override ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input); @Override ListenableFuture<RpcResult<AddFilterOutput>> addFilter(final AddFilterInput input); @Override ListenableFuture<RpcResult<AddPeerGroupOutput>> addPeerGroup(final AddPeerGroupInput input); @Override ListenableFuture<RpcResult<DeleteConnectionTemplateOutput>> deleteConnectionTemplate(
            final DeleteConnectionTemplateInput input); @Override ListenableFuture<RpcResult<DeleteNodeOutput>> deleteNode(final DeleteNodeInput input); @Override ListenableFuture<RpcResult<DeleteBindingsOutput>> deleteBindings(final DeleteBindingsInput input); @Override void close(); @Override ListenableFuture<RpcResult<DeleteConnectionOutput>> deleteConnection(final DeleteConnectionInput input); @Override ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input); @Override ListenableFuture<RpcResult<DeletePeerGroupOutput>> deletePeerGroup(final DeletePeerGroupInput input); @Override ListenableFuture<RpcResult<DeleteDomainOutput>> deleteDomain(final DeleteDomainInput input); @Override ListenableFuture<RpcResult<AddConnectionTemplateOutput>> addConnectionTemplate(
            final AddConnectionTemplateInput input); @Override ListenableFuture<RpcResult<GetConnectionsOutput>> getConnections(final GetConnectionsInput input); @Override ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input); @Override ListenableFuture<RpcResult<GetPeerGroupOutput>> getPeerGroup(final GetPeerGroupInput input); @Override ListenableFuture<RpcResult<GetPeerGroupsOutput>> getPeerGroups(final GetPeerGroupsInput input); @Override ListenableFuture<RpcResult<AddNodeOutput>> addNode(final AddNodeInput input); @Override ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input); @Override ListenableFuture<RpcResult<AddBindingsOutput>> addBindings(final AddBindingsInput input); @Override ListenableFuture<RpcResult<UpdateFilterOutput>> updateFilter(final UpdateFilterInput input); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final DeleteFilterOutputBuilder output = new DeleteFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDeleteFilter event | {}", input.toString()); if (input.getFilterSpecific() == null) { final LogicalDatastoreType datastoreType; SxpPeerGroup group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), LogicalDatastoreType.CONFIGURATION); if (group == null || group.getSxpFilter() == null || group.getSxpFilter().isEmpty()) { datastoreType = LogicalDatastoreType.OPERATIONAL; group = datastoreAccess.readSynchronous(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())), datastoreType); } else { datastoreType = LogicalDatastoreType.CONFIGURATION; } final List<SxpFilter> filters = group == null || group.getSxpFilter() == null ? new ArrayList<>() : group.getSxpFilter(); filters.forEach(f -> { if (f.getFilterType().equals(input.getFilterType())) output.setResult(datastoreAccess.checkAndDelete(getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(f.getFilterSpecific(), f.getFilterType())), datastoreType)); }); } else { final InstanceIdentifier identifier = getIdentifier(nodeId).child(SxpPeerGroups.class) .child(SxpPeerGroup.class, new SxpPeerGroupKey(input.getPeerGroupName())) .child(SxpFilter.class, new SxpFilterKey(input.getFilterSpecific(), input.getFilterType())); output.setResult(datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.CONFIGURATION) || datastoreAccess.checkAndDelete(identifier, LogicalDatastoreType.OPERATIONAL)); } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); @Override ListenableFuture<RpcResult<AddConnectionOutput>> addConnection(final AddConnectionInput input); @Override ListenableFuture<RpcResult<DeleteDomainFilterOutput>> deleteDomainFilter(final DeleteDomainFilterInput input); @Override ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input); @Override ListenableFuture<RpcResult<AddFilterOutput>> addFilter(final AddFilterInput input); @Override ListenableFuture<RpcResult<AddPeerGroupOutput>> addPeerGroup(final AddPeerGroupInput input); @Override ListenableFuture<RpcResult<DeleteConnectionTemplateOutput>> deleteConnectionTemplate(
            final DeleteConnectionTemplateInput input); @Override ListenableFuture<RpcResult<DeleteNodeOutput>> deleteNode(final DeleteNodeInput input); @Override ListenableFuture<RpcResult<DeleteBindingsOutput>> deleteBindings(final DeleteBindingsInput input); @Override void close(); @Override ListenableFuture<RpcResult<DeleteConnectionOutput>> deleteConnection(final DeleteConnectionInput input); @Override ListenableFuture<RpcResult<DeleteFilterOutput>> deleteFilter(final DeleteFilterInput input); @Override ListenableFuture<RpcResult<DeletePeerGroupOutput>> deletePeerGroup(final DeletePeerGroupInput input); @Override ListenableFuture<RpcResult<DeleteDomainOutput>> deleteDomain(final DeleteDomainInput input); @Override ListenableFuture<RpcResult<AddConnectionTemplateOutput>> addConnectionTemplate(
            final AddConnectionTemplateInput input); @Override ListenableFuture<RpcResult<GetConnectionsOutput>> getConnections(final GetConnectionsInput input); @Override ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input); @Override ListenableFuture<RpcResult<GetPeerGroupOutput>> getPeerGroup(final GetPeerGroupInput input); @Override ListenableFuture<RpcResult<GetPeerGroupsOutput>> getPeerGroups(final GetPeerGroupsInput input); @Override ListenableFuture<RpcResult<AddNodeOutput>> addNode(final AddNodeInput input); @Override ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input); @Override ListenableFuture<RpcResult<AddBindingsOutput>> addBindings(final AddBindingsInput input); @Override ListenableFuture<RpcResult<UpdateFilterOutput>> updateFilter(final UpdateFilterInput input);  }