Fix checkstyle violations in clustering-it-provider 33/69233/2
authorTom Pantelis <tompantelis@gmail.com>
Wed, 7 Mar 2018 20:51:18 +0000 (15:51 -0500)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 9 Mar 2018 15:23:05 +0000 (15:23 +0000)
Change-Id: Ic592165a0e8963001c361195e3ba0b4ca9a68ea4
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
17 files changed:
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/CarProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FinalizableScheduledExecutorService.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixLeaderHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java

index 5dee90db877e57368ec12dee7ff54a2d245e2bf0..f68ea1d33b36253508e71d81fb7224ebdefbf72c 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.clustering.it.listener;
 
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 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;
@@ -26,46 +27,45 @@ import org.slf4j.LoggerFactory;
 
 public class PeopleCarListener implements CarPurchaseListener {
 
-  private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class);
+    private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class);
 
-  private DataBroker dataProvider;
+    private DataBroker dataProvider;
 
 
 
-  public void setDataProvider(final DataBroker salDataProvider) {
-    this.dataProvider = salDataProvider;
-  }
+    public void setDataProvider(final DataBroker salDataProvider) {
+        this.dataProvider = salDataProvider;
+    }
 
-  @Override
-  public void onCarBought(CarBought notification) {
+    @Override
+    public void onCarBought(CarBought notification) {
 
-    final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
-    carPersonBuilder.setCarId(notification.getCarId());
-    carPersonBuilder.setPersonId(notification.getPersonId());
-    CarPersonKey key = new CarPersonKey(notification.getCarId(), notification.getPersonId());
-    carPersonBuilder.setKey(key);
-    final CarPerson carPerson = carPersonBuilder.build();
+        final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
+        carPersonBuilder.setCarId(notification.getCarId());
+        carPersonBuilder.setPersonId(notification.getPersonId());
+        CarPersonKey key = new CarPersonKey(notification.getCarId(), notification.getPersonId());
+        carPersonBuilder.setKey(key);
+        final CarPerson carPerson = carPersonBuilder.build();
 
-    LOG.info("Car bought, adding car-person entry: [{}]", carPerson);
+        LOG.info("Car bought, adding car-person entry: [{}]", carPerson);
 
-    InstanceIdentifier<CarPerson> carPersonIId =
-        InstanceIdentifier.<CarPeople>builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build();
+        InstanceIdentifier<CarPerson> carPersonIId = InstanceIdentifier.<CarPeople>builder(CarPeople.class)
+                .child(CarPerson.class, carPerson.getKey()).build();
 
 
-    WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
-    tx.put(LogicalDatastoreType.CONFIGURATION, carPersonIId, carPerson, true);
+        WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
+        tx.put(LogicalDatastoreType.CONFIGURATION, carPersonIId, carPerson, true);
 
-    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
-      @Override
-      public void onSuccess(final Void result) {
-        LOG.info("Successfully added car-person entry: [{}]", carPerson);
-      }
+        Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                LOG.info("Successfully added car-person entry: [{}]", carPerson);
+            }
 
-      @Override
-      public void onFailure(final Throwable t) {
-        LOG.error(String.format("Failed to add car-person entry: [%s]", carPerson), t);
-      }
-    });
-
-  }
+            @Override
+            public void onFailure(final Throwable ex) {
+                LOG.error(String.format("Failed to add car-person entry: [%s]", carPerson), ex);
+            }
+        }, MoreExecutors.directExecutor());
+    }
 }
