2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.messages;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Optional;
13 import java.util.SortedSet;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16 import org.opendaylight.controller.cluster.datastore.ReadWriteShardDataTreeTransaction;
19 * Transaction ReadyTransaction message that is forwarded to the local Shard from the ShardTransaction.
21 * @author Thomas Pantelis
23 public class ForwardedReadyTransaction {
24 private final TransactionIdentifier transactionId;
25 private final ReadWriteShardDataTreeTransaction transaction;
26 private final boolean doImmediateCommit;
27 private final short txnClientVersion;
28 private @Nullable final SortedSet<String> participatingShardNames;
30 public ForwardedReadyTransaction(TransactionIdentifier transactionId, short txnClientVersion,
31 ReadWriteShardDataTreeTransaction transaction, boolean doImmediateCommit,
32 Optional<SortedSet<String>> participatingShardNames) {
33 this.transactionId = requireNonNull(transactionId);
34 this.transaction = requireNonNull(transaction);
35 this.txnClientVersion = txnClientVersion;
36 this.doImmediateCommit = doImmediateCommit;
37 this.participatingShardNames = requireNonNull(participatingShardNames).orElse(null);
40 public TransactionIdentifier getTransactionId() {
44 public ReadWriteShardDataTreeTransaction getTransaction() {
48 public short getTxnClientVersion() {
49 return txnClientVersion;
52 public boolean isDoImmediateCommit() {
53 return doImmediateCommit;
56 public Optional<SortedSet<String>> getParticipatingShardNames() {
57 return Optional.ofNullable(participatingShardNames);
61 public String toString() {
62 return "ForwardedReadyTransaction [transactionId=" + transactionId + ", transaction=" + transaction
63 + ", doImmediateCommit=" + doImmediateCommit + ", participatingShardNames=" + participatingShardNames
64 + ", txnClientVersion=" + txnClientVersion + "]";