import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
+import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PersonContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.Person;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.PersonBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.Future;
-
public class PeopleProvider implements PeopleService, AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(PeopleProvider.class);
}
- public void setRpcRegistration(BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration) {
+ public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration) {
this.rpcRegistration = rpcRegistration;
}
@Override
- public Future<RpcResult<Void>> addPerson(AddPersonInput input) {
+ public Future<RpcResult<Void>> addPerson(final AddPersonInput input) {
log.info("RPC addPerson : adding person [{}]", input);
PersonBuilder builder = new PersonBuilder(input);
final InstanceIdentifier.InstanceIdentifierBuilder<Person> personIdBuilder =
InstanceIdentifier.<People>builder(People.class)
.child(Person.class, person.getKey());
- final InstanceIdentifier personId = personIdBuilder.build();
+ final InstanceIdentifier<Person> personId = personIdBuilder.build();
// Place entry in data store tree
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, personId, person);
+ tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
@Override
public void onFailure(final Throwable t) {
- log.info("RPC addPerson : person addition failed [{}]", person);
+ log.error(String.format("RPC addPerson : person addition failed [%s]", person), t);
futureResult.set(RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, t.getMessage()).build());
}