index 803d3b76525aea6a64b6f8773ca5fbf7f8d0d640..33ec2ed7d6dc9fdb4991a006ec6b993347f6d6d1 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -53,6 +54,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * Implementation of CarService.
+ *
  * @author Thomas Pantelis
  */
 public class CarProvider implements CarService {
@@ -97,12 +100,14 @@ public class CarProvider implements CarService {
     }
 
     private void stopThread() {
-        if(testThread != null) {
+        if (testThread != null) {
             stopThread = true;
             testThread.interrupt();
             try {
                 testThread.join();
-            } catch (InterruptedException e) {}
+            } catch (InterruptedException e) {
+                // don't care
+            }
             testThread = null;
         }
     }
@@ -150,10 +155,10 @@ public class CarProvider implements CarService {
         testThread = new Thread(() -> {
             sw.start();
             AtomicLong count = new AtomicLong();
-            while(!stopThread) {
+            while (!stopThread) {
                 long id = count.incrementAndGet();
                 WriteTransaction tx1 = dataProvider.newWriteOnlyTransaction();
-                CarEntry car = new CarEntryBuilder().setId(new CarId("car"+id)).build();
+                CarEntry car = new CarEntryBuilder().setId(new CarId("car" + id)).build();
                 tx1.put(LogicalDatastoreType.CONFIGURATION,
                         InstanceIdentifier.<Cars>builder(Cars.class).child(CarEntry.class, car.getKey()).build(),
                         car);
@@ -167,19 +172,19 @@ public class CarProvider implements CarService {
                     }
 
                     @Override
-                    public void onFailure(final Throwable t) {
+                    public void onFailure(final Throwable ex) {
                         // Transaction failed
                         failureCounter.getAndIncrement();
-                        LOG_CAR_PROVIDER.error("Put Cars failed", t);
+                        LOG_CAR_PROVIDER.error("Put Cars failed", ex);
                     }
-                });
+                }, MoreExecutors.directExecutor());
                 try {
                     TimeUnit.NANOSECONDS.sleep(sleep);
                 } catch (InterruptedException e) {
                     break;
                 }
 
-                if(count.get() % 1000 == 0) {
+                if (count.get() % 1000 == 0) {
                     LOG_PURCHASE_CAR.info("Cars created {}, time: {}",count.get(),sw.elapsed(TimeUnit.SECONDS));
                 }
 
@@ -204,9 +209,9 @@ public class CarProvider implements CarService {
                 .setSuccessCount(succcessCounter.longValue())
                 .setFailureCount(failureCounter.longValue());
 
-        StopStressTestOutput result = stopStressTestOutput.build();
-        LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; " +
-                "No. of cars failed {}; ", succcessCounter, failureCounter);
+        final StopStressTestOutput result = stopStressTestOutput.build();
+        LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; "
+                "No. of cars failed {}; ", succcessCounter, failureCounter);
         // clear counters
         succcessCounter.set(0);
         failureCounter.set(0);
@@ -216,7 +221,7 @@ public class CarProvider implements CarService {
 
     @Override
     public Future<RpcResult<Void>> registerOwnership(final RegisterOwnershipInput input) {
-        if(registeredListener.compareAndSet(false, true)) {
+        if (registeredListener.compareAndSet(false, true)) {
             ownershipService.registerListener(ENTITY_TYPE, ownershipListener);
         }
 
index e0e8d99d1aab3eac8df847bf7075de6e15b0257e..c5427bef595e355983658c2946c6fbb5953951be 100644 (file)
@@ -137,8 +137,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
     private final DOMDataTreeChangeService domDataTreeChangeService;
     private final ActorSystem actorSystem;
 
-    private final Map<InstanceIdentifier<?>, DOMRpcImplementationRegistration<RoutedGetConstantService>> routedRegistrations =
-            new HashMap<>();
+    private final Map<InstanceIdentifier<?>, DOMRpcImplementationRegistration<RoutedGetConstantService>>
+            routedRegistrations = new HashMap<>();
 
     private final Map<String, ListenerRegistration<YnlListener>> ynlRegistrations = new HashMap<>();
 
@@ -190,13 +190,14 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<Void>> unregisterSingletonConstant() {
         LOG.debug("unregister-singleton-constant");
 
         if (getSingletonConstantRegistration == null) {
             LOG.debug("No get-singleton-constant registration present.");
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "missing-registration", "No get-singleton-constant rpc registration present.");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration",
+                    "No get-singleton-constant rpc registration present.");
             final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
         }
@@ -206,10 +207,10 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
             getSingletonConstantRegistration = null;
 
             return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
-        } catch (final Exception e) {
+        } catch (Exception e) {
             LOG.debug("There was a problem closing the singleton constant service", e);
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "error-closing", "There was a problem closing get-singleton-constant");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "error-closing",
+                    "There was a problem closing get-singleton-constant");
             final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
         }
@@ -300,18 +301,18 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
     public Future<RpcResult<Void>> unregisterBoundConstant(final UnregisterBoundConstantInput input) {
         LOG.debug("unregister-bound-constant, {}", input);
 
-        final DOMRpcImplementationRegistration<RoutedGetConstantService> registration =
+        final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration =
                 routedRegistrations.remove(input.getContext());
 
-        if (registration == null) {
+        if (rpcRegistration == null) {
             LOG.debug("No get-contexted-constant registration for context: {}", input.getContext());
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "missing-registration", "No get-constant rpc registration present.");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration",
+                    "No get-constant rpc registration present.");
             final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
         }
 
-        registration.close();
+        rpcRegistration.close();
         return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
     }
 
@@ -341,8 +342,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
     public Future<RpcResult<Void>> unregisterConstant() {
 
         if (globalGetConstantRegistration == null) {
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "missing-registration", "No get-constant rpc registration present.");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration",
+                    "No get-constant rpc registration present.");
             final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
         }
