@Test public void testGetEmptyLocalNodeBindings() throws Exception { initMasterDatabaseOperations(SxpRpcServiceImplTest.generalAnswer); final RpcResult<GetNodeBindingsOutput> result = service.getNodeBindings(new GetNodeBindingsInputBuilder().setRequestedNode(new NodeId("0.0.0.1")) .setDomainName(SxpNode.DEFAULT_DOMAIN) .setBindingsRange(GetNodeBindingsInput.BindingsRange.Local) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertNotNull(result.getResult().getBinding()); assertTrue(result.getResult().getBinding().isEmpty()); }
@Override public ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final GetNodeBindingsOutputBuilder output = new GetNodeBindingsOutputBuilder().setBinding(new ArrayList<>()); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcGetNodeBindings event | {}", input.toString()); final MasterDatabaseInf masterDatabase = getMasterDatabase(nodeId, input.getDomainName()); if (masterDatabase != null) { final Collection<MasterDatabaseBinding> bindings; if (GetNodeBindingsInput.BindingsRange.Local.equals(input.getBindingsRange())) { bindings = masterDatabase.getBindings(BindingOriginsConfig.LOCAL_ORIGIN); } else { bindings = masterDatabase.getBindings(); } final Map<Sgt, List<IpPrefix>> sgtListMap = bindings.stream() .collect(Collectors.groupingBy(MasterDatabaseBinding::getSecurityGroupTag, Collectors.mapping(MasterDatabaseBinding::getIpPrefix, Collectors.toList()))); final List<Binding> result = sgtListMap.entrySet().stream() .map(sgtIpPrefixEntry -> new BindingBuilder() .setSgt(sgtIpPrefixEntry.getKey()) .setIpPrefix(sgtIpPrefixEntry.getValue()) .build()) .collect(Collectors.toList()); output.setBinding(result); } return RpcResultBuilder.success(output.build()).build(); }); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final GetNodeBindingsOutputBuilder output = new GetNodeBindingsOutputBuilder().setBinding(new ArrayList<>()); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcGetNodeBindings event | {}", input.toString()); final MasterDatabaseInf masterDatabase = getMasterDatabase(nodeId, input.getDomainName()); if (masterDatabase != null) { final Collection<MasterDatabaseBinding> bindings; if (GetNodeBindingsInput.BindingsRange.Local.equals(input.getBindingsRange())) { bindings = masterDatabase.getBindings(BindingOriginsConfig.LOCAL_ORIGIN); } else { bindings = masterDatabase.getBindings(); } final Map<Sgt, List<IpPrefix>> sgtListMap = bindings.stream() .collect(Collectors.groupingBy(MasterDatabaseBinding::getSecurityGroupTag, Collectors.mapping(MasterDatabaseBinding::getIpPrefix, Collectors.toList()))); final List<Binding> result = sgtListMap.entrySet().stream() .map(sgtIpPrefixEntry -> new BindingBuilder() .setSgt(sgtIpPrefixEntry.getKey()) .setIpPrefix(sgtIpPrefixEntry.getValue()) .build()) .collect(Collectors.toList()); output.setBinding(result); } return RpcResultBuilder.success(output.build()).build(); }); } }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final GetNodeBindingsOutputBuilder output = new GetNodeBindingsOutputBuilder().setBinding(new ArrayList<>()); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcGetNodeBindings event | {}", input.toString()); final MasterDatabaseInf masterDatabase = getMasterDatabase(nodeId, input.getDomainName()); if (masterDatabase != null) { final Collection<MasterDatabaseBinding> bindings; if (GetNodeBindingsInput.BindingsRange.Local.equals(input.getBindingsRange())) { bindings = masterDatabase.getBindings(BindingOriginsConfig.LOCAL_ORIGIN); } else { bindings = masterDatabase.getBindings(); } final Map<Sgt, List<IpPrefix>> sgtListMap = bindings.stream() .collect(Collectors.groupingBy(MasterDatabaseBinding::getSecurityGroupTag, Collectors.mapping(MasterDatabaseBinding::getIpPrefix, Collectors.toList()))); final List<Binding> result = sgtListMap.entrySet().stream() .map(sgtIpPrefixEntry -> new BindingBuilder() .setSgt(sgtIpPrefixEntry.getKey()) .setIpPrefix(sgtIpPrefixEntry.getValue()) .build()) .collect(Collectors.toList()); output.setBinding(result); } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final GetNodeBindingsOutputBuilder output = new GetNodeBindingsOutputBuilder().setBinding(new ArrayList<>()); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcGetNodeBindings event | {}", input.toString()); final MasterDatabaseInf masterDatabase = getMasterDatabase(nodeId, input.getDomainName()); if (masterDatabase != null) { final Collection<MasterDatabaseBinding> bindings; if (GetNodeBindingsInput.BindingsRange.Local.equals(input.getBindingsRange())) { bindings = masterDatabase.getBindings(BindingOriginsConfig.LOCAL_ORIGIN); } else { bindings = masterDatabase.getBindings(); } final Map<Sgt, List<IpPrefix>> sgtListMap = bindings.stream() .collect(Collectors.groupingBy(MasterDatabaseBinding::getSecurityGroupTag, Collectors.mapping(MasterDatabaseBinding::getIpPrefix, Collectors.toList()))); final List<Binding> result = sgtListMap.entrySet().stream() .map(sgtIpPrefixEntry -> new BindingBuilder() .setSgt(sgtIpPrefixEntry.getKey()) .setIpPrefix(sgtIpPrefixEntry.getValue()) .build()) .collect(Collectors.toList()); output.setBinding(result); } 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<GetNodeBindingsOutput>> getNodeBindings(final GetNodeBindingsInput input) { final String nodeId = getNodeId(input.getRequestedNode()); final GetNodeBindingsOutputBuilder output = new GetNodeBindingsOutputBuilder().setBinding(new ArrayList<>()); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcGetNodeBindings event | {}", input.toString()); final MasterDatabaseInf masterDatabase = getMasterDatabase(nodeId, input.getDomainName()); if (masterDatabase != null) { final Collection<MasterDatabaseBinding> bindings; if (GetNodeBindingsInput.BindingsRange.Local.equals(input.getBindingsRange())) { bindings = masterDatabase.getBindings(BindingOriginsConfig.LOCAL_ORIGIN); } else { bindings = masterDatabase.getBindings(); } final Map<Sgt, List<IpPrefix>> sgtListMap = bindings.stream() .collect(Collectors.groupingBy(MasterDatabaseBinding::getSecurityGroupTag, Collectors.mapping(MasterDatabaseBinding::getIpPrefix, Collectors.toList()))); final List<Binding> result = sgtListMap.entrySet().stream() .map(sgtIpPrefixEntry -> new BindingBuilder() .setSgt(sgtIpPrefixEntry.getKey()) .setIpPrefix(sgtIpPrefixEntry.getValue()) .build()) .collect(Collectors.toList()); output.setBinding(result); } 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);  }