Remove use of CheckedFuture in clustering-it-provider
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / PeopleProvider.java
index 868b9d09627e1ca01615292bef736344248846bd..58fcdc48500da026f141c912cdf9513883ec2c17 100644 (file)
@@ -5,20 +5,21 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.clustering.it.provider;
 
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 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.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.People;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PeopleService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PersonContext;
@@ -49,18 +50,16 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
     }
 
     @Override
-    public Future<RpcResult<Void>> addPerson(final AddPersonInput input) {
+    public ListenableFuture<RpcResult<AddPersonOutput>> addPerson(final AddPersonInput input) {
         LOG.info("RPC addPerson : adding person [{}]", input);
 
         PersonBuilder builder = new PersonBuilder(input);
         final Person person = builder.build();
-        final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
+        final SettableFuture<RpcResult<AddPersonOutput>> futureResult = SettableFuture.create();
 
         // Each entry will be identifiable by a unique key, we have to create that identifier
-        final InstanceIdentifier.InstanceIdentifierBuilder<Person> personIdBuilder =
-                InstanceIdentifier.<People>builder(People.class)
-                .child(Person.class, person.getKey());
-        final InstanceIdentifier<Person> personId = personIdBuilder.build();
+        final InstanceIdentifier<Person> personId = InstanceIdentifier.builder(People.class)
+                .child(Person.class, person.key()).build();
         // Place entry in data store tree
         WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);
@@ -71,13 +70,13 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
                 LOG.info("RPC addPerson : person added successfully [{}]", person);
                 rpcRegistration.registerPath(PersonContext.class, personId);
                 LOG.info("RPC addPerson : routed rpc registered for instance ID [{}]", personId);
-                futureResult.set(RpcResultBuilder.<Void>success().build());
+                futureResult.set(RpcResultBuilder.success(new AddPersonOutputBuilder().build()).build());
             }
 
             @Override
             public void onFailure(final Throwable ex) {
                 LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), ex);
-                futureResult.set(RpcResultBuilder.<Void>failed()
+                futureResult.set(RpcResultBuilder.<AddPersonOutput>failed()
                         .withError(RpcError.ErrorType.APPLICATION, ex.getMessage()).build());
             }
         }, MoreExecutors.directExecutor());