atomic-storage: remove type dependency at segment level I/O
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ForwardedReadyTransaction.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore.messages;
9
10 import static java.util.Objects.requireNonNull;
11
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;
17
18 /**
19  * Transaction ReadyTransaction message that is forwarded to the local Shard from the ShardTransaction.
20  *
21  * @author Thomas Pantelis
22  */
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;
29
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);
38     }
39
40     public TransactionIdentifier getTransactionId() {
41         return transactionId;
42     }
43
44     public ReadWriteShardDataTreeTransaction getTransaction() {
45         return transaction;
46     }
47
48     public short getTxnClientVersion() {
49         return txnClientVersion;
50     }
51
52     public boolean isDoImmediateCommit() {
53         return doImmediateCommit;
54     }
55
56     public Optional<SortedSet<String>> getParticipatingShardNames() {
57         return Optional.ofNullable(participatingShardNames);
58     }
59
60     @Override
61     public String toString() {
62         return "ForwardedReadyTransaction [transactionId=" + transactionId + ", transaction=" + transaction
63                 + ", doImmediateCommit=" + doImmediateCommit + ", participatingShardNames=" + participatingShardNames
64                 + ", txnClientVersion=" + txnClientVersion + "]";
65     }
66 }