2 * Copyright (c) 2016 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.access.concepts.TransactionIdentifier;
17 * Base class for a 3PC message.
19 * @author Thomas Pantelis
21 public abstract class AbstractThreePhaseCommitMessage extends VersionedExternalizableMessage {
22 private static final long serialVersionUID = 1L;
24 private TransactionIdentifier transactionId;
26 protected AbstractThreePhaseCommitMessage() {
29 protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
31 this.transactionId = Preconditions.checkNotNull(transactionId);
34 public TransactionIdentifier getTransactionId() {
39 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
40 super.readExternal(in);
41 transactionId = TransactionIdentifier.readFrom(in);
45 public void writeExternal(ObjectOutput out) throws IOException {
46 super.writeExternal(out);
47 transactionId.writeTo(out);
51 public String toString() {
52 return getClass().getSimpleName() + " [transactionId=" + transactionId + ", version=" + getVersion() + "]";