2 * Copyright (c) 2015 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 com.google.common.base.Preconditions;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
17 * Message used to batch write, merge, delete modification operations to the ShardTransaction actor.
19 * @author Thomas Pantelis
21 public class BatchedModifications extends MutableCompositeModification implements SerializableMessage {
22 private static final long serialVersionUID = 1L;
24 private boolean ready;
25 private boolean doCommitOnReady;
26 private int totalMessagesSent;
27 private String transactionID;
28 private String transactionChainID;
30 public BatchedModifications() {
33 public BatchedModifications(String transactionID, short version, String transactionChainID) {
35 this.transactionID = Preconditions.checkNotNull(transactionID, "transactionID can't be null");
36 this.transactionChainID = transactionChainID != null ? transactionChainID : "";
39 public boolean isReady() {
43 public void setReady(boolean ready) {
47 public boolean isDoCommitOnReady() {
48 return doCommitOnReady;
51 public void setDoCommitOnReady(boolean doCommitOnReady) {
52 this.doCommitOnReady = doCommitOnReady;
55 public int getTotalMessagesSent() {
56 return totalMessagesSent;
59 public void setTotalMessagesSent(int totalMessagesSent) {
60 this.totalMessagesSent = totalMessagesSent;
63 public String getTransactionID() {
67 public String getTransactionChainID() {
68 return transactionChainID;
72 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
73 super.readExternal(in);
74 transactionID = in.readUTF();
75 transactionChainID = in.readUTF();
76 ready = in.readBoolean();
77 totalMessagesSent = in.readInt();
78 doCommitOnReady = in.readBoolean();
82 public void writeExternal(ObjectOutput out) throws IOException {
83 super.writeExternal(out);
84 out.writeUTF(transactionID);
85 out.writeUTF(transactionChainID);
86 out.writeBoolean(ready);
87 out.writeInt(totalMessagesSent);
88 out.writeBoolean(doCommitOnReady);
92 public Object toSerializable() {
97 public String toString() {
98 StringBuilder builder = new StringBuilder();
99 builder.append("BatchedModifications [transactionID=").append(transactionID).append(", transactionChainID=")
100 .append(transactionChainID).append(", ready=").append(ready).append(", totalMessagesSent=")
101 .append(totalMessagesSent).append(", modifications size=").append(getModifications().size())
103 return builder.toString();