Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / AbstractThreePhaseCommitMessage.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16
17 /**
18  * Base class for a 3PC message.
19  *
20  * @author Thomas Pantelis
21  */
22 @Deprecated(since = "9.0.0", forRemoval = true)
23 public abstract class AbstractThreePhaseCommitMessage extends VersionedExternalizableMessage {
24     private static final long serialVersionUID = 1L;
25
26     private TransactionIdentifier transactionId;
27
28     protected AbstractThreePhaseCommitMessage() {
29     }
30
31     protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
32         super(version);
33         this.transactionId = requireNonNull(transactionId);
34     }
35
36     public TransactionIdentifier getTransactionId() {
37         return transactionId;
38     }
39
40     @Override
41     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
42         super.readExternal(in);
43         transactionId = TransactionIdentifier.readFrom(in);
44     }
45
46     @Override
47     public void writeExternal(final ObjectOutput out) throws IOException {
48         super.writeExternal(out);
49         transactionId.writeTo(out);
50     }
51
52     @Override
53     public String toString() {
54         return getClass().getSimpleName() + " [transactionId=" + transactionId + ", version=" + getVersion() + "]";
55     }
56 }