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.protobuff.messages.transaction.ShardTransactionMessages;
16 public class CreateTransactionReply extends VersionedExternalizableMessage {
17 private static final long serialVersionUID = 1L;
19 private String transactionPath;
20 private String transactionId;
22 public CreateTransactionReply() {
25 public CreateTransactionReply(final String transactionPath, final String transactionId, final short version) {
27 this.transactionPath = transactionPath;
28 this.transactionId = transactionId;
31 public String getTransactionPath() {
32 return transactionPath;
35 public String getTransactionId() {
40 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
41 super.readExternal(in);
42 transactionId = in.readUTF();
43 transactionPath = in.readUTF();
47 public void writeExternal(ObjectOutput out) throws IOException {
48 super.writeExternal(out);
49 out.writeUTF(transactionId);
50 out.writeUTF(transactionPath);
55 protected Object newLegacySerializedInstance() {
56 return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath)
57 .setTransactionId(transactionId).setMessageVersion(getVersion()).build();
61 public String toString() {
62 StringBuilder builder = new StringBuilder();
63 builder.append("CreateTransactionReply [transactionPath=").append(transactionPath).append(", transactionId=")
64 .append(transactionId).append(", version=").append(getVersion()).append("]");
65 return builder.toString();
68 public static CreateTransactionReply fromSerializable(Object serializable) {
69 if(serializable instanceof CreateTransactionReply) {
70 return (CreateTransactionReply)serializable;
72 ShardTransactionMessages.CreateTransactionReply o =
73 (ShardTransactionMessages.CreateTransactionReply) serializable;
74 return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(),
75 (short)o.getMessageVersion());
79 public static boolean isSerializedType(Object message) {
80 return message instanceof CreateTransactionReply ||
81 message instanceof ShardTransactionMessages.CreateTransactionReply;