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 static java.util.Objects.requireNonNull;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 * Base class for a 3PC message.
20 * @author Thomas Pantelis
22 public abstract class AbstractThreePhaseCommitMessage extends VersionedExternalizableMessage {
23 private static final long serialVersionUID = 1L;
25 private TransactionIdentifier transactionId;
27 protected AbstractThreePhaseCommitMessage() {
30 protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
32 this.transactionId = requireNonNull(transactionId);
35 public TransactionIdentifier getTransactionId() {
40 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
41 super.readExternal(in);
42 transactionId = TransactionIdentifier.readFrom(in);
46 public void writeExternal(final ObjectOutput out) throws IOException {
47 super.writeExternal(out);
48 transactionId.writeTo(out);
52 public String toString() {
53 return getClass().getSimpleName() + " [transactionId=" + transactionId + ", version=" + getVersion() + "]";