@@ -358,8 +359,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         LOG.debug("unregister-flapping-singleton received.");
 
         if (flappingSingletonService == null) {
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "missing-registration", "No flapping-singleton registration present.");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration",
+                    "No flapping-singleton registration present.");
             final RpcResult<UnregisterFlappingSingletonOutput> result =
                     RpcResultBuilder.<UnregisterFlappingSingletonOutput>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
@@ -391,11 +392,10 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         idIntsDdtl = new IdIntsDOMDataTreeLIstener();
 
         try {
-            ddtlReg =
-                    domDataTreeService.registerListener(idIntsDdtl,
-                            Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
-                                    ProduceTransactionsHandler.ID_INT_YID))
-                            , true, Collections.emptyList());
+            ddtlReg = domDataTreeService.registerListener(idIntsDdtl,
+                    Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
+                            ProduceTransactionsHandler.ID_INT_YID)),
+                    true, Collections.emptyList());
         } catch (DOMDataTreeLoopException e) {
             LOG.error("Failed to register DOMDataTreeListener.", e);
 
@@ -426,11 +426,11 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
             return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
         }
 
-        final DOMRpcImplementationRegistration<RoutedGetConstantService> registration =
+        final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration =
                 RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService,
                         input.getConstant(), input.getContext());
 
-        routedRegistrations.put(input.getContext(), registration);
+        routedRegistrations.put(input.getContext(), rpcRegistration);
         return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
     }
 
@@ -456,15 +456,15 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         if (idIntsListener == null || dtclReg == null) {
             final RpcError error = RpcResultBuilder.newError(
                     ErrorType.RPC, "Dtcl missing.", "No DataTreeChangeListener registered.");
-            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
+            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
+                    .withRpcError(error).build());
         }
 
         try {
             idIntsListener.tryFinishProcessing().get(120, TimeUnit.SECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.",
-                    "clustering-it", "clustering-it", e);
+            final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport",
+                    "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
                     .withRpcError(error).build());
         }
@@ -474,8 +474,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
         if (!idIntsListener.hasTriggered()) {
             final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" +
-                            "any notifications.");
+                    ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received"
+                            "any notifications.");
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
                     .withRpcError(error).build());
         }
@@ -522,17 +522,17 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         LOG.debug("Received unsubscribe-ynl, input: {}", input);
 
         if (!ynlRegistrations.containsKey(input.getId())) {
-            final RpcError rpcError = RpcResultBuilder
-                    .newError(ErrorType.APPLICATION, "missing-registration", "No ynl listener with this id registered.");
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration",
+                    "No ynl listener with this id registered.");
             final RpcResult<UnsubscribeYnlOutput> result =
                     RpcResultBuilder.<UnsubscribeYnlOutput>failed().withRpcError(rpcError).build();
             return Futures.immediateFuture(result);
         }
 
