import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
-public class AbortTransactionReply extends EmptyReply {
+public class AbortTransactionReply extends VersionedExternalizableMessage {
private static final Object SERIALIZED_INSTANCE =
ThreePhaseCommitCohortMessages.AbortTransactionReply.newBuilder().build();
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
/**
* Base class for a 3PC message.
this.transactionID = Preconditions.checkNotNull(transactionID);
}
- protected abstract Object newLegacySerializedInstance();
-
public String getTransactionID() {
return transactionID;
}
out.writeUTF(transactionID);
}
- @Override
- public Object toSerializable() {
- return getVersion() >= DataStoreVersions.BORON_VERSION ? this : newLegacySerializedInstance();
- }
-
@Override
public String toString() {
return getClass().getSimpleName() + " [transactionID=" + transactionID + ", version=" + getVersion()
}
@Override
- public Object toSerializable() {
+ protected Object newLegacySerializedInstance() {
+ // no legacy serialized type for this class; return self
return this;
}
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return canCommit ? YES_SERIALIZED : NO_SERIALIZED;
- }
+ protected Object newLegacySerializedInstance() {
+ return canCommit ? YES_SERIALIZED : NO_SERIALIZED;
}
@Override
package org.opendaylight.controller.cluster.datastore.messages;
-import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
public class CloseTransaction extends VersionedExternalizableMessage {
}
@Override
- public Object toSerializable() {
- return getVersion() >= DataStoreVersions.BORON_VERSION ? this : SERIALIZED_INSTANCE;
+ protected Object newLegacySerializedInstance() {
+ return SERIALIZED_INSTANCE;
}
public static boolean isSerializedType(Object message) {
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return ShardTransactionChainMessages.CloseTransactionChain.newBuilder()
- .setTransactionChainId(transactionChainId).build();
- }
+ protected Object newLegacySerializedInstance() {
+ return ShardTransactionChainMessages.CloseTransactionChain.newBuilder().setTransactionChainId(transactionChainId)
+ .build();
}
public static CloseTransactionChain fromSerializable(final Object serializable){
}
@Override
- public Object toSerializable() {
+ protected Object newLegacySerializedInstance() {
+ // no legacy serialized type for this class; return self
return this;
}
}
import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
-public class CommitTransactionReply extends EmptyReply {
+public class CommitTransactionReply extends VersionedExternalizableMessage {
private static final Object SERIALIZED_INSTANCE =
ThreePhaseCommitCohortMessages.CommitTransactionReply.newBuilder().build();
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.ShardTransactionMessages;
public class CreateTransaction extends VersionedExternalizableMessage {
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return ShardTransactionMessages.CreateTransaction.newBuilder()
- .setTransactionId(transactionId).setTransactionType(transactionType)
- .setTransactionChainId(transactionChainId).setMessageVersion(getVersion()).build();
- }
+ protected Object newLegacySerializedInstance() {
+ return ShardTransactionMessages.CreateTransaction.newBuilder().setTransactionId(transactionId)
+ .setTransactionType(transactionType).setTransactionChainId(transactionChainId)
+ .setMessageVersion(getVersion()).build();
}
@Override
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.ShardTransactionMessages;
public class CreateTransactionReply extends VersionedExternalizableMessage {
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath)
- .setTransactionId(transactionId).setMessageVersion(getVersion()).build();
- }
+ protected Object newLegacySerializedInstance() {
+ return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath)
+ .setTransactionId(transactionId).setMessageVersion(getVersion()).build();
}
@Override
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return ShardTransactionMessages.DataExists.newBuilder().setInstanceIdentifierPathArguments(
- InstanceIdentifierUtils.toSerializable(getPath())).build();
- }
+ protected Object newLegacySerializedInstance() {
+ return ShardTransactionMessages.DataExists.newBuilder()
+ .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(getPath())).build();
}
@Override
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return exists ? SERIALIZABLE_TRUE : SERIALIZABLE_FALSE;
- }
+ protected Object newLegacySerializedInstance() {
+ return exists ? SERIALIZABLE_TRUE : SERIALIZABLE_FALSE;
}
public static DataExistsReply fromSerializable(final Object serializable) {
+++ /dev/null
-/*
- * Copyright (c) 2015 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 org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-
-/**
- * A reply with no data.
- *
- * @author Thomas Pantelis
- */
-public abstract class EmptyReply extends VersionedExternalizableMessage {
- protected EmptyReply() {
- }
-
- protected EmptyReply(short version) {
- super(version);
- }
-
- protected abstract Object newLegacySerializedInstance();
-
- @Override
- public Object toSerializable() {
- return getVersion() >= DataStoreVersions.BORON_VERSION ? this : newLegacySerializedInstance();
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + " [version=" + getVersion() + "]";
- }
-}
}
@Override
- public Object toSerializable() {
- if(getVersion() >= DataStoreVersions.BORON_VERSION) {
- return this;
- } else {
- return ShardTransactionMessages.ReadData.newBuilder().setInstanceIdentifierPathArguments(
- InstanceIdentifierUtils.toSerializable(getPath())).build();
- }
+ protected Object newLegacySerializedInstance() {
+ return ShardTransactionMessages.ReadData.newBuilder()
+ .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(getPath())).build();
}
@Override
}
@Override
- public Object toSerializable() {
+ protected Object newLegacySerializedInstance() {
+ // no legacy serialized type for this class; return self
return this;
}
}
@Override
- public Object toSerializable() {
+ protected Object newLegacySerializedInstance() {
+ // no legacy serialized type for this class; return self
return this;
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeShort(version);
}
+
+ protected abstract Object newLegacySerializedInstance();
+
+ @Override
+ public final Object toSerializable() {
+ return getVersion() >= DataStoreVersions.BORON_VERSION ? this : newLegacySerializedInstance();
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [version=" + getVersion() + "]";
+ }
}