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);
54 protected Object newLegacySerializedInstance() {
55 return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath)
56 .setTransactionId(transactionId).setMessageVersion(getVersion()).build();
60 public String toString() {
61 StringBuilder builder = new StringBuilder();
62 builder.append("CreateTransactionReply [transactionPath=").append(transactionPath).append(", transactionId=")
63 .append(transactionId).append(", version=").append(getVersion()).append("]");
64 return builder.toString();
67 public static CreateTransactionReply fromSerializable(Object serializable) {
68 if(serializable instanceof CreateTransactionReply) {
69 return (CreateTransactionReply)serializable;
71 ShardTransactionMessages.CreateTransactionReply o =
72 (ShardTransactionMessages.CreateTransactionReply) serializable;
73 return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(),
74 (short)o.getMessageVersion());
78 public static boolean isSerializedType(Object message) {
79 return message instanceof CreateTransactionReply ||
80 message instanceof ShardTransactionMessages.CreateTransactionReply;