@Test public void testAddConflictingTypeBinding() throws Exception { assertTrue(addBindingOrigin("LOCAL", (short) 0).getResult().isResult()); assertFalse(addBindingOrigin("LOCAL", (short) 1).getResult().isResult()); }
@Override public ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input) { final AddBindingOriginOutputBuilder output = new AddBindingOriginOutputBuilder().setResult(false); return executor.submit(() -> { LOG.info("RpcAddBindingOrigin event | {}", input.toString()); final OriginType origin = input.getOrigin(); if (origin == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'origin' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } final Short priority = input.getPriority(); if (priority == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'priority' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } synchronized (BindingOriginsConfig.INSTANCE) { final boolean addToInternal = BindingOriginsConfig.INSTANCE .addBindingOrigin(origin, priority.intValue()); if (addToInternal) { final BindingOrigin bindingOrigin = new BindingOriginBuilder() .setOrigin(origin) .setPriority(priority) .build(); final boolean addToDataStore = datastoreAccess .putIfNotExists(InstanceIdentifier.builder(BindingOrigins.class) .child(BindingOrigin.class, new BindingOriginKey(new OriginType(origin))).build(), bindingOrigin, LogicalDatastoreType.CONFIGURATION); output.setResult(addToDataStore); } } return RpcResultBuilder.success(output.build()).build(); }); }
SxpConfigRpcServiceImpl implements SxpConfigControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input) { final AddBindingOriginOutputBuilder output = new AddBindingOriginOutputBuilder().setResult(false); return executor.submit(() -> { LOG.info("RpcAddBindingOrigin event | {}", input.toString()); final OriginType origin = input.getOrigin(); if (origin == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'origin' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } final Short priority = input.getPriority(); if (priority == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'priority' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } synchronized (BindingOriginsConfig.INSTANCE) { final boolean addToInternal = BindingOriginsConfig.INSTANCE .addBindingOrigin(origin, priority.intValue()); if (addToInternal) { final BindingOrigin bindingOrigin = new BindingOriginBuilder() .setOrigin(origin) .setPriority(priority) .build(); final boolean addToDataStore = datastoreAccess .putIfNotExists(InstanceIdentifier.builder(BindingOrigins.class) .child(BindingOrigin.class, new BindingOriginKey(new OriginType(origin))).build(), bindingOrigin, LogicalDatastoreType.CONFIGURATION); output.setResult(addToDataStore); } } return RpcResultBuilder.success(output.build()).build(); }); } }
SxpConfigRpcServiceImpl implements SxpConfigControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input) { final AddBindingOriginOutputBuilder output = new AddBindingOriginOutputBuilder().setResult(false); return executor.submit(() -> { LOG.info("RpcAddBindingOrigin event | {}", input.toString()); final OriginType origin = input.getOrigin(); if (origin == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'origin' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } final Short priority = input.getPriority(); if (priority == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'priority' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } synchronized (BindingOriginsConfig.INSTANCE) { final boolean addToInternal = BindingOriginsConfig.INSTANCE .addBindingOrigin(origin, priority.intValue()); if (addToInternal) { final BindingOrigin bindingOrigin = new BindingOriginBuilder() .setOrigin(origin) .setPriority(priority) .build(); final boolean addToDataStore = datastoreAccess .putIfNotExists(InstanceIdentifier.builder(BindingOrigins.class) .child(BindingOrigin.class, new BindingOriginKey(new OriginType(origin))).build(), bindingOrigin, LogicalDatastoreType.CONFIGURATION); output.setResult(addToDataStore); } } return RpcResultBuilder.success(output.build()).build(); }); } SxpConfigRpcServiceImpl(final DataBroker broker); }
SxpConfigRpcServiceImpl implements SxpConfigControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input) { final AddBindingOriginOutputBuilder output = new AddBindingOriginOutputBuilder().setResult(false); return executor.submit(() -> { LOG.info("RpcAddBindingOrigin event | {}", input.toString()); final OriginType origin = input.getOrigin(); if (origin == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'origin' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } final Short priority = input.getPriority(); if (priority == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'priority' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } synchronized (BindingOriginsConfig.INSTANCE) { final boolean addToInternal = BindingOriginsConfig.INSTANCE .addBindingOrigin(origin, priority.intValue()); if (addToInternal) { final BindingOrigin bindingOrigin = new BindingOriginBuilder() .setOrigin(origin) .setPriority(priority) .build(); final boolean addToDataStore = datastoreAccess .putIfNotExists(InstanceIdentifier.builder(BindingOrigins.class) .child(BindingOrigin.class, new BindingOriginKey(new OriginType(origin))).build(), bindingOrigin, LogicalDatastoreType.CONFIGURATION); output.setResult(addToDataStore); } } return RpcResultBuilder.success(output.build()).build(); }); } SxpConfigRpcServiceImpl(final DataBroker broker); @Override void close(); @Override ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input); @Override ListenableFuture<RpcResult<UpdateBindingOriginOutput>> updateBindingOrigin(UpdateBindingOriginInput input); @Override ListenableFuture<RpcResult<DeleteBindingOriginOutput>> deleteBindingOrigin(DeleteBindingOriginInput input); }
SxpConfigRpcServiceImpl implements SxpConfigControllerService, AutoCloseable { @Override public ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input) { final AddBindingOriginOutputBuilder output = new AddBindingOriginOutputBuilder().setResult(false); return executor.submit(() -> { LOG.info("RpcAddBindingOrigin event | {}", input.toString()); final OriginType origin = input.getOrigin(); if (origin == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'origin' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } final Short priority = input.getPriority(); if (priority == null) { LOG.info("RpcAddBindingOrigin exception | Parameter 'priority' not defined", input.toString()); return RpcResultBuilder.success(output.build()).build(); } synchronized (BindingOriginsConfig.INSTANCE) { final boolean addToInternal = BindingOriginsConfig.INSTANCE .addBindingOrigin(origin, priority.intValue()); if (addToInternal) { final BindingOrigin bindingOrigin = new BindingOriginBuilder() .setOrigin(origin) .setPriority(priority) .build(); final boolean addToDataStore = datastoreAccess .putIfNotExists(InstanceIdentifier.builder(BindingOrigins.class) .child(BindingOrigin.class, new BindingOriginKey(new OriginType(origin))).build(), bindingOrigin, LogicalDatastoreType.CONFIGURATION); output.setResult(addToDataStore); } } return RpcResultBuilder.success(output.build()).build(); }); } SxpConfigRpcServiceImpl(final DataBroker broker); @Override void close(); @Override ListenableFuture<RpcResult<AddBindingOriginOutput>> addBindingOrigin(final AddBindingOriginInput input); @Override ListenableFuture<RpcResult<UpdateBindingOriginOutput>> updateBindingOrigin(UpdateBindingOriginInput input); @Override ListenableFuture<RpcResult<DeleteBindingOriginOutput>> deleteBindingOrigin(DeleteBindingOriginInput input);  }