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 CreateTransactionReply extends VersionedExternalizableMessage {
18 private static final long serialVersionUID = 1L;
20 private String transactionPath;
21 private String transactionId;
23 public CreateTransactionReply() {
26 public CreateTransactionReply(final String transactionPath, final String transactionId, final short version) {
28 this.transactionPath = transactionPath;
29 this.transactionId = transactionId;
32 public String getTransactionPath() {
33 return transactionPath;
36 public String getTransactionId() {
41 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
42 super.readExternal(in);
43 transactionId = in.readUTF();
44 transactionPath = in.readUTF();
48 public void writeExternal(ObjectOutput out) throws IOException {
49 super.writeExternal(out);
50 out.writeUTF(transactionId);
51 out.writeUTF(transactionPath);
55 public Object toSerializable() {
56 if(getVersion() >= DataStoreVersions.BORON_VERSION) {
59 return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath)
60 .setTransactionId(transactionId).setMessageVersion(getVersion()).build();
65 public String toString() {
66 StringBuilder builder = new StringBuilder();
67 builder.append("CreateTransactionReply [transactionPath=").append(transactionPath).append(", transactionId=")
68 .append(transactionId).append(", version=").append(getVersion()).append("]");
69 return builder.toString();
72 public static CreateTransactionReply fromSerializable(Object serializable) {
73 if(serializable instanceof CreateTransactionReply) {
74 return (CreateTransactionReply)serializable;
76 ShardTransactionMessages.CreateTransactionReply o =
77 (ShardTransactionMessages.CreateTransactionReply) serializable;
78 return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(),
79 (short)o.getMessageVersion());
83 public static boolean isSerializedType(Object message) {
84 return message instanceof CreateTransactionReply ||
85 message instanceof ShardTransactionMessages.CreateTransactionReply;