@Test public void testAddDomain() throws Exception { initMasterDatabaseOperations(SxpRpcServiceImplTest.generalAnswer); final RpcResult<AddDomainOutput> result = service .addDomain(new AddDomainInputBuilder() .setNodeId(new NodeId("0.0.0.0")) .setDomainName(SxpNode.DEFAULT_DOMAIN) .build()).get(); assertNotNull(result); assertTrue(result.isSuccessful()); assertNotNull(result.getResult()); assertTrue(result.getResult().isResult()); }
@Override public ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input) { final String nodeId = getNodeId(input.getNodeId()); final AddDomainOutputBuilder output = new AddDomainOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDomain event | {}", input.toString()); final String domainName = input.getDomainName(); if (domainName != null) { final SxpDomainBuilder domainBuilder = new SxpDomainBuilder(); domainBuilder.setDomainName(domainName); domainBuilder.setConnections(ConfigLoader.parseConnections(input.getConnections())); domainBuilder.setDomainFilters(new DomainFiltersBuilder().setDomainFilter(new ArrayList<>()).build()); domainBuilder.setConnectionTemplates( new ConnectionTemplatesBuilder().setConnectionTemplate(new ArrayList<>()).build()); try { mergeSxpDomainToDs(nodeId, domainName, domainBuilder.build(), LogicalDatastoreType.CONFIGURATION) .get(1000, TimeUnit.MILLISECONDS); } catch (final Exception e) { LOG.error("Failed to merge SXP domain " + domainName + " to data store | {}", e); return RpcResultBuilder.success(output.build()).build(); } if (containsBindings(input.getMasterDatabase())) { final OriginType origin = input.getOrigin(); if (origin == null) { LOG.warn("RpcDomain event exception | Parameter 'origin' not defined"); return RpcResultBuilder.success(output.build()).build(); } final SxpNode registeredNode = NodesRegister.getRegisteredNode(nodeId); for (int i = 0; (registeredNode == null || registeredNode.getDomain(domainName) == null) && i < 10; i++) { try { Thread.sleep(100); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for SXP domain " + domainName + " to appear in configuration | {}", e); return RpcResultBuilder.success(output.build()).build(); } } if (registeredNode == null || registeredNode.getDomain(domainName) == null) { return RpcResultBuilder.success(output.build()).build(); } final boolean mergeBindingsToDs = mergeDatabaseBindingsToDs(nodeId, domainName, input.getMasterDatabase(), origin); output.setResult(mergeBindingsToDs); } else { output.setResult(true); } } return RpcResultBuilder.success(output.build()).build(); }); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input) { final String nodeId = getNodeId(input.getNodeId()); final AddDomainOutputBuilder output = new AddDomainOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDomain event | {}", input.toString()); final String domainName = input.getDomainName(); if (domainName != null) { final SxpDomainBuilder domainBuilder = new SxpDomainBuilder(); domainBuilder.setDomainName(domainName); domainBuilder.setConnections(ConfigLoader.parseConnections(input.getConnections())); domainBuilder.setDomainFilters(new DomainFiltersBuilder().setDomainFilter(new ArrayList<>()).build()); domainBuilder.setConnectionTemplates( new ConnectionTemplatesBuilder().setConnectionTemplate(new ArrayList<>()).build()); try { mergeSxpDomainToDs(nodeId, domainName, domainBuilder.build(), LogicalDatastoreType.CONFIGURATION) .get(1000, TimeUnit.MILLISECONDS); } catch (final Exception e) { LOG.error("Failed to merge SXP domain " + domainName + " to data store | {}", e); return RpcResultBuilder.success(output.build()).build(); } if (containsBindings(input.getMasterDatabase())) { final OriginType origin = input.getOrigin(); if (origin == null) { LOG.warn("RpcDomain event exception | Parameter 'origin' not defined"); return RpcResultBuilder.success(output.build()).build(); } final SxpNode registeredNode = NodesRegister.getRegisteredNode(nodeId); for (int i = 0; (registeredNode == null || registeredNode.getDomain(domainName) == null) && i < 10; i++) { try { Thread.sleep(100); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for SXP domain " + domainName + " to appear in configuration | {}", e); return RpcResultBuilder.success(output.build()).build(); } } if (registeredNode == null || registeredNode.getDomain(domainName) == null) { return RpcResultBuilder.success(output.build()).build(); } final boolean mergeBindingsToDs = mergeDatabaseBindingsToDs(nodeId, domainName, input.getMasterDatabase(), origin); output.setResult(mergeBindingsToDs); } else { output.setResult(true); } } return RpcResultBuilder.success(output.build()).build(); }); } }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input) { final String nodeId = getNodeId(input.getNodeId()); final AddDomainOutputBuilder output = new AddDomainOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDomain event | {}", input.toString()); final String domainName = input.getDomainName(); if (domainName != null) { final SxpDomainBuilder domainBuilder = new SxpDomainBuilder(); domainBuilder.setDomainName(domainName); domainBuilder.setConnections(ConfigLoader.parseConnections(input.getConnections())); domainBuilder.setDomainFilters(new DomainFiltersBuilder().setDomainFilter(new ArrayList<>()).build()); domainBuilder.setConnectionTemplates( new ConnectionTemplatesBuilder().setConnectionTemplate(new ArrayList<>()).build()); try { mergeSxpDomainToDs(nodeId, domainName, domainBuilder.build(), LogicalDatastoreType.CONFIGURATION) .get(1000, TimeUnit.MILLISECONDS); } catch (final Exception e) { LOG.error("Failed to merge SXP domain " + domainName + " to data store | {}", e); return RpcResultBuilder.success(output.build()).build(); } if (containsBindings(input.getMasterDatabase())) { final OriginType origin = input.getOrigin(); if (origin == null) { LOG.warn("RpcDomain event exception | Parameter 'origin' not defined"); return RpcResultBuilder.success(output.build()).build(); } final SxpNode registeredNode = NodesRegister.getRegisteredNode(nodeId); for (int i = 0; (registeredNode == null || registeredNode.getDomain(domainName) == null) && i < 10; i++) { try { Thread.sleep(100); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for SXP domain " + domainName + " to appear in configuration | {}", e); return RpcResultBuilder.success(output.build()).build(); } } if (registeredNode == null || registeredNode.getDomain(domainName) == null) { return RpcResultBuilder.success(output.build()).build(); } final boolean mergeBindingsToDs = mergeDatabaseBindingsToDs(nodeId, domainName, input.getMasterDatabase(), origin); output.setResult(mergeBindingsToDs); } else { output.setResult(true); } } return RpcResultBuilder.success(output.build()).build(); }); } SxpRpcServiceImpl(final DataBroker broker); }
SxpRpcServiceImpl implements SxpControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddDomainOutput>> addDomain(final AddDomainInput input) { final String nodeId = getNodeId(input.getNodeId()); final AddDomainOutputBuilder output = new AddDomainOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDomain event | {}", input.toString()); final String domainName = input.getDomainName(); if (domainName != null) { final SxpDomainBuilder domainBuilder = new SxpDomainBuilder(); domainBuilder.setDomainName(domainName); domainBuilder.setConnections(ConfigLoader.parseConnections(input.getConnections())); domainBuilder.setDomainFilters(new DomainFiltersBuilder().setDomainFilter(new ArrayList<>()).build()); domainBuilder.setConnectionTemplates( new ConnectionTemplatesBuilder().setConnectionTemplate(new ArrayList<>()).build()); try { mergeSxpDomainToDs(nodeId, domainName, domainBuilder.build(), LogicalDatastoreType.CONFIGURATION) .get(1000, TimeUnit.MILLISECONDS); } catch (final Exception e) { LOG.error("Failed to merge SXP domain " + domainName + " to data store | {}", e); return RpcResultBuilder.success(output.build()).build(); } if (containsBindings(input.getMasterDatabase())) { final OriginType origin = input.getOrigin(); if (origin == null) { LOG.warn("RpcDomain event exception | Parameter 'origin' not defined"); return RpcResultBuilder.success(output.build()).build(); } final SxpNode registeredNode = NodesRegister.getRegisteredNode(nodeId); for (int i = 0; (registeredNode == null || registeredNode.getDomain(domainName) == null) && i < 10; i++) { try { Thread.sleep(100); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for SXP domain " + domainName + " to appear in configuration | {}", e); return RpcResultBuilder.success(output.build()).build(); } } if (registeredNode == null || registeredNode.getDomain(domainName) == null) { return RpcResultBuilder.success(output.build()).build(); } final boolean mergeBindingsToDs = mergeDatabaseBindingsToDs(nodeId, domainName, input.getMasterDatabase(), origin); output.setResult(mergeBindingsToDs); } else { output.setResult(true); } } 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<AddDomainOutput>> addDomain(final AddDomainInput input) { final String nodeId = getNodeId(input.getNodeId()); final AddDomainOutputBuilder output = new AddDomainOutputBuilder().setResult(false); return getResponse(nodeId, output.build(), () -> { LOG.info("RpcDomain event | {}", input.toString()); final String domainName = input.getDomainName(); if (domainName != null) { final SxpDomainBuilder domainBuilder = new SxpDomainBuilder(); domainBuilder.setDomainName(domainName); domainBuilder.setConnections(ConfigLoader.parseConnections(input.getConnections())); domainBuilder.setDomainFilters(new DomainFiltersBuilder().setDomainFilter(new ArrayList<>()).build()); domainBuilder.setConnectionTemplates( new ConnectionTemplatesBuilder().setConnectionTemplate(new ArrayList<>()).build()); try { mergeSxpDomainToDs(nodeId, domainName, domainBuilder.build(), LogicalDatastoreType.CONFIGURATION) .get(1000, TimeUnit.MILLISECONDS); } catch (final Exception e) { LOG.error("Failed to merge SXP domain " + domainName + " to data store | {}", e); return RpcResultBuilder.success(output.build()).build(); } if (containsBindings(input.getMasterDatabase())) { final OriginType origin = input.getOrigin(); if (origin == null) { LOG.warn("RpcDomain event exception | Parameter 'origin' not defined"); return RpcResultBuilder.success(output.build()).build(); } final SxpNode registeredNode = NodesRegister.getRegisteredNode(nodeId); for (int i = 0; (registeredNode == null || registeredNode.getDomain(domainName) == null) && i < 10; i++) { try { Thread.sleep(100); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for SXP domain " + domainName + " to appear in configuration | {}", e); return RpcResultBuilder.success(output.build()).build(); } } if (registeredNode == null || registeredNode.getDomain(domainName) == null) { return RpcResultBuilder.success(output.build()).build(); } final boolean mergeBindingsToDs = mergeDatabaseBindingsToDs(nodeId, domainName, input.getMasterDatabase(), origin); output.setResult(mergeBindingsToDs); } else { output.setResult(true); } } 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);  }