Improve cluster test app logging 63/14663/1
authortpantelis <tpanteli@brocade.com>
Sat, 31 Jan 2015 05:18:30 +0000 (00:18 -0500)
committertpantelis <tpanteli@brocade.com>
Sat, 31 Jan 2015 05:18:30 +0000 (00:18 -0500)
Made a few improvements to the logging in PeopleCarListener and
PeopleProvider to help debugging test failures.

Change-Id: I25d27e4abbc4b0096b2dc812bfcbada208c588e4
Signed-off-by: tpantelis <tpanteli@brocade.com>
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java

index 4737d6eb49254ed6a2ded147d3429848d9a2bb4c..bbaf6becf4b10ceef502005578f1f4311d9ca2cb 100644 (file)
@@ -38,7 +38,6 @@ public class PeopleCarListener implements CarPurchaseListener {
 
   @Override
   public void onCarBought(CarBought notification) {
-    log.info("onCarBought notification : Adding car person entry");
 
     final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
     carPersonBuilder.setCarId(notification.getCarId());
@@ -47,6 +46,8 @@ public class PeopleCarListener implements CarPurchaseListener {
     carPersonBuilder.setKey(key);
     final CarPerson carPerson = carPersonBuilder.build();
 
+    log.info("Car bought, adding car-person entry: [{}]", carPerson);
+
     InstanceIdentifier<CarPerson> carPersonIId =
         InstanceIdentifier.<CarPeople>builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build();
 
@@ -57,12 +58,12 @@ public class PeopleCarListener implements CarPurchaseListener {
     Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
       @Override
       public void onSuccess(final Void result) {
-        log.info("Car bought, entry added to map of people and car [{}]", carPerson);
+        log.info("Successfully added car-person entry: [{}]", carPerson);
       }
 
       @Override
       public void onFailure(final Throwable t) {
-        log.info("Car bought, Failed entry addition to map of people and car [{}]", carPerson);
+        log.error(String.format("Failed to add car-person entry: [%s]", carPerson), t);
       }
     });
 
index e0d3f753499468fe6294d128df7040fa1a005952..ef666817e82c21c9b7941b9c3657c166b5502d61 100644 (file)
@@ -11,6 +11,7 @@ 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.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;
@@ -22,15 +23,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 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);
@@ -76,7 +75,7 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
 
       @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());
       }