Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadyLocalTransaction.java
1 /*
2  * Copyright (c) 2015 Cisco 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.DataStoreVersions;
17 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
18
19 /**
20  * Message notifying the shard leader to apply modifications which have been
21  * prepared locally against its DataTree. This message is not directly serializable,
22  * simply because the leader and sender need to be on the same system. When it needs
23  * to be sent out to a remote system, it needs to be intercepted by {@link ReadyLocalTransactionSerializer}
24  * and turned into {@link BatchedModifications}.
25  */
26 @Deprecated(since = "9.0.0", forRemoval = true)
27 public final class ReadyLocalTransaction {
28     private final DataTreeModification modification;
29     private final TransactionIdentifier transactionId;
30     private final boolean doCommitOnReady;
31     private final @Nullable SortedSet<String> participatingShardNames;
32
33     // The version of the remote system used only when needing to convert to BatchedModifications.
34     private short remoteVersion = DataStoreVersions.CURRENT_VERSION;
35
36     public ReadyLocalTransaction(final TransactionIdentifier transactionId, final DataTreeModification modification,
37             final boolean doCommitOnReady, final Optional<SortedSet<String>> participatingShardNames) {
38         this.transactionId = requireNonNull(transactionId);
39         this.modification = requireNonNull(modification);
40         this.doCommitOnReady = doCommitOnReady;
41         this.participatingShardNames = requireNonNull(participatingShardNames).orElse(null);
42     }
43
44     public TransactionIdentifier getTransactionId() {
45         return transactionId;
46     }
47
48     public DataTreeModification getModification() {
49         return modification;
50     }
51
52     public boolean isDoCommitOnReady() {
53         return doCommitOnReady;
54     }
55
56     public short getRemoteVersion() {
57         return remoteVersion;
58     }
59
60     public void setRemoteVersion(final short remoteVersion) {
61         this.remoteVersion = remoteVersion;
62     }
63
64     public Optional<SortedSet<String>> getParticipatingShardNames() {
65         return Optional.ofNullable(participatingShardNames);
66     }
67 }