@Test public void testRegisterEndpoint_containmentEndpointWithChildFail() throws Exception { ContainmentEndpoint contEpWithChild = createBaseContEpBuilder().setChildEndpoint(Arrays.asList(BASE_L2_CHILD)).build(); RegisterEndpointInputBuilder inputBuilder = new RegisterEndpointInputBuilder(); setContEpsToBuilder(inputBuilder, contEpWithChild); RpcResult<Void> rpcResult = baseEndpointRpcRegistry.registerEndpoint(inputBuilder.build()).get(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertNull(rpcResult.getResult()); Assert.assertEquals(1, rpcResult.getErrors().size()); }
@Override public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) { long timestamp = System.currentTimeMillis(); ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); ListenableFuture<RpcResult<Void>> failResult = RegisterEndpointInputVerificator.verifyRegisterEndpointInput(input, t); if (failResult != null) { t.cancel(); return failResult; } List<ContainmentEndpointReg> endpoints = input.getContainmentEndpointReg(); for (ContainmentEndpointReg ce : nullToEmpty(endpoints)) { long stamp = (ce.getTimestamp() == null || ce.getTimestamp() == 0) ? timestamp : ce.getTimestamp(); ContainmentEndpoint endpoint = buildContainmentEndpoint(ce).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(endpoint.getKey()), endpoint, true); addContainmentEndpointToChilds(t, endpoint); } List<AddressEndpointReg> addressEndpoints = input.getAddressEndpointReg(); for (AddressEndpointReg ae : nullToEmpty(addressEndpoints)) { long stamp = (ae.getTimestamp() == null || ae.getTimestamp() == 0) ? timestamp : ae.getTimestamp(); AddressEndpoint endpoint = buildAddressEndpoint(ae).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(endpoint.getKey()), endpoint, true); addAddressEndpointToChilds(t, endpoint); addAddressEndpointToParents(t, endpoint); } return Futures.transform(t.submit(), TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) { long timestamp = System.currentTimeMillis(); ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); ListenableFuture<RpcResult<Void>> failResult = RegisterEndpointInputVerificator.verifyRegisterEndpointInput(input, t); if (failResult != null) { t.cancel(); return failResult; } List<ContainmentEndpointReg> endpoints = input.getContainmentEndpointReg(); for (ContainmentEndpointReg ce : nullToEmpty(endpoints)) { long stamp = (ce.getTimestamp() == null || ce.getTimestamp() == 0) ? timestamp : ce.getTimestamp(); ContainmentEndpoint endpoint = buildContainmentEndpoint(ce).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(endpoint.getKey()), endpoint, true); addContainmentEndpointToChilds(t, endpoint); } List<AddressEndpointReg> addressEndpoints = input.getAddressEndpointReg(); for (AddressEndpointReg ae : nullToEmpty(addressEndpoints)) { long stamp = (ae.getTimestamp() == null || ae.getTimestamp() == 0) ? timestamp : ae.getTimestamp(); AddressEndpoint endpoint = buildAddressEndpoint(ae).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(endpoint.getKey()), endpoint, true); addAddressEndpointToChilds(t, endpoint); addAddressEndpointToParents(t, endpoint); } return Futures.transform(t.submit(), TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) { long timestamp = System.currentTimeMillis(); ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); ListenableFuture<RpcResult<Void>> failResult = RegisterEndpointInputVerificator.verifyRegisterEndpointInput(input, t); if (failResult != null) { t.cancel(); return failResult; } List<ContainmentEndpointReg> endpoints = input.getContainmentEndpointReg(); for (ContainmentEndpointReg ce : nullToEmpty(endpoints)) { long stamp = (ce.getTimestamp() == null || ce.getTimestamp() == 0) ? timestamp : ce.getTimestamp(); ContainmentEndpoint endpoint = buildContainmentEndpoint(ce).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(endpoint.getKey()), endpoint, true); addContainmentEndpointToChilds(t, endpoint); } List<AddressEndpointReg> addressEndpoints = input.getAddressEndpointReg(); for (AddressEndpointReg ae : nullToEmpty(addressEndpoints)) { long stamp = (ae.getTimestamp() == null || ae.getTimestamp() == 0) ? timestamp : ae.getTimestamp(); AddressEndpoint endpoint = buildAddressEndpoint(ae).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(endpoint.getKey()), endpoint, true); addAddressEndpointToChilds(t, endpoint); addAddressEndpointToParents(t, endpoint); } return Futures.transform(t.submit(), TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) { long timestamp = System.currentTimeMillis(); ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); ListenableFuture<RpcResult<Void>> failResult = RegisterEndpointInputVerificator.verifyRegisterEndpointInput(input, t); if (failResult != null) { t.cancel(); return failResult; } List<ContainmentEndpointReg> endpoints = input.getContainmentEndpointReg(); for (ContainmentEndpointReg ce : nullToEmpty(endpoints)) { long stamp = (ce.getTimestamp() == null || ce.getTimestamp() == 0) ? timestamp : ce.getTimestamp(); ContainmentEndpoint endpoint = buildContainmentEndpoint(ce).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(endpoint.getKey()), endpoint, true); addContainmentEndpointToChilds(t, endpoint); } List<AddressEndpointReg> addressEndpoints = input.getAddressEndpointReg(); for (AddressEndpointReg ae : nullToEmpty(addressEndpoints)) { long stamp = (ae.getTimestamp() == null || ae.getTimestamp() == 0) ? timestamp : ae.getTimestamp(); AddressEndpoint endpoint = buildAddressEndpoint(ae).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(endpoint.getKey()), endpoint, true); addAddressEndpointToChilds(t, endpoint); addAddressEndpointToParents(t, endpoint); } return Futures.transform(t.submit(), TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override void close(); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) { long timestamp = System.currentTimeMillis(); ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); ListenableFuture<RpcResult<Void>> failResult = RegisterEndpointInputVerificator.verifyRegisterEndpointInput(input, t); if (failResult != null) { t.cancel(); return failResult; } List<ContainmentEndpointReg> endpoints = input.getContainmentEndpointReg(); for (ContainmentEndpointReg ce : nullToEmpty(endpoints)) { long stamp = (ce.getTimestamp() == null || ce.getTimestamp() == 0) ? timestamp : ce.getTimestamp(); ContainmentEndpoint endpoint = buildContainmentEndpoint(ce).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(endpoint.getKey()), endpoint, true); addContainmentEndpointToChilds(t, endpoint); } List<AddressEndpointReg> addressEndpoints = input.getAddressEndpointReg(); for (AddressEndpointReg ae : nullToEmpty(addressEndpoints)) { long stamp = (ae.getTimestamp() == null || ae.getTimestamp() == 0) ? timestamp : ae.getTimestamp(); AddressEndpoint endpoint = buildAddressEndpoint(ae).setTimestamp(stamp).build(); t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(endpoint.getKey()), endpoint, true); addAddressEndpointToChilds(t, endpoint); addAddressEndpointToParents(t, endpoint); } return Futures.transform(t.submit(), TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override void close();  }