From 7c6334fbe717fd51f76984e5789ae3d8ee2eb29a Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 7 Mar 2018 15:51:18 -0500 Subject: [PATCH] Fix checkstyle violations in clustering-it-provider Change-Id: Ic592165a0e8963001c361195e3ba0b4ca9a68ea4 Signed-off-by: Tom Pantelis --- .../it/listener/PeopleCarListener.java | 60 +++++----- .../clustering/it/provider/CarProvider.java | 29 +++-- .../provider/MdsalLowLevelTestProvider.java | 85 +++++++------- .../it/provider/PeopleProvider.java | 110 +++++++++--------- .../it/provider/PurchaseCarProvider.java | 45 ++++--- .../impl/AbstractTransactionHandler.java | 2 +- .../FinalizableScheduledExecutorService.java | 3 +- .../impl/FlappingSingletonService.java | 6 +- .../it/provider/impl/GetConstantService.java | 2 +- .../impl/IdIntsDOMDataTreeLIstener.java | 8 +- .../it/provider/impl/IdIntsListener.java | 7 +- .../it/provider/impl/PrefixLeaderHandler.java | 2 +- .../it/provider/impl/PrefixShardHandler.java | 20 ++-- .../impl/ProduceTransactionsHandler.java | 8 +- .../impl/RoutedGetConstantService.java | 2 +- .../impl/SingletonGetConstantService.java | 11 +- .../impl/WriteTransactionsHandler.java | 9 +- 17 files changed, 209 insertions(+), 200 deletions(-) diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java index 5dee90db87..f68ea1d33b 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java @@ -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 carPersonIId = - InstanceIdentifier.builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build(); + InstanceIdentifier carPersonIId = InstanceIdentifier.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() { - @Override - public void onSuccess(final Void result) { - LOG.info("Successfully added car-person entry: [{}]", carPerson); - } + Futures.addCallback(tx.submit(), new FutureCallback() { + @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()); + } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java index 803d3b7652..33ec2ed7d6 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java @@ -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.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> registerOwnership(final RegisterOwnershipInput input) { - if(registeredListener.compareAndSet(false, true)) { + if (registeredListener.compareAndSet(false, true)) { ownershipService.registerListener(ENTITY_TYPE, ownershipListener); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java index e0e8d99d1a..c5427bef59 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java @@ -137,8 +137,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService private final DOMDataTreeChangeService domDataTreeChangeService; private final ActorSystem actorSystem; - private final Map, DOMRpcImplementationRegistration> routedRegistrations = - new HashMap<>(); + private final Map, DOMRpcImplementationRegistration> + routedRegistrations = new HashMap<>(); private final Map> ynlRegistrations = new HashMap<>(); @@ -190,13 +190,14 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService } @Override + @SuppressWarnings("checkstyle:IllegalCatch") public Future> 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 result = RpcResultBuilder.failed().withRpcError(rpcError).build(); return Futures.immediateFuture(result); } @@ -206,10 +207,10 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService getSingletonConstantRegistration = null; return Futures.immediateFuture(RpcResultBuilder.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 result = RpcResultBuilder.failed().withRpcError(rpcError).build(); return Futures.immediateFuture(result); } @@ -300,18 +301,18 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService public Future> unregisterBoundConstant(final UnregisterBoundConstantInput input) { LOG.debug("unregister-bound-constant, {}", input); - final DOMRpcImplementationRegistration registration = + final DOMRpcImplementationRegistration 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 result = RpcResultBuilder.failed().withRpcError(rpcError).build(); return Futures.immediateFuture(result); } - registration.close(); + rpcRegistration.close(); return Futures.immediateFuture(RpcResultBuilder.success().build()); } @@ -341,8 +342,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService public Future> 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 result = RpcResultBuilder.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 result = RpcResultBuilder.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.failed().withRpcError(error).build()); } - final DOMRpcImplementationRegistration registration = + final DOMRpcImplementationRegistration rpcRegistration = RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService, input.getConstant(), input.getContext()); - routedRegistrations.put(input.getContext(), registration); + routedRegistrations.put(input.getContext(), rpcRegistration); return Futures.immediateFuture(RpcResultBuilder.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.failed().withRpcError(error).build()); + return Futures.immediateFuture(RpcResultBuilder.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.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.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 result = RpcResultBuilder.failed().withRpcError(rpcError).build(); return Futures.immediateFuture(result); } - final ListenerRegistration registration = ynlRegistrations.remove(input.getId()); - final UnsubscribeYnlOutput output = registration.getInstance().getOutput(); + final ListenerRegistration reg = ynlRegistrations.remove(input.getId()); + final UnsubscribeYnlOutput output = reg.getInstance().getOutput(); - registration.close(); + reg.close(); return Futures.immediateFuture(RpcResultBuilder.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> 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.failed().withRpcError(error).build()); + return Futures.immediateFuture(RpcResultBuilder.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.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.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( diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java index 09822831b2..868b9d0962 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java @@ -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 rpcRegistration; - - public void setDataProvider(final DataBroker salDataProvider) { - this.dataProvider = salDataProvider; - } - - - public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration rpcRegistration) { - this.rpcRegistration = rpcRegistration; - } - - @Override - public Future> addPerson(final AddPersonInput input) { - LOG.info("RPC addPerson : adding person [{}]", input); - - PersonBuilder builder = new PersonBuilder(input); - final Person person = builder.build(); - final SettableFuture> futureResult = SettableFuture.create(); - - // Each entry will be identifiable by a unique key, we have to create that identifier - final InstanceIdentifier.InstanceIdentifierBuilder personIdBuilder = - InstanceIdentifier.builder(People.class) - .child(Person.class, person.getKey()); - final InstanceIdentifier 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() { - @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.success().build()); - } - - @Override - public void onFailure(final Throwable t) { - LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), t); - futureResult.set(RpcResultBuilder.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 rpcRegistration; + + public void setDataProvider(final DataBroker salDataProvider) { + this.dataProvider = salDataProvider; + } + + + public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration rpcRegistration) { + this.rpcRegistration = rpcRegistration; + } + + @Override + public Future> addPerson(final AddPersonInput input) { + LOG.info("RPC addPerson : adding person [{}]", input); + + PersonBuilder builder = new PersonBuilder(input); + final Person person = builder.build(); + final SettableFuture> futureResult = SettableFuture.create(); + + // Each entry will be identifiable by a unique key, we have to create that identifier + final InstanceIdentifier.InstanceIdentifierBuilder personIdBuilder = + InstanceIdentifier.builder(People.class) + .child(Person.class, person.getKey()); + final InstanceIdentifier 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() { + @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.success().build()); + } + + @Override + public void onFailure(final Throwable ex) { + LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), ex); + futureResult.set(RpcResultBuilder.failed() + .withError(RpcError.ErrorType.APPLICATION, ex.getMessage()).build()); + } + }, MoreExecutors.directExecutor()); + return futureResult; + } + + @Override + public void close() throws Exception { + } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java index c31a508b75..ebd5b2e994 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java @@ -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> buyCar(BuyCarInput input) { - LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input); - SettableFuture> futureResult = SettableFuture.create(); - CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder(); - carBoughtBuilder.setCarId(input.getCarId()); - carBoughtBuilder.setPersonId(input.getPersonId()); - notificationProvider.publish(carBoughtBuilder.build()); - futureResult.set(RpcResultBuilder.success().build()); - return futureResult; - } - @Override - public void close() throws Exception { + @Override + public Future> buyCar(BuyCarInput input) { + LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input); + final SettableFuture> futureResult = SettableFuture.create(); + CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder(); + carBoughtBuilder.setCarId(input.getCarId()); + carBoughtBuilder.setPersonId(input.getPersonId()); + notificationProvider.publish(carBoughtBuilder.build()); + futureResult.set(RpcResultBuilder.success().build()); + return futureResult; + } - } + @Override + public void close() { + } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java index d3b0a7b049..661db64092 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/AbstractTransactionHandler.java @@ -224,7 +224,7 @@ abstract class AbstractTransactionHandler { runTimedOut(new TimeoutException("Collection did not finish in " + DEAD_TIMEOUT_SECONDS + " seconds")); } - abstract ListenableFuture execWrite(final long txId); + abstract ListenableFuture execWrite(long txId); abstract void runFailed(Throwable cause); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FinalizableScheduledExecutorService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FinalizableScheduledExecutorService.java index 19e2373653..758185346c 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FinalizableScheduledExecutorService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FinalizableScheduledExecutorService.java @@ -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(); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java index 197fadad9b..2894ee3598 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java @@ -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 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; diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java index 6f04b5f2ff..4ff725f3dd 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java @@ -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); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java index f5b55fd077..2b80f84a0d 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java @@ -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 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 { } } } - } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java index f98822b6f7..3e644393f1 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java @@ -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 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 future; - public CheckFinishedTask(final SettableFuture future) { + CheckFinishedTask(final SettableFuture future) { this.future = future; } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixLeaderHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixLeaderHandler.java index 5644a6bfc4..0eb8b37021 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixLeaderHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixLeaderHandler.java @@ -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); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java index 4ffb415d82..e3b6f98061 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java @@ -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 ensureFuture = ensureListExists(); + final ListenableFuture ensureFuture = ensureListExists(); Futures.addCallback(ensureFuture, new FutureCallback() { @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.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 ensureListExists() { + private ListenableFuture ensureListExists() { final CollectionNodeBuilder mapBuilder = ImmutableNodes.mapNodeBuilder(ID_INT); @@ -185,7 +183,7 @@ public class PrefixShardHandler { cursor.merge(containerNode.getIdentifier(), containerNode); cursor.close(); - final CheckedFuture future = tx.submit(); + final ListenableFuture future = tx.submit(); Futures.addCallback(future, new FutureCallback() { @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; } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java index 05fd59d218..164e81ad00 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java @@ -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> 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); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java index 92b741d929..ec0afe328e 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java @@ -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); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java index 084f4d54b6..8f3dc2caad 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java @@ -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 invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode input) { + public CheckedFuture invokeRpc(@Nonnull DOMRpcIdentifier rpc, + @Nullable NormalizedNode input) { LOG.debug("get-singleton-constant invoked, current value: {}", constant); final LeafNode value = ImmutableLeafNodeBuilder.create() diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java index a8363c1d2f..6426bc09e2 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java @@ -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.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.failed() .withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build()); -- 2.36.6