From 925cb4a228d0fda99c7bfeb432eb25285a223887 Mon Sep 17 00:00:00 2001
From: Tom Pantelis
Date: Thu, 6 Oct 2016 18:46:11 -0400
Subject: [PATCH] Fix warnings/javadocs in sal-distributed-datastore
First off, I apologize for the size of this patch. There's a ton of classes
in this project and I didn't even get to all of them (will follow-up). While
a lot of files were touched, the changes were mostly small.
Fixed a lot of checkstyle warnings and cleaned up javadocs. Most of the
warnings/changes were for:
- white space before if/for/while/catch
- white space before beginning brace
- line too long
- illegal catching of Exception (suppressed)
- variable name too short
- indentation
- missing period after first sentence in javadoc
- missing first sentence in javadoc
- missing in javadoc
Change-Id: Id56d874a8fbcbbc9285279a71c0a5aba393653a9
Signed-off-by: Tom Pantelis
---
.../cluster/databroker/AbstractDOMBroker.java | 17 +-
.../AbstractDOMBrokerTransaction.java | 21 +-
.../AbstractDOMBrokerWriteTransaction.java | 21 +-
.../AbstractDOMTransactionFactory.java | 22 +-
.../databroker/ConcurrentDOMDataBroker.java | 50 +-
.../DOMBrokerReadOnlyTransaction.java | 3 +-
.../DOMBrokerReadWriteTransaction.java | 13 +-
.../databroker/DOMBrokerTransactionChain.java | 12 +-
.../DOMBrokerWriteOnlyTransaction.java | 8 +-
.../ShardedDOMStoreReadTransaction.java | 3 +-
.../ShardedDOMStoreReadWriteTransaction.java | 4 +-
.../ShardedDOMStoreWriteTransaction.java | 2 +-
.../AbstractDataListenerSupport.java | 26 +-
...taTreeNotificationPublisherActorProxy.java | 8 +-
.../AbstractShardDataTreeTransaction.java | 3 +-
.../datastore/AbstractTransactionContext.java | 2 +-
.../AbstractTransactionContextFactory.java | 38 +-
.../datastore/ChainedCommitCohort.java | 11 +-
.../cluster/datastore/ClusterWrapper.java | 2 +
.../cluster/datastore/ClusterWrapperImpl.java | 13 +-
.../cluster/datastore/CohortEntry.java | 19 +-
.../datastore/CompositeDataTreeCohort.java | 33 +-
.../cluster/datastore/DataChangeListener.java | 17 +-
.../datastore/DataChangeListenerProxy.java | 4 +-
.../DataChangeListenerRegistrationActor.java | 6 +-
.../DataChangeListenerRegistrationProxy.java | 33 +-
.../datastore/DataChangeListenerSupport.java | 2 +-
.../datastore/DataTreeCandidatePayload.java | 7 +
.../DataTreeChangeListenerActor.java | 6 +-
.../DataTreeChangeListenerProxy.java | 15 +-
...taTreeChangeListenerRegistrationActor.java | 5 +-
.../DataTreeChangeListenerSupport.java | 8 +-
.../datastore/DataTreeCohortActor.java | 21 +-
.../DataTreeCohortActorRegistry.java | 15 +-
.../DataTreeCohortRegistrationProxy.java | 6 +-
.../cluster/datastore/DatastoreContext.java | 52 +-
.../DatastoreContextConfigAdminOverlay.java | 15 +-
.../DatastoreContextIntrospector.java | 100 ++--
.../datastore/DatastoreSnapshotRestore.java | 21 +-
.../DebugThreePhaseCommitCohort.java | 4 +-
...faultShardDataChangeListenerPublisher.java | 11 +-
.../DelayedListenerRegistration.java | 14 +-
.../cluster/datastore/DelegateFactory.java | 6 +-
.../datastore/DistributedDataStore.java | 49 +-
.../ForwardingDataTreeChangeListener.java | 2 +-
.../FrontendHistoryMetadataBuilder.java | 3 +-
.../datastore/LeaderLocalDelegateFactory.java | 6 +-
.../LocalThreePhaseCommitCohort.java | 9 +-
.../datastore/LocalTransactionChain.java | 4 +-
.../datastore/LocalTransactionContext.java | 7 +-
.../LocalTransactionFactoryImpl.java | 8 +-
.../datastore/NoOpTransactionContext.java | 6 +-
.../cluster/datastore/OperationCallback.java | 6 +-
.../cluster/datastore/OperationLimiter.java | 6 +-
.../datastore/RemoteTransactionContext.java | 51 +-
.../RemoteTransactionContextSupport.java | 51 +-
.../controller/cluster/datastore/Shard.java | 81 +--
.../datastore/ShardCommitCoordinator.java | 26 +-
...DataChangeListenerPublisherActorProxy.java | 5 +-
.../cluster/datastore/ShardDataTree.java | 81 +--
...TreeChangeListenerPublisherActorProxy.java | 3 +-
.../datastore/ShardDataTreeMetadata.java | 2 +
...ardDataTreeNotificationPublisherActor.java | 4 +-
.../ShardDataTreeTransactionChain.java | 6 +-
.../ShardDataTreeTransactionParent.java | 1 +
.../cluster/datastore/ShardManager.java | 4 +-
.../datastore/ShardManagerSnapshot.java | 2 +-
.../datastore/ShardReadTransaction.java | 3 +-
.../datastore/ShardReadWriteTransaction.java | 7 +-
.../datastore/ShardRecoveryCoordinator.java | 5 +-
.../datastore/ShardSnapshotCohort.java | 1 +
.../cluster/datastore/ShardTransaction.java | 48 +-
...java => ShardTransactionActorFactory.java} | 28 +-
.../ShardTransactionMessageRetrySupport.java | 9 +-
.../datastore/ShardWriteTransaction.java | 17 +-
.../datastore/SimpleShardDataTreeCohort.java | 32 +-
.../datastore/SingleCommitCohortProxy.java | 2 +-
.../cluster/datastore/TerminationMonitor.java | 8 +-
.../ThreePhaseCommitCohortProxy.java | 52 +-
.../datastore/TransactionChainProxy.java | 49 +-
.../cluster/datastore/TransactionContext.java | 7 +-
.../datastore/TransactionContextFactory.java | 6 +-
.../datastore/TransactionContextWrapper.java | 11 +-
.../datastore/TransactionOperation.java | 2 +-
.../cluster/datastore/TransactionProxy.java | 61 +--
.../TransactionRateLimitingCallback.java | 12 +-
.../TransactionReadyReplyMapper.java | 3 +-
.../datastore/config/Configuration.java | 8 +-
.../datastore/config/ConfigurationImpl.java | 46 +-
.../config/FileModuleShardConfigProvider.java | 26 +-
.../datastore/config/ModuleConfig.java | 20 +-
.../LocalShardNotFoundException.java | 2 +-
.../exceptions/NotInitializedException.java | 1 +
.../exceptions/PrimaryNotFoundException.java | 3 +-
.../exceptions/TimeoutException.java | 5 +-
.../identifiers/ShardIdentifier.java | 24 +-
.../identifiers/ShardManagerIdentifier.java | 16 +-
.../jmx/mbeans/shard/ShardMBeanFactory.java | 3 +-
.../jmx/mbeans/shard/ShardStats.java | 23 +-
.../jmx/mbeans/shard/ShardStatsMXBean.java | 78 +--
.../datastore/messages/AbortTransaction.java | 2 +-
.../datastore/messages/AddShardReplica.java | 8 +-
...seDataChangeListenerRegistrationReply.java | 3 +-
...oseDataTreeChangeListenerRegistration.java | 3 +-
...taTreeChangeListenerRegistrationReply.java | 3 +-
.../messages/CloseTransactionChain.java | 5 +-
.../datastore/messages/DataChanged.java | 20 +-
.../datastore/messages/DataExists.java | 7 +-
.../datastore/messages/FindLocalShard.java | 5 +-
.../datastore/messages/FindPrimary.java | 3 +-
.../datastore/messages/LocalShardFound.java | 5 +-
.../messages/LocalShardNotFound.java | 6 +-
.../cluster/datastore/messages/ReadData.java | 7 +-
.../RegisterDataTreeChangeListener.java | 4 +-
.../messages/RemoveShardReplica.java | 4 +-
.../messages/UpdateSchemaContext.java | 14 +-
.../VersionedExternalizableMessage.java | 5 +-
.../modification/AbstractModification.java | 2 +-
.../modification/CompositeModification.java | 5 +-
.../modification/DeleteModification.java | 2 +-
.../modification/MergeModification.java | 2 +-
.../datastore/modification/Modification.java | 13 +-
.../MutableCompositeModification.java | 42 +-
.../modification/WriteModification.java | 12 +-
.../persisted/AbortTransactionPayload.java | 3 +
.../AbstractIdentifiablePayload.java | 15 +-
...bstractVersionedShardDataTreeSnapshot.java | 12 +-
.../persisted/CommitTransactionPayload.java | 3 +
.../DataTreeCandidateInputOutput.java | 148 +++---
.../DeletedDataTreeCandidateNode.java | 2 +-
...FrontendShardDataTreeSnapshotMetadata.java | 3 +
.../MetadataShardDataTreeSnapshot.java | 10 +-
.../ModifiedDataTreeCandidateNode.java | 8 +-
.../datastore/persisted/PayloadVersion.java | 19 +-
.../ShardDataTreeSnapshotMetadata.java | 9 +-
.../AbstractShardManagerCreator.java | 26 +-
.../shardmanager/ShardInformation.java | 48 +-
.../datastore/shardmanager/ShardManager.java | 488 +++++++++---------
.../ShardManagerGetSnapshotReplyActor.java | 16 +-
.../shardmanager/ShardManagerInfo.java | 3 +-
.../shardmanager/ShardManagerInfoMBean.java | 28 +-
.../shardmanager/ShardManagerSnapshot.java | 4 +-
.../ShardPeerAddressResolver.java | 8 +-
.../shardstrategy/DefaultShardStrategy.java | 6 +-
.../shardstrategy/ModuleShardStrategy.java | 2 +-
.../shardstrategy/ShardStrategy.java | 22 +-
.../shardstrategy/ShardStrategyFactory.java | 2 +-
.../cluster/datastore/utils/ActorContext.java | 130 ++---
.../utils/DataTreeModificationOutput.java | 9 +-
.../cluster/datastore/utils/Dispatchers.java | 17 +-
.../utils/NormalizedNodeAggregator.java | 18 +-
.../utils/NormalizedNodeXMLOutput.java | 8 +-
.../utils/PruningDataTreeModification.java | 22 +-
.../datastore/utils/SerializationUtils.java | 46 +-
.../utils/TransactionRateLimiter.java | 36 +-
.../impl/ActorSystemProviderImpl.java | 16 +-
.../impl/ActorSystemProviderModule.java | 7 +-
.../ActorSystemProviderModuleFactory.java | 9 +-
.../DomConcurrentDataBrokerModule.java | 8 +-
.../DomConcurrentDataBrokerModuleFactory.java | 3 +-
...tributedConfigDataStoreProviderModule.java | 27 +-
...dConfigDataStoreProviderModuleFactory.java | 23 +-
...tedOperationalDataStoreProviderModule.java | 34 +-
...ationalDataStoreProviderModuleFactory.java | 22 +-
.../ForwardingDistributedDataStore.java | 4 +-
165 files changed, 1677 insertions(+), 1569 deletions(-)
rename opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/{ShardTransactionFactory.java => ShardTransactionActorFactory.java} (80%)
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
index 52837183b5..45b82ddec5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
@@ -9,6 +9,7 @@
package org.opendaylight.controller.cluster.databroker;
import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.EnumMap;
@@ -53,13 +54,15 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory
}
if (treeChange) {
- extensions = ImmutableMap., DOMDataBrokerExtension>of(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
+ extensions = ImmutableMap.of(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
@Override
- public ListenerRegistration registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) {
+ public ListenerRegistration registerDataTreeChangeListener(
+ final DOMDataTreeIdentifier treeId, final L listener) {
DOMStore publisher = getTxFactories().get(treeId.getDatastoreType());
checkState(publisher != null, "Requested logical data store is not available.");
- return ((DOMStoreTreeChangePublisher) publisher).registerTreeChangeListener(treeId.getRootIdentifier(), listener);
+ return ((DOMStoreTreeChangePublisher) publisher).registerTreeChangeListener(
+ treeId.getRootIdentifier(), listener);
}
});
} else {
@@ -72,6 +75,7 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
super.close();
@@ -91,8 +95,8 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory
@Override
public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store,
- final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
-
+ final YangInstanceIdentifier path, final DOMDataChangeListener listener,
+ final DataChangeScope triggeringScope) {
DOMStore potentialStore = getTxFactories().get(store);
checkState(potentialStore != null, "Requested logical data store is not available.");
return potentialStore.registerChangeListener(path, listener, triggeringScope);
@@ -107,7 +111,8 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory
public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
checkNotClosed();
- final Map backingChains = new EnumMap<>(LogicalDatastoreType.class);
+ final Map backingChains =
+ new EnumMap<>(LogicalDatastoreType.class);
for (Map.Entry entry : getTxFactories().entrySet()) {
backingChains.put(entry.getKey(), entry.getValue().createTransactionChain());
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java
index 0570e72860..d033785588 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java
@@ -22,28 +22,28 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public abstract class AbstractDOMBrokerTransaction implements
AsyncTransaction> {
- private EnumMap backingTxs;
+ private final EnumMap backingTxs;
private final Object identifier;
private final Map storeTxFactories;
/**
- *
* Creates new composite Transactions.
*
- * @param identifier
- * Identifier of transaction.
+ * @param identifier Identifier of transaction.
*/
- protected AbstractDOMBrokerTransaction(final Object identifier, Map storeTxFactories) {
+ protected AbstractDOMBrokerTransaction(final Object identifier,
+ Map storeTxFactories) {
this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null");
- this.storeTxFactories = Preconditions.checkNotNull(storeTxFactories, "Store Transaction Factories should not be null");
+ this.storeTxFactories = Preconditions.checkNotNull(storeTxFactories,
+ "Store Transaction Factories should not be null");
this.backingTxs = new EnumMap<>(LogicalDatastoreType.class);
}
/**
* Returns subtransaction associated with supplied key.
*
- * @param key
- * @return
+ * @param key the data store type key
+ * @return the subtransaction
* @throws NullPointerException
* if key is null
* @throws IllegalArgumentException
@@ -53,7 +53,7 @@ public abstract class AbstractDOMBrokerTransaction implements DOMDataWriteTransaction {
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater IMPL_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class, AbstractDOMTransactionFactory.class, "commitImpl");
+ private static final AtomicReferenceFieldUpdater
+ IMPL_UPDATER = AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class,
+ AbstractDOMTransactionFactory.class, "commitImpl");
@SuppressWarnings("rawtypes")
private static final AtomicReferenceFieldUpdater FUTURE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class, Future.class, "commitFuture");
+ AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class, Future.class,
+ "commitFuture");
private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBrokerWriteTransaction.class);
private static final Future> CANCELLED_FUTURE = Futures.immediateCancelledFuture();
@@ -55,7 +57,7 @@ public abstract class AbstractDOMBrokerWriteTransaction
* Lazy set is safe for use because it is only referenced to in the
* {@link #cancel()} slow path, where we will busy-wait for it. The
* fast path gets the benefit of a store-store barrier instead of the
@@ -64,13 +66,15 @@ public abstract class AbstractDOMBrokerWriteTransaction commitFuture;
protected AbstractDOMBrokerWriteTransaction(final Object identifier,
- final Map storeTxFactories, final AbstractDOMTransactionFactory> commitImpl) {
+ final Map storeTxFactories,
+ final AbstractDOMTransactionFactory> commitImpl) {
super(identifier, storeTxFactories);
this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
}
@Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode, ?> data) {
+ public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode, ?> data) {
checkRunning(commitImpl);
checkInstanceIdentifierReferencesData(path,data);
getSubtransaction(store).write(path, data);
@@ -80,7 +84,7 @@ public abstract class AbstractDOMBrokerWriteTransaction data) {
final PathArgument lastArg = path.getLastPathArgument();
Preconditions.checkArgument(
- (lastArg == data.getIdentifier()) || (lastArg != null && lastArg.equals(data.getIdentifier())),
+ lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
"Instance identifier references %s but data identifier is %s", lastArg, data);
}
@@ -91,7 +95,8 @@ public abstract class AbstractDOMBrokerWriteTransaction data) {
+ public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode, ?> data) {
checkRunning(commitImpl);
checkInstanceIdentifierReferencesData(path, data);
getSubtransaction(store).merge(path, data);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java
index c251095176..43db918156 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java
@@ -35,24 +35,26 @@ public abstract class AbstractDOMTransactionFactory submit(final DOMDataWriteTransaction transaction,
- final Collection cohorts);
+ protected abstract CheckedFuture submit(DOMDataWriteTransaction transaction,
+ Collection cohorts);
/**
+ * Creates a new read-only transaction.
*
- * @return
+ * @return the transaction instance
*/
public final DOMDataReadOnlyTransaction newReadOnlyTransaction() {
checkNotClosed();
@@ -62,8 +64,9 @@ public abstract class AbstractDOMTransactionFactory datastores, Executor listenableFutureExecutor) {
+ public ConcurrentDOMDataBroker(final Map datastores,
+ Executor listenableFutureExecutor) {
this(datastores, listenableFutureExecutor, DurationStatisticsTracker.createConcurrent());
}
- public ConcurrentDOMDataBroker(final Map datastores, Executor listenableFutureExecutor,
- DurationStatisticsTracker commitStatsTracker) {
+ public ConcurrentDOMDataBroker(final Map datastores,
+ Executor listenableFutureExecutor, DurationStatisticsTracker commitStatsTracker) {
super(datastores);
this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
this.commitStatsTracker = Preconditions.checkNotNull(commitStatsTracker);
@@ -82,7 +83,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
- if(cohorts.isEmpty()){
+ if (cohorts.isEmpty()) {
return Futures.immediateCheckedFuture(null);
}
@@ -113,7 +114,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
new TransactionCommitFailedException(
"Can Commit failed, no detailed cause available."));
} else {
- if(!cohortIterator.hasNext()) {
+ if (!cohortIterator.hasNext()) {
// All cohorts completed successfully - we can move on to the preCommit phase
doPreCommit(startTime, clientSubmitFuture, transaction, cohorts);
} else {
@@ -124,9 +125,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Throwable failure) {
handleException(clientSubmitFuture, transaction, cohorts, CAN_COMMIT,
- TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER, t);
+ TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER, failure);
}
};
@@ -144,7 +145,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
FutureCallback futureCallback = new FutureCallback() {
@Override
public void onSuccess(Void notUsed) {
- if(!cohortIterator.hasNext()) {
+ if (!cohortIterator.hasNext()) {
// All cohorts completed successfully - we can move on to the commit phase
doCommit(startTime, clientSubmitFuture, transaction, cohorts);
} else {
@@ -154,9 +155,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Throwable failure) {
handleException(clientSubmitFuture, transaction, cohorts, PRE_COMMIT,
- TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER, t);
+ TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER, failure);
}
};
@@ -174,7 +175,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
FutureCallback futureCallback = new FutureCallback() {
@Override
public void onSuccess(Void notUsed) {
- if(!cohortIterator.hasNext()) {
+ if (!cohortIterator.hasNext()) {
// All cohorts completed successfully - we're done.
commitStatsTracker.addDuration(System.nanoTime() - startTime);
@@ -186,9 +187,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Throwable throwable) {
handleException(clientSubmitFuture, transaction, cohorts, COMMIT,
- TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER, t);
+ TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER, throwable);
}
};
@@ -200,21 +201,21 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
final DOMDataWriteTransaction transaction,
final Collection cohorts,
final String phase, final TransactionCommitFailedExceptionMapper exMapper,
- final Throwable t) {
+ final Throwable throwable) {
if (clientSubmitFuture.isDone()) {
// We must have had failures from multiple cohorts.
return;
}
- LOG.warn("Tx: {} Error during phase {}, starting Abort", transaction.getIdentifier(), phase, t);
+ LOG.warn("Tx: {} Error during phase {}, starting Abort", transaction.getIdentifier(), phase, throwable);
final Exception e;
- if(t instanceof NoShardLeaderException || t instanceof ShardLeaderNotRespondingException) {
- e = new DataStoreUnavailableException(t.getMessage(), t);
- } else if (t instanceof Exception) {
- e = (Exception)t;
+ if (throwable instanceof NoShardLeaderException || throwable instanceof ShardLeaderNotRespondingException) {
+ e = new DataStoreUnavailableException(throwable.getMessage(), throwable);
+ } else if (throwable instanceof Exception) {
+ e = (Exception)throwable;
} else {
- e = new RuntimeException("Unexpected error occurred", t);
+ e = new RuntimeException("Unexpected error occurred", throwable);
}
final TransactionCommitFailedException clientException = exMapper.apply(e);
@@ -223,9 +224,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
@SuppressWarnings("unchecked")
ListenableFuture[] canCommitFutures = new ListenableFuture[cohorts.size()];
- int i = 0;
+ int index = 0;
for (DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- canCommitFutures[i++] = cohort.abort();
+ canCommitFutures[index++] = cohort.abort();
}
ListenableFuture> combinedFuture = Futures.allAsList(canCommitFutures);
@@ -237,8 +238,8 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
}
@Override
- public void onFailure(Throwable t) {
- LOG.error("Tx: {} Error during Abort.", transaction.getIdentifier(), t);
+ public void onFailure(Throwable failure) {
+ LOG.error("Tx: {} Error during Abort.", transaction.getIdentifier(), failure);
// Propagate the original exception as that is what caused the Tx to fail and is
// what's interesting to the client.
@@ -254,7 +255,6 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
* the thread that completed this future, as a common use case is to pass an executor that runs
* tasks in the same thread as the caller (ie MoreExecutors#sameThreadExecutor)
* to {@link #addListener}.
- *
* FIXME: This class should probably be moved to yangtools common utils for re-usability and
* unified with AsyncNotifyingListenableFutureTask.
*/
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java
index 64d79cb637..3575731511 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java
@@ -27,7 +27,8 @@ public class DOMBrokerReadOnlyTransaction
*
* @param identifier Identifier of transaction.
*/
- protected DOMBrokerReadOnlyTransaction(Object identifier, Map storeTxFactories) {
+ protected DOMBrokerReadOnlyTransaction(Object identifier,
+ Map storeTxFactories) {
super(identifier, storeTxFactories);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
index 58dcedce62..a2693a6171 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
@@ -21,13 +21,16 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public class DOMBrokerReadWriteTransaction
extends AbstractDOMBrokerWriteTransaction implements DOMDataReadWriteTransaction {
+
/**
- * Creates new composite Transactions.
+ * Constructs an instance.
*
- * @param identifier Identifier of transaction.
- * @param storeTxFactories
+ * @param identifier identifier of transaction.
+ * @param storeTxFactories the backing transaction store factories
*/
- protected DOMBrokerReadWriteTransaction(Object identifier, Map storeTxFactories, final AbstractDOMTransactionFactory> commitImpl) {
+ protected DOMBrokerReadWriteTransaction(Object identifier,
+ Map storeTxFactories,
+ final AbstractDOMTransactionFactory> commitImpl) {
super(identifier, storeTxFactories, commitImpl);
}
@@ -48,6 +51,4 @@ public class DOMBrokerReadWriteTransaction
protected DOMStoreReadWriteTransaction createTransaction(LogicalDatastoreType key) {
return getTxFactory(key).newReadWriteTransaction();
}
-
-
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java
index aef9f0d47f..4bc22e4643 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java
@@ -50,6 +50,7 @@ final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory chains,
- AbstractDOMBroker broker, final TransactionChainListener listener) {
+ DOMBrokerTransactionChain(final long chainId, final Map chains,
+ AbstractDOMBroker broker, final TransactionChainListener listener) {
super(chains);
this.chainId = chainId;
this.broker = Preconditions.checkNotNull(broker);
@@ -94,8 +94,8 @@ final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory {
+
/**
- * Creates new composite Transactions.
+ * Constructs an instance.
*
- * @param identifier
- * Identifier of transaction.
- * @param storeTxFactories
+ * @param identifier identifier of transaction.
+ * @param storeTxFactories the backing transaction store factories
*/
public DOMBrokerWriteOnlyTransaction(Object identifier,
Map storeTxFactories,
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadTransaction.java
index cadb61a460..1badccb862 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadTransaction.java
@@ -33,7 +33,8 @@ class ShardedDOMStoreReadTransaction extends AbstractShardedTransaction implemen
}
@Override
- public final CheckedFuture>, ReadFailedException> read(final YangInstanceIdentifier path) {
+ public final CheckedFuture>, ReadFailedException> read(
+ final YangInstanceIdentifier path) {
return transaction().read(path);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadWriteTransaction.java
index 7172770f77..55139d3440 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadWriteTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreReadWriteTransaction.java
@@ -19,8 +19,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*
* @author Robert Varga
*/
-final class ShardedDOMStoreReadWriteTransaction extends ShardedDOMStoreReadTransaction implements DOMStoreReadWriteTransaction {
-
+final class ShardedDOMStoreReadWriteTransaction extends ShardedDOMStoreReadTransaction
+ implements DOMStoreReadWriteTransaction {
ShardedDOMStoreReadWriteTransaction(final ClientTransaction tx) {
super(tx);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreWriteTransaction.java
index 6161620583..4c804d762b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreWriteTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ShardedDOMStoreWriteTransaction.java
@@ -45,7 +45,7 @@ final class ShardedDOMStoreWriteTransaction extends AbstractShardedTransaction i
}
@Override
- public final void close() {
+ public void close() {
transaction().abort();
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataListenerSupport.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataListenerSupport.java
index a253b794db..f23f9567a7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataListenerSupport.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataListenerSupport.java
@@ -21,9 +21,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-abstract class AbstractDataListenerSupport, LR extends ListenerRegistration>
- extends LeaderLocalDelegateFactory> {
+abstract class AbstractDataListenerSupport, R extends ListenerRegistration>
+ extends LeaderLocalDelegateFactory> {
private final Logger log = LoggerFactory.getLogger(getClass());
private final ArrayList delayedListenerRegistrations = new ArrayList<>();
@@ -39,12 +39,12 @@ abstract class AbstractDataListenerSupport registration;
- if((hasLeader && message.isRegisterOnAllInstances()) || isLeader) {
- final Entry> res = createDelegate(message);
+ if (hasLeader && message.isRegisterOnAllInstances() || isLeader) {
+ final Entry> res = createDelegate(message);
registration = res.getKey();
} else {
log.debug("{}: Shard is not the leader - delaying registration", persistenceId());
D delayedReg = newDelayedListenerRegistration(message);
- if(message.isRegisterOnAllInstances()) {
+ if (message.isRegisterOnAllInstances()) {
delayedListenerOnAllRegistrations.add(delayedReg);
} else {
delayedListenerRegistrations.add(delayedReg);
@@ -99,7 +99,7 @@ abstract class AbstractDataListenerSupport registration);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java
index 61a22d4c2c..b7356d28bc 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java
@@ -23,7 +23,8 @@ import org.slf4j.LoggerFactory;
*/
@NotThreadSafe
abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements ShardDataTreeNotificationPublisher {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractShardDataTreeNotificationPublisherActorProxy.class);
+ private static final Logger LOG = LoggerFactory.getLogger(
+ AbstractShardDataTreeNotificationPublisherActorProxy.class);
private final ActorContext actorContext;
private final String actorName;
@@ -50,14 +51,15 @@ abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements S
}
private ActorRef getNotifierActor() {
- if(notifierActor == null) {
+ if (notifierActor == null) {
LOG.debug("Creating actor {}", actorName);
String dispatcher = new Dispatchers(actorContext.system().dispatchers()).getDispatcherPath(
Dispatchers.DispatcherType.Notification);
notifierActor = actorContext.actorOf(ShardDataTreeNotificationPublisherActor.props(actorName)
.withDispatcher(dispatcher).withMailbox(
- org.opendaylight.controller.cluster.datastore.utils.ActorContext.BOUNDED_MAILBOX), actorName);
+ org.opendaylight.controller.cluster.datastore.utils.ActorContext.BOUNDED_MAILBOX),
+ actorName);
}
return notifierActor;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java
index 377af4d5d7..f7f8af2923 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java
@@ -57,7 +57,8 @@ abstract class AbstractShardDataTreeTransaction {
@Override
public final String toString() {
- return MoreObjects.toStringHelper(this).add("id", id).add("closed", closed).add("snapshot", snapshot).toString();
+ return MoreObjects.toStringHelper(this).add("id", id).add("closed", closed).add("snapshot", snapshot)
+ .toString();
}
abstract void abort();
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContext.java
index 057dbfa56a..6c4fc6097d 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContext.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContext.java
@@ -50,7 +50,7 @@ abstract class AbstractTransactionContext implements TransactionContext {
handOffComplete = true;
}
- protected boolean isOperationHandOffComplete(){
+ protected boolean isOperationHandOffComplete() {
return handOffComplete;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java
index b5afd596bf..69c69bb84b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java
@@ -62,7 +62,9 @@ abstract class AbstractTransactionContextFactory findPrimaryFuture = findPrimaryShard(shardName, parent.getIdentifier());
- if(findPrimaryFuture.isCompleted()) {
+ if (findPrimaryFuture.isCompleted()) {
Try maybe = findPrimaryFuture.value().get();
- if(maybe.isSuccess()) {
+ if (maybe.isSuccess()) {
onFindPrimaryShardSuccess(maybe.get(), parent, shardName, transactionContextWrapper);
} else {
onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, transactionContextWrapper);
@@ -144,13 +145,13 @@ abstract class AbstractTransactionContextFactory maybeDataTree = primaryShardInfo.getLocalShardDataTree();
if (maybeDataTree.isPresent()) {
- if(!knownLocal.containsKey(shardName)) {
+ if (!knownLocal.containsKey(shardName)) {
LOG.debug("Shard {} resolved to local data tree - adding local factory", shardName);
F factory = factoryForShard(shardName, primaryShardInfo.getPrimaryShardActor(), maybeDataTree.get());
knownLocal.putIfAbsent(shardName, factory);
}
- } else if(knownLocal.containsKey(shardName)) {
+ } else if (knownLocal.containsKey(shardName)) {
LOG.debug("Shard {} invalidating local data tree", shardName);
knownLocal.remove(shardName);
@@ -183,8 +184,8 @@ abstract class AbstractTransactionContextFactory void onTransactionReady(@Nonnull TransactionIdentifier transaction, @Nonnull Collection> cohortFutures);
+ protected abstract void onTransactionReady(@Nonnull TransactionIdentifier transaction,
+ @Nonnull Collection> cohortFutures);
/**
* Callback invoked when the internal TransactionContext has been created for a transaction.
@@ -208,7 +210,7 @@ abstract class AbstractTransactionContextFactory 0,
- "No akka roles were specified\n" +
- "One way to specify the member name is to pass a property on the command line like so\n" +
- " -Dakka.cluster.roles.0=member-3\n" +
- "member-3 here would be the name of the member"
- );
+ "No akka roles were specified.\n"
+ + "One way to specify the member name is to pass a property on the command line like so\n"
+ + " -Dakka.cluster.roles.0=member-3\n"
+ + "member-3 here would be the name of the member");
currentMemberName = MemberName.forName(cluster.getSelfRoles().iterator().next());
selfAddress = cluster.selfAddress();
}
@Override
- public void subscribeToMemberEvents(ActorRef actorRef){
+ public void subscribeToMemberEvents(ActorRef actorRef) {
Preconditions.checkNotNull(actorRef, "actorRef should not be null");
cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(),
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java
index 767749af29..f585bb66c3 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java
@@ -80,16 +80,17 @@ final class CohortEntry {
return lastBatchedModificationsException;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
void applyModifications(final Iterable modifications) {
totalBatchedModificationsReceived++;
- if(lastBatchedModificationsException == null) {
+ if (lastBatchedModificationsException == null) {
for (Modification modification : modifications) {
- try {
- modification.apply(transaction.getSnapshot());
- } catch (RuntimeException e) {
- lastBatchedModificationsException = e;
- throw e;
- }
+ try {
+ modification.apply(transaction.getSnapshot());
+ } catch (RuntimeException e) {
+ lastBatchedModificationsException = e;
+ throw e;
+ }
}
}
}
@@ -115,7 +116,7 @@ final class CohortEntry {
cohort = transaction.ready();
- if(cohortDecorator != null) {
+ if (cohortDecorator != null) {
// Call the hook for unit tests.
cohort = cohortDecorator.decorate(transactionID, cohort);
}
@@ -152,4 +153,4 @@ final class CohortEntry {
.append(doImmediateCommit).append("]");
return builder.toString();
}
-}
\ No newline at end of file
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
index 8115473a05..05b9981113 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
@@ -13,7 +13,6 @@ import akka.actor.Status.Failure;
import akka.dispatch.ExecutionContexts;
import akka.dispatch.Futures;
import akka.dispatch.Recover;
-import akka.japi.Function;
import akka.pattern.Patterns;
import akka.util.Timeout;
import com.google.common.base.Preconditions;
@@ -33,9 +32,8 @@ import scala.concurrent.Await;
import scala.concurrent.Future;
/**
- *
* Composite cohort, which coordinates multiple user-provided cohorts as if it was only one cohort.
- *
+ *
* It tracks current operation and list of cohorts which successfuly finished previous phase in
* case, if abort is necessary to invoke it only on cohort steps which are still active.
*
@@ -73,13 +71,10 @@ class CompositeDataTreeCohort {
COMMITED,
/**
* Some of cohorts responsed back with unsuccessful message.
- *
*/
FAILED,
/**
- *
* Abort message was send to all cohorts which responded with success previously.
- *
*/
ABORTED
}
@@ -110,14 +105,9 @@ class CompositeDataTreeCohort {
void canCommit(final DataTreeCandidate tip) throws ExecutionException, TimeoutException {
Collection messages = registry.createCanCommitMessages(txId, tip, schema);
// FIXME: Optimize empty collection list with pre-created futures, containing success.
- Future> canCommitsFuture =
- Futures.traverse(messages, new Function>() {
- @Override
- public Future
*/
public class Shard extends RaftActor {
@@ -147,7 +146,7 @@ public class Shard extends RaftActor {
new ShardDataTreeChangeListenerPublisherActorProxy(getContext(), name + "-DTCL-publisher");
ShardDataChangeListenerPublisherActorProxy dataChangeListenerPublisher =
new ShardDataChangeListenerPublisherActorProxy(getContext(), name + "-DCL-publisher");
- if(builder.getDataTree() != null) {
+ if (builder.getDataTree() != null) {
store = new ShardDataTree(this, builder.getSchemaContext(), builder.getDataTree(),
treeChangeListenerPublisher, dataChangeListenerPublisher, name);
} else {
@@ -262,16 +261,16 @@ public class Shard extends RaftActor {
commitCoordinator.checkForExpiredTransactions(transactionCommitTimeout, this);
} else if (message instanceof DatastoreContext) {
onDatastoreContext((DatastoreContext)message);
- } else if (message instanceof RegisterRoleChangeListener){
+ } else if (message instanceof RegisterRoleChangeListener) {
roleChangeNotifier.get().forward(message, context());
} else if (message instanceof FollowerInitialSyncUpStatus) {
shardMBean.setFollowerInitialSyncStatus(((FollowerInitialSyncUpStatus) message).isInitialSyncDone());
context().parent().tell(message, self());
- } else if (GET_SHARD_MBEAN_MESSAGE.equals(message)){
+ } else if (GET_SHARD_MBEAN_MESSAGE.equals(message)) {
sender().tell(getShardMBean(), self());
} else if (message instanceof GetShardDataTree) {
sender().tell(store.getDataTree(), self());
- } else if (message instanceof ServerRemoved){
+ } else if (message instanceof ServerRemoved) {
context().parent().forward(message, context());
} else if (ShardTransactionMessageRetrySupport.TIMER_MESSAGE_CLASS.isInstance(message)) {
messageRetrySupport.onTimerMessage(message);
@@ -302,7 +301,8 @@ public class Shard extends RaftActor {
}
@Override
- protected LeaderStateChanged newLeaderStateChanged(final String memberId, final String leaderId, final short leaderPayloadVersion) {
+ protected LeaderStateChanged newLeaderStateChanged(final String memberId, final String leaderId,
+ final short leaderPayloadVersion) {
return isLeader() ? new ShardLeaderStateChanged(memberId, leaderId, store.getDataTree(), leaderPayloadVersion)
: new ShardLeaderStateChanged(memberId, leaderId, leaderPayloadVersion);
}
@@ -348,7 +348,7 @@ public class Shard extends RaftActor {
LOG.debug("{}: Can committing transaction {}", persistenceId(), canCommit.getTransactionID());
if (isLeader()) {
- commitCoordinator.handleCanCommit(canCommit.getTransactionID(), getSender(), this);
+ commitCoordinator.handleCanCommit(canCommit.getTransactionID(), getSender(), this);
} else {
ActorSelection leader = getLeader();
if (leader == null) {
@@ -361,6 +361,7 @@ public class Shard extends RaftActor {
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
protected void handleBatchedModificationsLocal(final BatchedModifications batched, final ActorRef sender) {
try {
commitCoordinator.handleBatchedModifications(batched, sender, this);
@@ -397,8 +398,9 @@ public class Shard extends RaftActor {
// we need to reconstruct previous BatchedModifications from the transaction
// DataTreeModification, honoring the max batched modification count, and forward all the
// previous BatchedModifications to the new leader.
- Collection newModifications = commitCoordinator.createForwardedBatchedModifications(
- batched, datastoreContext.getShardBatchedModificationCount());
+ Collection newModifications = commitCoordinator
+ .createForwardedBatchedModifications(batched,
+ datastoreContext.getShardBatchedModificationCount());
LOG.debug("{}: Forwarding {} BatchedModifications to leader {}", persistenceId(),
newModifications.size(), leader);
@@ -413,8 +415,8 @@ public class Shard extends RaftActor {
private boolean failIfIsolatedLeader(final ActorRef sender) {
if (isIsolatedLeader()) {
sender.tell(new akka.actor.Status.Failure(new NoShardLeaderException(String.format(
- "Shard %s was the leader but has lost contact with all of its followers. Either all" +
- " other follower nodes are down or this node is isolated by a network partition.",
+ "Shard %s was the leader but has lost contact with all of its followers. Either all"
+ + " other follower nodes are down or this node is isolated by a network partition.",
persistenceId()))), getSelf());
return true;
}
@@ -426,6 +428,7 @@ public class Shard extends RaftActor {
return getRaftState() == RaftState.IsolatedLeader;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void handleReadyLocalTransaction(final ReadyLocalTransaction message) {
LOG.debug("{}: handleReadyLocalTransaction for {}", persistenceId(), message.getTransactionID());
@@ -496,10 +499,11 @@ public class Shard extends RaftActor {
store.closeTransactionChain(closeTransactionChain.getIdentifier());
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void createTransaction(final CreateTransaction createTransaction) {
try {
- if (TransactionType.fromInt(createTransaction.getTransactionType()) != TransactionType.READ_ONLY &&
- failIfIsolatedLeader(getSender())) {
+ if (TransactionType.fromInt(createTransaction.getTransactionType()) != TransactionType.READ_ONLY
+ && failIfIsolatedLeader(getSender())) {
return;
}
@@ -621,9 +625,8 @@ public class Shard extends RaftActor {
}
}
} else {
- commitCoordinator.abortPendingTransactions(
- "The transacton was aborted due to inflight leadership change and the leader address isn't available.",
- this);
+ commitCoordinator.abortPendingTransactions("The transacton was aborted due to inflight leadership "
+ + "change and the leader address isn't available.", this);
}
}
@@ -638,7 +641,8 @@ public class Shard extends RaftActor {
* @return the converted messages
*/
public Collection> convertPendingTransactionsToMessages() {
- return commitCoordinator.convertPendingTransactionsToMessages(datastoreContext.getShardBatchedModificationCount());
+ return commitCoordinator.convertPendingTransactionsToMessages(
+ datastoreContext.getShardBatchedModificationCount());
}
@Override
@@ -675,7 +679,7 @@ public class Shard extends RaftActor {
return new Builder();
}
- public static abstract class AbstractBuilder, S extends Shard> {
+ public abstract static class AbstractBuilder, S extends Shard> {
private final Class shardClass;
private ShardIdentifier id;
private Map peerAddresses = Collections.emptyMap();
@@ -698,39 +702,39 @@ public class Shard extends RaftActor {
return (T) this;
}
- public T id(final ShardIdentifier id) {
+ public T id(final ShardIdentifier newId) {
checkSealed();
- this.id = id;
+ this.id = newId;
return self();
}
- public T peerAddresses(final Map peerAddresses) {
+ public T peerAddresses(final Map newPeerAddresses) {
checkSealed();
- this.peerAddresses = peerAddresses;
+ this.peerAddresses = newPeerAddresses;
return self();
}
- public T datastoreContext(final DatastoreContext datastoreContext) {
+ public T datastoreContext(final DatastoreContext newDatastoreContext) {
checkSealed();
- this.datastoreContext = datastoreContext;
+ this.datastoreContext = newDatastoreContext;
return self();
}
- public T schemaContext(final SchemaContext schemaContext) {
+ public T schemaContext(final SchemaContext newSchemaContext) {
checkSealed();
- this.schemaContext = schemaContext;
+ this.schemaContext = newSchemaContext;
return self();
}
- public T restoreFromSnapshot(final DatastoreSnapshot.ShardSnapshot restoreFromSnapshot) {
+ public T restoreFromSnapshot(final DatastoreSnapshot.ShardSnapshot newRestoreFromSnapshot) {
checkSealed();
- this.restoreFromSnapshot = restoreFromSnapshot;
+ this.restoreFromSnapshot = newRestoreFromSnapshot;
return self();
}
- public T dataTree(final TipProducingDataTree dataTree) {
+ public T dataTree(final TipProducingDataTree newDataTree) {
checkSealed();
- this.dataTree = dataTree;
+ this.dataTree = newDataTree;
return self();
}
@@ -760,13 +764,14 @@ public class Shard extends RaftActor {
public TreeType getTreeType() {
switch (datastoreContext.getLogicalStoreType()) {
- case CONFIGURATION:
- return TreeType.CONFIGURATION;
- case OPERATIONAL:
- return TreeType.OPERATIONAL;
+ case CONFIGURATION:
+ return TreeType.CONFIGURATION;
+ case OPERATIONAL:
+ return TreeType.OPERATIONAL;
+ default:
+ throw new IllegalStateException("Unhandled logical store type "
+ + datastoreContext.getLogicalStoreType());
}
-
- throw new IllegalStateException("Unhandled logical store type " + datastoreContext.getLogicalStoreType());
}
protected void verify() {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java
index b3feadcfb9..7e3cd02efb 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java
@@ -97,7 +97,6 @@ final class ShardCommitCoordinator {
* @param ready the ForwardedReadyTransaction message to process
* @param sender the sender of the message
* @param shard the transaction's shard actor
- * @param schema
*/
void handleForwardedReadyTransaction(final ForwardedReadyTransaction ready, final ActorRef sender,
final Shard shard) {
@@ -217,8 +216,8 @@ final class ShardCommitCoordinator {
cohortEntry.getTransaction().getSnapshot().applyToCursor(new AbstractBatchedModificationsCursor() {
@Override
protected BatchedModifications getModifications() {
- if (newModifications.isEmpty() ||
- newModifications.getLast().getModifications().size() >= maxModificationsPerBatch) {
+ if (newModifications.isEmpty()
+ || newModifications.getLast().getModifications().size() >= maxModificationsPerBatch) {
newModifications.add(new BatchedModifications(from.getTransactionID(), from.getVersion()));
}
@@ -249,12 +248,12 @@ final class ShardCommitCoordinator {
}
@Override
- public void onFailure(final Throwable t) {
+ public void onFailure(final Throwable failure) {
log.debug("{}: An exception occurred during canCommit for {}: {}", name,
- cohortEntry.getTransactionID(), t);
+ cohortEntry.getTransactionID(), failure);
cohortCache.remove(cohortEntry.getTransactionID());
- cohortEntry.getReplySender().tell(new Failure(t), cohortEntry.getShard().self());
+ cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self());
}
});
}
@@ -300,12 +299,12 @@ final class ShardCommitCoordinator {
}
@Override
- public void onFailure(final Throwable t) {
+ public void onFailure(final Throwable failure) {
log.error("{} An exception occurred while preCommitting transaction {}", name,
- cohortEntry.getTransactionID(), t);
+ cohortEntry.getTransactionID(), failure);
cohortCache.remove(cohortEntry.getTransactionID());
- cohortEntry.getReplySender().tell(new Failure(t), cohortEntry.getShard().self());
+ cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self());
}
});
}
@@ -326,12 +325,12 @@ final class ShardCommitCoordinator {
}
@Override
- public void onFailure(final Throwable t) {
+ public void onFailure(final Throwable failure) {
log.error("{}, An exception occurred while committing transaction {}", persistenceId(),
- cohortEntry.getTransactionID(), t);
+ cohortEntry.getTransactionID(), failure);
cohortCache.remove(cohortEntry.getTransactionID());
- sender.tell(new Failure(t), cohortEntry.getShard().self());
+ sender.tell(new Failure(failure), cohortEntry.getShard().self());
}
});
}
@@ -359,6 +358,7 @@ final class ShardCommitCoordinator {
doCommit(cohortEntry);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
void handleAbort(final Identifier transactionID, final ActorRef sender, final Shard shard) {
CohortEntry cohortEntry = cohortCache.remove(transactionID);
if (cohortEntry == null) {
@@ -389,7 +389,7 @@ final class ShardCommitCoordinator {
Iterator iter = cohortCache.values().iterator();
while (iter.hasNext()) {
CohortEntry cohortEntry = iter.next();
- if(cohortEntry.isFailed()) {
+ if (cohortEntry.isFailed()) {
iter.remove();
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangeListenerPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangeListenerPublisherActorProxy.java
index 0b898ede3c..e3c71830a8 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangeListenerPublisherActorProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangeListenerPublisherActorProxy.java
@@ -36,8 +36,9 @@ class ShardDataChangeListenerPublisherActorProxy extends AbstractShardDataTreeNo
}
@Override
- public >> DataChangeListenerRegistration registerDataChangeListener(
- YangInstanceIdentifier path, L listener, DataChangeScope scope) {
+ public >>
+ DataChangeListenerRegistration registerDataChangeListener(YangInstanceIdentifier path, L listener,
+ DataChangeScope scope) {
return delegatePublisher.registerDataChangeListener(path, listener, scope);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
index bf3b200825..5a7ce80ffd 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
@@ -76,7 +76,7 @@ import scala.concurrent.duration.Duration;
* Internal shard state, similar to a DOMStore, but optimized for use in the actor system,
* e.g. it does not expose public interfaces and assumes it is only ever called from a
* single thread.
- *
+ *
* This class is not part of the API contract and is subject to change at any time.
*/
@NotThreadSafe
@@ -146,9 +146,9 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
return schemaContext;
}
- void updateSchemaContext(final SchemaContext schemaContext) {
- dataTree.setSchemaContext(schemaContext);
- this.schemaContext = Preconditions.checkNotNull(schemaContext);
+ void updateSchemaContext(final SchemaContext newSchemaContext) {
+ dataTree.setSchemaContext(newSchemaContext);
+ this.schemaContext = Preconditions.checkNotNull(newSchemaContext);
}
/**
@@ -171,7 +171,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
return new MetadataShardDataTreeSnapshot(rootNode, metaBuilder.build());
}
- private void applySnapshot(final @Nonnull ShardDataTreeSnapshot snapshot,
+ private void applySnapshot(@Nonnull final ShardDataTreeSnapshot snapshot,
final UnaryOperator wrapper) throws DataValidationFailedException {
final Stopwatch elapsed = Stopwatch.createStarted();
@@ -215,6 +215,17 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
LOG.debug("{}: state snapshot applied in %s", logContext, elapsed);
}
+ /**
+ * Apply a snapshot coming from the leader. This method assumes the leader and follower SchemaContexts match and
+ * does not perform any pruning.
+ *
+ * @param snapshot Snapshot that needs to be applied
+ * @throws DataValidationFailedException when the snapshot fails to apply
+ */
+ void applySnapshot(@Nonnull final ShardDataTreeSnapshot snapshot) throws DataValidationFailedException {
+ applySnapshot(snapshot, UnaryOperator.identity());
+ }
+
private PruningDataTreeModification wrapWithPruning(final DataTreeModification delegate) {
return new PruningDataTreeModification(delegate, dataTree, schemaContext);
}
@@ -237,18 +248,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
applySnapshot(snapshot, this::wrapWithPruning);
}
-
- /**
- * Apply a snapshot coming from the leader. This method assumes the leader and follower SchemaContexts match and
- * does not perform any pruning.
- *
- * @param snapshot Snapshot that needs to be applied
- * @throws DataValidationFailedException when the snapshot fails to apply
- */
- void applySnapshot(final @Nonnull ShardDataTreeSnapshot snapshot) throws DataValidationFailedException {
- applySnapshot(snapshot, UnaryOperator.identity());
- }
-
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void applyRecoveryCandidate(final DataTreeCandidate candidate) throws DataValidationFailedException {
final PruningDataTreeModification mod = wrapWithPruning(dataTree.takeSnapshot().newModification());
DataTreeCandidates.applyToModification(mod, candidate);
@@ -280,7 +280,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
*/
void applyRecoveryPayload(final @Nonnull Payload payload) throws IOException, DataValidationFailedException {
if (payload instanceof CommitTransactionPayload) {
- final Entry e = ((CommitTransactionPayload) payload).getCandidate();
+ final Entry e =
+ ((CommitTransactionPayload) payload).getCandidate();
applyRecoveryCandidate(e.getValue());
allMetadataCommittedTransaction(e.getKey());
} else if (payload instanceof DataTreeCandidatePayload) {
@@ -330,7 +331,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
*/
if (payload instanceof CommitTransactionPayload) {
if (identifier == null) {
- final Entry e = ((CommitTransactionPayload) payload).getCandidate();
+ final Entry e =
+ ((CommitTransactionPayload) payload).getCandidate();
applyReplicatedCandidate(e.getKey(), e.getValue());
allMetadataCommittedTransaction(e.getKey());
} else {
@@ -437,22 +439,23 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
Optional> registerChangeListener(final YangInstanceIdentifier path,
final AsyncDataChangeListener> listener,
final DataChangeScope scope) {
- final DataChangeListenerRegistration>> reg =
+ DataChangeListenerRegistration>> reg =
dataChangeListenerPublisher.registerDataChangeListener(path, listener, scope);
return new SimpleEntry<>(reg, readCurrentData());
}
private Optional readCurrentData() {
- final Optional> currentState = dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY);
+ final Optional> currentState =
+ dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY);
return currentState.isPresent() ? Optional.of(DataTreeCandidates.fromNormalizedNode(
YangInstanceIdentifier.EMPTY, currentState.get())) : Optional.absent();
}
- public Entry, Optional> registerTreeChangeListener(
- final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener) {
- final ListenerRegistration reg = treeChangeListenerPublisher.registerTreeChangeListener(
- path, listener);
+ public Entry, Optional>
+ registerTreeChangeListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener) {
+ final ListenerRegistration reg =
+ treeChangeListenerPublisher.registerTreeChangeListener(path, listener);
return new SimpleEntry<>(reg, readCurrentData());
}
@@ -488,6 +491,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
}
/**
+ * Commits a modification.
+ *
* @deprecated This method violates DataTree containment and will be removed.
*/
@VisibleForTesting
@@ -502,7 +507,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
public Collection getAndClearPendingTransactions() {
Collection ret = new ArrayList<>(pendingTransactions.size());
- for(CommitEntry entry: pendingTransactions) {
+ for (CommitEntry entry: pendingTransactions) {
ret.add(entry.cohort);
}
@@ -510,13 +515,14 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
return ret;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void processNextTransaction() {
while (!pendingTransactions.isEmpty()) {
final CommitEntry entry = pendingTransactions.peek();
final SimpleShardDataTreeCohort cohort = entry.cohort;
final DataTreeModification modification = cohort.getDataTreeModification();
- if(cohort.getState() != State.CAN_COMMIT_PENDING) {
+ if (cohort.getState() != State.CAN_COMMIT_PENDING) {
break;
}
@@ -538,7 +544,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
// For debugging purposes, allow dumping of the modification. Coupled with the above
// precondition log, it should allow us to understand what went on.
- LOG.debug("{}: Store Tx {}: modifications: {} tree: {}", cohort.getIdentifier(), modification, dataTree);
+ LOG.debug("{}: Store Tx {}: modifications: {} tree: {}", cohort.getIdentifier(), modification,
+ dataTree);
cause = new TransactionCommitFailedException("Data did not pass validation.", e);
} catch (Exception e) {
LOG.warn("{}: Unexpected failure in validation phase", logContext, e);
@@ -568,6 +575,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
processNextTransaction();
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
void startPreCommit(final SimpleShardDataTreeCohort cohort) {
final CommitEntry entry = pendingTransactions.peek();
Preconditions.checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
@@ -599,6 +607,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
processNextTransaction();
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void finishCommit(final SimpleShardDataTreeCohort cohort) {
final TransactionIdentifier txId = cohort.getIdentifier();
final DataTreeCandidate candidate = cohort.getCandidate();
@@ -764,12 +773,12 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
}
private void maybeRunOperationOnPendingTransactionsComplete() {
- if (runOnPendingTransactionsComplete != null && pendingTransactions.isEmpty()) {
- LOG.debug("{}: Pending transactions complete - running operation {}", logContext,
- runOnPendingTransactionsComplete);
-
- runOnPendingTransactionsComplete.run();
- runOnPendingTransactionsComplete = null;
- }
- }
+ if (runOnPendingTransactionsComplete != null && pendingTransactions.isEmpty()) {
+ LOG.debug("{}: Pending transactions complete - running operation {}", logContext,
+ runOnPendingTransactionsComplete);
+
+ runOnPendingTransactionsComplete.run();
+ runOnPendingTransactionsComplete = null;
+ }
+ }
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java
index 2ac3ee8843..7196f839e4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java
@@ -23,7 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
implements ShardDataTreeChangeListenerPublisher {
- private final ShardDataTreeChangeListenerPublisher delegatePublisher = new DefaultShardDataTreeChangeListenerPublisher();
+ private final ShardDataTreeChangeListenerPublisher delegatePublisher =
+ new DefaultShardDataTreeChangeListenerPublisher();
ShardDataTreeChangeListenerPublisherActorProxy(ActorContext actorContext, String actorName) {
super(actorContext, actorName);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeMetadata.java
index d10a44d7ab..c0c3d6cbb0 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeMetadata.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeMetadata.java
@@ -31,6 +31,8 @@ abstract class ShardDataTreeMetadata>
// Lifecycle events
abstract void onTransactionCommitted(TransactionIdentifier txId);
+
abstract void onHistoryClosed(LocalHistoryIdentifier historyId);
+
abstract void onHistoryPurged(LocalHistoryIdentifier historyId);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
index 8102356280..76c52c9bb5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
@@ -29,7 +29,7 @@ public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActo
@Override
protected void handleReceive(Object message) {
- if(message instanceof PublishNotifications) {
+ if (message instanceof PublishNotifications) {
PublishNotifications publisher = (PublishNotifications)message;
timer.start();
@@ -38,7 +38,7 @@ public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActo
} finally {
long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS);
- if(elapsedTime >= ShardDataTreeNotificationPublisher.PUBLISH_DELAY_THRESHOLD_IN_MS) {
+ if (elapsedTime >= ShardDataTreeNotificationPublisher.PUBLISH_DELAY_THRESHOLD_IN_MS) {
LOG.warn("{}: Generation of change events for {} took longer than expected. Elapsed time: {}",
publisher.logContext, name, timer);
} else {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java
index eefebb6af8..004e305f70 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java
@@ -67,7 +67,8 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
@Override
protected void abortTransaction(final AbstractShardDataTreeTransaction> transaction) {
if (transaction instanceof ReadWriteShardDataTreeTransaction) {
- Preconditions.checkState(openTransaction != null, "Attempted to abort transaction %s while none is outstanding", transaction);
+ Preconditions.checkState(openTransaction != null,
+ "Attempted to abort transaction %s while none is outstanding", transaction);
LOG.debug("Aborted transaction {}", transaction);
openTransaction = null;
}
@@ -75,7 +76,8 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
@Override
protected ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) {
- Preconditions.checkState(openTransaction != null, "Attempted to finish transaction %s while none is outstanding", transaction);
+ Preconditions.checkState(openTransaction != null,
+ "Attempted to finish transaction %s while none is outstanding", transaction);
// dataTree is finalizing ready the transaction, we just record it for the next
// transaction in chain
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionParent.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionParent.java
index ee04aff515..26e17057a7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionParent.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionParent.java
@@ -9,5 +9,6 @@ package org.opendaylight.controller.cluster.datastore;
abstract class ShardDataTreeTransactionParent {
abstract void abortTransaction(AbstractShardDataTreeTransaction> transaction);
+
abstract ShardDataTreeCohort finishTransaction(ReadWriteShardDataTreeTransaction transaction);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
index 3eba622c84..3021080758 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
@@ -11,6 +11,8 @@ import java.io.Serializable;
import java.util.Set;
/**
+ * Manages shards.
+ *
* @deprecated This is a deprecated placeholder to keep its inner class present. It serves no other purpose.
*/
@Deprecated
@@ -25,7 +27,7 @@ public final class ShardManager {
private final Set modules;
- public SchemaContextModules(Set modules){
+ public SchemaContextModules(Set modules) {
this.modules = modules;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManagerSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManagerSnapshot.java
index 3e7274ce67..eb8c139903 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManagerSnapshot.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManagerSnapshot.java
@@ -16,7 +16,7 @@ import java.util.List;
import javax.annotation.Nonnull;
/**
- * Persisted data of the ShardManager
+ * Persisted data of the ShardManager.
*
* @deprecated Use {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot} instead.
* This class is scheduled for removal once persistence migration from Beryllium is no longer needed.
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java
index 7986886086..dfb0897b48 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java
@@ -15,8 +15,9 @@ import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
/**
+ * Actor for a shard read transaction.
+ *
* @author: syedbahm
- * Date: 8/6/14
*/
public class ShardReadTransaction extends ShardTransaction {
private final AbstractShardDataTreeTransaction> transaction;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java
index 46a5039012..2978fc8d07 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadWriteTransaction.java
@@ -14,8 +14,9 @@ import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
/**
+ * Actor for a shard read/write transaction.
+ *
* @author: syedbahm
- * Date: 8/6/14
*/
public class ShardReadWriteTransaction extends ShardWriteTransaction {
public ShardReadWriteTransaction(ReadWriteShardDataTreeTransaction transaction, ActorRef shardActor,
@@ -25,9 +26,9 @@ public class ShardReadWriteTransaction extends ShardWriteTransaction {
@Override
public void handleReceive(Object message) {
- if(ReadData.isSerializedType(message)) {
+ if (ReadData.isSerializedType(message)) {
readData(ReadData.fromSerializable(message));
- } else if(DataExists.isSerializedType(message)) {
+ } else if (DataExists.isSerializedType(message)) {
dataExists((DataExists) message);
} else {
super.handleReceive(message);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
index 5b7f289eed..5e0d3407fb 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
@@ -34,7 +34,8 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
private boolean open;
- ShardRecoveryCoordinator(final ShardDataTree store, final byte[] restoreFromSnapshot, final String shardName, final Logger log) {
+ ShardRecoveryCoordinator(final ShardDataTree store, final byte[] restoreFromSnapshot, final String shardName,
+ final Logger log) {
this.store = Preconditions.checkNotNull(store);
this.shardName = Preconditions.checkNotNull(shardName);
this.log = Preconditions.checkNotNull(log);
@@ -49,6 +50,7 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void appendRecoveredLogEntry(final Payload payload) {
Preconditions.checkState(open, "call startLogRecovery before calling appendRecoveredLogEntry");
@@ -83,6 +85,7 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
* @param snapshotBytes the serialized snapshot
*/
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void applyRecoverySnapshot(final byte[] snapshotBytes) {
log.debug("{}: Applying recovered snapshot", shardName);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java
index adf60a0c21..6dc3f03081 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java
@@ -62,6 +62,7 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort {
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void applySnapshot(final byte[] snapshotBytes) {
// Since this will be done only on Recovery or when this actor is a Follower
// we can safely commit everything in here. We not need to worry about event notifications
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
index 2421cce26c..2b109b056c 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
@@ -29,16 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * The ShardTransaction Actor represents a remote transaction
- *
- * The ShardTransaction Actor delegates all actions to DOMDataReadWriteTransaction
- *
- *
- * Handles Messages
- * ----------------
- *
{@link org.opendaylight.controller.cluster.datastore.messages.ReadData}
- * {@link org.opendaylight.controller.cluster.datastore.messages.CloseTransaction}
- *
+ * The ShardTransaction Actor represents a remote transaction that delegates all actions to DOMDataReadWriteTransaction.
*/
public abstract class ShardTransaction extends AbstractUntypedActorWithMetering {
private final ActorRef shardActor;
@@ -52,8 +43,8 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
this.transactionID = Preconditions.checkNotNull(transactionID);
}
- public static Props props(TransactionType type, AbstractShardDataTreeTransaction> transaction, ActorRef shardActor,
- DatastoreContext datastoreContext, ShardStats shardStats) {
+ public static Props props(TransactionType type, AbstractShardDataTreeTransaction> transaction,
+ ActorRef shardActor, DatastoreContext datastoreContext, ShardStats shardStats) {
return Props.create(new ShardTransactionCreator(type, transaction, shardActor, datastoreContext, shardStats));
}
@@ -86,7 +77,7 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
private void closeTransaction(boolean sendReply) {
getDOMStoreTransaction().abort();
- if(sendReply && returnCloseTransactionReply()) {
+ if (sendReply && returnCloseTransactionReply()) {
getSender().tell(new CloseTransactionReply(), getSelf());
}
@@ -97,7 +88,8 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
final boolean ret = transaction.isClosed();
if (ret) {
shardStats.incrementFailedReadTransactionsCount();
- getSender().tell(new akka.actor.Status.Failure(new ReadFailedException("Transaction is closed")), getSelf());
+ getSender().tell(new akka.actor.Status.Failure(new ReadFailedException("Transaction is closed")),
+ getSelf());
}
return ret;
}
@@ -133,8 +125,8 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
final ShardStats shardStats;
final TransactionType type;
- ShardTransactionCreator(TransactionType type, AbstractShardDataTreeTransaction> transaction, ActorRef shardActor,
- DatastoreContext datastoreContext, ShardStats shardStats) {
+ ShardTransactionCreator(TransactionType type, AbstractShardDataTreeTransaction> transaction,
+ ActorRef shardActor, DatastoreContext datastoreContext, ShardStats shardStats) {
this.transaction = Preconditions.checkNotNull(transaction);
this.shardActor = shardActor;
this.shardStats = shardStats;
@@ -146,17 +138,19 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
public ShardTransaction create() throws Exception {
final ShardTransaction tx;
switch (type) {
- case READ_ONLY:
- tx = new ShardReadTransaction(transaction, shardActor, shardStats);
- break;
- case READ_WRITE:
- tx = new ShardReadWriteTransaction((ReadWriteShardDataTreeTransaction)transaction, shardActor, shardStats);
- break;
- case WRITE_ONLY:
- tx = new ShardWriteTransaction((ReadWriteShardDataTreeTransaction)transaction, shardActor, shardStats);
- break;
- default:
- throw new IllegalArgumentException("Unhandled transaction type " + type);
+ case READ_ONLY:
+ tx = new ShardReadTransaction(transaction, shardActor, shardStats);
+ break;
+ case READ_WRITE:
+ tx = new ShardReadWriteTransaction((ReadWriteShardDataTreeTransaction)transaction, shardActor,
+ shardStats);
+ break;
+ case WRITE_ONLY:
+ tx = new ShardWriteTransaction((ReadWriteShardDataTreeTransaction)transaction, shardActor,
+ shardStats);
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled transaction type " + type);
}
tx.getContext().setReceiveTimeout(datastoreContext.getShardTransactionIdleTimeout());
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java
similarity index 80%
rename from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java
rename to opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java
index ecfd2aa50d..0ba36640a8 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionActorFactory.java
@@ -59,20 +59,20 @@ class ShardTransactionActorFactory {
ActorRef newShardTransaction(TransactionType type, TransactionIdentifier transactionID) {
final AbstractShardDataTreeTransaction> transaction;
switch (type) {
- case READ_ONLY:
- transaction = dataTree.newReadOnlyTransaction(transactionID);
- shardMBean.incrementReadOnlyTransactionCount();
- break;
- case READ_WRITE:
- transaction = dataTree.newReadWriteTransaction(transactionID);
- shardMBean.incrementReadWriteTransactionCount();
- break;
- case WRITE_ONLY:
- transaction = dataTree.newReadWriteTransaction(transactionID);
- shardMBean.incrementWriteOnlyTransactionCount();
- break;
- default:
- throw new IllegalArgumentException("Unsupported transaction type " + type);
+ case READ_ONLY:
+ transaction = dataTree.newReadOnlyTransaction(transactionID);
+ shardMBean.incrementReadOnlyTransactionCount();
+ break;
+ case READ_WRITE:
+ transaction = dataTree.newReadWriteTransaction(transactionID);
+ shardMBean.incrementReadWriteTransactionCount();
+ break;
+ case WRITE_ONLY:
+ transaction = dataTree.newReadWriteTransaction(transactionID);
+ shardMBean.incrementWriteOnlyTransactionCount();
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported transaction type " + type);
}
return actorContext.actorOf(ShardTransaction.props(type, transaction, shardActor, datastoreContext, shardMBean)
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionMessageRetrySupport.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionMessageRetrySupport.java
index 291867cf8f..eea201e56d 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionMessageRetrySupport.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionMessageRetrySupport.java
@@ -48,14 +48,14 @@ class ShardTransactionMessageRetrySupport implements Closeable {
}
void retryMessages() {
- if(messagesToRetry.isEmpty()) {
+ if (messagesToRetry.isEmpty()) {
return;
}
MessageInfo[] copy = messagesToRetry.toArray(new MessageInfo[messagesToRetry.size()]);
messagesToRetry.clear();
- for(MessageInfo info: copy) {
+ for (MessageInfo info: copy) {
LOG.debug("{}: Retrying message {}", shard.persistenceId(), info.message);
info.retry(shard);
}
@@ -72,7 +72,7 @@ class ShardTransactionMessageRetrySupport implements Closeable {
@Override
public void close() {
- for(MessageInfo info: messagesToRetry) {
+ for (MessageInfo info: messagesToRetry) {
info.timedOut(shard);
}
@@ -97,7 +97,8 @@ class ShardTransactionMessageRetrySupport implements Closeable {
}
void timedOut(Shard shard) {
- replyTo.tell(new Failure(new NoShardLeaderException(failureMessage, shard.persistenceId())), shard.getSelf());
+ replyTo.tell(new Failure(new NoShardLeaderException(failureMessage, shard.persistenceId())),
+ shard.getSelf());
}
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java
index 3b175a9c05..ee61090eea 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java
@@ -21,8 +21,9 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadData;
import org.opendaylight.controller.cluster.datastore.modification.Modification;
/**
+ * Actor for a shard write-only transaction.
+ *
* @author: syedbahm
- * Date: 8/6/14
*/
public class ShardWriteTransaction extends ShardTransaction {
@@ -50,6 +51,7 @@ public class ShardWriteTransaction extends ShardTransaction {
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void batchedModifications(BatchedModifications batched) {
if (checkClosed()) {
if (batched.isReady()) {
@@ -59,17 +61,17 @@ public class ShardWriteTransaction extends ShardTransaction {
}
try {
- for(Modification modification: batched.getModifications()) {
+ for (Modification modification: batched.getModifications()) {
modification.apply(transaction.getSnapshot());
}
totalBatchedModificationsReceived++;
- if(batched.isReady()) {
- if(lastBatchedModificationsException != null) {
+ if (batched.isReady()) {
+ if (lastBatchedModificationsException != null) {
throw lastBatchedModificationsException;
}
- if(totalBatchedModificationsReceived != batched.getTotalMessagesSent()) {
+ if (totalBatchedModificationsReceived != batched.getTotalMessagesSent()) {
throw new IllegalStateException(String.format(
"The total number of batched messages received %d does not match the number sent %d",
totalBatchedModificationsReceived, batched.getTotalMessagesSent()));
@@ -83,7 +85,7 @@ public class ShardWriteTransaction extends ShardTransaction {
lastBatchedModificationsException = e;
getSender().tell(new akka.actor.Status.Failure(e), getSelf());
- if(batched.isReady()) {
+ if (batched.isReady()) {
getSelf().tell(PoisonPill.getInstance(), getSelf());
}
}
@@ -99,7 +101,8 @@ public class ShardWriteTransaction extends ShardTransaction {
private boolean checkClosed() {
if (transaction.isClosed()) {
- getSender().tell(new akka.actor.Status.Failure(new IllegalStateException("Transaction is closed, no modifications allowed")), getSelf());
+ getSender().tell(new akka.actor.Status.Failure(new IllegalStateException(
+ "Transaction is closed, no modifications allowed")), getSelf());
return true;
} else {
return false;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java
index 5fac0abe6b..71eaf7dbc8 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java
@@ -70,21 +70,21 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort implements Ide
}
@Override
- public void canCommit(final FutureCallback callback) {
- if(state == State.CAN_COMMIT_PENDING) {
+ public void canCommit(final FutureCallback newCallback) {
+ if (state == State.CAN_COMMIT_PENDING) {
return;
}
checkState(State.READY);
- this.callback = Preconditions.checkNotNull(callback);
+ this.callback = Preconditions.checkNotNull(newCallback);
state = State.CAN_COMMIT_PENDING;
dataTree.startCanCommit(this);
}
@Override
- public void preCommit(final FutureCallback callback) {
+ public void preCommit(final FutureCallback newCallback) {
checkState(State.CAN_COMMIT_COMPLETE);
- this.callback = Preconditions.checkNotNull(callback);
+ this.callback = Preconditions.checkNotNull(newCallback);
state = State.PRE_COMMIT_PENDING;
if (nextFailure == null) {
@@ -125,9 +125,9 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort implements Ide
}
@Override
- public void commit(final FutureCallback callback) {
+ public void commit(final FutureCallback newCallback) {
checkState(State.PRE_COMMIT_COMPLETE);
- this.callback = Preconditions.checkNotNull(callback);
+ this.callback = Preconditions.checkNotNull(newCallback);
state = State.COMMIT_PENDING;
dataTree.startCommit(this, candidate);
}
@@ -153,20 +153,20 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort implements Ide
* Run user-defined canCommit and preCommit hooks. We want to run these before we initiate persistence so that
* any failure to validate is propagated before we record the transaction.
*
- * @param candidate {@link DataTreeCandidate} under consideration
- * @throws ExecutionException
- * @throws TimeoutException
+ * @param dataTreeCandidate {@link DataTreeCandidate} under consideration
+ * @throws ExecutionException if the operation fails
+ * @throws TimeoutException if the operation times out
*/
// FIXME: this should be asynchronous
- void userPreCommit(final DataTreeCandidate candidate) throws ExecutionException, TimeoutException {
- userCohorts.canCommit(candidate);
+ void userPreCommit(final DataTreeCandidate dataTreeCandidate) throws ExecutionException, TimeoutException {
+ userCohorts.canCommit(dataTreeCandidate);
userCohorts.preCommit();
}
- void successfulPreCommit(final DataTreeCandidateTip candidate) {
- LOG.trace("Transaction {} prepared candidate {}", transaction, candidate);
- this.candidate = Verify.verifyNotNull(candidate);
- switchState(State.PRE_COMMIT_COMPLETE).onSuccess(candidate);
+ void successfulPreCommit(final DataTreeCandidateTip dataTreeCandidate) {
+ LOG.trace("Transaction {} prepared candidate {}", transaction, dataTreeCandidate);
+ this.candidate = Verify.verifyNotNull(dataTreeCandidate);
+ switchState(State.PRE_COMMIT_COMPLETE).onSuccess(dataTreeCandidate);
}
void failedPreCommit(final Exception cause) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java
index 505c959337..033cbeaae7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java
@@ -53,7 +53,7 @@ class SingleCommitCohortProxy extends AbstractThreePhaseCommitCohort {
cohortFuture.onComplete(new OnComplete() {
@Override
public void onComplete(Throwable failure, Object cohortResponse) {
- if(failure != null) {
+ if (failure != null) {
operationCallbackRef.get().failure();
returnFuture.setException(failure);
return;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TerminationMonitor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TerminationMonitor.java
index 3820cc4eb8..5ab85f1db2 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TerminationMonitor.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TerminationMonitor.java
@@ -14,20 +14,20 @@ import org.opendaylight.controller.cluster.common.actor.Monitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TerminationMonitor extends UntypedActor{
+public class TerminationMonitor extends UntypedActor {
private static final Logger LOG = LoggerFactory.getLogger(TerminationMonitor.class);
public static final String ADDRESS = "termination-monitor";
- public TerminationMonitor(){
+ public TerminationMonitor() {
LOG.debug("Created TerminationMonitor");
}
@Override
public void onReceive(Object message) throws Exception {
- if(message instanceof Terminated){
+ if (message instanceof Terminated) {
Terminated terminated = (Terminated) message;
LOG.debug("Actor terminated : {}", terminated.actor());
- } else if(message instanceof Monitor){
+ } else if (message instanceof Monitor) {
Monitor monitor = (Monitor) message;
getContext().watch(monitor.getActorRef());
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
index 357ab92c81..17017b9b66 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
/**
- * ThreePhaseCommitCohortProxy represents a set of remote cohort proxies
+ * ThreePhaseCommitCohortProxy represents a set of remote cohort proxies.
*/
public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort {
@@ -76,31 +76,31 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
this.cohorts = cohorts;
this.transactionId = Preconditions.checkNotNull(transactionId);
- if(cohorts.isEmpty()) {
+ if (cohorts.isEmpty()) {
cohortsResolvedFuture.set(null);
}
}
private ListenableFuture resolveCohorts() {
- if(cohortsResolvedFuture.isDone()) {
+ if (cohortsResolvedFuture.isDone()) {
return cohortsResolvedFuture;
}
final AtomicInteger completed = new AtomicInteger(cohorts.size());
- for(final CohortInfo info: cohorts) {
+ for (final CohortInfo info: cohorts) {
info.getActorFuture().onComplete(new OnComplete() {
@Override
public void onComplete(Throwable failure, ActorSelection actor) {
- synchronized(completed) {
+ synchronized (completed) {
boolean done = completed.decrementAndGet() == 0;
- if(failure != null) {
+ if (failure != null) {
LOG.debug("Tx {}: a cohort Future failed", transactionId, failure);
cohortsResolvedFuture.setException(failure);
- } else if(!cohortsResolvedFuture.isDone()) {
+ } else if (!cohortsResolvedFuture.isDone()) {
LOG.debug("Tx {}: cohort actor {} resolved", transactionId, actor);
info.setResolvedActor(actor);
- if(done) {
+ if (done) {
LOG.debug("Tx {}: successfully resolved all cohort actors", transactionId);
cohortsResolvedFuture.set(null);
}
@@ -144,7 +144,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
LOG.debug("Tx {} finishCanCommit", transactionId);
// For empty transactions return immediately
- if(cohorts.size() == 0){
+ if (cohorts.size() == 0) {
LOG.debug("Tx {}: canCommit returning result true", transactionId);
returnFuture.set(Boolean.TRUE);
return;
@@ -186,7 +186,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
return;
}
- if(iterator.hasNext() && result) {
+ if (iterator.hasNext() && result) {
sendCanCommitTransaction(iterator.next(), this);
} else {
LOG.debug("Tx {}: canCommit returning result: {}", transactionId, result);
@@ -202,9 +202,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
private void sendCanCommitTransaction(CohortInfo toCohortInfo, OnComplete onComplete) {
CanCommitTransaction message = new CanCommitTransaction(transactionId, toCohortInfo.getActorVersion());
- if(LOG.isDebugEnabled()) {
- LOG.debug("Tx {}: sending {} to {}", transactionId, message, toCohortInfo.getResolvedActor());
- }
+ LOG.debug("Tx {}: sending {} to {}", transactionId, message, toCohortInfo.getResolvedActor());
Future future = actorContext.executeOperationAsync(toCohortInfo.getResolvedActor(),
message.toSerializable(), actorContext.getTransactionCommitOperationTimeout());
@@ -213,12 +211,10 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
private Future> invokeCohorts(MessageSupplier messageSupplier) {
List> futureList = Lists.newArrayListWithCapacity(cohorts.size());
- for(CohortInfo cohort : cohorts) {
+ for (CohortInfo cohort : cohorts) {
Object message = messageSupplier.newMessage(transactionId, cohort.getActorVersion());
- if(LOG.isDebugEnabled()) {
- LOG.debug("Tx {}: Sending {} to cohort {}", transactionId, message , cohort);
- }
+ LOG.debug("Tx {}: Sending {} to cohort {}", transactionId, message , cohort);
futureList.add(actorContext.executeOperationAsync(cohort.getResolvedActor(), message,
actorContext.getTransactionCommitOperationTimeout()));
@@ -255,15 +251,16 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
CommitTransactionReply.class, true, operationCallback);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private static boolean successfulFuture(ListenableFuture future) {
- if(!future.isDone()) {
+ if (!future.isDone()) {
return false;
}
try {
future.get();
return true;
- } catch(Exception e) {
+ } catch (Exception e) {
return false;
}
}
@@ -279,7 +276,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
// if not for some reason, we'll try to build it here.
ListenableFuture future = resolveCohorts();
- if(successfulFuture(future)) {
+ if (successfulFuture(future)) {
finishVoidOperation(operationName, messageSupplier, expectedResponseClass, propagateException,
returnFuture, callback);
} else {
@@ -294,7 +291,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
public void onFailure(Throwable failure) {
LOG.debug("Tx {}: a {} cohort path Future failed: {}", transactionId, operationName, failure);
- if(propagateException) {
+ if (propagateException) {
returnFuture.setException(failure);
} else {
returnFuture.set(null);
@@ -319,9 +316,9 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
@Override
public void onComplete(Throwable failure, Iterable responses) throws Throwable {
Throwable exceptionToPropagate = failure;
- if(exceptionToPropagate == null) {
- for(Object response: responses) {
- if(!response.getClass().equals(expectedResponseClass)) {
+ if (exceptionToPropagate == null) {
+ for (Object response: responses) {
+ if (!response.getClass().equals(expectedResponseClass)) {
exceptionToPropagate = new IllegalArgumentException(
String.format("Unexpected response type %s", response.getClass()));
break;
@@ -329,9 +326,9 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
}
}
- if(exceptionToPropagate != null) {
+ if (exceptionToPropagate != null) {
LOG.debug("Tx {}: a {} cohort Future failed", transactionId, operationName, exceptionToPropagate);
- if(propagateException) {
+ if (propagateException) {
// We don't log the exception here to avoid redundant logging since we're
// propagating to the caller in MD-SAL core who will log it.
returnFuture.setException(exceptionToPropagate);
@@ -357,7 +354,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
@Override
List> getCohortFutures() {
List> cohortFutures = new ArrayList<>(cohorts.size());
- for(CohortInfo info: cohorts) {
+ for (CohortInfo info: cohorts) {
cohortFutures.add(info.getActorFuture());
}
@@ -395,6 +392,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
private interface MessageSupplier {
Object newMessage(TransactionIdentifier transactionId, short version);
+
boolean isSerializedReplyType(Object reply);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
index 6cfc7e1f05..91658a23b7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
@@ -18,7 +18,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import java.util.function.Function;
import javax.annotation.Nonnull;
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -40,8 +39,9 @@ import scala.concurrent.Promise;
* at a time. For remote transactions, it also tracks the outstanding readiness requests
* towards the shard and unblocks operations only after all have completed.
*/
-final class TransactionChainProxy extends AbstractTransactionContextFactory implements DOMStoreTransactionChain {
- private static abstract class State {
+final class TransactionChainProxy extends AbstractTransactionContextFactory
+ implements DOMStoreTransactionChain {
+ private abstract static class State {
/**
* Check if it is okay to allocate a new transaction.
* @throws IllegalStateException if a transaction may not be allocated.
@@ -56,7 +56,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory previousFuture();
}
- private static abstract class Pending extends State {
+ private abstract static class Pending extends State {
private final TransactionIdentifier transaction;
private final Future> previousFuture;
@@ -97,7 +97,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory previousFuture() {
return null;
@@ -129,22 +129,23 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory
* 1) Create write tx1 on chain
* 2) do write and submit
* 3) Create read-only tx2 on chain and issue read
* 4) Create write tx3 on chain, do write but do not submit
- *
+ *
* if the sequence/timing is right, tx3 may create its local tx on the LocalTransactionChain before tx2,
* which results in tx2 failing b/c tx3 isn't ready yet. So maintaining ordering prevents this issue
* (see Bug 4774).
- *
+ *
* A Promise is added via newReadOnlyTransaction. When the parent class completes the primary shard
* lookup and creates the TransactionContext (either success or failure), onTransactionContextCreated is
* called which completes the Promise. A write tx that is created prior to completion will wait on the
* Promise's Future via findPrimaryShard.
*/
- private final ConcurrentMap> priorReadOnlyTxPromises = new ConcurrentHashMap<>();
+ private final ConcurrentMap> priorReadOnlyTxPromises =
+ new ConcurrentHashMap<>();
TransactionChainProxy(final TransactionContextFactory parent, final LocalHistoryIdentifier historyId) {
super(parent.getActorContext(), historyId);
@@ -177,12 +178,8 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory() {
- @Override
- public Object apply(Short version) {
- return new CloseTransactionChain(getHistoryId(), version).toSerializable();
- }
- }, CloseTransactionChain.class);
+ getActorContext().broadcast(version -> new CloseTransactionChain(getHistoryId(), version).toSerializable(),
+ CloseTransactionChain.class);
}
private TransactionProxy allocateWriteTransaction(final TransactionType type) {
@@ -195,7 +192,8 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory Future combineFutureWithPossiblePriorReadOnlyTxFutures(final Future future,
final TransactionIdentifier txId) {
- if(!priorReadOnlyTxPromises.containsKey(txId) && !priorReadOnlyTxPromises.isEmpty()) {
+ if (!priorReadOnlyTxPromises.containsKey(txId) && !priorReadOnlyTxPromises.isEmpty()) {
Collection>> priorReadOnlyTxPromiseEntries =
new ArrayList<>(priorReadOnlyTxPromises.entrySet());
- if(priorReadOnlyTxPromiseEntries.isEmpty()) {
+ if (priorReadOnlyTxPromiseEntries.isEmpty()) {
return future;
}
List> priorReadOnlyTxFutures = new ArrayList<>(priorReadOnlyTxPromiseEntries.size());
- for(Entry> entry: priorReadOnlyTxPromiseEntries) {
+ for (Entry> entry: priorReadOnlyTxPromiseEntries) {
LOG.debug("Tx: {} - waiting on future for prior read-only Tx {}", txId, entry.getKey());
priorReadOnlyTxFutures.add(entry.getValue().future());
}
@@ -292,11 +290,14 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory void onTransactionReady(final TransactionIdentifier transaction, final Collection> cohortFutures) {
+ protected void onTransactionReady(final TransactionIdentifier transaction,
+ final Collection> cohortFutures) {
final State localState = currentState;
- Preconditions.checkState(localState instanceof Allocated, "Readying transaction %s while state is %s", transaction, localState);
+ Preconditions.checkState(localState instanceof Allocated, "Readying transaction %s while state is %s",
+ transaction, localState);
final TransactionIdentifier currentTx = ((Allocated)localState).getIdentifier();
- Preconditions.checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated", transaction, currentTx);
+ Preconditions.checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated",
+ transaction, currentTx);
// Transaction ready and we are not waiting for futures -- go to idle
if (cohortFutures.isEmpty()) {
@@ -324,7 +325,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory promise = priorReadOnlyTxPromises.remove(transactionId);
- if(promise != null) {
+ if (promise != null) {
promise.success(null);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java
index 765d5bb7ec..1e23120f0b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java
@@ -32,15 +32,16 @@ interface TransactionContext {
* Invoked by {@link TransactionContextWrapper} when it has finished handing
* off operations to this context. From this point on, the context is responsible
* for throttling operations.
- *
+ *
* Implementations can rely on the wrapper calling this operation in a synchronized
* block, so they do not need to ensure visibility of this state transition themselves.
*/
void operationHandOffComplete();
/**
- * A TransactionContext that uses Operation limiting should return true else false
- * @return
+ * A TransactionContext that uses operation limiting should return true else false.
+ *
+ * @return true if operation limiting is used, false otherwise
*/
boolean usesOperationLimiting();
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java
index 8c4f6b3456..d7f493565b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java
@@ -35,7 +35,8 @@ final class TransactionContextFactory extends AbstractTransactionContextFactory<
}
@Override
- protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader, final DataTree dataTree) {
+ protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader,
+ final DataTree dataTree) {
return new LocalTransactionFactoryImpl(getActorContext(), shardLeader, dataTree);
}
@@ -45,7 +46,8 @@ final class TransactionContextFactory extends AbstractTransactionContextFactory<
}
@Override
- protected void onTransactionReady(final TransactionIdentifier transaction, final Collection> cohortFutures) {
+ protected void onTransactionReady(final TransactionIdentifier transaction,
+ final Collection> cohortFutures) {
// Transactions are disconnected, this is a no-op
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextWrapper.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextWrapper.java
index ef9ee68bf0..6dae7cec31 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextWrapper.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextWrapper.java
@@ -51,7 +51,8 @@ class TransactionContextWrapper {
TransactionContextWrapper(final TransactionIdentifier identifier, final ActorContext actorContext) {
this.identifier = Preconditions.checkNotNull(identifier);
this.limiter = new OperationLimiter(identifier,
- actorContext.getDatastoreContext().getShardBatchedModificationCount() + 1, // 1 extra permit for the ready operation
+ // 1 extra permit for the ready operation
+ actorContext.getDatastoreContext().getShardBatchedModificationCount() + 1,
TimeUnit.MILLISECONDS.toSeconds(actorContext.getDatastoreContext().getOperationTimeoutInMillis()));
}
@@ -98,7 +99,7 @@ class TransactionContextWrapper {
}
void executePriorTransactionOperations(final TransactionContext localTransactionContext) {
- while(true) {
+ while (true) {
// Access to queuedTxOperations and transactionContext must be protected and atomic
// (ie synchronized) with respect to #addTxOperationOnComplete to handle timing
// issues and ensure no TransactionOperation is missed and that they are processed
@@ -114,7 +115,7 @@ class TransactionContextWrapper {
// We're done invoking the TransactionOperations so we can now publish the
// TransactionContext.
localTransactionContext.operationHandOffComplete();
- if(!localTransactionContext.usesOperationLimiting()){
+ if (!localTransactionContext.usesOperationLimiting()){
limiter.releaseAll();
}
transactionContext = localTransactionContext;
@@ -143,8 +144,8 @@ class TransactionContextWrapper {
final Promise promise = Futures.promise();
enqueueTransactionOperation(new TransactionOperation() {
@Override
- public void invoke(TransactionContext transactionContext) {
- promise.completeWith(transactionContext.readyTransaction());
+ public void invoke(TransactionContext newTransactionContext) {
+ promise.completeWith(newTransactionContext.readyTransaction());
}
});
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionOperation.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionOperation.java
index dc965edec7..3defd2cc50 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionOperation.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionOperation.java
@@ -15,7 +15,7 @@ abstract class TransactionOperation {
/**
* Execute the delayed operation.
*
- * @param transactionContext
+ * @param transactionContext the TransactionContext
*/
protected abstract void invoke(TransactionContext transactionContext);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
index 164dc5ef73..405eb0f95b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
@@ -50,12 +50,14 @@ import scala.concurrent.Promise;
/**
* A transaction potentially spanning multiple backend shards.
*/
-public class TransactionProxy extends AbstractDOMStoreTransaction implements DOMStoreReadWriteTransaction {
+public class TransactionProxy extends AbstractDOMStoreTransaction
+ implements DOMStoreReadWriteTransaction {
private enum TransactionState {
OPEN,
READY,
CLOSED,
}
+
private static final Logger LOG = LoggerFactory.getLogger(TransactionProxy.class);
private final Map txContextWrappers = new HashMap<>();
@@ -79,11 +81,10 @@ public class TransactionProxy extends AbstractDOMStoreTransaction CheckedFuture executeRead(String shardName, final AbstractRead readCmd) {
- Preconditions.checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
+ Preconditions.checkState(type != TransactionType.WRITE_ONLY,
+ "Reads from write-only transactions are not allowed");
- if(LOG.isDebugEnabled()) {
- LOG.debug("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath());
- }
+ LOG.debug("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath());
final SettableFuture proxyFuture = SettableFuture.create();
TransactionContextWrapper contextWrapper = getContextWrapper(shardName);
@@ -99,7 +100,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>, ReadFailedException> read(final YangInstanceIdentifier path) {
- Preconditions.checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
+ Preconditions.checkState(type != TransactionType.WRITE_ONLY,
+ "Reads from write-only transactions are not allowed");
LOG.debug("Tx {} read {}", getIdentifier(), path);
@@ -117,7 +119,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>, ReadFailedException> readAllData() {
final Set allShardNames = txContextFactory.getActorContext().getConfiguration().getAllShardNames();
- final Collection>, ReadFailedException>> futures = new ArrayList<>(allShardNames.size());
+ final Collection>, ReadFailedException>> futures =
+ new ArrayList<>(allShardNames.size());
for (String shardName : allShardNames) {
futures.add(singleShardRead(shardName, YangInstanceIdentifier.EMPTY));
@@ -126,9 +129,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>>> listFuture = Futures.allAsList(futures);
final ListenableFuture>> aggregateFuture;
- aggregateFuture = Futures.transform(listFuture, new Function>>, Optional>>() {
- @Override
- public Optional> apply(final List>> input) {
+ aggregateFuture = Futures.transform(listFuture,
+ (Function>>, Optional>>) input -> {
try {
return NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.EMPTY, input,
txContextFactory.getActorContext().getSchemaContext(),
@@ -136,8 +138,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction ret;
switch (txContextWrappers.size()) {
- case 0:
- ret = NoOpDOMStoreThreePhaseCommitCohort.INSTANCE;
- break;
- case 1:
- final Entry e = Iterables.getOnlyElement(txContextWrappers.entrySet());
- ret = createSingleCommitCohort(e.getKey(), e.getValue());
- break;
- default:
- ret = createMultiCommitCohort(txContextWrappers.entrySet());
+ case 0:
+ ret = NoOpDOMStoreThreePhaseCommitCohort.INSTANCE;
+ break;
+ case 1:
+ final Entry e = Iterables.getOnlyElement(
+ txContextWrappers.entrySet());
+ ret = createSingleCommitCohort(e.getKey(), e.getValue());
+ break;
+ default:
+ ret = createMultiCommitCohort(txContextWrappers.entrySet());
}
txContextFactory.onTransactionReady(getIdentifier(), ret.getCohortFutures());
@@ -255,8 +255,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction txVersionSupplier = new Supplier() {
- @Override
- public Short get() {
- return wrapper.getTransactionContext().getTransactionVersion();
- }
- };
+ Supplier txVersionSupplier = () -> wrapper.getTransactionContext().getTransactionVersion();
cohorts.add(new ThreePhaseCommitCohortProxy.CohortInfo(wrapper.readyTransaction(), txVersionSupplier));
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java
index 3da5bed5a7..f35e30a06c 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionRateLimitingCallback.java
@@ -17,9 +17,9 @@ import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
/**
* TransactionRateLimitingCallback computes the new transaction rate limit on the successful completion of a
- * transaction
+ * transaction.
*/
-public class TransactionRateLimitingCallback implements OperationCallback{
+public class TransactionRateLimitingCallback implements OperationCallback {
private static Ticker TICKER = Ticker.systemTicker();
private enum State {
@@ -33,7 +33,7 @@ public class TransactionRateLimitingCallback implements OperationCallback{
private long elapsedTime;
private volatile State state = State.STOPPED;
- TransactionRateLimitingCallback(ActorContext actorContext){
+ TransactionRateLimitingCallback(ActorContext actorContext) {
commitTimer = actorContext.getOperationTimer(ActorContext.COMMIT);
}
@@ -45,7 +45,7 @@ public class TransactionRateLimitingCallback implements OperationCallback{
@Override
public void pause() {
- if(state == State.RUNNING) {
+ if (state == State.RUNNING) {
elapsedTime += TICKER.read() - startTime;
state = State.PAUSED;
}
@@ -53,7 +53,7 @@ public class TransactionRateLimitingCallback implements OperationCallback{
@Override
public void resume() {
- if(state != State.RUNNING) {
+ if (state != State.RUNNING) {
startTime = TICKER.read();
state = State.RUNNING;
}
@@ -78,4 +78,4 @@ public class TransactionRateLimitingCallback implements OperationCallback{
static void setTicker(Ticker ticker) {
TICKER = ticker;
}
-}
\ No newline at end of file
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionReadyReplyMapper.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionReadyReplyMapper.java
index 43c3be11c2..986cca5f3d 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionReadyReplyMapper.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionReadyReplyMapper.java
@@ -20,10 +20,9 @@ import scala.concurrent.Future;
/**
* A {@link Mapper} extracting the {@link ActorSelection} pointing to the actor which
* is backing a particular transaction.
- *
+ *
* This class is not for general consumption. It is public only to support the pre-lithium compatibility
* package.
- *
* TODO: once we remove compatibility, make this class package-private and final.
*/
public class TransactionReadyReplyMapper extends Mapper {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/Configuration.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/Configuration.java
index fa823a7285..970f9f6ac6 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/Configuration.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/Configuration.java
@@ -63,12 +63,12 @@ public interface Configuration {
boolean isShardConfigured(String shardName);
/**
- * Adds the given member as the new replica for the given shardName
+ * Adds the given member as the new replica for the given shardName.
*/
- void addMemberReplicaForShard (String shardName, MemberName memberName);
+ void addMemberReplicaForShard(String shardName, MemberName memberName);
/**
- * Removes the given member as a replica for the given shardName
+ * Removes the given member as a replica for the given shardName.
*/
- void removeMemberReplicaForShard (String shardName, MemberName memberName);
+ void removeMemberReplicaForShard(String shardName, MemberName memberName);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationImpl.java
index 1af8ed63e0..06ae6ec767 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationImpl.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationImpl.java
@@ -37,7 +37,7 @@ public class ConfigurationImpl implements Configuration {
public ConfigurationImpl(final ModuleShardConfigProvider provider) {
ImmutableMap.Builder mapBuilder = ImmutableMap.builder();
- for(Map.Entry e: provider.retrieveModuleConfigs(this).entrySet()) {
+ for (Map.Entry e: provider.retrieveModuleConfigs(this).entrySet()) {
mapBuilder.put(e.getKey(), e.getValue().build());
}
@@ -49,7 +49,7 @@ public class ConfigurationImpl implements Configuration {
private static Set createAllShardNames(Iterable moduleConfigs) {
final ImmutableSet.Builder builder = ImmutableSet.builder();
- for(ModuleConfig moduleConfig : moduleConfigs) {
+ for (ModuleConfig moduleConfig : moduleConfigs) {
builder.addAll(moduleConfig.getShardNames());
}
@@ -58,8 +58,8 @@ public class ConfigurationImpl implements Configuration {
private static Map createNamespaceToModuleName(Iterable moduleConfigs) {
final ImmutableMap.Builder builder = ImmutableMap.builder();
- for(ModuleConfig moduleConfig : moduleConfigs) {
- if(moduleConfig.getNameSpace() != null) {
+ for (ModuleConfig moduleConfig : moduleConfigs) {
+ if (moduleConfig.getNameSpace() != null) {
builder.put(moduleConfig.getNameSpace(), moduleConfig.getName());
}
}
@@ -68,13 +68,13 @@ public class ConfigurationImpl implements Configuration {
}
@Override
- public Collection getMemberShardNames(final MemberName memberName){
+ public Collection getMemberShardNames(final MemberName memberName) {
Preconditions.checkNotNull(memberName, "memberName should not be null");
List shards = new ArrayList<>();
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
for (ShardConfig shardConfig: moduleConfig.getShardConfigs()) {
- if(shardConfig.getReplicas().contains(memberName)) {
+ if (shardConfig.getReplicas().contains(memberName)) {
shards.add(shardConfig.getName());
}
}
@@ -95,7 +95,7 @@ public class ConfigurationImpl implements Configuration {
Preconditions.checkNotNull(moduleName, "moduleName should not be null");
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
- return moduleConfig != null ? moduleConfig.getShardStrategy(): null;
+ return moduleConfig != null ? moduleConfig.getShardStrategy() : null;
}
@Override
@@ -105,16 +105,16 @@ public class ConfigurationImpl implements Configuration {
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
Collection shardConfigs = moduleConfig != null ? moduleConfig.getShardConfigs() :
Collections.emptySet();
- return !shardConfigs.isEmpty() ? shardConfigs.iterator().next().getName(): null;
+ return !shardConfigs.isEmpty() ? shardConfigs.iterator().next().getName() : null;
}
@Override
public Collection getMembersFromShardName(final String shardName) {
Preconditions.checkNotNull(shardName, "shardName should not be null");
- for(ModuleConfig moduleConfig: moduleConfigMap.values()) {
+ for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
- if(shardConfig != null) {
+ if (shardConfig != null) {
return shardConfig.getReplicas();
}
}
@@ -130,7 +130,7 @@ public class ConfigurationImpl implements Configuration {
@Override
public Collection getUniqueMemberNamesForAllShards() {
Set allNames = new HashSet<>();
- for(String shardName: getAllShardNames()) {
+ for (String shardName: getAllShardNames()) {
allNames.addAll(getMembersFromShardName(shardName));
}
@@ -141,15 +141,15 @@ public class ConfigurationImpl implements Configuration {
public synchronized void addModuleShardConfiguration(ModuleShardConfiguration config) {
Preconditions.checkNotNull(config, "ModuleShardConfiguration should not be null");
- ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()).
- nameSpace(config.getNamespace().toASCIIString()).
- shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())).
- shardConfig(config.getShardName(), config.getShardMemberNames()).build();
+ ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName())
+ .nameSpace(config.getNamespace().toASCIIString())
+ .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName()))
+ .shardConfig(config.getShardName(), config.getShardMemberNames()).build();
updateModuleConfigMap(moduleConfig);
- namespaceToModuleName = ImmutableMap.builder().putAll(namespaceToModuleName).
- put(moduleConfig.getNameSpace(), moduleConfig.getName()).build();
+ namespaceToModuleName = ImmutableMap.builder().putAll(namespaceToModuleName)
+ .put(moduleConfig.getNameSpace(), moduleConfig.getName()).build();
allShardNames = ImmutableSet.builder().addAll(allShardNames).add(config.getShardName()).build();
}
@@ -164,13 +164,13 @@ public class ConfigurationImpl implements Configuration {
}
@Override
- public void addMemberReplicaForShard (String shardName, MemberName newMemberName) {
+ public void addMemberReplicaForShard(String shardName, MemberName newMemberName) {
Preconditions.checkNotNull(shardName, "shardName should not be null");
Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
- for(ModuleConfig moduleConfig: moduleConfigMap.values()) {
+ for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
- if(shardConfig != null) {
+ if (shardConfig != null) {
Set replicas = new HashSet<>(shardConfig.getReplicas());
replicas.add(newMemberName);
updateModuleConfigMap(ModuleConfig.builder(moduleConfig).shardConfig(shardName, replicas).build());
@@ -180,13 +180,13 @@ public class ConfigurationImpl implements Configuration {
}
@Override
- public void removeMemberReplicaForShard (String shardName, MemberName newMemberName) {
+ public void removeMemberReplicaForShard(String shardName, MemberName newMemberName) {
Preconditions.checkNotNull(shardName, "shardName should not be null");
Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
- for(ModuleConfig moduleConfig: moduleConfigMap.values()) {
+ for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
- if(shardConfig != null) {
+ if (shardConfig != null) {
Set replicas = new HashSet<>(shardConfig.getReplicas());
replicas.remove(newMemberName);
updateModuleConfigMap(ModuleConfig.builder(moduleConfig).shardConfig(shardName, replicas).build());
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileModuleShardConfigProvider.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileModuleShardConfigProvider.java
index c51e193131..2920f45fe9 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileModuleShardConfigProvider.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileModuleShardConfigProvider.java
@@ -42,7 +42,7 @@ public class FileModuleShardConfigProvider implements ModuleShardConfigProvider
File modulesFile = new File("./configuration/initial/" + modulesConfigPath);
Config moduleShardsConfig = null;
- if(moduleShardsFile.exists()) {
+ if (moduleShardsFile.exists()) {
LOG.info("module shards config file exists - reading config from it");
moduleShardsConfig = ConfigFactory.parseFile(moduleShardsFile);
} else {
@@ -51,7 +51,7 @@ public class FileModuleShardConfigProvider implements ModuleShardConfigProvider
}
Config modulesConfig = null;
- if(modulesFile.exists()) {
+ if (modulesFile.exists()) {
LOG.info("modules config file exists - reading config from it");
modulesConfig = ConfigFactory.parseFile(modulesFile);
} else {
@@ -69,19 +69,19 @@ public class FileModuleShardConfigProvider implements ModuleShardConfigProvider
Configuration configuration) {
List extends ConfigObject> modulesConfigObjectList = modulesConfig.getObjectList("modules");
- for(ConfigObject o : modulesConfigObjectList){
- ConfigObjectWrapper w = new ConfigObjectWrapper(o);
+ for (ConfigObject o : modulesConfigObjectList) {
+ ConfigObjectWrapper wrapper = new ConfigObjectWrapper(o);
- String moduleName = w.stringValue("name");
+ String moduleName = wrapper.stringValue("name");
ModuleConfig.Builder builder = moduleConfigMap.get(moduleName);
- if(builder == null) {
+ if (builder == null) {
builder = ModuleConfig.builder(moduleName);
moduleConfigMap.put(moduleName, builder);
}
- builder.nameSpace(w.stringValue("namespace"));
+ builder.nameSpace(wrapper.stringValue("namespace"));
builder.shardStrategy(ShardStrategyFactory.newShardStrategyInstance(moduleName,
- w.stringValue("shard-strategy"), configuration));
+ wrapper.stringValue("shard-strategy"), configuration));
}
}
@@ -90,14 +90,14 @@ public class FileModuleShardConfigProvider implements ModuleShardConfigProvider
moduleShardsConfig.getObjectList("module-shards");
Map moduleConfigMap = new HashMap<>();
- for(ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList){
+ for (ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList) {
String moduleName = moduleShardConfigObject.get("name").unwrapped().toString();
ModuleConfig.Builder builder = ModuleConfig.builder(moduleName);
List extends ConfigObject> shardsConfigObjectList =
moduleShardConfigObject.toConfig().getObjectList("shards");
- for(ConfigObject shard : shardsConfigObjectList){
+ for (ConfigObject shard : shardsConfigObjectList) {
String shardName = shard.get("name").unwrapped().toString();
List replicas = shard.toConfig().getStringList("replicas").stream()
.map(MemberName::forName).collect(Collectors.toList());
@@ -110,15 +110,15 @@ public class FileModuleShardConfigProvider implements ModuleShardConfigProvider
return moduleConfigMap;
}
- private static class ConfigObjectWrapper{
+ private static class ConfigObjectWrapper {
private final ConfigObject configObject;
- ConfigObjectWrapper(final ConfigObject configObject){
+ ConfigObjectWrapper(final ConfigObject configObject) {
this.configObject = configObject;
}
- public String stringValue(final String name){
+ public String stringValue(final String name) {
return configObject.get(name).unwrapped().toString();
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java
index 5b1421b544..d5094a5691 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java
@@ -52,8 +52,8 @@ public class ModuleConfig {
}
@Nullable
- public ShardConfig getShardConfig(String name) {
- return shardConfigs.get(name);
+ public ShardConfig getShardConfig(String forName) {
+ return shardConfigs.get(forName);
}
@Nonnull
@@ -93,23 +93,23 @@ public class ModuleConfig {
}
}
- public Builder name(String name) {
- this.name = name;
+ public Builder name(String newName) {
+ this.name = newName;
return this;
}
- public Builder nameSpace(String nameSpace) {
- this.nameSpace = nameSpace;
+ public Builder nameSpace(String newNameSpace) {
+ this.nameSpace = newNameSpace;
return this;
}
- public Builder shardStrategy(ShardStrategy shardStrategy) {
- this.shardStrategy = shardStrategy;
+ public Builder shardStrategy(ShardStrategy newShardStrategy) {
+ this.shardStrategy = newShardStrategy;
return this;
}
- public Builder shardConfig(String name, Collection replicas) {
- shardConfigs.put(name, new ShardConfig(name, replicas));
+ public Builder shardConfig(String shardName, Collection replicas) {
+ shardConfigs.put(shardName, new ShardConfig(shardName, replicas));
return this;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/LocalShardNotFoundException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/LocalShardNotFoundException.java
index 7a976b86ed..fae05d98f3 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/LocalShardNotFoundException.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/LocalShardNotFoundException.java
@@ -15,7 +15,7 @@ package org.opendaylight.controller.cluster.datastore.exceptions;
public class LocalShardNotFoundException extends RuntimeException {
private static final long serialVersionUID = 1L;
- public LocalShardNotFoundException(String message){
+ public LocalShardNotFoundException(String message) {
super(message);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java
index 839cce63e5..ba40c8cd60 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.datastore.exceptions;
public class NotInitializedException extends RuntimeException {
private static final long serialVersionUID = 1L;
+
public NotInitializedException(String message) {
super(message);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java
index c98e2bd384..2f82ccf102 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/PrimaryNotFoundException.java
@@ -10,7 +10,8 @@ package org.opendaylight.controller.cluster.datastore.exceptions;
public class PrimaryNotFoundException extends RuntimeException {
private static final long serialVersionUID = 1L;
- public PrimaryNotFoundException(String message){
+
+ public PrimaryNotFoundException(String message) {
super(message);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java
index 5590877aa7..a3bb4b30b4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/TimeoutException.java
@@ -10,7 +10,8 @@ package org.opendaylight.controller.cluster.datastore.exceptions;
public class TimeoutException extends RuntimeException {
private static final long serialVersionUID = 1L;
- public TimeoutException(String message, Exception e){
- super(message, e);
+
+ public TimeoutException(String message, Exception cause) {
+ super(message, cause);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java
index fc3aa592f9..e8824fbe11 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java
@@ -43,15 +43,15 @@ public class ShardIdentifier {
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (obj == null || getClass() != obj.getClass()) {
return false;
}
- ShardIdentifier that = (ShardIdentifier) o;
+ ShardIdentifier that = (ShardIdentifier) obj;
if (!memberName.equals(that.memberName)) {
return false;
@@ -97,26 +97,26 @@ public class ShardIdentifier {
private MemberName memberName;
private String type;
- public ShardIdentifier build(){
+ public ShardIdentifier build() {
return new ShardIdentifier(shardName, memberName, type);
}
- public Builder shardName(String shardName){
- this.shardName = shardName;
+ public Builder shardName(String newShardName) {
+ this.shardName = newShardName;
return this;
}
- public Builder memberName(MemberName memberName){
- this.memberName = memberName;
+ public Builder memberName(MemberName newMemberName) {
+ this.memberName = newMemberName;
return this;
}
- public Builder type(String type){
- this.type = type;
+ public Builder type(String newType) {
+ this.type = newType;
return this;
}
- public Builder fromShardIdString(String shardId){
+ public Builder fromShardIdString(String shardId) {
Matcher matcher = PATTERN.matcher(shardId);
if (matcher.matches()) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardManagerIdentifier.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardManagerIdentifier.java
index 65bf010b0a..98dbba3ca4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardManagerIdentifier.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardManagerIdentifier.java
@@ -16,15 +16,15 @@ public class ShardManagerIdentifier {
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (obj == null || getClass() != obj.getClass()) {
return false;
}
- ShardManagerIdentifier that = (ShardManagerIdentifier) o;
+ ShardManagerIdentifier that = (ShardManagerIdentifier) obj;
if (!type.equals(that.type)) {
return false;
@@ -44,19 +44,19 @@ public class ShardManagerIdentifier {
return builder.toString();
}
- public static Builder builder(){
+ public static Builder builder() {
return new Builder();
}
public static class Builder {
private String type;
- public Builder type(String type){
- this.type = type;
+ public Builder type(String newType) {
+ this.type = newType;
return this;
}
- public ShardManagerIdentifier build(){
+ public ShardManagerIdentifier build() {
return new ShardManagerIdentifier(this.type);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java
index 5d3fe8b2d0..b42926d2f2 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java
@@ -9,8 +9,9 @@ package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
/**
- * @author Basheeruddin syedbahm@cisco.com
+ * Factory for creating ShardStats mbeans.
*
+ * @author Basheeruddin syedbahm@cisco.com
*/
public class ShardMBeanFactory {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java
index b01eb099a5..6e8ff146d4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStats.java
@@ -39,7 +39,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- private static final Cache onDemandRaftStateCache =
+ private static final Cache ONDEMAND_RAFT_STATE_CACHE =
CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.SECONDS).build();
private long committedTransactionsCount;
@@ -78,14 +78,15 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
this.shard = shard;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private OnDemandRaftState getOnDemandRaftState() {
String name = getShardName();
- OnDemandRaftState state = onDemandRaftStateCache.getIfPresent(name);
- if(state == null) {
+ OnDemandRaftState state = ONDEMAND_RAFT_STATE_CACHE.getIfPresent(name);
+ if (state == null) {
statRetrievalError = null;
statRetrievalTime = null;
- if(shard != null) {
+ if (shard != null) {
Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
try {
Stopwatch timer = Stopwatch.createStarted();
@@ -94,7 +95,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
GetOnDemandRaftState.INSTANCE, timeout), timeout.duration());
statRetrievalTime = timer.stop().toString();
- onDemandRaftStateCache.put(name, state);
+ ONDEMAND_RAFT_STATE_CACHE.put(name, state);
} catch (Exception e) {
statRetrievalError = e.toString();
}
@@ -195,6 +196,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
public String getVotedFor() {
return getOnDemandRaftState().getVotedFor();
}
+
@Override
public boolean isVoting() {
return getOnDemandRaftState().isVoting();
@@ -254,8 +256,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
return failedReadTransactionsCount.incrementAndGet();
}
- public long incrementAbortTransactionsCount ()
- {
+ public long incrementAbortTransactionsCount() {
return ++abortTransactionsCount;
}
@@ -264,7 +265,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
}
@Override
- public long getInMemoryJournalDataSize(){
+ public long getInMemoryJournalDataSize() {
return getOnDemandRaftState().getInMemoryJournalDataSize();
}
@@ -274,10 +275,10 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
}
/**
- * resets the counters related to transactions
+ * Resets the counters related to transactions.
*/
@Override
- public void resetTransactionCounters(){
+ public void resetTransactionCounters() {
committedTransactionsCount = 0;
readOnlyTransactionCount = 0;
@@ -358,7 +359,7 @@ public class ShardStats extends AbstractMXBean implements ShardStatsMXBean {
@Override
public void captureSnapshot() {
- if(shard != null) {
+ if (shard != null) {
shard.getSelf().tell(new InitiateCaptureSnapshot(), ActorRef.noSender());
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMXBean.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMXBean.java
index 1ae58e2fe8..f32b13e69b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMXBean.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardStatsMXBean.java
@@ -12,83 +12,85 @@ import java.util.List;
import org.opendaylight.controller.cluster.raft.client.messages.FollowerInfo;
/**
+ * MXBean interface for shard stats.
+ *
* @author: syedbahm
*/
public interface ShardStatsMXBean {
- String getShardName();
+ String getShardName();
- String getStatRetrievalTime();
+ String getStatRetrievalTime();
- String getStatRetrievalError();
+ String getStatRetrievalError();
- long getCommittedTransactionsCount();
+ long getCommittedTransactionsCount();
- long getReadOnlyTransactionCount();
+ long getReadOnlyTransactionCount();
- long getWriteOnlyTransactionCount();
+ long getWriteOnlyTransactionCount();
- long getReadWriteTransactionCount();
+ long getReadWriteTransactionCount();
- long getLastLogIndex();
+ long getLastLogIndex();
- long getLastLogTerm();
+ long getLastLogTerm();
- long getCurrentTerm();
+ long getCurrentTerm();
- long getCommitIndex();
+ long getCommitIndex();
- long getLastApplied();
+ long getLastApplied();
- long getLastIndex();
+ long getLastIndex();
- long getLastTerm();
+ long getLastTerm();
- long getSnapshotIndex();
+ long getSnapshotIndex();
- long getSnapshotTerm();
+ long getSnapshotTerm();
- long getReplicatedToAllIndex();
+ long getReplicatedToAllIndex();
- String getLastCommittedTransactionTime();
+ String getLastCommittedTransactionTime();
- long getFailedTransactionsCount();
+ long getFailedTransactionsCount();
- long getAbortTransactionsCount();
+ long getAbortTransactionsCount();
- long getFailedReadTransactionsCount();
+ long getFailedReadTransactionsCount();
- String getLeader();
+ String getLeader();
- String getRaftState();
+ String getRaftState();
- String getVotedFor();
+ String getVotedFor();
- boolean isSnapshotCaptureInitiated();
+ boolean isSnapshotCaptureInitiated();
- boolean isVoting();
+ boolean isVoting();
- void resetTransactionCounters();
+ void resetTransactionCounters();
- long getInMemoryJournalDataSize();
+ long getInMemoryJournalDataSize();
- long getInMemoryJournalLogSize();
+ long getInMemoryJournalLogSize();
- boolean getFollowerInitialSyncStatus();
+ boolean getFollowerInitialSyncStatus();
- List getFollowerInfo();
+ List getFollowerInfo();
- String getPeerAddresses();
+ String getPeerAddresses();
- String getPeerVotingStates();
+ String getPeerVotingStates();
- long getLeadershipChangeCount();
+ long getLeadershipChangeCount();
- String getLastLeadershipChangeTime();
+ String getLastLeadershipChangeTime();
- int getPendingTxCommitQueueSize();
+ int getPendingTxCommitQueueSize();
- int getTxCohortCacheSize();
+ int getTxCohortCacheSize();
- void captureSnapshot();
+ void captureSnapshot();
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java
index 57a4e395fa..25c13989d5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransaction.java
@@ -23,7 +23,7 @@ public class AbortTransaction extends AbstractThreePhaseCommitMessage {
public static AbortTransaction fromSerializable(Object serializable) {
Preconditions.checkArgument(serializable instanceof AbortTransaction);
- return (AbortTransaction)serializable;
+ return (AbortTransaction)serializable;
}
public static boolean isSerializedType(Object message) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AddShardReplica.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AddShardReplica.java
index fd20d20c0b..c9028466d4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AddShardReplica.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AddShardReplica.java
@@ -8,8 +8,8 @@
package org.opendaylight.controller.cluster.datastore.messages;
-import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
/**
* A message sent to the ShardManager to dynamically add a new local shard
@@ -27,16 +27,16 @@ public class AddShardReplica {
* @param shardName name of the shard that is to be locally replicated.
*/
- public AddShardReplica (@Nonnull String shardName){
+ public AddShardReplica(@Nonnull String shardName) {
this.shardName = Preconditions.checkNotNull(shardName, "ShardName should not be null");
}
- public String getShardName(){
+ public String getShardName() {
return this.shardName;
}
@Override
- public String toString(){
+ public String toString() {
return "AddShardReplica[ShardName=" + shardName + "]";
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java
index 563b330b98..430202af42 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataChangeListenerRegistrationReply.java
@@ -10,7 +10,8 @@ package org.opendaylight.controller.cluster.datastore.messages;
public class CloseDataChangeListenerRegistrationReply {
- public static final CloseDataChangeListenerRegistrationReply INSTANCE = new CloseDataChangeListenerRegistrationReply();
+ public static final CloseDataChangeListenerRegistrationReply INSTANCE =
+ new CloseDataChangeListenerRegistrationReply();
private CloseDataChangeListenerRegistrationReply() {
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistration.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistration.java
index 032f4c10b0..dfcc894ffe 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistration.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistration.java
@@ -12,7 +12,8 @@ import java.io.Serializable;
public final class CloseDataTreeChangeListenerRegistration implements Serializable {
private static final long serialVersionUID = 1L;
- private static final CloseDataTreeChangeListenerRegistration INSTANCE = new CloseDataTreeChangeListenerRegistration();
+ private static final CloseDataTreeChangeListenerRegistration INSTANCE =
+ new CloseDataTreeChangeListenerRegistration();
private CloseDataTreeChangeListenerRegistration() {
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistrationReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistrationReply.java
index 9d83fac27c..a7717b69e0 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistrationReply.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseDataTreeChangeListenerRegistrationReply.java
@@ -12,7 +12,8 @@ import java.io.Serializable;
public final class CloseDataTreeChangeListenerRegistrationReply implements Serializable {
private static final long serialVersionUID = 1L;
- private static final CloseDataTreeChangeListenerRegistrationReply INSTANCE = new CloseDataTreeChangeListenerRegistrationReply();
+ private static final CloseDataTreeChangeListenerRegistrationReply INSTANCE =
+ new CloseDataTreeChangeListenerRegistrationReply();
private CloseDataTreeChangeListenerRegistrationReply() {
// Use getInstance() instead
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
index 24c0c5cab1..2fe96cbe67 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
@@ -15,7 +15,8 @@ import java.io.ObjectOutput;
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
import org.opendaylight.yangtools.concepts.Identifiable;
-public class CloseTransactionChain extends VersionedExternalizableMessage implements Identifiable {
+public class CloseTransactionChain extends VersionedExternalizableMessage
+ implements Identifiable {
private static final long serialVersionUID = 1L;
private LocalHistoryIdentifier transactionChainId;
@@ -45,7 +46,7 @@ public class CloseTransactionChain extends VersionedExternalizableMessage implem
transactionChainId.writeTo(out);
}
- public static CloseTransactionChain fromSerializable(final Object serializable){
+ public static CloseTransactionChain fromSerializable(final Object serializable) {
Preconditions.checkArgument(serializable instanceof CloseTransactionChain);
return (CloseTransactionChain)serializable;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java
index 97231dc366..c48adf2d80 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java
@@ -54,7 +54,7 @@ public class DataChanged implements Externalizable {
// Read created data
int size = in.readInt();
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
NormalizedNode, ?> node = streamReader.readNormalizedNode();
builder.addCreated(path, node);
@@ -63,7 +63,7 @@ public class DataChanged implements Externalizable {
// Read updated data
size = in.readInt();
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
NormalizedNode, ?> before = streamReader.readNormalizedNode();
NormalizedNode, ?> after = streamReader.readNormalizedNode();
@@ -73,7 +73,7 @@ public class DataChanged implements Externalizable {
// Read removed data
size = in.readInt();
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
NormalizedNode, ?> node = streamReader.readNormalizedNode();
builder.addRemoved(path, node);
@@ -82,14 +82,14 @@ public class DataChanged implements Externalizable {
// Read original subtree
boolean present = in.readBoolean();
- if(present) {
+ if (present) {
builder.setBefore(streamReader.readNormalizedNode());
}
// Read updated subtree
present = in.readBoolean();
- if(present) {
+ if (present) {
builder.setAfter(streamReader.readNormalizedNode());
}
@@ -106,7 +106,7 @@ public class DataChanged implements Externalizable {
Map> createdData = change.getCreatedData();
out.writeInt(createdData.size());
- for(Map.Entry> e: createdData.entrySet()) {
+ for (Map.Entry> e: createdData.entrySet()) {
streamWriter.writeYangInstanceIdentifier(e.getKey());
streamWriter.writeNormalizedNode(e.getValue());
}
@@ -116,7 +116,7 @@ public class DataChanged implements Externalizable {
Map> originalData = change.getOriginalData();
Map> updatedData = change.getUpdatedData();
out.writeInt(updatedData.size());
- for(Map.Entry> e: updatedData.entrySet()) {
+ for (Map.Entry> e: updatedData.entrySet()) {
streamWriter.writeYangInstanceIdentifier(e.getKey());
streamWriter.writeNormalizedNode(originalData.get(e.getKey()));
streamWriter.writeNormalizedNode(e.getValue());
@@ -126,7 +126,7 @@ public class DataChanged implements Externalizable {
Set removed = change.getRemovedPaths();
out.writeInt(removed.size());
- for(YangInstanceIdentifier path: removed) {
+ for (YangInstanceIdentifier path: removed) {
streamWriter.writeYangInstanceIdentifier(path);
streamWriter.writeNormalizedNode(originalData.get(path));
}
@@ -135,7 +135,7 @@ public class DataChanged implements Externalizable {
NormalizedNode, ?> originalSubtree = change.getOriginalSubtree();
out.writeBoolean(originalSubtree != null);
- if(originalSubtree != null) {
+ if (originalSubtree != null) {
streamWriter.writeNormalizedNode(originalSubtree);
}
@@ -143,7 +143,7 @@ public class DataChanged implements Externalizable {
NormalizedNode, ?> updatedSubtree = change.getUpdatedSubtree();
out.writeBoolean(updatedSubtree != null);
- if(updatedSubtree != null) {
+ if (updatedSubtree != null) {
streamWriter.writeNormalizedNode(updatedSubtree);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
index db62547d42..1bd687cbb7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
@@ -32,10 +32,11 @@ public class DataExists extends AbstractRead {
@Override
public void processResponse(Object response, SettableFuture returnFuture) {
- if(DataExistsReply.isSerializedType(response)) {
+ if (DataExistsReply.isSerializedType(response)) {
returnFuture.set(Boolean.valueOf(DataExistsReply.fromSerializable(response).exists()));
} else {
- returnFuture.setException(new ReadFailedException("Invalid response checking exists for path " + getPath()));
+ returnFuture.setException(new ReadFailedException("Invalid response checking exists for path "
+ + getPath()));
}
}
@@ -44,7 +45,7 @@ public class DataExists extends AbstractRead {
return new DataExists(getPath(), withVersion);
}
- public static DataExists fromSerializable(final Object serializable){
+ public static DataExists fromSerializable(final Object serializable) {
Preconditions.checkArgument(serializable instanceof DataExists);
return (DataExists)serializable;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindLocalShard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindLocalShard.java
index 2449a2b3da..380e71e78a 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindLocalShard.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindLocalShard.java
@@ -9,8 +9,9 @@
package org.opendaylight.controller.cluster.datastore.messages;
/**
- * FindLocalShard is a message that should be sent to the {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager}
- * when we need to find a reference to a LocalShard
+ * FindLocalShard is a message that should be sent to the
+ * {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager} when we need to find a reference
+ * to a LocalShard.
*/
public class FindLocalShard {
private final String shardName;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java
index 0b7fcf0ed5..507f61520a 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java
@@ -12,8 +12,7 @@ import com.google.common.base.Preconditions;
import java.io.Serializable;
/**
- * The FindPrimary message is used to locate the primary of any given shard
- *
+ * The FindPrimary message is used to locate the primary of any given shard.
*/
public class FindPrimary implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardFound.java
index b0b66ae372..5c58a894db 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardFound.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardFound.java
@@ -11,8 +11,9 @@ package org.opendaylight.controller.cluster.datastore.messages;
import akka.actor.ActorRef;
/**
- * LocalShardFound is a message that is sent by the {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager}
- * when it finds a shard with the specified name in it's local shard registry
+ * LocalShardFound is a message that is sent by the
+ * {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager}
+ * when it finds a shard with the specified name in it's local shard registry.
*/
public class LocalShardFound {
private final ActorRef path;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardNotFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardNotFound.java
index 6d08be4847..381eb56231 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardNotFound.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalShardNotFound.java
@@ -9,13 +9,15 @@
package org.opendaylight.controller.cluster.datastore.messages;
/**
- * LocalShardNotFound is a message that is sent by the {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager}
- * when it cannot locate a shard in it's local registry with the shardName specified
+ * LocalShardNotFound is a message that is sent by the
+ * {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager}
+ * when it cannot locate a shard in it's local registry with the shardName specified.
*/
public class LocalShardNotFound {
private final String shardName;
/**
+ * Constructs an instance.
*
* @param shardName the name of the shard that could not be found
*/
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
index a9d1311d61..e79513e06a 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
@@ -28,15 +28,16 @@ public class ReadData extends AbstractRead>> {
}
@Override
- public CheckedFuture>, ReadFailedException> apply(DOMStoreReadTransaction readDelegate) {
+ public CheckedFuture>, ReadFailedException> apply(
+ DOMStoreReadTransaction readDelegate) {
return readDelegate.read(getPath());
}
@Override
public void processResponse(Object readResponse, SettableFuture>> returnFuture) {
- if(ReadDataReply.isSerializedType(readResponse)) {
+ if (ReadDataReply.isSerializedType(readResponse)) {
ReadDataReply reply = ReadDataReply.fromSerializable(readResponse);
- returnFuture.set(Optional.> fromNullable(reply.getNormalizedNode()));
+ returnFuture.set(Optional.>fromNullable(reply.getNormalizedNode()));
} else {
returnFuture.setException(new ReadFailedException("Invalid response reading data for path " + getPath()));
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java
index f48811203c..1f457780e5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java
@@ -17,8 +17,8 @@ import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
- * Request a {@link org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener} registration be made on the shard
- * leader.
+ * Request a {@link org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener} registration be made on the
+ * shard leader.
*/
public final class RegisterDataTreeChangeListener implements Externalizable, ListenerRegistrationMessage {
private static final long serialVersionUID = 1L;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoveShardReplica.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoveShardReplica.java
index 51f9d59f85..0325ee9f2b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoveShardReplica.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoveShardReplica.java
@@ -26,12 +26,12 @@ public class RemoveShardReplica {
*
* @param shardName name of the local shard that is to be dynamically removed.
*/
- public RemoveShardReplica (@Nonnull String shardName, @Nonnull MemberName memberName) {
+ public RemoveShardReplica(@Nonnull String shardName, @Nonnull MemberName memberName) {
this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null");
}
- public String getShardName(){
+ public String getShardName() {
return shardName;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/UpdateSchemaContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/UpdateSchemaContext.java
index 47f9ea8c4f..16f49e278a 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/UpdateSchemaContext.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/UpdateSchemaContext.java
@@ -11,13 +11,13 @@ package org.opendaylight.controller.cluster.datastore.messages;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class UpdateSchemaContext {
- private final SchemaContext schemaContext;
+ private final SchemaContext schemaContext;
- public UpdateSchemaContext(SchemaContext schemaContext) {
- this.schemaContext = schemaContext;
- }
+ public UpdateSchemaContext(SchemaContext schemaContext) {
+ this.schemaContext = schemaContext;
+ }
- public SchemaContext getSchemaContext() {
- return schemaContext;
- }
+ public SchemaContext getSchemaContext() {
+ return schemaContext;
+ }
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/VersionedExternalizableMessage.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/VersionedExternalizableMessage.java
index 51a9079d20..781580a643 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/VersionedExternalizableMessage.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/VersionedExternalizableMessage.java
@@ -27,7 +27,7 @@ public abstract class VersionedExternalizableMessage implements Externalizable,
}
public VersionedExternalizableMessage(short version) {
- this.version = version <= DataStoreVersions.CURRENT_VERSION ? version: DataStoreVersions.CURRENT_VERSION;
+ this.version = version <= DataStoreVersions.CURRENT_VERSION ? version : DataStoreVersions.CURRENT_VERSION;
}
public short getVersion() {
@@ -47,7 +47,8 @@ public abstract class VersionedExternalizableMessage implements Externalizable,
@Override
public final Object toSerializable() {
if (getVersion() < DataStoreVersions.BORON_VERSION) {
- throw new UnsupportedOperationException("Versions prior to " + DataStoreVersions.BORON_VERSION + " are not supported");
+ throw new UnsupportedOperationException("Versions prior to " + DataStoreVersions.BORON_VERSION
+ + " are not supported");
}
return this;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
index 77f0858d7b..02b8047b44 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
@@ -12,7 +12,7 @@ package org.opendaylight.controller.cluster.datastore.modification;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
- * Base class to be used for all simple modifications that can be applied to a DOMStoreTransaction
+ * Base class to be used for all simple modifications that can be applied to a DOMStoreTransaction.
*/
public abstract class AbstractModification implements Modification {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java
index 4c856d31eb..2bc6d1d84c 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java
@@ -19,8 +19,9 @@ import java.util.List;
*/
public interface CompositeModification extends Modification {
/**
- * Get a list of Modifications contained by this Composite
- * @return
+ * Get a list of modifications contained by this composite.
+ *
+ * @return list of modifications
*/
List getModifications();
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
index 08274ef705..a069d6c5c4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
/**
- * DeleteModification store all the parameters required to delete a path from the data tree
+ * DeleteModification store all the parameters required to delete a path from the data tree.
*/
public class DeleteModification extends AbstractModification {
private static final long serialVersionUID = 1L;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
index 10b9b94242..47c6f5d4f5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
/**
- * MergeModification stores all the parameters required to merge data into the specified path
+ * MergeModification stores all the parameters required to merge data into the specified path.
*/
public class MergeModification extends WriteModification {
private static final long serialVersionUID = 1L;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
index e9d2fdf291..97b5e745df 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
@@ -22,8 +22,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification
*
*
*
- * Modifications can in turn be lumped into a single {@link org.opendaylight.controller.cluster.datastore.modification.CompositeModification}
- * which can then be applied to a write transaction
+ * Modifications can in turn be lumped into a single
+ * {@link org.opendaylight.controller.cluster.datastore.modification.CompositeModification}
+ * which can then be applied to a write transaction.
*
*/
public interface Modification extends Externalizable {
@@ -34,16 +35,16 @@ public interface Modification extends Externalizable {
byte DELETE = 4;
/**
- * Apply the modification to the specified transaction
+ * Apply the modification to the specified transaction.
*
- * @param transaction
+ * @param transaction the transaction
*/
void apply(DOMStoreWriteTransaction transaction);
/**
- * Apply the modification to the specified transaction
+ * Apply the modification to the specified transaction.
*
- * @param transaction
+ * @param transaction the transaction
*/
void apply(DataTreeModification transaction);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
index 0c9a73a0d0..163e23d2d1 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
@@ -23,8 +23,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
/**
- * MutableCompositeModification is just a mutable version of a
- * CompositeModification {@link org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification#addModification(Modification)}
+ * MutableCompositeModification is just a mutable version of a CompositeModification.
*/
public class MutableCompositeModification extends VersionedExternalizableMessage implements CompositeModification {
private static final long serialVersionUID = 1L;
@@ -59,10 +58,9 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
}
/**
- * Add a new Modification to the list of Modifications represented by this
- * composite
+ * Add a new Modification to the list of Modifications represented by this composite.
*
- * @param modification
+ * @param modification the modification to add.
*/
public void addModification(Modification modification) {
modifications.add(modification);
@@ -79,25 +77,27 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
int size = in.readInt();
- if(size > 1) {
+ if (size > 1) {
SerializationUtils.REUSABLE_READER_TL.set(new NormalizedNodeInputStreamReader(in));
}
try {
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
byte type = in.readByte();
- switch(type) {
- case Modification.WRITE:
- modifications.add(WriteModification.fromStream(in, getVersion()));
- break;
-
- case Modification.MERGE:
- modifications.add(MergeModification.fromStream(in, getVersion()));
- break;
-
- case Modification.DELETE:
- modifications.add(DeleteModification.fromStream(in, getVersion()));
- break;
+ switch (type) {
+ case Modification.WRITE:
+ modifications.add(WriteModification.fromStream(in, getVersion()));
+ break;
+
+ case Modification.MERGE:
+ modifications.add(MergeModification.fromStream(in, getVersion()));
+ break;
+
+ case Modification.DELETE:
+ modifications.add(DeleteModification.fromStream(in, getVersion()));
+ break;
+ default:
+ break;
}
}
} finally {
@@ -111,12 +111,12 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
out.writeInt(modifications.size());
- if(modifications.size() > 1) {
+ if (modifications.size() > 1) {
SerializationUtils.REUSABLE_WRITER_TL.set(NormalizedNodeInputOutput.newDataOutput(out));
}
try {
- for(Modification mod: modifications) {
+ for (Modification mod: modifications) {
out.writeByte(mod.getType());
mod.writeExternal(out);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
index e400fcc1df..cbc25d71c3 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
/**
- * WriteModification stores all the parameters required to write data to the specified path
+ * WriteModification stores all the parameters required to write data to the specified path.
*/
public class WriteModification extends AbstractModification {
private static final long serialVersionUID = 1L;
@@ -76,12 +76,8 @@ public class WriteModification extends AbstractModification {
return mod;
}
- private static final Applier APPLIER = new Applier() {
- @Override
- public void apply(WriteModification instance, YangInstanceIdentifier path,
- NormalizedNode, ?> node) {
- instance.setPath(path);
- instance.data = node;
- }
+ private static final Applier APPLIER = (instance, path, node) -> {
+ instance.setPath(path);
+ instance.data = node;
};
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java
index 5c3723e2aa..b553bf92a2 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java
@@ -22,6 +22,9 @@ public final class AbortTransactionPayload extends AbstractIdentifiablePayload {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java
index 122c96938e..4692236532 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java
@@ -26,7 +26,8 @@ import org.opendaylight.yangtools.concepts.Identifier;
*
* @author Robert Varga
*/
-public abstract class AbstractIdentifiablePayload extends Payload implements Identifiable, Serializable {
+public abstract class AbstractIdentifiablePayload
+ extends Payload implements Identifiable, Serializable {
protected abstract static class AbstractProxy implements Externalizable {
private static final long serialVersionUID = 1L;
private byte[] serialized;
@@ -58,15 +59,18 @@ public abstract class AbstractIdentifiablePayload extends
return Verify.verifyNotNull(createObject(identifier, serialized));
}
- protected abstract @Nonnull T readIdentifier(@Nonnull DataInput in) throws IOException;
- protected abstract @Nonnull Identifiable createObject(@Nonnull T identifier, @Nonnull byte[] serialized);
+ @Nonnull
+ protected abstract T readIdentifier(@Nonnull DataInput in) throws IOException;
+
+ @Nonnull
+ protected abstract Identifiable createObject(@Nonnull T identifier, @Nonnull byte[] serialized);
}
private static final long serialVersionUID = 1L;
private final byte[] serialized;
private final T identifier;
- AbstractIdentifiablePayload(final @Nonnull T identifier, final @Nonnull byte[] serialized) {
+ AbstractIdentifiablePayload(@Nonnull final T identifier, @Nonnull final byte[] serialized) {
this.identifier = Preconditions.checkNotNull(identifier);
this.serialized = Preconditions.checkNotNull(serialized);
}
@@ -85,5 +89,6 @@ public abstract class AbstractIdentifiablePayload extends
return Verify.verifyNotNull(externalizableProxy(serialized));
}
- protected abstract @Nonnull AbstractProxy externalizableProxy(@Nonnull byte[] serialized);
+ @Nonnull
+ protected abstract AbstractProxy externalizableProxy(@Nonnull byte[] serialized);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java
index 0d92eac586..48d2673421 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnapshot {
private static final Logger LOG = LoggerFactory.getLogger(AbstractVersionedShardDataTreeSnapshot.class);
+ @SuppressWarnings("checkstyle:FallThrough")
static ShardDataTreeSnapshot deserialize(final DataInputStream is) throws IOException {
final PayloadVersion version = PayloadVersion.readFrom(is);
switch (version) {
@@ -44,6 +45,8 @@ abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnaps
case TEST_PAST_VERSION:
// These versions are never returned and this code is effectively dead
break;
+ default:
+ throw new IOException("Invalid payload version in snapshot");
}
// Not included as default in above switch to ensure we get warnings when new versions are added
@@ -60,14 +63,16 @@ abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnaps
*
* @return The root node.
*/
- abstract @Nonnull NormalizedNode, ?> rootNode();
+ @Nonnull
+ abstract NormalizedNode, ?> rootNode();
/**
* Return the snapshot payload version. Implementations of this method should return a constant.
*
* @return Snapshot payload version
*/
- abstract @Nonnull PayloadVersion version();
+ @Nonnull
+ abstract PayloadVersion version();
private void versionedSerialize(final DataOutputStream dos, final PayloadVersion version) throws IOException {
switch (version) {
@@ -80,7 +85,8 @@ abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnaps
case TEST_FUTURE_VERSION:
case TEST_PAST_VERSION:
break;
-
+ default:
+ throw new IOException("Invalid payload version in snapshot");
}
throw new IOException("Encountered unhandled version" + version);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java
index c348727cf8..080ecfbe4a 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java
@@ -35,6 +35,9 @@ public final class CommitTransactionPayload extends Payload implements Serializa
private static final long serialVersionUID = 1L;
private byte[] serialized;
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java
index 9d0153f6b7..b765cabc7e 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java
@@ -80,20 +80,20 @@ public final class DataTreeCandidateInputOutput {
private static DataTreeCandidateNode readNode(final NormalizedNodeDataInput in) throws IOException {
final byte type = in.readByte();
switch (type) {
- case APPEARED:
- return readModifiedNode(ModificationType.APPEARED, in);
- case DELETE:
- return DeletedDataTreeCandidateNode.create(in.readPathArgument());
- case DISAPPEARED:
- return readModifiedNode(ModificationType.DISAPPEARED, in);
- case SUBTREE_MODIFIED:
- return readModifiedNode(ModificationType.SUBTREE_MODIFIED, in);
- case UNMODIFIED:
- return null;
- case WRITE:
- return DataTreeCandidateNodes.fromNormalizedNode(in.readNormalizedNode());
- default:
- throw new IllegalArgumentException("Unhandled node type " + type);
+ case APPEARED:
+ return readModifiedNode(ModificationType.APPEARED, in);
+ case DELETE:
+ return DeletedDataTreeCandidateNode.create(in.readPathArgument());
+ case DISAPPEARED:
+ return readModifiedNode(ModificationType.DISAPPEARED, in);
+ case SUBTREE_MODIFIED:
+ return readModifiedNode(ModificationType.SUBTREE_MODIFIED, in);
+ case UNMODIFIED:
+ return null;
+ case WRITE:
+ return DataTreeCandidateNodes.fromNormalizedNode(in.readNormalizedNode());
+ default:
+ throw new IllegalArgumentException("Unhandled node type " + type);
}
}
@@ -104,17 +104,17 @@ public final class DataTreeCandidateInputOutput {
final DataTreeCandidateNode rootNode;
switch (type) {
- case DELETE:
- rootNode = DeletedDataTreeCandidateNode.create();
- break;
- case SUBTREE_MODIFIED:
- rootNode = ModifiedDataTreeCandidateNode.create(readChildren(reader));
- break;
- case WRITE:
- rootNode = DataTreeCandidateNodes.fromNormalizedNode(reader.readNormalizedNode());
- break;
- default:
- throw new IllegalArgumentException("Unhandled node type " + type);
+ case DELETE:
+ rootNode = DeletedDataTreeCandidateNode.create();
+ break;
+ case SUBTREE_MODIFIED:
+ rootNode = ModifiedDataTreeCandidateNode.create(readChildren(reader));
+ break;
+ case WRITE:
+ rootNode = DataTreeCandidateNodes.fromNormalizedNode(reader.readNormalizedNode());
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled node type " + type);
}
return DataTreeCandidates.newDataTreeCandidate(rootPath, rootNode);
@@ -132,67 +132,67 @@ public final class DataTreeCandidateInputOutput {
private static void writeNode(final NormalizedNodeDataOutput out, final DataTreeCandidateNode node)
throws IOException {
switch (node.getModificationType()) {
- case APPEARED:
- out.writeByte(APPEARED);
- out.writePathArgument(node.getIdentifier());
- writeChildren(out, node.getChildNodes());
- break;
- case DELETE:
- out.writeByte(DELETE);
- out.writePathArgument(node.getIdentifier());
- break;
- case DISAPPEARED:
- out.writeByte(DISAPPEARED);
- out.writePathArgument(node.getIdentifier());
- writeChildren(out, node.getChildNodes());
- break;
- case SUBTREE_MODIFIED:
- out.writeByte(SUBTREE_MODIFIED);
- out.writePathArgument(node.getIdentifier());
- writeChildren(out, node.getChildNodes());
- break;
- case WRITE:
- out.writeByte(WRITE);
- out.writeNormalizedNode(node.getDataAfter().get());
- break;
- case UNMODIFIED:
- out.writeByte(UNMODIFIED);
- break;
- default:
- throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
- }
- }
-
- public static void writeDataTreeCandidate(final DataOutput out, DataTreeCandidate candidate) throws IOException {
- try (final NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
- writer.writeYangInstanceIdentifier(candidate.getRootPath());
-
- final DataTreeCandidateNode node = candidate.getRootNode();
- switch (node.getModificationType()) {
case APPEARED:
- writer.writeByte(APPEARED);
- writeChildren(writer, node.getChildNodes());
+ out.writeByte(APPEARED);
+ out.writePathArgument(node.getIdentifier());
+ writeChildren(out, node.getChildNodes());
break;
case DELETE:
- writer.writeByte(DELETE);
+ out.writeByte(DELETE);
+ out.writePathArgument(node.getIdentifier());
break;
case DISAPPEARED:
- writer.writeByte(DISAPPEARED);
- writeChildren(writer, node.getChildNodes());
+ out.writeByte(DISAPPEARED);
+ out.writePathArgument(node.getIdentifier());
+ writeChildren(out, node.getChildNodes());
break;
case SUBTREE_MODIFIED:
- writer.writeByte(SUBTREE_MODIFIED);
- writeChildren(writer, node.getChildNodes());
- break;
- case UNMODIFIED:
- writer.writeByte(UNMODIFIED);
+ out.writeByte(SUBTREE_MODIFIED);
+ out.writePathArgument(node.getIdentifier());
+ writeChildren(out, node.getChildNodes());
break;
case WRITE:
- writer.writeByte(WRITE);
- writer.writeNormalizedNode(node.getDataAfter().get());
+ out.writeByte(WRITE);
+ out.writeNormalizedNode(node.getDataAfter().get());
+ break;
+ case UNMODIFIED:
+ out.writeByte(UNMODIFIED);
break;
default:
throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
+ }
+ }
+
+ public static void writeDataTreeCandidate(final DataOutput out, DataTreeCandidate candidate) throws IOException {
+ try (final NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
+ writer.writeYangInstanceIdentifier(candidate.getRootPath());
+
+ final DataTreeCandidateNode node = candidate.getRootNode();
+ switch (node.getModificationType()) {
+ case APPEARED:
+ writer.writeByte(APPEARED);
+ writeChildren(writer, node.getChildNodes());
+ break;
+ case DELETE:
+ writer.writeByte(DELETE);
+ break;
+ case DISAPPEARED:
+ writer.writeByte(DISAPPEARED);
+ writeChildren(writer, node.getChildNodes());
+ break;
+ case SUBTREE_MODIFIED:
+ writer.writeByte(SUBTREE_MODIFIED);
+ writeChildren(writer, node.getChildNodes());
+ break;
+ case UNMODIFIED:
+ writer.writeByte(UNMODIFIED);
+ break;
+ case WRITE:
+ writer.writeByte(WRITE);
+ writer.writeNormalizedNode(node.getDataAfter().get());
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
}
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DeletedDataTreeCandidateNode.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DeletedDataTreeCandidateNode.java
index 14397794ed..085a8457d1 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DeletedDataTreeCandidateNode.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DeletedDataTreeCandidateNode.java
@@ -34,7 +34,7 @@ abstract class DeletedDataTreeCandidateNode extends AbstractDataTreeCandidateNod
static DataTreeCandidateNode create(final PathArgument identifier) {
return new DeletedDataTreeCandidateNode() {
@Override
- public final PathArgument getIdentifier() {
+ public PathArgument getIdentifier() {
return identifier;
}
};
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java
index 55d9757371..4ad82602b1 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java
@@ -25,6 +25,9 @@ public final class FrontendShardDataTreeSnapshotMetadata extends
private List clients;
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java
index 8cde0d9532..36a82e543e 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java
@@ -29,7 +29,8 @@ import org.slf4j.LoggerFactory;
* @author Robert Varga
*/
@Beta
-public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardDataTreeSnapshot implements Serializable {
+public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardDataTreeSnapshot
+ implements Serializable {
private static final class Proxy implements Externalizable {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(MetadataShardDataTreeSnapshot.class);
@@ -37,6 +38,9 @@ public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardD
private Map>, ShardDataTreeSnapshotMetadata>> metadata;
private NormalizedNode, ?> rootNode;
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
@@ -62,8 +66,8 @@ public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardD
Preconditions.checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize);
// Default pre-allocate is 4, which should be fine
- final Builder>, ShardDataTreeSnapshotMetadata>> metaBuilder =
- ImmutableMap.builder();
+ final Builder>, ShardDataTreeSnapshotMetadata>>
+ metaBuilder = ImmutableMap.builder();
for (int i = 0; i < metaSize; ++i) {
final ShardDataTreeSnapshotMetadata> m = (ShardDataTreeSnapshotMetadata>) in.readObject();
if (m != null) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java
index 59d03d465e..c319286bf7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java
@@ -22,7 +22,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
abstract class ModifiedDataTreeCandidateNode extends AbstractDataTreeCandidateNode {
private final Collection children;
- private ModifiedDataTreeCandidateNode(final ModificationType type, final Collection children) {
+ private ModifiedDataTreeCandidateNode(final ModificationType type,
+ final Collection children) {
super(type);
this.children = Preconditions.checkNotNull(children);
}
@@ -36,10 +37,11 @@ abstract class ModifiedDataTreeCandidateNode extends AbstractDataTreeCandidateNo
};
}
- static DataTreeCandidateNode create(final PathArgument identifier, final ModificationType type, final Collection children) {
+ static DataTreeCandidateNode create(final PathArgument identifier, final ModificationType type,
+ final Collection children) {
return new ModifiedDataTreeCandidateNode(type, children) {
@Override
- public final PathArgument getIdentifier() {
+ public PathArgument getIdentifier() {
return identifier;
}
};
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PayloadVersion.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PayloadVersion.java
index 051a375cd6..0f52dacc5b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PayloadVersion.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PayloadVersion.java
@@ -21,7 +21,7 @@ import org.opendaylight.yangtools.concepts.WritableObject;
* whenever:
* - a new event is defined
* - serialization format is changed
- *
+ *
* This version effectively defines the protocol version between actors participating on a particular shard. A shard
* participant instance should oppose RAFT candidates which produce persistence of an unsupported version. If a follower
* encounters an unsupported version it must not become fully-operational, as it does not have an accurate view
@@ -73,7 +73,8 @@ public enum PayloadVersion implements WritableObject {
*
* @return Current {@link PayloadVersion}
*/
- public static @Nonnull PayloadVersion current() {
+ @Nonnull
+ public static PayloadVersion current() {
return BORON;
}
@@ -81,23 +82,24 @@ public enum PayloadVersion implements WritableObject {
* Return the {@link PayloadVersion} corresponding to an unsigned short integer. This method is provided for callers
* which provide their own recovery strategy in case of version incompatibility.
*
- * @param s Short integer as returned from {@link #shortValue()}
+ * @param version Short integer as returned from {@link #shortValue()}
* @return {@link PayloadVersion}
* @throws FutureVersionException if the specified integer identifies a future version
* @throws PastVersionException if the specified integer identifies a past version which is no longer supported
*/
- public static @Nonnull PayloadVersion valueOf(final short s) throws FutureVersionException, PastVersionException {
- switch (Short.toUnsignedInt(s)) {
+ @Nonnull
+ public static PayloadVersion valueOf(final short version) throws FutureVersionException, PastVersionException {
+ switch (Short.toUnsignedInt(version)) {
case 0:
case 1:
case 2:
case 3:
case 4:
- throw new PastVersionException(s, BORON);
+ throw new PastVersionException(version, BORON);
case 5:
return BORON;
default:
- throw new FutureVersionException(s, BORON);
+ throw new FutureVersionException(version, BORON);
}
}
@@ -114,7 +116,8 @@ public enum PayloadVersion implements WritableObject {
* @return An {@link PayloadVersion}
* @throws IOException If read fails or an unsupported version is encountered
*/
- public static @Nonnull PayloadVersion readFrom(final @Nonnull DataInput in) throws IOException {
+ @Nonnull
+ public static PayloadVersion readFrom(@Nonnull final DataInput in) throws IOException {
final short s = in.readShort();
try {
return valueOf(s);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java
index 7941c9fa59..f883a8d358 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java
@@ -16,17 +16,18 @@ import javax.annotation.Nonnull;
* Base class for various bits of metadata attached to a {@link MetadataShardDataTreeSnapshot}. This class is not
* an interface because we want to make sure all subclasses implement the externalizable proxy pattern, for which
* we need to force {@link #readResolve()} to be abstract.
- *
+ *
* All concrete subclasses of this class should be final so as to form a distinct set of possible metadata. Since
* metadata is serialized along with {@link MetadataShardDataTreeSnapshot}, this set is part of the serialization format
* guarded by {@link PayloadVersion}.
- *
+ *
* If a new metadata type is introduced or a type is removed, {@link PayloadVersion} needs to be bumped to ensure
* compatibility.
*
* @author Robert Varga
*/
-public abstract class ShardDataTreeSnapshotMetadata> implements Serializable {
+public abstract class ShardDataTreeSnapshotMetadata>
+ implements Serializable {
private static final long serialVersionUID = 1L;
ShardDataTreeSnapshotMetadata() {
@@ -38,7 +39,7 @@ public abstract class ShardDataTreeSnapshotMetadata iter = onShardInitializedSet.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext()) {
OnShardInitialized onShardInitialized = iter.next();
if (!(onShardInitialized instanceof OnShardReady) || ready) {
iter.remove();
@@ -211,14 +209,14 @@ final class ShardInformation {
notifyOnShardInitializedCallbacks();
}
- void setFollowerSyncStatus(boolean syncStatus){
+ void setFollowerSyncStatus(boolean syncStatus) {
this.followerSyncStatus = syncStatus;
}
- boolean isInSync(){
- if(RaftState.Follower.name().equals(this.role)){
+ boolean isInSync() {
+ if (RaftState.Follower.name().equals(this.role)) {
return followerSyncStatus;
- } else if(RaftState.Leader.name().equals(this.role)){
+ } else if (RaftState.Leader.name().equals(this.role)) {
return true;
}
@@ -226,9 +224,9 @@ final class ShardInformation {
}
boolean setLeaderId(String leaderId) {
- boolean changed = !Objects.equals(this.leaderId, leaderId);
+ final boolean changed = !Objects.equals(this.leaderId, leaderId);
this.leaderId = leaderId;
- if(leaderId != null) {
+ if (leaderId != null) {
this.leaderAvailable = true;
}
notifyOnShardInitializedCallbacks();
@@ -243,7 +241,7 @@ final class ShardInformation {
void setLeaderAvailable(boolean leaderAvailable) {
this.leaderAvailable = leaderAvailable;
- if(leaderAvailable) {
+ if (leaderAvailable) {
notifyOnShardInitializedCallbacks();
}
}
@@ -263,4 +261,4 @@ final class ShardInformation {
void setActiveMember(boolean isActiveMember) {
this.isActiveMember = isActiveMember;
}
-}
\ No newline at end of file
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
index bbb5985960..7653aea3fb 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
@@ -9,6 +9,7 @@
package org.opendaylight.controller.cluster.datastore.shardmanager;
import static akka.pattern.Patterns.ask;
+
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Cancellable;
@@ -106,16 +107,15 @@ import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
/**
- * The ShardManager has the following jobs,
+ * Manages the shards for a data store. The ShardManager has the following jobs:
*
* - Create all the local shard replicas that belong on this cluster member
*
- Find the address of the local shard
*
- Find the primary replica for any given shard
*
- Monitor the cluster members and store their addresses
- *
*/
class ShardManager extends AbstractUntypedPersistentActorWithMetering {
-
private static final Logger LOG = LoggerFactory.getLogger(ShardManager.class);
// Stores a mapping between a shard name and it's corresponding information
@@ -133,7 +133,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private final String shardDispatcherPath;
- private final ShardManagerInfo mBean;
+ private final ShardManagerInfo shardManagerMBean;
private DatastoreContextFactory datastoreContextFactory;
@@ -172,85 +172,85 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
// Subscribe this actor to cluster member events
cluster.subscribeToMemberEvents(getSelf());
- mBean = new ShardManagerInfo(getSelf(), cluster.getCurrentMemberName(), "shard-manager-" + this.type,
+ shardManagerMBean = new ShardManagerInfo(getSelf(), cluster.getCurrentMemberName(),
+ "shard-manager-" + this.type,
datastoreContextFactory.getBaseDatastoreContext().getDataStoreMXBeanType());
- mBean.registerMBean();
+ shardManagerMBean.registerMBean();
}
@Override
public void postStop() {
LOG.info("Stopping ShardManager {}", persistenceId());
- mBean.unregisterMBean();
+ shardManagerMBean.unregisterMBean();
}
@Override
public void handleCommand(Object message) throws Exception {
if (message instanceof FindPrimary) {
findPrimary((FindPrimary)message);
- } else if(message instanceof FindLocalShard){
+ } else if (message instanceof FindLocalShard) {
findLocalShard((FindLocalShard) message);
} else if (message instanceof UpdateSchemaContext) {
updateSchemaContext(message);
- } else if(message instanceof ActorInitialized) {
+ } else if (message instanceof ActorInitialized) {
onActorInitialized(message);
- } else if (message instanceof ClusterEvent.MemberUp){
+ } else if (message instanceof ClusterEvent.MemberUp) {
memberUp((ClusterEvent.MemberUp) message);
- } else if (message instanceof ClusterEvent.MemberWeaklyUp){
+ } else if (message instanceof ClusterEvent.MemberWeaklyUp) {
memberWeaklyUp((ClusterEvent.MemberWeaklyUp) message);
- } else if (message instanceof ClusterEvent.MemberExited){
+ } else if (message instanceof ClusterEvent.MemberExited) {
memberExited((ClusterEvent.MemberExited) message);
- } else if(message instanceof ClusterEvent.MemberRemoved) {
+ } else if (message instanceof ClusterEvent.MemberRemoved) {
memberRemoved((ClusterEvent.MemberRemoved) message);
- } else if(message instanceof ClusterEvent.UnreachableMember) {
- memberUnreachable((ClusterEvent.UnreachableMember)message);
- } else if(message instanceof ClusterEvent.ReachableMember) {
+ } else if (message instanceof ClusterEvent.UnreachableMember) {
+ memberUnreachable((ClusterEvent.UnreachableMember) message);
+ } else if (message instanceof ClusterEvent.ReachableMember) {
memberReachable((ClusterEvent.ReachableMember) message);
- } else if(message instanceof DatastoreContextFactory) {
- onDatastoreContextFactory((DatastoreContextFactory)message);
- } else if(message instanceof RoleChangeNotification) {
+ } else if (message instanceof DatastoreContextFactory) {
+ onDatastoreContextFactory((DatastoreContextFactory) message);
+ } else if (message instanceof RoleChangeNotification) {
onRoleChangeNotification((RoleChangeNotification) message);
- } else if(message instanceof FollowerInitialSyncUpStatus){
+ } else if (message instanceof FollowerInitialSyncUpStatus) {
onFollowerInitialSyncStatus((FollowerInitialSyncUpStatus) message);
- } else if(message instanceof ShardNotInitializedTimeout) {
- onShardNotInitializedTimeout((ShardNotInitializedTimeout)message);
- } else if(message instanceof ShardLeaderStateChanged) {
+ } else if (message instanceof ShardNotInitializedTimeout) {
+ onShardNotInitializedTimeout((ShardNotInitializedTimeout) message);
+ } else if (message instanceof ShardLeaderStateChanged) {
onLeaderStateChanged((ShardLeaderStateChanged) message);
- } else if(message instanceof SwitchShardBehavior){
+ } else if (message instanceof SwitchShardBehavior) {
onSwitchShardBehavior((SwitchShardBehavior) message);
- } else if(message instanceof CreateShard) {
- onCreateShard((CreateShard)message);
- } else if(message instanceof AddShardReplica){
- onAddShardReplica((AddShardReplica)message);
- } else if(message instanceof ForwardedAddServerReply) {
- ForwardedAddServerReply msg = (ForwardedAddServerReply)message;
- onAddServerReply(msg.shardInfo, msg.addServerReply, getSender(), msg.leaderPath,
- msg.removeShardOnFailure);
- } else if(message instanceof ForwardedAddServerFailure) {
- ForwardedAddServerFailure msg = (ForwardedAddServerFailure)message;
+ } else if (message instanceof CreateShard) {
+ onCreateShard((CreateShard) message);
+ } else if (message instanceof AddShardReplica) {
+ onAddShardReplica((AddShardReplica) message);
+ } else if (message instanceof ForwardedAddServerReply) {
+ ForwardedAddServerReply msg = (ForwardedAddServerReply) message;
+ onAddServerReply(msg.shardInfo, msg.addServerReply, getSender(), msg.leaderPath, msg.removeShardOnFailure);
+ } else if (message instanceof ForwardedAddServerFailure) {
+ ForwardedAddServerFailure msg = (ForwardedAddServerFailure) message;
onAddServerFailure(msg.shardName, msg.failureMessage, msg.failure, getSender(), msg.removeShardOnFailure);
- } else if(message instanceof RemoveShardReplica) {
+ } else if (message instanceof RemoveShardReplica) {
onRemoveShardReplica((RemoveShardReplica) message);
- } else if(message instanceof WrappedShardResponse){
+ } else if (message instanceof WrappedShardResponse) {
onWrappedShardResponse((WrappedShardResponse) message);
- } else if(message instanceof GetSnapshot) {
+ } else if (message instanceof GetSnapshot) {
onGetSnapshot();
- } else if(message instanceof ServerRemoved){
+ } else if (message instanceof ServerRemoved) {
onShardReplicaRemoved((ServerRemoved) message);
- } else if(message instanceof ChangeShardMembersVotingStatus){
+ } else if (message instanceof ChangeShardMembersVotingStatus) {
onChangeShardServersVotingStatus((ChangeShardMembersVotingStatus) message);
- } else if(message instanceof FlipShardMembersVotingStatus){
+ } else if (message instanceof FlipShardMembersVotingStatus) {
onFlipShardMembersVotingStatus((FlipShardMembersVotingStatus) message);
- } else if(message instanceof SaveSnapshotSuccess) {
- onSaveSnapshotSuccess((SaveSnapshotSuccess)message);
- } else if(message instanceof SaveSnapshotFailure) {
- LOG.error("{}: SaveSnapshotFailure received for saving snapshot of shards",
- persistenceId(), ((SaveSnapshotFailure) message).cause());
- } else if(message instanceof Shutdown) {
+ } else if (message instanceof SaveSnapshotSuccess) {
+ onSaveSnapshotSuccess((SaveSnapshotSuccess) message);
+ } else if (message instanceof SaveSnapshotFailure) {
+ LOG.error("{}: SaveSnapshotFailure received for saving snapshot of shards", persistenceId(),
+ ((SaveSnapshotFailure) message).cause());
+ } else if (message instanceof Shutdown) {
onShutDown();
} else if (message instanceof GetLocalShardIds) {
onGetLocalShardIds();
- } else if(message instanceof RunnableMessage) {
+ } else if (message instanceof RunnableMessage) {
((RunnableMessage)message).run();
} else {
unknownMessage(message);
@@ -263,14 +263,16 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
if (info.getActor() != null) {
LOG.debug("{}: Issuing gracefulStop to shard {}", persistenceId(), info.getShardId());
- FiniteDuration duration = info.getDatastoreContext().getShardRaftConfig().getElectionTimeOutInterval().$times(2);
+ FiniteDuration duration = info.getDatastoreContext().getShardRaftConfig()
+ .getElectionTimeOutInterval().$times(2);
stopFutures.add(Patterns.gracefulStop(info.getActor(), duration, Shutdown.INSTANCE));
}
}
LOG.info("Shutting down ShardManager {} - waiting on {} shards", persistenceId(), stopFutures.size());
- ExecutionContext dispatcher = new Dispatchers(context().system().dispatchers()).getDispatcher(Dispatchers.DispatcherType.Client);
+ ExecutionContext dispatcher = new Dispatchers(context().system().dispatchers())
+ .getDispatcher(Dispatchers.DispatcherType.Client);
Future> combinedFutures = Futures.sequence(stopFutures, dispatcher);
combinedFutures.onComplete(new OnComplete>() {
@@ -280,17 +282,17 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
self().tell(PoisonPill.getInstance(), self());
- if(failure != null) {
+ if (failure != null) {
LOG.warn("{}: An error occurred attempting to shut down the shards", persistenceId(), failure);
} else {
int nfailed = 0;
- for(Boolean r: results) {
- if(!r) {
+ for (Boolean result: results) {
+ if (!result) {
nfailed++;
}
}
- if(nfailed > 0) {
+ if (nfailed > 0) {
LOG.warn("{}: {} shards did not shut down gracefully", persistenceId(), nfailed);
}
}
@@ -309,14 +311,14 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String leaderPath) {
shardReplicaOperationsInProgress.remove(shardId.getShardName());
- LOG.debug ("{}: Received {} for shard {}", persistenceId(), replyMsg, shardId.getShardName());
+ LOG.debug("{}: Received {} for shard {}", persistenceId(), replyMsg, shardId.getShardName());
if (replyMsg.getStatus() == ServerChangeStatus.OK) {
- LOG.debug ("{}: Leader shard successfully removed the replica shard {}", persistenceId(),
+ LOG.debug("{}: Leader shard successfully removed the replica shard {}", persistenceId(),
shardId.getShardName());
originalSender.tell(new Status.Success(null), getSelf());
} else {
- LOG.warn ("{}: Leader failed to remove shard replica {} with status {}",
+ LOG.warn("{}: Leader failed to remove shard replica {} with status {}",
persistenceId(), shardId, replyMsg.getStatus());
Exception failure = getServerChangeException(RemoveServer.class, replyMsg.getStatus(), leaderPath, shardId);
@@ -326,7 +328,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void removeShardReplica(RemoveShardReplica contextMessage, final String shardName, final String primaryPath,
final ActorRef sender) {
- if(isShardReplicaOperationInProgress(shardName, sender)) {
+ if (isShardReplicaOperationInProgress(shardName, sender)) {
return;
}
@@ -337,11 +339,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
final DatastoreContext datastoreContext = newShardDatastoreContextBuilder(shardName).build();
//inform ShardLeader to remove this shard as a replica by sending an RemoveServer message
- LOG.debug ("{}: Sending RemoveServer message to peer {} for shard {}", persistenceId(),
+ LOG.debug("{}: Sending RemoveServer message to peer {} for shard {}", persistenceId(),
primaryPath, shardId);
- Timeout removeServerTimeout = new Timeout(datastoreContext.getShardLeaderElectionTimeout().
- duration());
+ Timeout removeServerTimeout = new Timeout(datastoreContext.getShardLeaderElectionTimeout().duration());
Future futureObj = ask(getContext().actorSelection(primaryPath),
new RemoveServer(shardId.toString()), removeServerTimeout);
@@ -353,7 +354,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String msg = String.format("RemoveServer request to leader %s for shard %s failed",
primaryPath, shardName);
- LOG.debug ("{}: {}", persistenceId(), msg, failure);
+ LOG.debug("{}: {}", persistenceId(), msg, failure);
// FAILURE
sender.tell(new Status.Failure(new RuntimeException(msg, failure)), self());
@@ -368,10 +369,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void onShardReplicaRemoved(ServerRemoved message) {
final ShardIdentifier shardId = new ShardIdentifier.Builder().fromShardIdString(message.getServerId()).build();
final ShardInformation shardInformation = localShards.remove(shardId.getShardName());
- if(shardInformation == null) {
+ if (shardInformation == null) {
LOG.debug("{} : Shard replica {} is not present in list", persistenceId(), shardId.toString());
return;
- } else if(shardInformation.getActor() != null) {
+ } else if (shardInformation.getActor() != null) {
LOG.debug("{} : Sending Shutdown to Shard actor {}", persistenceId(), shardInformation.getActor());
shardInformation.getActor().tell(Shutdown.INSTANCE, self());
}
@@ -383,9 +384,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
LOG.debug("{}: onGetSnapshot", persistenceId());
List notInitialized = null;
- for(ShardInformation shardInfo: localShards.values()) {
- if(!shardInfo.isShardInitialized()) {
- if(notInitialized == null) {
+ for (ShardInformation shardInfo : localShards.values()) {
+ if (!shardInfo.isShardInitialized()) {
+ if (notInitialized == null) {
notInitialized = new ArrayList<>();
}
@@ -393,14 +394,14 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
}
- if(notInitialized != null) {
+ if (notInitialized != null) {
getSender().tell(new Status.Failure(new IllegalStateException(String.format(
"%d shard(s) %s are not initialized", notInitialized.size(), notInitialized))), getSelf());
return;
}
byte[] shardManagerSnapshot = null;
- if(currentSnapshot != null) {
+ if (currentSnapshot != null) {
shardManagerSnapshot = SerializationUtils.serialize(currentSnapshot);
}
@@ -408,18 +409,19 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
new ArrayList<>(localShards.keySet()), type, shardManagerSnapshot , getSender(), persistenceId(),
datastoreContextFactory.getBaseDatastoreContext().getShardInitializationTimeout().duration()));
- for(ShardInformation shardInfo: localShards.values()) {
+ for (ShardInformation shardInfo: localShards.values()) {
shardInfo.getActor().tell(GetSnapshot.INSTANCE, replyActor);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void onCreateShard(CreateShard createShard) {
LOG.debug("{}: onCreateShard: {}", persistenceId(), createShard);
Object reply;
try {
String shardName = createShard.getModuleShardConfig().getShardName();
- if(localShards.containsKey(shardName)) {
+ if (localShards.containsKey(shardName)) {
LOG.debug("{}: Shard {} already exists", persistenceId(), shardName);
reply = new Status.Success(String.format("Shard with name %s already exists", shardName));
} else {
@@ -431,7 +433,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
reply = new Status.Failure(e);
}
- if(getSender() != null && !getContext().system().deadLetters().equals(getSender())) {
+ if (getSender() != null && !getContext().system().deadLetters().equals(getSender())) {
getSender().tell(reply, getSelf());
}
}
@@ -443,7 +445,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
configuration.addModuleShardConfiguration(moduleShardConfig);
DatastoreContext shardDatastoreContext = createShard.getDatastoreContext();
- if(shardDatastoreContext == null) {
+ if (shardDatastoreContext == null) {
shardDatastoreContext = newShardDatastoreContext(shardName);
} else {
shardDatastoreContext = DatastoreContext.newBuilderFrom(shardDatastoreContext).shardPeerAddressResolver(
@@ -452,13 +454,13 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
ShardIdentifier shardId = getShardIdentifier(cluster.getCurrentMemberName(), shardName);
- boolean shardWasInRecoveredSnapshot = currentSnapshot != null &&
- currentSnapshot.getShardList().contains(shardName);
+ boolean shardWasInRecoveredSnapshot = currentSnapshot != null
+ && currentSnapshot.getShardList().contains(shardName);
Map peerAddresses;
boolean isActiveMember;
- if(shardWasInRecoveredSnapshot || configuration.getMembersFromShardName(shardName).
- contains(cluster.getCurrentMemberName())) {
+ if (shardWasInRecoveredSnapshot || configuration.getMembersFromShardName(shardName)
+ .contains(cluster.getCurrentMemberName())) {
peerAddresses = getPeerAddresses(shardName);
isActiveMember = true;
} else {
@@ -468,8 +470,8 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
// subsequent AddServer request will be needed to make it an active member.
isActiveMember = false;
peerAddresses = Collections.emptyMap();
- shardDatastoreContext = DatastoreContext.newBuilderFrom(shardDatastoreContext).
- customRaftPolicyImplementation(DisableElectionsRaftPolicy.class.getName()).build();
+ shardDatastoreContext = DatastoreContext.newBuilderFrom(shardDatastoreContext)
+ .customRaftPolicyImplementation(DisableElectionsRaftPolicy.class.getName()).build();
}
LOG.debug("{} doCreateShard: shardId: {}, memberNames: {}, peerAddresses: {}, isActiveMember: {}",
@@ -481,21 +483,21 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
info.setActiveMember(isActiveMember);
localShards.put(info.getShardName(), info);
- if(schemaContext != null) {
+ if (schemaContext != null) {
info.setActor(newShardActor(schemaContext, info));
}
}
private DatastoreContext.Builder newShardDatastoreContextBuilder(String shardName) {
- return DatastoreContext.newBuilderFrom(datastoreContextFactory.getShardDatastoreContext(shardName)).
- shardPeerAddressResolver(peerAddressResolver);
+ return DatastoreContext.newBuilderFrom(datastoreContextFactory.getShardDatastoreContext(shardName))
+ .shardPeerAddressResolver(peerAddressResolver);
}
private DatastoreContext newShardDatastoreContext(String shardName) {
return newShardDatastoreContextBuilder(shardName).build();
}
- private void checkReady(){
+ private void checkReady() {
if (isReadyWithLeaderId()) {
LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}",
persistenceId(), type, waitTillReadyCountdownLatch.getCount());
@@ -508,10 +510,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
LOG.info("{}: Received LeaderStateChanged message: {}", persistenceId(), leaderStateChanged);
ShardInformation shardInformation = findShardInformation(leaderStateChanged.getMemberId());
- if(shardInformation != null) {
+ if (shardInformation != null) {
shardInformation.setLocalDataTree(leaderStateChanged.getLocalShardDataTree());
shardInformation.setLeaderVersion(leaderStateChanged.getLeaderPayloadVersion());
- if(shardInformation.setLeaderId(leaderStateChanged.getLeaderId())) {
+ if (shardInformation.setLeaderId(leaderStateChanged.getLeaderId())) {
primaryShardInfoCache.remove(shardInformation.getShardName());
}
@@ -529,7 +531,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
shardInfo.removeOnShardInitialized(message.getOnShardInitialized());
- if(!shardInfo.isShardInitialized()) {
+ if (!shardInfo.isShardInitialized()) {
LOG.debug("{}: Returning NotInitializedException for shard {}", persistenceId(), shardInfo.getShardName());
message.getSender().tell(createNotInitializedException(shardInfo.getShardId()), getSelf());
} else {
@@ -544,10 +546,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
ShardInformation shardInformation = findShardInformation(status.getName());
- if(shardInformation != null) {
+ if (shardInformation != null) {
shardInformation.setFollowerSyncStatus(status.isInitialSyncDone());
- mBean.setSyncStatus(isInSync());
+ shardManagerMBean.setSyncStatus(isInSync());
}
}
@@ -557,17 +559,17 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
roleChanged.getOldRole(), roleChanged.getNewRole());
ShardInformation shardInformation = findShardInformation(roleChanged.getMemberId());
- if(shardInformation != null) {
+ if (shardInformation != null) {
shardInformation.setRole(roleChanged.getNewRole());
checkReady();
- mBean.setSyncStatus(isInSync());
+ shardManagerMBean.setSyncStatus(isInSync());
}
}
private ShardInformation findShardInformation(String memberId) {
- for(ShardInformation info : localShards.values()){
- if(info.getShardId().toString().equals(memberId)){
+ for (ShardInformation info : localShards.values()) {
+ if (info.getShardId().toString().equals(memberId)) {
return info;
}
}
@@ -578,7 +580,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private boolean isReadyWithLeaderId() {
boolean isReady = true;
for (ShardInformation info : localShards.values()) {
- if(!info.isShardReadyWithLeaderId()){
+ if (!info.isShardReadyWithLeaderId()) {
isReady = false;
break;
}
@@ -586,9 +588,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
return isReady;
}
- private boolean isInSync(){
+ private boolean isInSync() {
for (ShardInformation info : localShards.values()) {
- if(!info.isInSync()){
+ if (!info.isInSync()) {
return false;
}
}
@@ -636,6 +638,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void onRecoveryCompleted() {
LOG.info("Recovery complete : {}", persistenceId());
@@ -643,16 +646,16 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
// journal on upgrade from Helium.
deleteMessages(lastSequenceNr());
- if(currentSnapshot == null && restoreFromSnapshot != null &&
- restoreFromSnapshot.getShardManagerSnapshot() != null) {
- try(ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+ if (currentSnapshot == null && restoreFromSnapshot != null
+ && restoreFromSnapshot.getShardManagerSnapshot() != null) {
+ try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
restoreFromSnapshot.getShardManagerSnapshot()))) {
ShardManagerSnapshot snapshot = (ShardManagerSnapshot) ois.readObject();
LOG.debug("{}: Deserialized restored ShardManagerSnapshot: {}", persistenceId(), snapshot);
applyShardManagerSnapshot(snapshot);
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.error("{}: Error deserializing restored ShardManagerSnapshot", persistenceId(), e);
}
}
@@ -660,21 +663,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
createLocalShards();
}
- private void findLocalShard(FindLocalShard message) {
- final ShardInformation shardInformation = localShards.get(message.getShardName());
-
- if(shardInformation == null){
- getSender().tell(new LocalShardNotFound(message.getShardName()), getSelf());
- return;
- }
-
- sendResponse(shardInformation, message.isWaitUntilInitialized(), false, () -> new LocalShardFound(shardInformation.getActor()));
- }
-
private void sendResponse(ShardInformation shardInformation, boolean doWait,
boolean wantShardReady, final Supplier messageSupplier) {
- if (!shardInformation.isShardInitialized() || (wantShardReady && !shardInformation.isShardReadyWithLeaderId())) {
- if(doWait) {
+ if (!shardInformation.isShardInitialized() || wantShardReady && !shardInformation.isShardReadyWithLeaderId()) {
+ if (doWait) {
final ActorRef sender = getSender();
final ActorRef self = self();
@@ -685,8 +677,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
shardInformation.addOnShardInitialized(onShardInitialized);
- FiniteDuration timeout = shardInformation.getDatastoreContext().getShardInitializationTimeout().duration();
- if(shardInformation.isShardInitialized()) {
+ FiniteDuration timeout = shardInformation.getDatastoreContext()
+ .getShardInitializationTimeout().duration();
+ if (shardInformation.isShardInitialized()) {
// If the shard is already initialized then we'll wait enough time for the shard to
// elect a leader, ie 2 times the election timeout.
timeout = FiniteDuration.create(shardInformation.getDatastoreContext().getShardRaftConfig()
@@ -741,7 +734,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
peerAddressResolver.removePeerAddress(memberName);
- for(ShardInformation info : localShards.values()){
+ for (ShardInformation info : localShards.values()) {
info.peerDown(memberName, getShardIdentifier(memberName, info.getShardName()).toString(), getSelf());
}
}
@@ -754,7 +747,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
peerAddressResolver.removePeerAddress(memberName);
- for(ShardInformation info : localShards.values()){
+ for (ShardInformation info : localShards.values()) {
info.peerDown(memberName, getShardIdentifier(memberName, info.getShardName()).toString(), getSelf());
}
}
@@ -785,7 +778,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void addPeerAddress(MemberName memberName, Address address) {
peerAddressResolver.addPeerAddress(memberName, address);
- for(ShardInformation info : localShards.values()){
+ for (ShardInformation info : localShards.values()) {
String shardName = info.getShardName();
String peerId = getShardIdentifier(memberName, shardName).toString();
info.updatePeerAddress(peerId, peerAddressResolver.getShardActorAddress(shardName, memberName), getSelf());
@@ -882,16 +875,16 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
final ActorRef actor = info.getActor();
if (actor != null) {
actor.tell(switchBehavior, getSelf());
- } else {
+ } else {
LOG.warn("Could not switch the behavior of shard {} to {} - shard is not yet available",
info.getShardName(), switchBehavior.getNewState());
}
}
/**
- * Notifies all the local shards of a change in the schema context
+ * Notifies all the local shards of a change in the schema context.
*
- * @param message
+ * @param message the message to send
*/
private void updateSchemaContext(final Object message) {
schemaContext = ((UpdateSchemaContext) message).getSchemaContext();
@@ -930,22 +923,19 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
if (info != null && info.isActiveMember()) {
sendResponse(info, message.isWaitUntilReady(), true, () -> {
String primaryPath = info.getSerializedLeaderActor();
- Object found = canReturnLocalShardState && info.isLeader() ?
- new LocalPrimaryShardFound(primaryPath, info.getLocalShardDataTree().get()) :
+ Object found = canReturnLocalShardState && info.isLeader()
+ ? new LocalPrimaryShardFound(primaryPath, info.getLocalShardDataTree().get()) :
new RemotePrimaryShardFound(primaryPath, info.getLeaderVersion());
- if(LOG.isDebugEnabled()) {
- LOG.debug("{}: Found primary for {}: {}", persistenceId(), shardName, found);
- }
-
- return found;
+ LOG.debug("{}: Found primary for {}: {}", persistenceId(), shardName, found);
+ return found;
});
return;
}
final Collection visitedAddresses;
- if(message instanceof RemoteFindPrimary) {
+ if (message instanceof RemoteFindPrimary) {
visitedAddresses = ((RemoteFindPrimary)message).getVisitedAddresses();
} else {
visitedAddresses = new ArrayList<>(1);
@@ -953,8 +943,8 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
visitedAddresses.add(peerAddressResolver.getShardManagerActorPathBuilder(cluster.getSelfAddress()).toString());
- for(String address: peerAddressResolver.getShardManagerPeerActorAddresses()) {
- if(visitedAddresses.contains(address)) {
+ for (String address: peerAddressResolver.getShardManagerPeerActorAddresses()) {
+ if (visitedAddresses.contains(address)) {
continue;
}
@@ -972,38 +962,58 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String.format("No primary shard found for %s.", shardName)), getSelf());
}
+ private void findPrimary(final String shardName, final FindPrimaryResponseHandler handler) {
+ Timeout findPrimaryTimeout = new Timeout(datastoreContextFactory.getBaseDatastoreContext()
+ .getShardInitializationTimeout().duration().$times(2));
+
+ Future futureObj = ask(getSelf(), new FindPrimary(shardName, true), findPrimaryTimeout);
+ futureObj.onComplete(new OnComplete() {
+ @Override
+ public void onComplete(Throwable failure, Object response) {
+ if (failure != null) {
+ handler.onFailure(failure);
+ } else {
+ if (response instanceof RemotePrimaryShardFound) {
+ handler.onRemotePrimaryShardFound((RemotePrimaryShardFound) response);
+ } else if (response instanceof LocalPrimaryShardFound) {
+ handler.onLocalPrimaryFound((LocalPrimaryShardFound) response);
+ } else {
+ handler.onUnknownResponse(response);
+ }
+ }
+ }
+ }, new Dispatchers(context().system().dispatchers()).getDispatcher(Dispatchers.DispatcherType.Client));
+ }
+
/**
* Construct the name of the shard actor given the name of the member on
- * which the shard resides and the name of the shard
+ * which the shard resides and the name of the shard.
*
- * @param memberName
- * @param shardName
- * @return
+ * @param memberName the member name
+ * @param shardName the shard name
+ * @return a b
*/
- private ShardIdentifier getShardIdentifier(MemberName memberName, String shardName){
+ private ShardIdentifier getShardIdentifier(MemberName memberName, String shardName) {
return peerAddressResolver.getShardIdentifier(memberName, shardName);
}
/**
- * Create shards that are local to the member on which the ShardManager
- * runs
- *
+ * Create shards that are local to the member on which the ShardManager runs.
*/
private void createLocalShards() {
MemberName memberName = this.cluster.getCurrentMemberName();
Collection memberShardNames = this.configuration.getMemberShardNames(memberName);
Map shardSnapshots = new HashMap<>();
- if(restoreFromSnapshot != null)
- {
- for(DatastoreSnapshot.ShardSnapshot snapshot: restoreFromSnapshot.getShardSnapshots()) {
+ if (restoreFromSnapshot != null) {
+ for (DatastoreSnapshot.ShardSnapshot snapshot: restoreFromSnapshot.getShardSnapshots()) {
shardSnapshots.put(snapshot.getName(), snapshot);
}
}
restoreFromSnapshot = null; // null out to GC
- for(String shardName : memberShardNames){
+ for (String shardName : memberShardNames) {
ShardIdentifier shardId = getShardIdentifier(memberName, shardName);
LOG.debug("{}: Creating local shard: {}", persistenceId(), shardId);
@@ -1016,9 +1026,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
/**
- * Given the name of the shard find the addresses of all it's peers
+ * Given the name of the shard find the addresses of all it's peers.
*
- * @param shardName
+ * @param shardName the shard name
*/
private Map getPeerAddresses(String shardName) {
Collection members = configuration.getMembersFromShardName(shardName);
@@ -1043,9 +1053,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
(Function) t -> {
LOG.warn("Supervisor Strategy caught unexpected exception - resuming", t);
return SupervisorStrategy.resume();
- }
- );
-
+ });
}
@Override
@@ -1054,14 +1062,14 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
@VisibleForTesting
- ShardManagerInfoMBean getMBean(){
- return mBean;
+ ShardManagerInfoMBean getMBean() {
+ return shardManagerMBean;
}
private boolean isShardReplicaOperationInProgress(final String shardName, final ActorRef sender) {
if (shardReplicaOperationsInProgress.contains(shardName)) {
String msg = String.format("A shard replica operation for %s is already in progress", shardName);
- LOG.debug ("{}: {}", persistenceId(), msg);
+ LOG.debug("{}: {}", persistenceId(), msg);
sender.tell(new Status.Failure(new IllegalStateException(msg)), getSelf());
return true;
}
@@ -1069,15 +1077,15 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
return false;
}
- private void onAddShardReplica (final AddShardReplica shardReplicaMsg) {
+ private void onAddShardReplica(final AddShardReplica shardReplicaMsg) {
final String shardName = shardReplicaMsg.getShardName();
LOG.debug("{}: onAddShardReplica: {}", persistenceId(), shardReplicaMsg);
// verify the shard with the specified name is present in the cluster configuration
- if (!(this.configuration.isShardConfigured(shardName))) {
+ if (!this.configuration.isShardConfigured(shardName)) {
String msg = String.format("No module configuration exists for shard %s", shardName);
- LOG.debug ("{}: {}", persistenceId(), msg);
+ LOG.debug("{}: {}", persistenceId(), msg);
getSender().tell(new Status.Failure(new IllegalArgumentException(msg)), getSelf());
return;
}
@@ -1086,15 +1094,17 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
if (schemaContext == null) {
String msg = String.format(
"No SchemaContext is available in order to create a local shard instance for %s", shardName);
- LOG.debug ("{}: {}", persistenceId(), msg);
+ LOG.debug("{}: {}", persistenceId(), msg);
getSender().tell(new Status.Failure(new IllegalStateException(msg)), getSelf());
return;
}
- findPrimary(shardName, new AutoFindPrimaryFailureResponseHandler(getSender(), shardName, persistenceId(), getSelf()) {
+ findPrimary(shardName, new AutoFindPrimaryFailureResponseHandler(getSender(), shardName, persistenceId(),
+ getSelf()) {
@Override
public void onRemotePrimaryShardFound(RemotePrimaryShardFound response) {
- getSelf().tell((RunnableMessage) () -> addShard(getShardName(), response, getSender()), getTargetActor());
+ getSelf().tell((RunnableMessage) () -> addShard(getShardName(), response, getSender()),
+ getTargetActor());
}
@Override
@@ -1107,12 +1117,12 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void sendLocalReplicaAlreadyExistsReply(String shardName, ActorRef sender) {
String msg = String.format("Local shard %s already exists", shardName);
- LOG.debug ("{}: {}", persistenceId(), msg);
+ LOG.debug("{}: {}", persistenceId(), msg);
sender.tell(new Status.Failure(new AlreadyExistsException(msg)), getSelf());
}
private void addShard(final String shardName, final RemotePrimaryShardFound response, final ActorRef sender) {
- if(isShardReplicaOperationInProgress(shardName, sender)) {
+ if (isShardReplicaOperationInProgress(shardName, sender)) {
return;
}
@@ -1121,12 +1131,12 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
final ShardInformation shardInfo;
final boolean removeShardOnFailure;
ShardInformation existingShardInfo = localShards.get(shardName);
- if(existingShardInfo == null) {
+ if (existingShardInfo == null) {
removeShardOnFailure = true;
ShardIdentifier shardId = getShardIdentifier(cluster.getCurrentMemberName(), shardName);
- DatastoreContext datastoreContext = newShardDatastoreContextBuilder(shardName).customRaftPolicyImplementation(
- DisableElectionsRaftPolicy.class.getName()).build();
+ DatastoreContext datastoreContext = newShardDatastoreContextBuilder(shardName)
+ .customRaftPolicyImplementation(DisableElectionsRaftPolicy.class.getName()).build();
shardInfo = new ShardInformation(shardName, shardId, getPeerAddresses(shardName), datastoreContext,
Shard.builder(), peerAddressResolver);
@@ -1141,11 +1151,11 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String localShardAddress = peerAddressResolver.getShardActorAddress(shardName, cluster.getCurrentMemberName());
//inform ShardLeader to add this shard as a replica by sending an AddServer message
- LOG.debug ("{}: Sending AddServer message to peer {} for shard {}", persistenceId(),
+ LOG.debug("{}: Sending AddServer message to peer {} for shard {}", persistenceId(),
response.getPrimaryPath(), shardInfo.getShardId());
- Timeout addServerTimeout = new Timeout(shardInfo.getDatastoreContext().getShardLeaderElectionTimeout().
- duration());
+ Timeout addServerTimeout = new Timeout(shardInfo.getDatastoreContext()
+ .getShardLeaderElectionTimeout().duration());
Future futureObj = ask(getContext().actorSelection(response.getPrimaryPath()),
new AddServer(shardInfo.getShardId().toString(), localShardAddress, true), addServerTimeout);
@@ -1153,7 +1163,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
@Override
public void onComplete(Throwable failure, Object addServerResponse) {
if (failure != null) {
- LOG.debug ("{}: AddServer request to {} for {} failed", persistenceId(),
+ LOG.debug("{}: AddServer request to {} for {} failed", persistenceId(),
response.getPrimaryPath(), shardName, failure);
String msg = String.format("AddServer request to leader %s for shard %s failed",
@@ -1171,7 +1181,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
boolean removeShardOnFailure) {
shardReplicaOperationsInProgress.remove(shardName);
- if(removeShardOnFailure) {
+ if (removeShardOnFailure) {
ShardInformation shardInfo = localShards.remove(shardName);
if (shardInfo.getActor() != null) {
shardInfo.getActor().tell(PoisonPill.getInstance(), getSelf());
@@ -1187,10 +1197,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String shardName = shardInfo.getShardName();
shardReplicaOperationsInProgress.remove(shardName);
- LOG.debug ("{}: Received {} for shard {} from leader {}", persistenceId(), replyMsg, shardName, leaderPath);
+ LOG.debug("{}: Received {} for shard {} from leader {}", persistenceId(), replyMsg, shardName, leaderPath);
if (replyMsg.getStatus() == ServerChangeStatus.OK) {
- LOG.debug ("{}: Leader shard successfully added the replica shard {}", persistenceId(), shardName);
+ LOG.debug("{}: Leader shard successfully added the replica shard {}", persistenceId(), shardName);
// Make the local shard voting capable
shardInfo.setDatastoreContext(newShardDatastoreContext(shardName), getSelf());
@@ -1198,13 +1208,14 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
persistShardList();
sender.tell(new Status.Success(null), getSelf());
- } else if(replyMsg.getStatus() == ServerChangeStatus.ALREADY_EXISTS) {
+ } else if (replyMsg.getStatus() == ServerChangeStatus.ALREADY_EXISTS) {
sendLocalReplicaAlreadyExistsReply(shardName, sender);
} else {
- LOG.warn ("{}: Leader failed to add shard replica {} with status {}",
+ LOG.warn("{}: Leader failed to add shard replica {} with status {}",
persistenceId(), shardName, replyMsg.getStatus());
- Exception failure = getServerChangeException(AddServer.class, replyMsg.getStatus(), leaderPath, shardInfo.getShardId());
+ Exception failure = getServerChangeException(AddServer.class, replyMsg.getStatus(), leaderPath,
+ shardInfo.getShardId());
onAddServerFailure(shardName, null, failure, sender, removeShardOnFailure);
}
@@ -1216,9 +1227,9 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
switch (serverChangeStatus) {
case TIMEOUT:
failure = new TimeoutException(String.format(
- "The shard leader %s timed out trying to replicate the initial data to the new shard %s." +
- "Possible causes - there was a problem replicating the data or shard leadership changed while replicating the shard data",
- leaderPath, shardId.getShardName()));
+ "The shard leader %s timed out trying to replicate the initial data to the new shard %s."
+ + "Possible causes - there was a problem replicating the data or shard leadership changed "
+ + "while replicating the shard data", leaderPath, shardId.getShardName()));
break;
case NO_LEADER:
failure = createNoShardLeaderException(shardId);
@@ -1235,7 +1246,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
return failure;
}
- private void onRemoveShardReplica (final RemoveShardReplica shardReplicaMsg) {
+ private void onRemoveShardReplica(final RemoveShardReplica shardReplicaMsg) {
LOG.debug("{}: onRemoveShardReplica: {}", persistenceId(), shardReplicaMsg);
findPrimary(shardReplicaMsg.getShardName(), new AutoFindPrimaryFailureResponseHandler(getSender(),
@@ -1251,7 +1262,8 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
private void doRemoveShardReplicaAsync(final String primaryPath) {
- getSelf().tell((RunnableMessage) () -> removeShardReplica(shardReplicaMsg, getShardName(), primaryPath, getSender()), getTargetActor());
+ getSelf().tell((RunnableMessage) () -> removeShardReplica(shardReplicaMsg, getShardName(),
+ primaryPath, getSender()), getTargetActor());
}
});
}
@@ -1263,7 +1275,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
shardList.remove(shardInfo.getShardName());
}
}
- LOG.debug ("{}: persisting the shard list {}", persistenceId(), shardList);
+ LOG.debug("{}: persisting the shard list {}", persistenceId(), shardList);
saveSnapshot(updateShardManagerSnapshot(shardList));
}
@@ -1275,7 +1287,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void applyShardManagerSnapshot(ShardManagerSnapshot snapshot) {
currentSnapshot = snapshot;
- LOG.debug ("{}: onSnapshotOffer: {}", persistenceId(), currentSnapshot);
+ LOG.debug("{}: onSnapshotOffer: {}", persistenceId(), currentSnapshot);
final MemberName currentMember = cluster.getCurrentMemberName();
Set configuredShardList =
@@ -1283,7 +1295,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
for (String shard : currentSnapshot.getShardList()) {
if (!configuredShardList.contains(shard)) {
// add the current member as a replica for the shard
- LOG.debug ("{}: adding shard {}", persistenceId(), shard);
+ LOG.debug("{}: adding shard {}", persistenceId(), shard);
configuration.addMemberReplicaForShard(shard, currentMember);
} else {
configuredShardList.remove(shard);
@@ -1291,13 +1303,13 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
for (String shard : configuredShardList) {
// remove the member as a replica for the shard
- LOG.debug ("{}: removing shard {}", persistenceId(), shard);
+ LOG.debug("{}: removing shard {}", persistenceId(), shard);
configuration.removeMemberReplicaForShard(shard, currentMember);
}
}
- private void onSaveSnapshotSuccess (SaveSnapshotSuccess successMessage) {
- LOG.debug ("{} saved ShardManager snapshot successfully. Deleting the prev snapshot if available",
+ private void onSaveSnapshotSuccess(SaveSnapshotSuccess successMessage) {
+ LOG.debug("{} saved ShardManager snapshot successfully. Deleting the prev snapshot if available",
persistenceId());
deleteSnapshots(new SnapshotSelectionCriteria(scala.Long.MaxValue(), successMessage.metadata().timestamp() - 1,
0, 0));
@@ -1308,7 +1320,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
String shardName = changeMembersVotingStatus.getShardName();
Map serverVotingStatusMap = new HashMap<>();
- for(Entry e: changeMembersVotingStatus.getMeberVotingStatusMap().entrySet()) {
+ for (Entry e: changeMembersVotingStatus.getMeberVotingStatusMap().entrySet()) {
serverVotingStatusMap.put(getShardIdentifier(MemberName.forName(e.getKey()), shardName).toString(),
e.getValue());
}
@@ -1316,8 +1328,8 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
ChangeServersVotingStatus changeServersVotingStatus = new ChangeServersVotingStatus(serverVotingStatusMap);
findLocalShard(shardName, getSender(),
- localShardFound -> changeShardMembersVotingStatus(changeServersVotingStatus, shardName,
- localShardFound.getPath(), getSender()));
+ localShardFound -> changeShardMembersVotingStatus(changeServersVotingStatus, shardName,
+ localShardFound.getPath(), getSender()));
}
private void onFlipShardMembersVotingStatus(FlipShardMembersVotingStatus flipMembersVotingStatus) {
@@ -1340,12 +1352,12 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
OnDemandRaftState raftState = (OnDemandRaftState) response;
Map serverVotingStatusMap = new HashMap<>();
- for(Entry e: raftState.getPeerVotingStates().entrySet()) {
+ for ( Entry e: raftState.getPeerVotingStates().entrySet()) {
serverVotingStatusMap.put(e.getKey(), !e.getValue());
}
- serverVotingStatusMap.put(getShardIdentifier(cluster.getCurrentMemberName(), shardName).
- toString(), !raftState.isVoting());
+ serverVotingStatusMap.put(getShardIdentifier(cluster.getCurrentMemberName(), shardName)
+ .toString(), !raftState.isVoting());
changeShardMembersVotingStatus(new ChangeServersVotingStatus(serverVotingStatusMap),
shardName, localShardFound.getPath(), sender);
@@ -1355,30 +1367,44 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
+ private void findLocalShard(FindLocalShard message) {
+ final ShardInformation shardInformation = localShards.get(message.getShardName());
+
+ if (shardInformation == null) {
+ getSender().tell(new LocalShardNotFound(message.getShardName()), getSelf());
+ return;
+ }
+
+ sendResponse(shardInformation, message.isWaitUntilInitialized(), false,
+ () -> new LocalShardFound(shardInformation.getActor()));
+ }
+
private void findLocalShard(final String shardName, final ActorRef sender,
final Consumer onLocalShardFound) {
- Timeout findLocalTimeout = new Timeout(datastoreContextFactory.getBaseDatastoreContext().
- getShardInitializationTimeout().duration().$times(2));
+ Timeout findLocalTimeout = new Timeout(datastoreContextFactory.getBaseDatastoreContext()
+ .getShardInitializationTimeout().duration().$times(2));
Future futureObj = ask(getSelf(), new FindLocalShard(shardName, true), findLocalTimeout);
futureObj.onComplete(new OnComplete() {
@Override
public void onComplete(Throwable failure, Object response) {
if (failure != null) {
- LOG.debug ("{}: Received failure from FindLocalShard for shard {}", persistenceId, shardName, failure);
+ LOG.debug("{}: Received failure from FindLocalShard for shard {}", persistenceId, shardName,
+ failure);
sender.tell(new Status.Failure(new RuntimeException(
String.format("Failed to find local shard %s", shardName), failure)), self());
} else {
- if(response instanceof LocalShardFound) {
- getSelf().tell((RunnableMessage) () -> onLocalShardFound.accept((LocalShardFound) response), sender);
- } else if(response instanceof LocalShardNotFound) {
+ if (response instanceof LocalShardFound) {
+ getSelf().tell((RunnableMessage) () -> onLocalShardFound.accept((LocalShardFound) response),
+ sender);
+ } else if (response instanceof LocalShardNotFound) {
String msg = String.format("Local shard %s does not exist", shardName);
- LOG.debug ("{}: {}", persistenceId, msg);
+ LOG.debug("{}: {}", persistenceId, msg);
sender.tell(new Status.Failure(new IllegalArgumentException(msg)), self());
} else {
String msg = String.format("Failed to find local shard %s: received response: %s",
shardName, response);
- LOG.debug ("{}: {}", persistenceId, msg);
+ LOG.debug("{}: {}", persistenceId, msg);
sender.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response :
new RuntimeException(msg)), self());
}
@@ -1389,7 +1415,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
private void changeShardMembersVotingStatus(ChangeServersVotingStatus changeServersVotingStatus,
final String shardName, final ActorRef shardActorRef, final ActorRef sender) {
- if(isShardReplicaOperationInProgress(shardName, sender)) {
+ if (isShardReplicaOperationInProgress(shardName, sender)) {
return;
}
@@ -1411,21 +1437,21 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
if (failure != null) {
String msg = String.format("ChangeServersVotingStatus request to local shard %s failed",
shardActorRef.path());
- LOG.debug ("{}: {}", persistenceId(), msg, failure);
+ LOG.debug("{}: {}", persistenceId(), msg, failure);
sender.tell(new Status.Failure(new RuntimeException(msg, failure)), self());
} else {
- LOG.debug ("{}: Received {} from local shard {}", persistenceId(), response, shardActorRef.path());
+ LOG.debug("{}: Received {} from local shard {}", persistenceId(), response, shardActorRef.path());
ServerChangeReply replyMsg = (ServerChangeReply) response;
- if(replyMsg.getStatus() == ServerChangeStatus.OK) {
- LOG.debug ("{}: ChangeServersVotingStatus succeeded for shard {}", persistenceId(), shardName);
+ if (replyMsg.getStatus() == ServerChangeStatus.OK) {
+ LOG.debug("{}: ChangeServersVotingStatus succeeded for shard {}", persistenceId(), shardName);
sender.tell(new Status.Success(null), getSelf());
- } else if(replyMsg.getStatus() == ServerChangeStatus.INVALID_REQUEST) {
+ } else if (replyMsg.getStatus() == ServerChangeStatus.INVALID_REQUEST) {
sender.tell(new Status.Failure(new IllegalArgumentException(String.format(
- "The requested voting state change for shard %s is invalid. At least one member must be voting",
- shardId.getShardName()))), getSelf());
+ "The requested voting state change for shard %s is invalid. At least one member "
+ + "must be voting", shardId.getShardName()))), getSelf());
} else {
- LOG.warn ("{}: ChangeServersVotingStatus failed for shard {} with status {}",
+ LOG.warn("{}: ChangeServersVotingStatus failed for shard {} with status {}",
persistenceId(), shardName, replyMsg.getStatus());
Exception error = getServerChangeException(ChangeServersVotingStatus.class,
@@ -1494,83 +1520,63 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
}
}
- private void findPrimary(final String shardName, final FindPrimaryResponseHandler handler) {
- Timeout findPrimaryTimeout = new Timeout(datastoreContextFactory.getBaseDatastoreContext().
- getShardInitializationTimeout().duration().$times(2));
-
-
- Future futureObj = ask(getSelf(), new FindPrimary(shardName, true), findPrimaryTimeout);
- futureObj.onComplete(new OnComplete() {
- @Override
- public void onComplete(Throwable failure, Object response) {
- if (failure != null) {
- handler.onFailure(failure);
- } else {
- if(response instanceof RemotePrimaryShardFound) {
- handler.onRemotePrimaryShardFound((RemotePrimaryShardFound) response);
- } else if(response instanceof LocalPrimaryShardFound) {
- handler.onLocalPrimaryFound((LocalPrimaryShardFound) response);
- } else {
- handler.onUnknownResponse(response);
- }
- }
- }
- }, new Dispatchers(context().system().dispatchers()).getDispatcher(Dispatchers.DispatcherType.Client));
- }
-
private interface RunnableMessage extends Runnable {
}
/**
* The FindPrimaryResponseHandler provides specific callback methods which are invoked when a response to the
- * a remote or local find primary message is processed
+ * a remote or local find primary message is processed.
*/
private interface FindPrimaryResponseHandler {
/**
- * Invoked when a Failure message is received as a response
+ * Invoked when a Failure message is received as a response.
*
- * @param failure
+ * @param failure the failure exception
*/
void onFailure(Throwable failure);
/**
- * Invoked when a RemotePrimaryShardFound response is received
+ * Invoked when a RemotePrimaryShardFound response is received.
*
- * @param response
+ * @param response the response
*/
void onRemotePrimaryShardFound(RemotePrimaryShardFound response);
/**
- * Invoked when a LocalPrimaryShardFound response is received
- * @param response
+ * Invoked when a LocalPrimaryShardFound response is received.
+ *
+ * @param response the response
*/
void onLocalPrimaryFound(LocalPrimaryShardFound response);
/**
* Invoked when an unknown response is received. This is another type of failure.
*
- * @param response
+ * @param response the response
*/
void onUnknownResponse(Object response);
}
/**
* The AutoFindPrimaryFailureResponseHandler automatically processes Failure responses when finding a primary
- * replica and sends a wrapped Failure response to some targetActor
+ * replica and sends a wrapped Failure response to some targetActor.
*/
- private static abstract class AutoFindPrimaryFailureResponseHandler implements FindPrimaryResponseHandler {
+ private abstract static class AutoFindPrimaryFailureResponseHandler implements FindPrimaryResponseHandler {
private final ActorRef targetActor;
private final String shardName;
private final String persistenceId;
private final ActorRef shardManagerActor;
/**
+ * Constructs an instance.
+ *
* @param targetActor The actor to whom the Failure response should be sent when a FindPrimary failure occurs
* @param shardName The name of the shard for which the primary replica had to be found
* @param persistenceId The persistenceId for the ShardManager
* @param shardManagerActor The ShardManager actor which triggered the call to FindPrimary
*/
- protected AutoFindPrimaryFailureResponseHandler(ActorRef targetActor, String shardName, String persistenceId, ActorRef shardManagerActor){
+ protected AutoFindPrimaryFailureResponseHandler(ActorRef targetActor, String shardName, String persistenceId,
+ ActorRef shardManagerActor) {
this.targetActor = Preconditions.checkNotNull(targetActor);
this.shardName = Preconditions.checkNotNull(shardName);
this.persistenceId = Preconditions.checkNotNull(persistenceId);
@@ -1587,7 +1593,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
@Override
public void onFailure(Throwable failure) {
- LOG.debug ("{}: Received failure from FindPrimary for shard {}", persistenceId, shardName, failure);
+ LOG.debug("{}: Received failure from FindPrimary for shard {}", persistenceId, shardName, failure);
targetActor.tell(new Status.Failure(new RuntimeException(
String.format("Failed to find leader for shard %s", shardName), failure)), shardManagerActor);
}
@@ -1596,7 +1602,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
public void onUnknownResponse(Object response) {
String msg = String.format("Failed to find leader for shard %s: received response: %s",
shardName, response);
- LOG.debug ("{}: {}", persistenceId, msg);
+ LOG.debug("{}: {}", persistenceId, msg);
targetActor.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response :
new RuntimeException(msg)), shardManagerActor);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java
index e4e71a492c..bc06c32fa7 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java
@@ -51,18 +51,18 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor {
@Override
public void onReceive(Object message) {
- if(message instanceof GetSnapshotReply) {
+ if (message instanceof GetSnapshotReply) {
onGetSnapshotReply((GetSnapshotReply)message);
- } else if(message instanceof Failure) {
+ } else if (message instanceof Failure) {
LOG.debug("{}: Received {}", params.id, message);
params.replyToActor.tell(message, getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
} else if (message instanceof ReceiveTimeout) {
String msg = String.format(
- "Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s did not respond.",
- params.receiveTimeout.toMillis(), params.shardNames.size(), remainingShardNames.size(),
- remainingShardNames);
+ "Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s "
+ + "did not respond.", params.receiveTimeout.toMillis(), params.shardNames.size(),
+ remainingShardNames.size(), remainingShardNames);
LOG.warn("{}: {}", params.id, msg);
params.replyToActor.tell(new Failure(new TimeoutException(msg)), getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
@@ -76,11 +76,11 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor {
shardSnapshots.add(new ShardSnapshot(shardId.getShardName(), getSnapshotReply.getSnapshot()));
remainingShardNames.remove(shardId.getShardName());
- if(remainingShardNames.isEmpty()) {
+ if (remainingShardNames.isEmpty()) {
LOG.debug("{}: All shard snapshots received", params.id);
- DatastoreSnapshot datastoreSnapshot = new DatastoreSnapshot(params.datastoreType, params.shardManagerSnapshot,
- shardSnapshots);
+ DatastoreSnapshot datastoreSnapshot = new DatastoreSnapshot(params.datastoreType,
+ params.shardManagerSnapshot, shardSnapshots);
params.replyToActor.tell(datastoreSnapshot, getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfo.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfo.java
index 41a2afe193..d7b4932d5d 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfo.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfo.java
@@ -42,7 +42,7 @@ final class ShardManagerInfo extends AbstractMXBean implements ShardManagerInfoM
this.memberName = Preconditions.checkNotNull(memberName);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
@Override
public List getLocalShards() {
try {
@@ -67,6 +67,7 @@ final class ShardManagerInfo extends AbstractMXBean implements ShardManagerInfoM
return memberName.getName();
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void requestSwitchShardState(final ShardIdentifier shardId, final String newState, final long term) {
// Validates strings argument
final RaftState state = RaftState.valueOf(newState);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfoMBean.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfoMBean.java
index 5f34578031..01204ce979 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfoMBean.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfoMBean.java
@@ -12,44 +12,48 @@ import java.util.List;
public interface ShardManagerInfoMBean {
/**
+ * Returns the list of all the local shard names.
*
* @return a list of all the local shard names
*/
List getLocalShards();
/**
+ * Returns the overall sync status for all shards.
*
* @return true if all local shards are in sync with their corresponding leaders
*/
boolean getSyncStatus();
/**
- * Get the name of of the current member
+ * Returns the name of the local member.
*
- * @return
+ * @return the local member name
*/
String getMemberName();
/**
- * Switch the Raft Behavior of all the local shards to the newBehavior
+ * Switches the raft behavior of all the local shards to the newBehavior.
*
* @param newBehavior should be either Leader/Follower only
- * @param term when switching to the Leader specifies for which term the Shard would be the Leader. Any modifications
- * made to state will be written with this term. This term will then be used by the Raft replication
- * implementation to decide which modifications should stay and which ones should be removed. Ideally
- * the term provided when switching to a new Leader should always be higher than the previous term.
+ * @param term when switching to the Leader specifies for which term the Shard would be the Leader. Any
+ * modifications made to state will be written with this term. This term will then be used by the Raft
+ * replication implementation to decide which modifications should stay and which ones should be
+ * removed. Ideally the term provided when switching to a new Leader should always be higher than the
+ * previous term.
*/
void switchAllLocalShardsState(String newBehavior, long term);
/**
- * Switch the Raft Behavior of the shard specified by shardName to the newBehavior
+ * Switches the raft behavior of the shard specified by shardName to the newBehavior.
*
* @param shardName a shard that is local to this shard manager
* @param newBehavior should be either Leader/Follower only
- * @param term when switching to the Leader specifies for which term the Shard would be the Leader. Any modifications
- * made to state will be written with this term. This term will then be used by the Raft replication
- * implementation to decide which modifications should stay and which ones should be removed. Ideally
- * the term provided when switching to a new Leader should always be higher than the previous term.
+ * @param term when switching to the Leader specifies for which term the Shard would be the Leader. Any
+ * modifications made to state will be written with this term. This term will then be used by the Raft
+ * replication implementation to decide which modifications should stay and which ones should be
+ * removed. Ideally the term provided when switching to a new Leader should always be higher than the
+ * previous term.
*/
void switchShardState(String shardName, String newBehavior, long term);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java
index b6fe842692..78dc1c2830 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java
@@ -14,7 +14,7 @@ import java.util.List;
import javax.annotation.Nonnull;
/**
- * Persisted data of the ShardManager
+ * Persisted data of the ShardManager.
*/
// FIXME: make this package-protected once forShardList is removed.
public final class ShardManagerSnapshot implements Serializable {
@@ -30,6 +30,8 @@ public final class ShardManagerSnapshot implements Serializable {
}
/**
+ * Creates a ShardManagerSnapshot.
+ *
* @deprecated This method is for migration only and should me removed once
* org.opendaylight.controller.cluster.datastore.ShardManagerSnapshot is removed.
*/
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java
index 62b8e93fb5..a05548b1a4 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java
@@ -33,7 +33,7 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
private final String shardManagerType;
private final MemberName localMemberName;
- public ShardPeerAddressResolver(String shardManagerType, MemberName localMemberName) {
+ ShardPeerAddressResolver(String shardManagerType, MemberName localMemberName) {
this.shardManagerIdentifier = ShardManagerIdentifier.builder().type(shardManagerType).build().toString();
this.shardManagerType = shardManagerType;
this.localMemberName = Preconditions.checkNotNull(localMemberName);
@@ -53,8 +53,8 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
Collection getShardManagerPeerActorAddresses() {
Collection peerAddresses = new ArrayList<>();
- for(Map.Entry entry: memberNameToAddress.entrySet()) {
- if(!localMemberName.equals(entry.getKey())) {
+ for (Map.Entry entry: memberNameToAddress.entrySet()) {
+ if (!localMemberName.equals(entry.getKey())) {
peerAddresses.add(getShardManagerActorPathBuilder(entry.getValue()).toString());
}
}
@@ -68,7 +68,7 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
String getShardActorAddress(String shardName, MemberName memberName) {
Address memberAddress = memberNameToAddress.get(memberName);
- if(memberAddress != null) {
+ if (memberAddress != null) {
return getShardManagerActorPathBuilder(memberAddress).append("/").append(
getShardIdentifier(memberName, shardName)).toString();
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java
index 6a3de4256b..a0712b6714 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/DefaultShardStrategy.java
@@ -11,10 +11,8 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
- * The DefaultShardStrategy basically puts all data into the default Shard
- *
- * The default shard stores data for all modules for which a specific set of shards has not been configured
- *
+ * The DefaultShardStrategy basically puts all data into the default shard. The default shard stores data for all
+ * modules for which a specific set of shards has not been configured. This is only intended for testing.
*/
public final class DefaultShardStrategy implements ShardStrategy {
public static final String NAME = "default";
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java
index 26cbc053f6..c90baf2760 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java
@@ -18,7 +18,7 @@ public class ModuleShardStrategy implements ShardStrategy {
private final String moduleName;
private final Configuration configuration;
- public ModuleShardStrategy(String moduleName, Configuration configuration){
+ public ModuleShardStrategy(String moduleName, Configuration configuration) {
this.moduleName = moduleName;
this.configuration = configuration;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java
index 9a05c381ea..0440b7f023 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategy.java
@@ -11,17 +11,17 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
- * The role of ShardStrategy is to figure out which Shards a given piece of data belongs to
+ * The role of ShardStrategy is to figure out which shards a given piece of data belongs to.
*/
public interface ShardStrategy {
- /**
- * Find the name of the shard in which the data pointed to by the specified path belongs in
- *
- * Should return the name of the default shard DefaultShardStrategy.DEFAULT_SHARD
- * if no matching shard was found
- *
- * @param path The location of the data in the logical tree
- * @return
- */
- String findShard(YangInstanceIdentifier path);
+ /**
+ * Find the name of the shard in which the data pointed to by the specified path belongs in.
+ *
+ * Should return the name of the default shard DefaultShardStrategy.DEFAULT_SHARD
+ * if no matching shard was found
+ *
+ * @param path the location of the data in the logical tree
+ * @return the corresponding shard name.
+ */
+ String findShard(YangInstanceIdentifier path);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
index 8ca6150038..a26dc56a75 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
@@ -36,7 +36,7 @@ public class ShardStrategyFactory {
public static ShardStrategy newShardStrategyInstance(String moduleName, String strategyName,
Configuration configuration) {
- if(ModuleShardStrategy.NAME.equals(strategyName)){
+ if (ModuleShardStrategy.NAME.equals(strategyName)) {
return new ModuleShardStrategy(moduleName, configuration);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
index ee0a4796ca..f1a1f145b3 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
@@ -9,6 +9,7 @@
package org.opendaylight.controller.cluster.datastore.utils;
import static akka.pattern.Patterns.ask;
+
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
@@ -74,11 +75,11 @@ public class ActorContext {
@Override
public Throwable apply(Throwable failure) {
Throwable actualFailure = failure;
- if(failure instanceof AskTimeoutException) {
+ if (failure instanceof AskTimeoutException) {
// A timeout exception most likely means the shard isn't initialized.
actualFailure = new NotInitializedException(
- "Timed out trying to find the primary shard. Most likely cause is the " +
- "shard is not initialized yet.");
+ "Timed out trying to find the primary shard. Most likely cause is the "
+ + "shard is not initialized yet.");
}
return actualFailure;
@@ -101,8 +102,13 @@ public class ActorContext {
private final Dispatchers dispatchers;
private volatile SchemaContext schemaContext;
+
+ // Used as a write memory barrier.
+ @SuppressWarnings("unused")
private volatile boolean updated;
- private final MetricRegistry metricRegistry = MetricsReporter.getInstance(DatastoreContext.METRICS_DOMAIN).getMetricsRegistry();
+
+ private final MetricRegistry metricRegistry = MetricsReporter.getInstance(DatastoreContext.METRICS_DOMAIN)
+ .getMetricsRegistry();
private final PrimaryShardInfoFutureCache primaryShardInfoCache;
private final ShardStrategyFactory shardStrategyFactory;
@@ -171,7 +177,7 @@ public class ActorContext {
public void setSchemaContext(SchemaContext schemaContext) {
this.schemaContext = schemaContext;
- if(shardManager != null) {
+ if (shardManager != null) {
shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
}
}
@@ -189,7 +195,7 @@ public class ActorContext {
updated = true;
- if(shardManager != null) {
+ if (shardManager != null) {
shardManager.tell(contextFactory, ActorRef.noSender());
}
}
@@ -200,7 +206,7 @@ public class ActorContext {
public Future findPrimaryShardAsync(final String shardName) {
Future ret = primaryShardInfoCache.getIfPresent(shardName);
- if(ret != null){
+ if (ret != null) {
return ret;
}
Future future = executeOperationAsync(shardManager,
@@ -209,20 +215,20 @@ public class ActorContext {
return future.transform(new Mapper() {
@Override
public PrimaryShardInfo checkedApply(Object response) throws UnknownMessageException {
- if(response instanceof RemotePrimaryShardFound) {
+ if (response instanceof RemotePrimaryShardFound) {
LOG.debug("findPrimaryShardAsync received: {}", response);
RemotePrimaryShardFound found = (RemotePrimaryShardFound)response;
return onPrimaryShardFound(shardName, found.getPrimaryPath(), found.getPrimaryVersion(), null);
- } else if(response instanceof LocalPrimaryShardFound) {
+ } else if (response instanceof LocalPrimaryShardFound) {
LOG.debug("findPrimaryShardAsync received: {}", response);
LocalPrimaryShardFound found = (LocalPrimaryShardFound)response;
return onPrimaryShardFound(shardName, found.getPrimaryPath(), DataStoreVersions.CURRENT_VERSION,
found.getLocalShardDataTree());
- } else if(response instanceof NotInitializedException) {
+ } else if (response instanceof NotInitializedException) {
throw (NotInitializedException)response;
- } else if(response instanceof PrimaryNotFoundException) {
+ } else if (response instanceof PrimaryNotFoundException) {
throw (PrimaryNotFoundException)response;
- } else if(response instanceof NoShardLeaderException) {
+ } else if (response instanceof NoShardLeaderException) {
throw (NoShardLeaderException)response;
}
@@ -242,7 +248,7 @@ public class ActorContext {
}
/**
- * Finds a local shard given its shard name and return it's ActorRef
+ * Finds a local shard given its shard name and return it's ActorRef.
*
* @param shardName the name of the local shard that needs to be found
* @return a reference to a local shard actor which represents the shard
@@ -273,13 +279,13 @@ public class ActorContext {
return future.map(new Mapper() {
@Override
public ActorRef checkedApply(Object response) throws Throwable {
- if(response instanceof LocalShardFound) {
+ if (response instanceof LocalShardFound) {
LocalShardFound found = (LocalShardFound)response;
LOG.debug("Local shard found {}", found.getPath());
return found.getPath();
- } else if(response instanceof NotInitializedException) {
+ } else if (response instanceof NotInitializedException) {
throw (NotInitializedException)response;
- } else if(response instanceof LocalShardNotFound) {
+ } else if (response instanceof LocalShardNotFound) {
throw new LocalShardNotFoundException(
String.format("Local shard for %s does not exist.", shardName));
}
@@ -291,49 +297,51 @@ public class ActorContext {
}
/**
- * Executes an operation on a local actor and wait for it's response
+ * Executes an operation on a local actor and wait for it's response.
*
- * @param actor
- * @param message
+ * @param actor the actor
+ * @param message the message to send
* @return The response of the operation
*/
+ @SuppressWarnings("checkstyle:IllegalCatch")
public Object executeOperation(ActorRef actor, Object message) {
Future future = executeOperationAsync(actor, message, operationTimeout);
try {
return Await.result(future, operationDuration);
} catch (Exception e) {
- throw new TimeoutException("Sending message " + message.getClass().toString() +
- " to actor " + actor.toString() + " failed. Try again later.", e);
+ throw new TimeoutException("Sending message " + message.getClass().toString()
+ + " to actor " + actor.toString() + " failed. Try again later.", e);
}
}
- public Future executeOperationAsync(ActorRef actor, Object message, Timeout timeout) {
- Preconditions.checkArgument(actor != null, "actor must not be null");
- Preconditions.checkArgument(message != null, "message must not be null");
-
- LOG.debug("Sending message {} to {}", message.getClass(), actor);
- return doAsk(actor, message, timeout);
- }
-
/**
- * Execute an operation on a remote actor and wait for it's response
+ * Execute an operation on a remote actor and wait for it's response.
*
- * @param actor
- * @param message
- * @return
+ * @param actor the actor
+ * @param message the message
+ * @return the response message
*/
+ @SuppressWarnings("checkstyle:IllegalCatch")
public Object executeOperation(ActorSelection actor, Object message) {
Future future = executeOperationAsync(actor, message);
try {
return Await.result(future, operationDuration);
} catch (Exception e) {
- throw new TimeoutException("Sending message " + message.getClass().toString() +
- " to actor " + actor.toString() + " failed. Try again later.", e);
+ throw new TimeoutException("Sending message " + message.getClass().toString()
+ + " to actor " + actor.toString() + " failed. Try again later.", e);
}
}
+ public Future executeOperationAsync(ActorRef actor, Object message, Timeout timeout) {
+ Preconditions.checkArgument(actor != null, "actor must not be null");
+ Preconditions.checkArgument(message != null, "message must not be null");
+
+ LOG.debug("Sending message {} to {}", message.getClass(), actor);
+ return doAsk(actor, message, timeout);
+ }
+
/**
* Execute an operation on a remote actor asynchronously.
*
@@ -379,11 +387,12 @@ public class ActorContext {
actor.tell(message, ActorRef.noSender());
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void shutdown() {
FiniteDuration duration = datastoreContext.getShardRaftConfig().getElectionTimeOutInterval().$times(3);
try {
Await.ready(Patterns.gracefulStop(shardManager, duration, Shutdown.INSTANCE), duration);
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.warn("ShardManager for {} data store did not shutdown gracefully", getDataStoreName(), e);
}
}
@@ -392,21 +401,21 @@ public class ActorContext {
return clusterWrapper;
}
- public MemberName getCurrentMemberName(){
+ public MemberName getCurrentMemberName() {
return clusterWrapper.getCurrentMemberName();
}
/**
- * Send the message to each and every shard
+ * Send the message to each and every shard.
*/
- public void broadcast(final Function messageSupplier, Class> messageClass){
- for(final String shardName : configuration.getAllShardNames()){
+ public void broadcast(final Function messageSupplier, Class> messageClass) {
+ for (final String shardName : configuration.getAllShardNames()) {
Future primaryFuture = findPrimaryShardAsync(shardName);
primaryFuture.onComplete(new OnComplete() {
@Override
public void onComplete(Throwable failure, PrimaryShardInfo primaryShardInfo) {
- if(failure != null) {
+ if (failure != null) {
LOG.warn("broadcast failed to send message {} to shard {}: {}",
messageClass.getSimpleName(), shardName, failure);
} else {
@@ -457,61 +466,64 @@ public class ActorContext {
* This is a utility method that lets us get a Timer object for any operation. This is a little open-ended to allow
* us to create a timer for pretty much anything.
*
- * @param operationName
- * @return
+ * @param operationName the name of the operation
+ * @return the Timer instance
*/
- public Timer getOperationTimer(String operationName){
+ public Timer getOperationTimer(String operationName) {
return getOperationTimer(datastoreContext.getDataStoreName(), operationName);
}
- public Timer getOperationTimer(String dataStoreType, String operationName){
+ public Timer getOperationTimer(String dataStoreType, String operationName) {
final String rate = MetricRegistry.name(DISTRIBUTED_DATA_STORE_METRIC_REGISTRY, dataStoreType,
operationName, METRIC_RATE);
return metricRegistry.timer(rate);
}
/**
- * Get the name of the data store to which this ActorContext belongs
+ * Get the name of the data store to which this ActorContext belongs.
*
- * @return
+ * @return the data store name
*/
public String getDataStoreName() {
return datastoreContext.getDataStoreName();
}
/**
- * Get the current transaction creation rate limit
- * @return
+ * Get the current transaction creation rate limit.
+ *
+ * @return the rate limit
*/
- public double getTxCreationLimit(){
+ public double getTxCreationLimit() {
return txRateLimiter.getTxCreationLimit();
}
/**
* Try to acquire a transaction creation permit. Will block if no permits are available.
*/
- public void acquireTxCreationPermit(){
+ public void acquireTxCreationPermit() {
txRateLimiter.acquire();
}
/**
- * Return the operation timeout to be used when committing transactions
- * @return
+ * Returns the operation timeout to be used when committing transactions.
+ *
+ * @return the operation timeout
*/
- public Timeout getTransactionCommitOperationTimeout(){
+ public Timeout getTransactionCommitOperationTimeout() {
return transactionCommitOperationTimeout;
}
/**
* An akka dispatcher that is meant to be used when processing ask Futures which were triggered by client
- * code on the datastore
- * @return
+ * code on the datastore.
+ *
+ * @return the dispatcher
*/
public ExecutionContext getClientDispatcher() {
return this.dispatchers.getDispatcher(Dispatchers.DispatcherType.Client);
}
- public String getNotificationDispatcherPath(){
+ public String getNotificationDispatcherPath() {
return this.dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Notification);
}
@@ -523,11 +535,11 @@ public class ActorContext {
return shardStrategyFactory;
}
- protected Future doAsk(ActorRef actorRef, Object message, Timeout timeout){
+ protected Future doAsk(ActorRef actorRef, Object message, Timeout timeout) {
return ask(actorRef, message, timeout);
}
- protected Future doAsk(ActorSelection actorRef, Object message, Timeout timeout){
+ protected Future doAsk(ActorSelection actorRef, Object message, Timeout timeout) {
return ask(actorRef, message, timeout);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/DataTreeModificationOutput.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/DataTreeModificationOutput.java
index 8e19441be7..84717e188f 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/DataTreeModificationOutput.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/DataTreeModificationOutput.java
@@ -31,10 +31,11 @@ public final class DataTreeModificationOutput {
private DataTreeModificationOutput() {
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
public static void toFile(File file, DataTreeModification modification) {
- try(FileOutputStream outStream = new FileOutputStream(file)) {
+ try (FileOutputStream outStream = new FileOutputStream(file)) {
modification.applyToCursor(new DataTreeModificationOutputCursor(new DataOutputStream(outStream)));
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.error("Error writing DataTreeModification to file {}", file, e);
}
}
@@ -52,7 +53,7 @@ public final class DataTreeModificationOutput {
output.write("\nDELETE -> ".getBytes());
output.write(current().node(child).toString().getBytes());
output.writeByte('\n');
- } catch(IOException e) {
+ } catch (IOException e) {
Throwables.propagate(e);
}
}
@@ -76,7 +77,7 @@ public final class DataTreeModificationOutput {
output.write(": \n".getBytes());
NormalizedNodeXMLOutput.toStream(output, data);
output.writeByte('\n');
- } catch(IOException | XMLStreamException e) {
+ } catch (IOException | XMLStreamException e) {
Throwables.propagate(e);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/Dispatchers.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/Dispatchers.java
index 15f49c3cbc..980289fcf9 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/Dispatchers.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/Dispatchers.java
@@ -27,34 +27,35 @@ public class Dispatchers {
Notification(NOTIFICATION_DISPATCHER_PATH);
private final String path;
- DispatcherType(String path){
+ DispatcherType(String path) {
this.path = path;
}
- private String path(akka.dispatch.Dispatchers dispatchers){
- if(dispatchers.hasDispatcher(path)){
+
+ private String path(akka.dispatch.Dispatchers dispatchers) {
+ if (dispatchers.hasDispatcher(path)) {
return path;
}
return DEFAULT_DISPATCHER_PATH;
}
- private ExecutionContext dispatcher(akka.dispatch.Dispatchers dispatchers){
- if(dispatchers.hasDispatcher(path)){
+ private ExecutionContext dispatcher(akka.dispatch.Dispatchers dispatchers) {
+ if (dispatchers.hasDispatcher(path)) {
return dispatchers.lookup(path);
}
return dispatchers.defaultGlobalDispatcher();
}
}
- public Dispatchers(akka.dispatch.Dispatchers dispatchers){
+ public Dispatchers(akka.dispatch.Dispatchers dispatchers) {
Preconditions.checkNotNull(dispatchers, "dispatchers should not be null");
this.dispatchers = dispatchers;
}
- public ExecutionContext getDispatcher(DispatcherType dispatcherType){
+ public ExecutionContext getDispatcher(DispatcherType dispatcherType) {
return dispatcherType.dispatcher(this.dispatchers);
}
- public String getDispatcherPath(DispatcherType dispatcherType){
+ public String getDispatcherPath(DispatcherType dispatcherType) {
return dispatcherType.path(this.dispatchers);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
index c0965675e0..cdbad0b29d 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
@@ -25,8 +25,9 @@ public class NormalizedNodeAggregator {
private final List>> nodes;
private final DataTree dataTree;
- private NormalizedNodeAggregator(final YangInstanceIdentifier rootIdentifier, final List>> nodes,
- final SchemaContext schemaContext, LogicalDatastoreType logicalDatastoreType) {
+ private NormalizedNodeAggregator(final YangInstanceIdentifier rootIdentifier,
+ final List>> nodes, final SchemaContext schemaContext,
+ LogicalDatastoreType logicalDatastoreType) {
this.rootIdentifier = rootIdentifier;
this.nodes = nodes;
this.dataTree = InMemoryDataTreeFactory.getInstance().create(
@@ -36,18 +37,11 @@ public class NormalizedNodeAggregator {
}
/**
- * Combine data from all the nodes in the list into a tree with root as rootIdentifier
- *
- * @param nodes
- * @param schemaContext
- * @param logicalDatastoreType
- * @return
- * @throws DataValidationFailedException
+ * Combine data from all the nodes in the list into a tree with root as rootIdentifier.
*/
public static Optional> aggregate(final YangInstanceIdentifier rootIdentifier,
- final List>> nodes,
- final SchemaContext schemaContext,
- LogicalDatastoreType logicalDatastoreType) throws DataValidationFailedException {
+ final List>> nodes, final SchemaContext schemaContext,
+ LogicalDatastoreType logicalDatastoreType) throws DataValidationFailedException {
return new NormalizedNodeAggregator(rootIdentifier, nodes, schemaContext, logicalDatastoreType).aggregate();
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeXMLOutput.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeXMLOutput.java
index ffcc00e557..dc8c77b432 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeXMLOutput.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeXMLOutput.java
@@ -11,6 +11,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import javanet.staxutils.IndentingXMLStreamWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -20,7 +21,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit
import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javanet.staxutils.IndentingXMLStreamWriter;
/**
* Utility class to output NormalizedNodes as XML.
@@ -40,7 +40,7 @@ public final class NormalizedNodeXMLOutput {
XMLStreamWriter xmlWriter = xmlFactory.createXMLStreamWriter(outStream);
IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter);
- try(NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(
+ try (NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(
indenting)) {
NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
nodeWriter.write(node);
@@ -49,9 +49,9 @@ public final class NormalizedNodeXMLOutput {
}
public static void toFile(File file, NormalizedNode, ?> node) {
- try(FileOutputStream outStream = new FileOutputStream(file)) {
+ try (FileOutputStream outStream = new FileOutputStream(file)) {
toStream(outStream, node);
- } catch(IOException | XMLStreamException e) {
+ } catch (IOException | XMLStreamException e) {
LOG.error("Error writing NormalizedNode to file {}", file, e);
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java
index 697b0c516a..0e97cd9588 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModification.java
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
/**
* The PruningDataTreeModification first removes all entries from the data which do not belong in the schemaContext
- * before delegating it to the actual DataTreeModification
+ * before delegating it to the actual DataTreeModification.
*/
public class PruningDataTreeModification extends ForwardingObject implements DataTreeModification {
@@ -53,7 +53,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
public void delete(YangInstanceIdentifier yangInstanceIdentifier) {
try {
delegate.delete(yangInstanceIdentifier);
- } catch(SchemaValidationFailedException e){
+ } catch (SchemaValidationFailedException e) {
LOG.warn("Node at path : {} does not exist ignoring delete", yangInstanceIdentifier);
}
}
@@ -61,12 +61,12 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
@Override
public void merge(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode, ?> normalizedNode) {
try {
- if(YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)){
+ if (YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)) {
pruneAndMergeNode(yangInstanceIdentifier, normalizedNode);
} else {
delegate.merge(yangInstanceIdentifier, normalizedNode);
}
- } catch (SchemaValidationFailedException e){
+ } catch (SchemaValidationFailedException e) {
LOG.warn("Node at path {} was pruned during merge due to validation error: {}",
yangInstanceIdentifier, e.getMessage());
@@ -78,7 +78,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
private void pruneAndMergeNode(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode, ?> normalizedNode) {
NormalizedNode,?> pruned = pruneNormalizedNode(yangInstanceIdentifier, normalizedNode);
- if(pruned != null) {
+ if (pruned != null) {
delegate.merge(yangInstanceIdentifier, pruned);
}
}
@@ -86,12 +86,12 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
@Override
public void write(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode, ?> normalizedNode) {
try {
- if(YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)){
+ if (YangInstanceIdentifier.EMPTY.equals(yangInstanceIdentifier)) {
pruneAndWriteNode(yangInstanceIdentifier, normalizedNode);
} else {
delegate.write(yangInstanceIdentifier, normalizedNode);
}
- } catch (SchemaValidationFailedException e){
+ } catch (SchemaValidationFailedException e) {
LOG.warn("Node at path : {} was pruned during write due to validation error: {}",
yangInstanceIdentifier, e.getMessage());
@@ -102,7 +102,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
private void pruneAndWriteNode(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode, ?> normalizedNode) {
NormalizedNode,?> pruned = pruneNormalizedNode(yangInstanceIdentifier, normalizedNode);
- if(pruned != null) {
+ if (pruned != null) {
delegate.write(yangInstanceIdentifier, pruned);
}
}
@@ -161,7 +161,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
public void write(PathArgument child, NormalizedNode, ?> data) {
YangInstanceIdentifier path = current().node(child);
NormalizedNode, ?> prunedNode = pruningModification.pruneNormalizedNode(path, data);
- if(prunedNode != null) {
+ if (prunedNode != null) {
toModification.write(path, prunedNode);
}
}
@@ -170,7 +170,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
public void merge(PathArgument child, NormalizedNode, ?> data) {
YangInstanceIdentifier path = current().node(child);
NormalizedNode, ?> prunedNode = pruningModification.pruneNormalizedNode(path, data);
- if(prunedNode != null) {
+ if (prunedNode != null) {
toModification.merge(path, prunedNode);
}
}
@@ -179,7 +179,7 @@ public class PruningDataTreeModification extends ForwardingObject implements Dat
public void delete(PathArgument child) {
try {
toModification.delete(current().node(child));
- } catch(SchemaValidationFailedException e) {
+ } catch (SchemaValidationFailedException e) {
// Ignoring since we would've already logged this in the call to the original modification.
}
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java
index 97e3383490..5ab0759915 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java
@@ -41,7 +41,7 @@ public final class SerializationUtils {
private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException {
NormalizedNodeDataOutput streamWriter = REUSABLE_WRITER_TL.get();
- if(streamWriter == null) {
+ if (streamWriter == null) {
streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
}
@@ -50,7 +50,7 @@ public final class SerializationUtils {
private static NormalizedNodeDataInput streamReader(DataInput in) throws IOException {
NormalizedNodeDataInput streamReader = REUSABLE_READER_TL.get();
- if(streamReader == null) {
+ if (streamReader == null) {
streamReader = new NormalizedNodeInputStreamReader(in);
}
@@ -82,17 +82,14 @@ public final class SerializationUtils {
}
}
- public static void serializeNormalizedNode(NormalizedNode, ?> node, DataOutput out) {
- try {
- out.writeBoolean(node != null);
- if(node != null) {
- NormalizedNodeDataOutput streamWriter = streamWriter(out);
- streamWriter.writeNormalizedNode(node);
- }
- } catch (IOException e) {
- throw new IllegalArgumentException(String.format("Error serializing NormalizedNode %s",
- node), e);
+ private static NormalizedNode, ?> tryDeserializeNormalizedNode(DataInput in) throws IOException {
+ boolean present = in.readBoolean();
+ if (present) {
+ NormalizedNodeDataInput streamReader = streamReader(in);
+ return streamReader.readNormalizedNode();
}
+
+ return null;
}
public static NormalizedNode, ?> deserializeNormalizedNode(DataInput in) {
@@ -103,20 +100,10 @@ public final class SerializationUtils {
}
}
- private static NormalizedNode, ?> tryDeserializeNormalizedNode(DataInput in) throws IOException {
- boolean present = in.readBoolean();
- if(present) {
- NormalizedNodeDataInput streamReader = streamReader(in);
- return streamReader.readNormalizedNode();
- }
-
- return null;
- }
-
public static NormalizedNode, ?> deserializeNormalizedNode(byte [] bytes) {
try {
return tryDeserializeNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes)));
- } catch(InvalidNormalizedNodeStreamException e) {
+ } catch (InvalidNormalizedNodeStreamException e) {
// Probably from legacy protobuf serialization - try that.
try {
NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(bytes);
@@ -129,6 +116,19 @@ public final class SerializationUtils {
}
}
+ public static void serializeNormalizedNode(NormalizedNode, ?> node, DataOutput out) {
+ try {
+ out.writeBoolean(node != null);
+ if (node != null) {
+ NormalizedNodeDataOutput streamWriter = streamWriter(out);
+ streamWriter.writeNormalizedNode(node);
+ }
+ } catch (IOException e) {
+ throw new IllegalArgumentException(String.format("Error serializing NormalizedNode %s",
+ node), e);
+ }
+ }
+
public static byte [] serializeNormalizedNode(NormalizedNode, ?> node) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
serializeNormalizedNode(node, new DataOutputStream(bos));
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java
index 58c1bd6c25..32faf3a00b 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiter.java
@@ -29,21 +29,22 @@ public class TransactionRateLimiter {
private volatile long pollOnCount = 1;
- public TransactionRateLimiter(ActorContext actorContext){
+ public TransactionRateLimiter(ActorContext actorContext) {
this.actorContext = actorContext;
this.commitTimeoutInSeconds = actorContext.getDatastoreContext().getShardTransactionCommitTimeoutInSeconds();
this.dataStoreName = actorContext.getDataStoreName();
- this.txRateLimiter = RateLimiter.create(actorContext.getDatastoreContext().getTransactionCreationInitialRateLimit());
+ this.txRateLimiter = RateLimiter.create(actorContext.getDatastoreContext()
+ .getTransactionCreationInitialRateLimit());
}
- public void acquire(){
+ public void acquire() {
adjustRateLimit();
txRateLimiter.acquire();
}
private void adjustRateLimit() {
final long count = acquireCount.incrementAndGet();
- if(count >= pollOnCount) {
+ if (count >= pollOnCount) {
final Timer commitTimer = actorContext.getOperationTimer(ActorContext.COMMIT);
double newRateLimit = calculateNewRateLimit(commitTimer, commitTimeoutInSeconds);
@@ -53,26 +54,26 @@ public class TransactionRateLimiter {
if (newRateLimit >= 1.0) {
txRateLimiter.setRate(newRateLimit);
- pollOnCount = count + ((long) newRateLimit/2);
+ pollOnCount = count + (long) newRateLimit / 2;
}
}
}
- public double getTxCreationLimit(){
+ public double getTxCreationLimit() {
return txRateLimiter.getRate();
}
- private double getRateLimitFromOtherDataStores(){
+ private double getRateLimitFromOtherDataStores() {
// Since we have no rate data for unused Tx's data store, adjust to the rate from another
// data store that does have rate data.
- for(String name: DatastoreContext.getGlobalDatastoreNames()) {
- if(name.equals(this.dataStoreName)) {
+ for (String name: DatastoreContext.getGlobalDatastoreNames()) {
+ if (name.equals(this.dataStoreName)) {
continue;
}
double newRateLimit = calculateNewRateLimit(actorContext.getOperationTimer(name, ActorContext.COMMIT),
this.commitTimeoutInSeconds);
- if(newRateLimit > 0.0) {
+ if (newRateLimit > 0.0) {
LOG.debug("On unused Tx - data Store {} commit rateLimit adjusted to {}",
this.dataStoreName, newRateLimit);
@@ -84,7 +85,7 @@ public class TransactionRateLimiter {
}
private static double calculateNewRateLimit(Timer commitTimer, long commitTimeoutInSeconds) {
- if(commitTimer == null) {
+ if (commitTimer == null) {
// This can happen in unit tests.
return 0;
}
@@ -96,13 +97,13 @@ public class TransactionRateLimiter {
// Find the time that it takes for transactions to get executed in every 10th percentile
// Compute the rate limit for that percentile and sum it up
- for(int i=1;i<=10;i++){
+ for (int i = 1; i <= 10; i++) {
// Get the amount of time transactions take in the i*10th percentile
double percentileTimeInNanos = timerSnapshot.getValue(i * 0.1D);
- if(percentileTimeInNanos > 0) {
+ if (percentileTimeInNanos > 0) {
// Figure out the rate limit for the i*10th percentile in nanos
- double percentileRateLimit = (commitTimeoutInNanos / percentileTimeInNanos);
+ double percentileRateLimit = commitTimeoutInNanos / percentileTimeInNanos;
// Add the percentileRateLimit to the total rate limit
newRateLimit += percentileRateLimit;
@@ -110,7 +111,7 @@ public class TransactionRateLimiter {
}
// Compute the rate limit per second
- return newRateLimit/(commitTimeoutInSeconds*10);
+ return newRateLimit / (commitTimeoutInSeconds * 10);
}
@VisibleForTesting
@@ -119,13 +120,12 @@ public class TransactionRateLimiter {
}
@VisibleForTesting
- void setPollOnCount(long value){
+ void setPollOnCount(long value) {
pollOnCount = value;
}
@VisibleForTesting
- void setAcquireCount(long value){
+ void setAcquireCount(long value) {
acquireCount.set(value);
}
-
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderImpl.java
index 1ab67384f1..585218f121 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderImpl.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderImpl.java
@@ -9,7 +9,6 @@ package org.opendaylight.controller.config.yang.config.actor_system_provider.imp
import akka.actor.ActorSystem;
import akka.actor.Props;
-import akka.japi.Effect;
import akka.osgi.BundleDelegatingClassLoader;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
@@ -51,15 +50,11 @@ public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseab
actorSystem.actorOf(Props.create(TerminationMonitor.class), TerminationMonitor.ADDRESS);
- actorSystem.actorOf(QuarantinedMonitorActor.props(new Effect() {
-
- @Override
- public void apply() throws Exception {
- // restart the entire karaf container
- LOG.warn("Restarting karaf container");
- System.setProperty("karaf.restart", "true");
- bundleContext.getBundle(0).stop();
- }
+ actorSystem.actorOf(QuarantinedMonitorActor.props(() -> {
+ // restart the entire karaf container
+ LOG.warn("Restarting karaf container");
+ System.setProperty("karaf.restart", "true");
+ bundleContext.getBundle(0).stop();
}), QuarantinedMonitorActor.ADDRESS);
}
@@ -76,6 +71,7 @@ public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseab
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
LOG.info("Shutting down ActorSystem");
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModule.java
index 511f5dfdee..1981c203e5 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModule.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModule.java
@@ -12,6 +12,8 @@ import akka.actor.ActorSystem;
import com.google.common.collect.ForwardingObject;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.ActorSystemProviderListener;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.osgi.framework.BundleContext;
@@ -19,11 +21,12 @@ import org.osgi.framework.BundleContext;
public class ActorSystemProviderModule extends AbstractActorSystemProviderModule {
private BundleContext bundleContext;
- public ActorSystemProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public ActorSystemProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public ActorSystemProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, ActorSystemProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public ActorSystemProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
+ ActorSystemProviderModule oldModule, AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModuleFactory.java
index cfc623d5a5..9e15085055 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModuleFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModuleFactory.java
@@ -24,8 +24,10 @@ import org.osgi.framework.BundleContext;
public class ActorSystemProviderModuleFactory extends AbstractActorSystemProviderModuleFactory {
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
- ActorSystemProviderModule module = (ActorSystemProviderModule)super.createModule(instanceName,dependencyResolver,bundleContext);
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ ActorSystemProviderModule module = (ActorSystemProviderModule)super.createModule(instanceName,
+ dependencyResolver,bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@@ -33,7 +35,8 @@ public class ActorSystemProviderModuleFactory extends AbstractActorSystemProvide
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
- ActorSystemProviderModule module = (ActorSystemProviderModule)super.createModule(instanceName, dependencyResolver,
+ ActorSystemProviderModule module = (ActorSystemProviderModule)super.createModule(instanceName,
+ dependencyResolver,
old, bundleContext);
module.setBundleContext(bundleContext);
return module;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModule.java
index 596229360a..6723d2b4f6 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModule.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModule.java
@@ -8,6 +8,7 @@
package org.opendaylight.controller.config.yang.config.concurrent_data_broker;
import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataBroker;
@@ -16,11 +17,14 @@ import org.osgi.framework.BundleContext;
public class DomConcurrentDataBrokerModule extends AbstractDomConcurrentDataBrokerModule {
private BundleContext bundleContext;
- public DomConcurrentDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
+ public DomConcurrentDataBrokerModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public DomConcurrentDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final DomConcurrentDataBrokerModule oldModule, final AutoCloseable oldInstance) {
+ public DomConcurrentDataBrokerModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver, final DomConcurrentDataBrokerModule oldModule,
+ final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModuleFactory.java
index c6f5a9e70c..b44abc9060 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModuleFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/concurrent_data_broker/DomConcurrentDataBrokerModuleFactory.java
@@ -14,7 +14,8 @@ import org.osgi.framework.BundleContext;
public class DomConcurrentDataBrokerModuleFactory extends AbstractDomConcurrentDataBrokerModuleFactory {
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
DomConcurrentDataBrokerModule module = (DomConcurrentDataBrokerModule)super.createModule(instanceName,
dependencyResolver, bundleContext);
module.setBundleContext(bundleContext);
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java
index 3076323450..e30b324a46 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java
@@ -10,12 +10,13 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_pro
import org.opendaylight.controller.cluster.datastore.DatastoreContext;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.osgi.framework.BundleContext;
-public class DistributedConfigDataStoreProviderModule extends
- org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModule {
+public class DistributedConfigDataStoreProviderModule extends AbstractDistributedConfigDataStoreProviderModule {
private BundleContext bundleContext;
public DistributedConfigDataStoreProviderModule(
@@ -24,11 +25,8 @@ public class DistributedConfigDataStoreProviderModule extends
super(identifier, dependencyResolver);
}
- public DistributedConfigDataStoreProviderModule(
- org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedConfigDataStoreProviderModule oldModule,
- java.lang.AutoCloseable oldInstance) {
+ public DistributedConfigDataStoreProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
+ DistributedConfigDataStoreProviderModule oldModule, AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@@ -58,22 +56,25 @@ public class DistributedConfigDataStoreProviderModule extends
private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
ConfigProperties props = inProps;
- if(props == null) {
+ if (props == null) {
props = new ConfigProperties();
}
return DatastoreContext.newBuilder()
.logicalStoreType(LogicalDatastoreType.CONFIGURATION)
.maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
- .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
- .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().getValue().intValue())
+ .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize()
+ .getValue().intValue())
+ .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize()
+ .getValue().intValue())
.maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
.shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
.operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
- .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
- getValue().intValue())
+ .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize()
+ .getValue().intValue())
.shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
- .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
+ .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage()
+ .getValue().intValue())
.shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
.shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
.shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModuleFactory.java
index 50930abc7f..fe12ce2e12 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModuleFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModuleFactory.java
@@ -5,16 +5,6 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
-/*
-* Generated file
-*
-* Generated from: yang module name: distributed-datastore-provider yang module local name: distributed-config-datastore-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Jun 24 17:14:50 PDT 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
import org.opendaylight.controller.config.api.DependencyResolver;
@@ -22,11 +12,14 @@ import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.spi.Module;
import org.osgi.framework.BundleContext;
-public class DistributedConfigDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModuleFactory {
+public class DistributedConfigDataStoreProviderModuleFactory
+ extends AbstractDistributedConfigDataStoreProviderModuleFactory {
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
- DistributedConfigDataStoreProviderModule module = (DistributedConfigDataStoreProviderModule)super.createModule(instanceName,dependencyResolver,bundleContext);
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ DistributedConfigDataStoreProviderModule module = (DistributedConfigDataStoreProviderModule)super.createModule(
+ instanceName,dependencyResolver,bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@@ -34,8 +27,8 @@ public class DistributedConfigDataStoreProviderModuleFactory extends org.openday
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
- DistributedConfigDataStoreProviderModule module = (DistributedConfigDataStoreProviderModule)super.createModule(instanceName, dependencyResolver,
- old, bundleContext);
+ DistributedConfigDataStoreProviderModule module = (DistributedConfigDataStoreProviderModule)super.createModule(
+ instanceName, dependencyResolver, old, bundleContext);
module.setBundleContext(bundleContext);
return module;
}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java
index e7589e0d36..0597aba5e2 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java
@@ -10,25 +10,24 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_pro
import org.opendaylight.controller.cluster.datastore.DatastoreContext;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.osgi.framework.BundleContext;
-public class DistributedOperationalDataStoreProviderModule extends
- org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule {
+public class DistributedOperationalDataStoreProviderModule
+ extends AbstractDistributedOperationalDataStoreProviderModule {
private BundleContext bundleContext;
- public DistributedOperationalDataStoreProviderModule(
- org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public DistributedOperationalDataStoreProviderModule(ModuleIdentifier identifier,
+ DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public DistributedOperationalDataStoreProviderModule(
- org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedOperationalDataStoreProviderModule oldModule,
- java.lang.AutoCloseable oldInstance) {
+ public DistributedOperationalDataStoreProviderModule(ModuleIdentifier identifier,
+ DependencyResolver dependencyResolver,DistributedOperationalDataStoreProviderModule oldModule,
+ AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@@ -58,22 +57,25 @@ public class DistributedOperationalDataStoreProviderModule extends
private static DatastoreContext newDatastoreContext(OperationalProperties inProps) {
OperationalProperties props = inProps;
- if(props == null) {
+ if (props == null) {
props = new OperationalProperties();
}
return DatastoreContext.newBuilder()
.logicalStoreType(LogicalDatastoreType.OPERATIONAL)
.maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
- .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
- .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().getValue().intValue())
+ .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize()
+ .getValue().intValue())
+ .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize()
+ .getValue().intValue())
.maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
.shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
.operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
- .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
- getValue().intValue())
+ .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize()
+ .getValue().intValue())
.shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
- .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
+ .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage()
+ .getValue().intValue())
.shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
.shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
.shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModuleFactory.java
index 2c76d2c1ae..b9df9669a1 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModuleFactory.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModuleFactory.java
@@ -5,16 +5,6 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
-/*
-* Generated file
-*
-* Generated from: yang module name: distributed-datastore-provider yang module local name: distributed-operational-datastore-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Jun 24 17:14:50 PDT 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
import org.opendaylight.controller.config.api.DependencyResolver;
@@ -22,10 +12,13 @@ import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.spi.Module;
import org.osgi.framework.BundleContext;
-public class DistributedOperationalDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModuleFactory {
+public class DistributedOperationalDataStoreProviderModuleFactory
+ extends AbstractDistributedOperationalDataStoreProviderModuleFactory {
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
- DistributedOperationalDataStoreProviderModule module = (DistributedOperationalDataStoreProviderModule)super.createModule(instanceName,dependencyResolver,bundleContext);
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ DistributedOperationalDataStoreProviderModule module = (DistributedOperationalDataStoreProviderModule)
+ super.createModule(instanceName,dependencyResolver,bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@@ -33,7 +26,8 @@ public class DistributedOperationalDataStoreProviderModuleFactory extends org.op
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
- DistributedOperationalDataStoreProviderModule module = (DistributedOperationalDataStoreProviderModule)super.createModule(instanceName, dependencyResolver,
+ DistributedOperationalDataStoreProviderModule module = (DistributedOperationalDataStoreProviderModule)
+ super.createModule(instanceName, dependencyResolver,
old, bundleContext);
module.setBundleContext(bundleContext);
return module;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java
index b04bf1bf81..de74726d70 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java
@@ -50,8 +50,8 @@ class ForwardingDistributedDataStore extends ForwardingObject implements Distrib
}
@Override
- public >> ListenerRegistration registerChangeListener(
- YangInstanceIdentifier path, L listener, DataChangeScope scope) {
+ public >> ListenerRegistration
+ registerChangeListener(YangInstanceIdentifier path, L listener, DataChangeScope scope) {
return delegate().registerChangeListener(path, listener, scope);
}
--
2.36.6