*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.util.Optional;
import java.util.SortedSet;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private boolean closed;
ShardDataTreeTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier, final ShardDataTree dataTree) {
- this.chainId = Preconditions.checkNotNull(localHistoryIdentifier);
- this.dataTree = Preconditions.checkNotNull(dataTree);
+ chainId = requireNonNull(localHistoryIdentifier);
+ this.dataTree = requireNonNull(dataTree);
}
private DataTreeSnapshot getSnapshot() {
- Preconditions.checkState(!closed, "TransactionChain %s has been closed", this);
- Preconditions.checkState(openTransaction == null, "Transaction %s is open", openTransaction);
+ checkState(!closed, "TransactionChain %s has been closed", this);
+ checkState(openTransaction == null, "Transaction %s is open", openTransaction);
if (previousTx == null) {
LOG.debug("Opening an unchained snapshot in {}", chainId);
return previousTx.getSnapshot();
}
- ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final TransactionIdentifier txId) {
+ @NonNull ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final TransactionIdentifier txId) {
final DataTreeSnapshot snapshot = getSnapshot();
LOG.debug("Allocated read-only transaction {} snapshot {}", txId, snapshot);
return new ReadOnlyShardDataTreeTransaction(this, txId, snapshot);
}
- ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) {
+ @NonNull ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) {
final DataTreeSnapshot snapshot = getSnapshot();
LOG.debug("Allocated read-write transaction {} snapshot {}", txId, snapshot);
- openTransaction = new ReadWriteShardDataTreeTransaction(this, txId, snapshot.newModification());
- return openTransaction;
+ final var ret = new ReadWriteShardDataTreeTransaction(this, txId, snapshot.newModification());
+ openTransaction = ret;
+ return ret;
}
void close() {
@Override
void abortFromTransactionActor(final AbstractShardDataTreeTransaction<?> transaction) {
if (transaction instanceof ReadWriteShardDataTreeTransaction) {
- Preconditions.checkState(openTransaction != null,
- "Attempted to abort transaction %s while none is outstanding", transaction);
+ checkState(openTransaction != null, "Attempted to abort transaction %s while none is outstanding",
+ transaction);
LOG.debug("Aborted open transaction {}", transaction);
openTransaction = null;
}
@Override
ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction,
final Optional<SortedSet<String>> participatingShardNames) {
- Preconditions.checkState(openTransaction != null,
- "Attempted to finish transaction %s while none is outstanding", transaction);
+ 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