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 int totalMessagesSent;
26 private String transactionID;
27 private String transactionChainID;
29 public BatchedModifications() {
32 public BatchedModifications(String transactionID, short version, String transactionChainID) {
34 this.transactionID = Preconditions.checkNotNull(transactionID, "transactionID can't be null");
35 this.transactionChainID = transactionChainID != null ? transactionChainID : "";
38 public boolean isReady() {
42 public void setReady(boolean ready) {
46 public int getTotalMessagesSent() {
47 return totalMessagesSent;
50 public void setTotalMessagesSent(int totalMessagesSent) {
51 this.totalMessagesSent = totalMessagesSent;
54 public String getTransactionID() {
58 public String getTransactionChainID() {
59 return transactionChainID;
63 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
64 super.readExternal(in);
65 transactionID = in.readUTF();
66 transactionChainID = in.readUTF();
67 ready = in.readBoolean();
68 totalMessagesSent = in.readInt();
72 public void writeExternal(ObjectOutput out) throws IOException {
73 super.writeExternal(out);
74 out.writeUTF(transactionID);
75 out.writeUTF(transactionChainID);
76 out.writeBoolean(ready);
77 out.writeInt(totalMessagesSent);
81 public Object toSerializable() {
86 public String toString() {
87 StringBuilder builder = new StringBuilder();
88 builder.append("BatchedModifications [transactionID=").append(transactionID).append(", transactionChainID=")
89 .append(transactionChainID).append(", ready=").append(ready).append(", totalMessagesSent=")
90 .append(totalMessagesSent).append(", modifications size=").append(getModifications().size())
92 return builder.toString();