2 * Copyright (c) 2014 Cisco 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
9 package org.opendaylight.controller.cluster.datastore.messages;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
15 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
17 public class CloseTransactionChain extends VersionedExternalizableMessage {
18 private static final long serialVersionUID = 1L;
20 private String transactionChainId;
22 public CloseTransactionChain() {
25 public CloseTransactionChain(final String transactionChainId, final short version) {
27 this.transactionChainId = transactionChainId;
30 public String getTransactionChainId() {
31 return transactionChainId;
35 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
36 super.readExternal(in);
37 transactionChainId = in.readUTF();
41 public void writeExternal(ObjectOutput out) throws IOException {
42 super.writeExternal(out);
43 out.writeUTF(transactionChainId);
47 protected Object newLegacySerializedInstance() {
48 return ShardTransactionChainMessages.CloseTransactionChain.newBuilder().setTransactionChainId(transactionChainId)
52 public static CloseTransactionChain fromSerializable(final Object serializable){
53 if(serializable instanceof CloseTransactionChain) {
54 return (CloseTransactionChain)serializable;
56 ShardTransactionChainMessages.CloseTransactionChain closeTransactionChain =
57 (ShardTransactionChainMessages.CloseTransactionChain) serializable;
58 return new CloseTransactionChain(closeTransactionChain.getTransactionChainId(),
59 DataStoreVersions.LITHIUM_VERSION);
63 public static boolean isSerializedType(Object message) {
64 return message instanceof CloseTransactionChain ||
65 message instanceof ShardTransactionChainMessages.CloseTransactionChain;