-        final ListenerRegistration<YnlListener> registration = ynlRegistrations.remove(input.getId());
-        final UnsubscribeYnlOutput output = registration.getInstance().getOutput();
+        final ListenerRegistration<YnlListener> reg = ynlRegistrations.remove(input.getId());
+        final UnsubscribeYnlOutput output = reg.getInstance().getOutput();
 
-        registration.close();
+        reg.close();
 
         return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeYnlOutput>success().withResult(output).build());
     }
@@ -554,7 +554,7 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         if (task.getLastError() != null) {
             final StringWriter sw = new StringWriter();
             final PrintWriter pw = new PrintWriter(sw);
-            task.getLastError().printStackTrace(pw);
+            LOG.error("Last error for {}", task, task.getLastError());
             checkPublishNotificationsOutputBuilder.setLastError(task.getLastError().toString() + sw.toString());
         }
 
@@ -666,21 +666,22 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<UnsubscribeDdtlOutput>> unsubscribeDdtl() {
         LOG.debug("Received unsubscribe-ddtl.");
 
         if (idIntsDdtl == null || ddtlReg == null) {
             final RpcError error = RpcResultBuilder.newError(
                     ErrorType.RPC, "Ddtl missing.", "No DOMDataTreeListener registered.");
-            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
+            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed()
+                    .withRpcError(error).build());
         }
 
         try {
             idIntsDdtl.tryFinishProcessing().get(120, TimeUnit.SECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.",
-                    "clustering-it", "clustering-it", e);
+            final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport",
+                    "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed()
                     .withRpcError(error).build());
         }
@@ -690,8 +691,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
         if (!idIntsDdtl.hasTriggered()) {
             final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" +
-                            "any notifications.");
+                    ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received"
+                            "any notifications.");
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed()
                     .withRpcError(error).build());
         }
@@ -709,7 +710,7 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         try {
             distributedDataStoreClient = SimpleDataStoreClientActor
                     .getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS);
-        } catch (final Exception e) {
+        } catch (RuntimeException e) {
             LOG.error("Failed to get actor for {}", distributedDataStoreClientProps, e);
             clientActor.tell(PoisonPill.getInstance(), noSender());
             final RpcError error = RpcResultBuilder.newError(
index 09822831b2c300865ca209eb23f7c248702a6271..868b9d09627e1ca01615292bef736344248846bd 100644 (file)
@@ -10,6 +10,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.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -32,59 +33,58 @@ import org.slf4j.LoggerFactory;
 
 public class PeopleProvider implements PeopleService, AutoCloseable {
 
-  private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class);
-
-  private DataBroker dataProvider;
-
-  private BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration;
-
-  public void setDataProvider(final DataBroker salDataProvider) {
-    this.dataProvider = salDataProvider;
-  }
-
-
-  public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration) {
-    this.rpcRegistration = rpcRegistration;
-  }
-
-  @Override
-  public Future<RpcResult<Void>> 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();
-
-    // 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();
-    // Place entry in data store tree
-    WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
-    tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);
-
-    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
-      @Override
-      public void onSuccess(final Void result) {
-        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());
-      }
-
-      @Override
-      public void onFailure(final Throwable t) {
-        LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), t);
-        futureResult.set(RpcResultBuilder.<Void>failed()
-            .withError(RpcError.ErrorType.APPLICATION, t.getMessage()).build());
-      }
-    });
-    return futureResult;
-  }
-
-  @Override
-  public void close() throws Exception {
-
-  }
+    private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class);
+
+    private DataBroker dataProvider;
+
+    private BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration;
+
+    public void setDataProvider(final DataBroker salDataProvider) {
+        this.dataProvider = salDataProvider;
+    }
+
+
+    public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration) {
+        this.rpcRegistration = rpcRegistration;
+    }
+
+    @Override
+    public Future<RpcResult<Void>> 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();
+
+        // 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();
+        // Place entry in data store tree
+        WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
+        tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);
+
+        Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                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());
+            }
+
+            @Override
+            public void onFailure(final Throwable ex) {
+                LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), ex);
+                futureResult.set(RpcResultBuilder.<Void>failed()
+                        .withError(RpcError.ErrorType.APPLICATION, ex.getMessage()).build());
+            }
+        }, MoreExecutors.directExecutor());
+        return futureResult;
+    }
+
+    @Override
+    public void close() throws Exception {
+    }
 }
