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.ShardTransactionMessages;
17 public class ReadyTransactionReply extends VersionedExternalizableMessage {
18 private static final long serialVersionUID = 1L;
20 public static final Class<ShardTransactionMessages.ReadyTransactionReply> SERIALIZABLE_CLASS =
21 ShardTransactionMessages.ReadyTransactionReply.class;
23 private String cohortPath;
25 public ReadyTransactionReply() {
28 public ReadyTransactionReply(String cohortPath) {
29 this(cohortPath, DataStoreVersions.CURRENT_VERSION);
32 public ReadyTransactionReply(String cohortPath, short version) {
34 this.cohortPath = cohortPath;
37 public String getCohortPath() {
42 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
43 super.readExternal(in);
44 cohortPath = in.readUTF();
48 public void writeExternal(ObjectOutput out) throws IOException {
49 super.writeExternal(out);
50 out.writeUTF(cohortPath);
54 public Object toSerializable() {
55 if(getVersion() >= DataStoreVersions.LITHIUM_VERSION) {
58 return ShardTransactionMessages.ReadyTransactionReply.newBuilder().setActorPath(cohortPath).build();
62 public static ReadyTransactionReply fromSerializable(Object serializable) {
63 if(serializable instanceof ReadyTransactionReply) {
64 return (ReadyTransactionReply)serializable;
66 ShardTransactionMessages.ReadyTransactionReply o =
67 (ShardTransactionMessages.ReadyTransactionReply) serializable;
68 return new ReadyTransactionReply(o.getActorPath(), DataStoreVersions.HELIUM_2_VERSION);
72 public static boolean isSerializedType(Object message) {
73 return message instanceof ReadyTransactionReply ||
74 message instanceof ShardTransactionMessages.ReadyTransactionReply;