package org.opendaylight.controller.protobuff.messages.transaction;
+@Deprecated
public final class ShardTransactionChainMessages {
private ShardTransactionChainMessages() {}
public static void registerAllExtensions(
return defaultInstance;
}
+ @Override
public CloseTransactionChain getDefaultInstanceForType() {
return defaultInstance;
}
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor;
}
+ @Override
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable
public static com.google.protobuf.Parser<CloseTransactionChain> PARSER =
new com.google.protobuf.AbstractParser<CloseTransactionChain>() {
- public CloseTransactionChain parsePartialFrom(
+ @Override
+ public CloseTransactionChain parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
/**
* <code>optional string transactionChainId = 1;</code>
*/
+ @Override
public boolean hasTransactionChainId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string transactionChainId = 1;</code>
*/
+ @Override
public java.lang.String getTransactionChainId() {
java.lang.Object ref = transactionChainId_;
if (ref instanceof java.lang.String) {
/**
* <code>optional string transactionChainId = 1;</code>
*/
+ @Override
public com.google.protobuf.ByteString
getTransactionChainIdBytes() {
java.lang.Object ref = transactionChainId_;
transactionChainId_ = "";
}
private byte memoizedIsInitialized = -1;
+ @Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
- if (isInitialized != -1) return isInitialized == 1;
+ if (isInitialized != -1) {
+ return isInitialized == 1;
+ }
memoizedIsInitialized = 1;
return true;
}
+ @Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
}
private int memoizedSerializedSize = -1;
+ @Override
public int getSerializedSize() {
int size = memoizedSerializedSize;
- if (size != -1) return size;
+ if (size != -1) {
+ return size;
+ }
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
}
public static Builder newBuilder() { return Builder.create(); }
+ @Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain prototype) {
return newBuilder().mergeFrom(prototype);
}
+ @Override
public Builder toBuilder() { return newBuilder(this); }
@java.lang.Override
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor;
}
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ @Override
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable
.ensureFieldAccessorsInitialized(
return new Builder();
}
- public Builder clear() {
+ @Override
+ public Builder clear() {
super.clear();
transactionChainId_ = "";
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
- public Builder clone() {
+ @Override
+ public Builder clone() {
return create().mergeFrom(buildPartial());
}
- public com.google.protobuf.Descriptors.Descriptor
+ @Override
+ public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor;
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain getDefaultInstanceForType() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain getDefaultInstanceForType() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain.getDefaultInstance();
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain build() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain build() {
org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
return result;
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain buildPartial() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain buildPartial() {
org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
return result;
}
- public Builder mergeFrom(com.google.protobuf.Message other) {
+ @Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain) {
return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain)other);
} else {
}
public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain other) {
- if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain.getDefaultInstance()) return this;
+ if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChain.getDefaultInstance()) {
+ return this;
+ }
if (other.hasTransactionChainId()) {
bitField0_ |= 0x00000001;
transactionChainId_ = other.transactionChainId_;
return this;
}
- public final boolean isInitialized() {
+ @Override
+ public final boolean isInitialized() {
return true;
}
- public Builder mergeFrom(
+ @Override
+ public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
/**
* <code>optional string transactionChainId = 1;</code>
*/
- public boolean hasTransactionChainId() {
+ @Override
+ public boolean hasTransactionChainId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string transactionChainId = 1;</code>
*/
- public java.lang.String getTransactionChainId() {
+ @Override
+ public java.lang.String getTransactionChainId() {
java.lang.Object ref = transactionChainId_;
if (!(ref instanceof java.lang.String)) {
java.lang.String s = ((com.google.protobuf.ByteString) ref)
/**
* <code>optional string transactionChainId = 1;</code>
*/
- public com.google.protobuf.ByteString
+ @Override
+ public com.google.protobuf.ByteString
getTransactionChainIdBytes() {
java.lang.Object ref = transactionChainId_;
if (ref instanceof String) {
return defaultInstance;
}
+ @Override
public CloseTransactionChainReply getDefaultInstanceForType() {
return defaultInstance;
}
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor;
}
+ @Override
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable
public static com.google.protobuf.Parser<CloseTransactionChainReply> PARSER =
new com.google.protobuf.AbstractParser<CloseTransactionChainReply>() {
- public CloseTransactionChainReply parsePartialFrom(
+ @Override
+ public CloseTransactionChainReply parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
private void initFields() {
}
private byte memoizedIsInitialized = -1;
+ @Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
- if (isInitialized != -1) return isInitialized == 1;
+ if (isInitialized != -1) {
+ return isInitialized == 1;
+ }
memoizedIsInitialized = 1;
return true;
}
+ @Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
}
private int memoizedSerializedSize = -1;
+ @Override
public int getSerializedSize() {
int size = memoizedSerializedSize;
- if (size != -1) return size;
+ if (size != -1) {
+ return size;
+ }
size = 0;
size += getUnknownFields().getSerializedSize();
}
public static Builder newBuilder() { return Builder.create(); }
+ @Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply prototype) {
return newBuilder().mergeFrom(prototype);
}
+ @Override
public Builder toBuilder() { return newBuilder(this); }
@java.lang.Override
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor;
}
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ @Override
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable
.ensureFieldAccessorsInitialized(
return new Builder();
}
- public Builder clear() {
+ @Override
+ public Builder clear() {
super.clear();
return this;
}
- public Builder clone() {
+ @Override
+ public Builder clone() {
return create().mergeFrom(buildPartial());
}
- public com.google.protobuf.Descriptors.Descriptor
+ @Override
+ public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor;
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply getDefaultInstanceForType() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply getDefaultInstanceForType() {
return org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.getDefaultInstance();
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply build() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply build() {
org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
return result;
}
- public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply buildPartial() {
+ @Override
+ public org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply buildPartial() {
org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply result = new org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply(this);
onBuilt();
return result;
}
- public Builder mergeFrom(com.google.protobuf.Message other) {
+ @Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply) {
return mergeFrom((org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply)other);
} else {
}
public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply other) {
- if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.getDefaultInstance()) return this;
+ if (other == org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.getDefaultInstance()) {
+ return this;
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
- public final boolean isInitialized() {
+ @Override
+ public final boolean isInitialized() {
return true;
}
- public Builder mergeFrom(
+ @Override
+ public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ @Override
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
package org.opendaylight.controller.cluster.datastore.messages;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
-public class CloseTransactionChain implements SerializableMessage {
- public static final Class<ShardTransactionChainMessages.CloseTransactionChain> SERIALIZABLE_CLASS =
- ShardTransactionChainMessages.CloseTransactionChain.class;
- private final String transactionChainId;
+public class CloseTransactionChain extends VersionedExternalizableMessage {
+ private static final long serialVersionUID = 1L;
- public CloseTransactionChain(final String transactionChainId){
+ private String transactionChainId;
+
+ public CloseTransactionChain() {
+ }
+
+ public CloseTransactionChain(final String transactionChainId, final short version) {
+ super(version);
this.transactionChainId = transactionChainId;
}
+ public String getTransactionChainId() {
+ return transactionChainId;
+ }
+
@Override
- public Object toSerializable() {
- return ShardTransactionChainMessages.CloseTransactionChain.newBuilder()
- .setTransactionChainId(transactionChainId).build();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ transactionChainId = in.readUTF();
}
- public static CloseTransactionChain fromSerializable(final Object message){
- ShardTransactionChainMessages.CloseTransactionChain closeTransactionChain
- = (ShardTransactionChainMessages.CloseTransactionChain) message;
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeUTF(transactionChainId);
+ }
+
+ @Override
+ public Object toSerializable() {
+ if(getVersion() >= DataStoreVersions.BORON_VERSION) {
+ return this;
+ } else {
+ return ShardTransactionChainMessages.CloseTransactionChain.newBuilder()
+ .setTransactionChainId(transactionChainId).build();
+ }
+ }
- return new CloseTransactionChain(closeTransactionChain.getTransactionChainId());
+ public static CloseTransactionChain fromSerializable(final Object serializable){
+ if(serializable instanceof CloseTransactionChain) {
+ return (CloseTransactionChain)serializable;
+ } else {
+ ShardTransactionChainMessages.CloseTransactionChain closeTransactionChain =
+ (ShardTransactionChainMessages.CloseTransactionChain) serializable;
+ return new CloseTransactionChain(closeTransactionChain.getTransactionChainId(),
+ DataStoreVersions.LITHIUM_VERSION);
+ }
}
- public String getTransactionChainId() {
- return transactionChainId;
+ public static boolean isSerializedType(Object message) {
+ return message instanceof CloseTransactionChain ||
+ message instanceof ShardTransactionChainMessages.CloseTransactionChain;
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.messages;
+
+import static org.junit.Assert.assertEquals;
+import java.io.Serializable;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionChainMessages;
+
+/**
+ * Unit tests for CloseTransactionChain.
+ *
+ * @author Thomas Pantelis
+ */
+public class CloseTransactionChainTest {
+
+ @Test
+ public void testSerialization() {
+ CloseTransactionChain expected = new CloseTransactionChain("txId", DataStoreVersions.CURRENT_VERSION);
+
+ Object serialized = expected.toSerializable();
+ assertEquals("Serialized type", CloseTransactionChain.class, serialized.getClass());
+
+ CloseTransactionChain actual = CloseTransactionChain.fromSerializable(
+ SerializationUtils.clone((Serializable) serialized));
+ assertEquals("getTransactionChainId", expected.getTransactionChainId(), actual.getTransactionChainId());
+ assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
+ }
+
+ @Test
+ public void testSerializationWithPreBoronVersion() {
+ CloseTransactionChain expected = new CloseTransactionChain("txId", DataStoreVersions.LITHIUM_VERSION);
+
+ Object serialized = expected.toSerializable();
+ assertEquals("Serialized type", ShardTransactionChainMessages.CloseTransactionChain.class, serialized.getClass());
+
+ CloseTransactionChain actual = CloseTransactionChain.fromSerializable(
+ SerializationUtils.clone((Serializable) serialized));
+ assertEquals("getTransactionChainId", expected.getTransactionChainId(), actual.getTransactionChainId());
+ assertEquals("getVersion", DataStoreVersions.LITHIUM_VERSION, actual.getVersion());
+ }
+
+ @Test
+ public void testIsSerializedType() {
+ assertEquals("isSerializedType", true, CloseTransactionChain.isSerializedType(
+ ShardTransactionChainMessages.CloseTransactionChain.newBuilder().setTransactionChainId("").build()));
+
+ assertEquals("isSerializedType", true, CloseTransactionChain.isSerializedType(new CloseTransactionChain()));
+ assertEquals("isSerializedType", false, CloseTransactionChain.isSerializedType(new Object()));
+ }
+}