@Test public void testAddDomainFilter() throws Exception { initMasterDatabaseOperations(SxpRpcServiceImplTest.generalAnswer); RpcResult<AddDomainFilterOutput> result = service.addDomainFilter( new AddDomainFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.1")).build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.addDomainFilter(new AddDomainFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setDomainName(null) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.addDomainFilter(new AddDomainFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setDomainName(SxpNode.DEFAULT_DOMAIN) .setSxpDomainFilter(null) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.addDomainFilter(new AddDomainFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setDomainName(SxpNode.DEFAULT_DOMAIN) .setSxpDomainFilter(new SxpDomainFilterBuilder().setFilterName(null) .setFilterEntries(new AclFilterEntriesBuilder().build()) .build()) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertFalse(result.getResult().isResult()); result = service.addDomainFilter(new AddDomainFilterInputBuilder().setRequestedNode(new NodeId("0.0.0.0")) .setDomainName(SxpNode.DEFAULT_DOMAIN) .setSxpDomainFilter(new SxpDomainFilterBuilder().setFilterName("basic-filter") .setFilterEntries(new AclFilterEntriesBuilder().build()) .build()) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertTrue(result.getResult().isResult()); }
@Override public ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final AddDomainFilterOutputBuilder output = new AddDomainFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcAddDomainFilter event | {}", input.toString()); if (input.getDomainName() != null && input.getSxpDomainFilter() != null && input.getSxpDomainFilter().getFilterName() != null) { if (NodesRegister.getRegisteredNode(nodeId).getDomain(input.getDomainName()) == null) { LOG.warn("RpcAddDomainFilter event | domain {} does not exist", input.getDomainName()); return RpcResultBuilder.success(output.build()).build(); } final DomainFilterBuilder filter = new DomainFilterBuilder(input.getSxpDomainFilter()); filter.setFilterSpecific(getFilterSpecific(filter.getFilterEntries())); output.setResult(datastoreAccess.checkAndPut(getIdentifier(nodeId).child(SxpDomains.class) .child(SxpDomain.class, new SxpDomainKey(input.getDomainName())) .child(DomainFilters.class) .child(DomainFilter.class, new DomainFilterKey(filter.getFilterName(), filter.getFilterSpecific())), filter.build(), getDatastoreType(input.getConfigPersistence()), false)); } return RpcResultBuilder.success(output.build()).build(); }); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final AddDomainFilterOutputBuilder output = new AddDomainFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcAddDomainFilter event | {}", input.toString()); if (input.getDomainName() != null && input.getSxpDomainFilter() != null && input.getSxpDomainFilter().getFilterName() != null) { if (NodesRegister.getRegisteredNode(nodeId).getDomain(input.getDomainName()) == null) { LOG.warn("RpcAddDomainFilter event | domain {} does not exist", input.getDomainName()); return RpcResultBuilder.success(output.build()).build(); } final DomainFilterBuilder filter = new DomainFilterBuilder(input.getSxpDomainFilter()); filter.setFilterSpecific(getFilterSpecific(filter.getFilterEntries())); output.setResult(datastoreAccess.checkAndPut(getIdentifier(nodeId).child(SxpDomains.class) .child(SxpDomain.class, new SxpDomainKey(input.getDomainName())) .child(DomainFilters.class) .child(DomainFilter.class, new DomainFilterKey(filter.getFilterName(), filter.getFilterSpecific())), filter.build(), getDatastoreType(input.getConfigPersistence()), false)); } return RpcResultBuilder.success(output.build()).build(); }); } }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final AddDomainFilterOutputBuilder output = new AddDomainFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcAddDomainFilter event | {}", input.toString()); if (input.getDomainName() != null && input.getSxpDomainFilter() != null && input.getSxpDomainFilter().getFilterName() != null) { if (NodesRegister.getRegisteredNode(nodeId).getDomain(input.getDomainName()) == null) { LOG.warn("RpcAddDomainFilter event | domain {} does not exist", input.getDomainName()); return RpcResultBuilder.success(output.build()).build(); } final DomainFilterBuilder filter = new DomainFilterBuilder(input.getSxpDomainFilter()); filter.setFilterSpecific(getFilterSpecific(filter.getFilterEntries())); output.setResult(datastoreAccess.checkAndPut(getIdentifier(nodeId).child(SxpDomains.class) .child(SxpDomain.class, new SxpDomainKey(input.getDomainName())) .child(DomainFilters.class) .child(DomainFilter.class, new DomainFilterKey(filter.getFilterName(), filter.getFilterSpecific())), filter.build(), getDatastoreType(input.getConfigPersistence()), false)); } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final AddDomainFilterOutputBuilder output = new AddDomainFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcAddDomainFilter event | {}", input.toString()); if (input.getDomainName() != null && input.getSxpDomainFilter() != null && input.getSxpDomainFilter().getFilterName() != null) { if (NodesRegister.getRegisteredNode(nodeId).getDomain(input.getDomainName()) == null) { LOG.warn("RpcAddDomainFilter event | domain {} does not exist", input.getDomainName()); return RpcResultBuilder.success(output.build()).build(); } final DomainFilterBuilder filter = new DomainFilterBuilder(input.getSxpDomainFilter()); filter.setFilterSpecific(getFilterSpecific(filter.getFilterEntries())); output.setResult(datastoreAccess.checkAndPut(getIdentifier(nodeId).child(SxpDomains.class) .child(SxpDomain.class, new SxpDomainKey(input.getDomainName())) .child(DomainFilters.class) .child(DomainFilter.class, new DomainFilterKey(filter.getFilterName(), filter.getFilterSpecific())), filter.build(), getDatastoreType(input.getConfigPersistence()), false)); } 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<AddDomainFilterOutput>> addDomainFilter(final AddDomainFilterInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final DatastoreAccess datastoreAccess = getDatastoreAccess(nodeId); final AddDomainFilterOutputBuilder output = new AddDomainFilterOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcAddDomainFilter event | {}", input.toString()); if (input.getDomainName() != null && input.getSxpDomainFilter() != null && input.getSxpDomainFilter().getFilterName() != null) { if (NodesRegister.getRegisteredNode(nodeId).getDomain(input.getDomainName()) == null) { LOG.warn("RpcAddDomainFilter event | domain {} does not exist", input.getDomainName()); return RpcResultBuilder.success(output.build()).build(); } final DomainFilterBuilder filter = new DomainFilterBuilder(input.getSxpDomainFilter()); filter.setFilterSpecific(getFilterSpecific(filter.getFilterEntries())); output.setResult(datastoreAccess.checkAndPut(getIdentifier(nodeId).child(SxpDomains.class) .child(SxpDomain.class, new SxpDomainKey(input.getDomainName())) .child(DomainFilters.class) .child(DomainFilter.class, new DomainFilterKey(filter.getFilterName(), filter.getFilterSpecific())), filter.build(), getDatastoreType(input.getConfigPersistence()), false)); } 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);  }