index c31a508b753fc28266e4fa614ba6ecb9214e9967..ebd5b2e9943b2f4ca28ce0c22d2871ef73fa8c0a 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.clustering.it.provider;
 
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.concurrent.Future;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarBoughtBuilder;
@@ -18,35 +19,31 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.Future;
-
-
-public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable{
-
-  private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
+public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable {
 
-  private NotificationProviderService notificationProvider;
+    private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
 
+    private NotificationProviderService notificationProvider;
 
-  public void setNotificationProvider(final NotificationProviderService salService) {
-    this.notificationProvider = salService;
-  }
 
+    public void setNotificationProvider(final NotificationProviderService salService) {
+        this.notificationProvider = salService;
+    }
 
-  @Override
-  public Future<RpcResult<Void>> buyCar(BuyCarInput input) {
-    LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
-    SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
-    CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
-    carBoughtBuilder.setCarId(input.getCarId());
-    carBoughtBuilder.setPersonId(input.getPersonId());
-    notificationProvider.publish(carBoughtBuilder.build());
-    futureResult.set(RpcResultBuilder.<Void>success().build());
-    return futureResult;
-  }
 
-  @Override
-  public void close() throws Exception {
+    @Override
+    public Future<RpcResult<Void>> buyCar(BuyCarInput input) {
+        LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
+        final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
+        CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
+        carBoughtBuilder.setCarId(input.getCarId());
+        carBoughtBuilder.setPersonId(input.getPersonId());
+        notificationProvider.publish(carBoughtBuilder.build());
+        futureResult.set(RpcResultBuilder.<Void>success().build());
+        return futureResult;
+    }
 
-  }
+    @Override
+    public void close() {
+    }
 }
index d3b0a7b0497fbbc204edb6900738cc15fa0005fa..661db640923e1deaf7d3db291807505bdce963d3 100644 (file)
@@ -224,7 +224,7 @@ abstract class AbstractTransactionHandler {
         runTimedOut(new TimeoutException("Collection did not finish in " + DEAD_TIMEOUT_SECONDS + " seconds"));
     }
 
-    abstract ListenableFuture<Void> execWrite(final long txId);
+    abstract ListenableFuture<Void> execWrite(long txId);
 
     abstract void runFailed(Throwable cause);
 
index 19e23736532da3ee9ff3dbcbf56805177edd09b8..758185346c896311dea2f1c4df11243fb5efef4f 100644 (file)
@@ -11,7 +11,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
 /**
- * A simple ScheduledExecutorService, which shutds down its threads after a period of inactivity. It is safe to not
+ * A simple ScheduledExecutorService, which shuts down its threads after a period of inactivity. It is safe to not
  * shutdown this
  *
  * @author Robert Varga
@@ -30,6 +30,7 @@ final class FinalizableScheduledExecutorService extends ScheduledThreadPoolExecu
 
     // This is a bit ugly, but allows
     @Override
+    @SuppressWarnings("checkstyle:NoFinalizer")
     protected void finalize() {
         super.shutdownNow();
     }
index 197fadad9b64056c3f175bf609b7fc5426b508fc..2894ee35986e95ac102972efb926e341d0f8d90c 100644 (file)
@@ -43,6 +43,7 @@ public class FlappingSingletonService implements ClusterSingletonService {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void instantiateServiceInstance() {
         LOG.debug("Instantiating flapping-singleton-service.");
 
@@ -52,7 +53,7 @@ public class FlappingSingletonService implements ClusterSingletonService {
             try {
                 registration.close();
                 registration = null;
-            } catch (final Exception e) {
+            } catch (Exception e) {
                 LOG.warn("There was a problem closing flapping singleton service.", e);
                 setInactive();
                 flapCount = -flapCount;
@@ -61,6 +62,7 @@ public class FlappingSingletonService implements ClusterSingletonService {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public ListenableFuture<Void> closeServiceInstance() {
         LOG.debug("Closing flapping-singleton-service, flapCount: {}", flapCount);
 
@@ -73,7 +75,7 @@ public class FlappingSingletonService implements ClusterSingletonService {
                 LOG.debug("Running re-registration");
                 try {
                     registration = singletonServiceProvider.registerClusterSingletonService(this);
-                } catch (final Exception e) {
+                } catch (RuntimeException e) {
                     LOG.warn("There was a problem re-registering flapping singleton service.", e);
                     setInactive();
                     flapCount = -flapCount - 1;
index 6f04b5f2ffa4d27a634801b5019ef0f7a688daa1..4ff725f3ddeb184371d73ce0780491d108aaf7a2 100644 (file)
@@ -30,7 +30,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class GetConstantService implements DOMRpcImplementation {
+public final class GetConstantService implements DOMRpcImplementation {
 
     private static final Logger LOG = LoggerFactory.getLogger(GetConstantService.class);
 
index f5b55fd0775eaf3f3442fcc98de9c06d8b467ba1..2b80f84a0daf6812874662e9f1e35be3c3b830ec 100644 (file)
@@ -33,7 +33,7 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener {
     private static final long SECOND_AS_NANO = 1000000000;
 
     private NormalizedNode<?, ?> localCopy = null;
-    private AtomicLong lastNotifTimestamp = new AtomicLong(0);
+    private final AtomicLong lastNotifTimestamp = new AtomicLong(0);
     private ScheduledFuture<?> scheduledFuture;
     private ScheduledExecutorService executorService;
 
@@ -81,7 +81,8 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener {
         executorService = Executors.newSingleThreadScheduledExecutor();
         final SettableFuture<Void> settableFuture = SettableFuture.create();
 
-        scheduledFuture = executorService.scheduleAtFixedRate(new CheckFinishedTask(settableFuture), 0, 1, TimeUnit.SECONDS);
+        scheduledFuture = executorService.scheduleAtFixedRate(new CheckFinishedTask(settableFuture),
+                0, 1, TimeUnit.SECONDS);
         return settableFuture;
     }
 
@@ -99,7 +100,7 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener {
 
         @Override
         public void run() {
-            if (System.nanoTime() - lastNotifTimestamp.get() > (SECOND_AS_NANO * 4)) {
+            if (System.nanoTime() - lastNotifTimestamp.get() > SECOND_AS_NANO * 4) {
                 scheduledFuture.cancel(false);
                 future.set(null);
 
@@ -107,5 +108,4 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener {
             }
         }
     }
-
 }
index f98822b6f70f020e65d4235337770be49c270491..3e644393f163975fb13ab220da40b2e80ab00fda 100644 (file)
@@ -30,7 +30,7 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener {
     private static final long SECOND_AS_NANO = 1000000000;
 
     private NormalizedNode<?, ?> localCopy = null;
-    private AtomicLong lastNotifTimestamp = new AtomicLong(0);
+    private final AtomicLong lastNotifTimestamp = new AtomicLong(0);
     private ScheduledExecutorService executorService;
     private ScheduledFuture<?> scheduledFuture;
 
@@ -76,7 +76,8 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener {
         executorService = Executors.newSingleThreadScheduledExecutor();
         final SettableFuture<Void> settableFuture = SettableFuture.create();
 
-        scheduledFuture = executorService.scheduleAtFixedRate(new CheckFinishedTask(settableFuture), 0, 1, TimeUnit.SECONDS);
+        scheduledFuture = executorService.scheduleAtFixedRate(new CheckFinishedTask(settableFuture),
+                0, 1, TimeUnit.SECONDS);
         return settableFuture;
     }
 
@@ -84,7 +85,7 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener {
 
         private final SettableFuture<Void> future;
 
-        public CheckFinishedTask(final SettableFuture<Void> future) {
+        CheckFinishedTask(final SettableFuture<Void> future) {
             this.future = future;
         }
 
index 5644a6bfc40f2e454749a45b5b125147f1b01a0e..0eb8b370210d70bb63ab089180ea7a239525b236 100644 (file)
@@ -46,7 +46,7 @@ public class PrefixLeaderHandler {
         final YangInstanceIdentifier yid = serializer.toYangInstanceIdentifier(input.getPrefix());
         final DOMDataTreeIdentifier prefix = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yid);
 
-        try (final CDSDataTreeProducer producer =
+        try (CDSDataTreeProducer producer =
                      (CDSDataTreeProducer) domDataTreeService.createProducer(Collections.singleton(prefix))) {
 
             final CDSShardAccess shardAccess = producer.getShardAccess(prefix);
index 4ffb415d82a5eea32a8b168aa02fcab7ef3994d4..e3b6f980616a4d040b946372890f40a19beaec76 100644 (file)
@@ -13,10 +13,10 @@ import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTr
 import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ID_INTS;
 import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ITEM;
 
-import com.google.common.util.concurrent.CheckedFuture;
 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.Collections;
 import java.util.HashMap;
@@ -29,7 +29,6 @@ import org.opendaylight.controller.cluster.sharding.DistributedShardFactory;
 import org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
@@ -82,7 +81,7 @@ public class PrefixShardHandler {
         final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
 
         try {
-             completionStage = shardFactory.createDistributedShard(
+            completionStage = shardFactory.createDistributedShard(
                     new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, identifier),
                     input.getReplicas().stream().map(MemberName::forName).collect(Collectors.toList()));
 
@@ -90,7 +89,7 @@ public class PrefixShardHandler {
                 LOG.debug("Shard[{}] created successfully.", identifier);
                 registrations.put(identifier, registration);
 
-                final CheckedFuture<Void, TransactionCommitFailedException> ensureFuture = ensureListExists();
+                final ListenableFuture<Void> ensureFuture = ensureListExists();
                 Futures.addCallback(ensureFuture, new FutureCallback<Void>() {
                     @Override
                     public void onSuccess(@Nullable final Void result) {
@@ -102,12 +101,11 @@ public class PrefixShardHandler {
                     public void onFailure(final Throwable throwable) {
                         LOG.warn("Shard[{}] creation failed:", identifier, throwable);
 
-                        final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
-                                "Shard creation failed", "cluster-test-app", "", throwable);
+                        final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION,
+                                "create-shard-failed", "Shard creation failed", "cluster-test-app", "", throwable);
                         future.set(RpcResultBuilder.<Void>failed().withRpcError(error).build());
                     }
-                });
-
+                }, MoreExecutors.directExecutor());
             });
             completionStage.exceptionally(throwable -> {
                 LOG.warn("Shard[{}] creation failed:", identifier, throwable);
@@ -155,7 +153,7 @@ public class PrefixShardHandler {
         return future;
     }
 
-    private CheckedFuture<Void, TransactionCommitFailedException> ensureListExists() {
+    private ListenableFuture<Void> ensureListExists() {
 
         final CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder = ImmutableNodes.mapNodeBuilder(ID_INT);
 
@@ -185,7 +183,7 @@ public class PrefixShardHandler {
         cursor.merge(containerNode.getIdentifier(), containerNode);
         cursor.close();
 
-        final CheckedFuture<Void, TransactionCommitFailedException> future = tx.submit();
+        final ListenableFuture<Void> future = tx.submit();
         Futures.addCallback(future, new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
@@ -201,7 +199,7 @@ public class PrefixShardHandler {
             public void onFailure(final Throwable throwable) {
                 //NOOP handled by the caller of this method.
             }
-        });
+        }, MoreExecutors.directExecutor());
         return future;
     }
 }
index 05fd59d218753da08237da80a101975c1999cdbb..164e81ad00b7a19c82ef21460f0c1a20caa760d8 100644 (file)
@@ -16,7 +16,9 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.SplittableRandom;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
@@ -38,7 +40,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ProduceTransactionsHandler extends AbstractTransactionHandler {
+public final class ProduceTransactionsHandler extends AbstractTransactionHandler {
     private static final Logger LOG = LoggerFactory.getLogger(ProduceTransactionsHandler.class);
 
     private final SettableFuture<RpcResult<ProduceTransactionsOutput>> future = SettableFuture.create();
@@ -76,8 +78,8 @@ public class ProduceTransactionsHandler extends AbstractTransactionHandler {
         cursor.close();
 
         try {
-            tx.submit().checkedGet(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
-        } catch (final Exception e) {
+            tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn("Unable to fill the initial item list.", e);
             closeProducer(itemProducer);
 
index 92b741d929733317d1b7d02ca09b326b3e5c0ef8..ec0afe328efa1e2b8970bc0beab8d0317da51ec0 100644 (file)
@@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RoutedGetConstantService implements DOMRpcImplementation {
+public final class RoutedGetConstantService implements DOMRpcImplementation {
 
     private static final Logger LOG = LoggerFactory.getLogger(RoutedGetConstantService.class);
 
index 084f4d54b660d54ce72528899b5b630e5e74f2b2..8f3dc2caad31c023081e6fda09c9ccad7ec3d7a2 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SingletonGetConstantService implements DOMRpcImplementation, ClusterSingletonService {
+public final class SingletonGetConstantService implements DOMRpcImplementation, ClusterSingletonService {
 
     private static final Logger LOG = LoggerFactory.getLogger(SingletonGetConstantService.class);
 
@@ -64,9 +64,9 @@ public class SingletonGetConstantService implements DOMRpcImplementation, Cluste
         this.constant = constant;
     }
 
-    public static ClusterSingletonServiceRegistration registerNew(final ClusterSingletonServiceProvider singletonService,
-                                                                  final DOMRpcProviderService rpcProviderService,
-                                                                  final String constant) {
+    public static ClusterSingletonServiceRegistration registerNew(
+            final ClusterSingletonServiceProvider singletonService, final DOMRpcProviderService rpcProviderService,
+            final String constant) {
         LOG.debug("Registering get-singleton-constant into ClusterSingletonService, value {}", constant);
 
         return singletonService
@@ -75,7 +75,8 @@ public class SingletonGetConstantService implements DOMRpcImplementation, Cluste
 
     @Nonnull
     @Override
-    public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input) {
+    public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc,
+            @Nullable NormalizedNode<?, ?> input) {
         LOG.debug("get-singleton-constant invoked, current value: {}", constant);
 
         final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
index a8363c1d2f27880c49bcae2cc1c0d01c032aaeee..6426bc09e207f18288680486f743a2753a3aa168 100644 (file)
@@ -16,6 +16,7 @@ import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.SplittableRandom;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
@@ -159,8 +160,8 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle
         tx.merge(LogicalDatastoreType.CONFIGURATION, idListItem, entry);
 
         try {
-            tx.submit().checkedGet(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
-        } catch (final Exception e) {
+            tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn("Unable to ensure IdInts list for id: {} exists.", id, e);
             return Futures.immediateFuture(RpcResultBuilder.<WriteTransactionsOutput>failed()
                     .withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build());
@@ -175,8 +176,8 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle
         tx.put(LogicalDatastoreType.CONFIGURATION, itemListId, mapBuilder.build());
 
         try {
-            tx.submit().checkedGet(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
-        } catch (final Exception e) {
+            tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn("Unable to fill the initial item list.", e);
             return Futures.immediateFuture(RpcResultBuilder.<WriteTransactionsOutput>failed()
                     .withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build());