Remove deprecated Helium Payload methods 10/33510/7
authorTom Pantelis <tpanteli@brocade.com>
Sun, 24 Jan 2016 05:44:09 +0000 (00:44 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 5 Feb 2016 16:24:42 +0000 (16:24 +0000)
Removed the deprecated encode/decode methods from Payload and its derived
classes.

Change-Id: I52beb2d3991efe9f3a7c2631b8682dc1f324e271
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ServerConfigurationPayload.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorDelegatingPersistentDataProviderTest.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/CompositeModificationByteStringPayload.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/CompositeModificationPayload.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/raft/protobuff/client/messages/Payload.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/CompositeModificationPayload.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/resources/CompositeModificationPayload.proto [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayload.java

index 87a77b2..8916d9f 100644 (file)
@@ -8,11 +8,8 @@
 
 package org.opendaylight.controller.cluster.example.messages;
 
-import com.google.protobuf.GeneratedMessage;
 import java.io.Serializable;
-import java.util.Map;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 
 public class KeyValue extends Payload implements Serializable {
     private static final long serialVersionUID = 1L;
@@ -50,16 +47,6 @@ public class KeyValue extends Payload implements Serializable {
             '}';
     }
 
-    // override this method to return  the protobuff related extension fields and their values
-    @Override public Map<GeneratedMessage.GeneratedExtension<?, ?>, String> encode() {
-        return null;
-    }
-
-    // override this method to assign the values from protobuff
-    @Override public Payload decode(AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) {
-        return null;
-    }
-
     @Override
     public int size() {
         return this.value.length() + this.key.length();
index b439cef..034af3b 100644 (file)
@@ -8,17 +8,14 @@
 package org.opendaylight.controller.cluster.raft;
 
 import com.google.common.base.Preconditions;
-import com.google.protobuf.GeneratedMessage.GeneratedExtension;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.List;
-import java.util.Map;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.PersistentPayload;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,19 +60,6 @@ public class ServerConfigurationPayload extends Payload implements PersistentPay
         return serializedSize;
     }
 
-    @Override
-    @Deprecated
-    @SuppressWarnings("rawtypes")
-    public <T> Map<GeneratedExtension, T> encode() {
-        return null;
-    }
-
-    @Override
-    @Deprecated
-    public Payload decode(AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload) {
-        return null;
-    }
-
     @Override
     public String toString() {
         return "ServerConfigurationPayload [serverConfig=" + serverConfig + "]";
index d42812a..25d14a2 100644 (file)
@@ -13,14 +13,12 @@ import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
 import akka.japi.Procedure;
-import com.google.protobuf.GeneratedMessage;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.controller.cluster.NonPersistentDataProvider;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -182,24 +180,11 @@ public class MockRaftActorContext extends RaftActorContextImpl {
             this.size = size;
         }
 
-        @Override public Map<GeneratedMessage.GeneratedExtension<?, ?>, String> encode() {
-            return null;
-        }
-
-        @Override public Payload decode(
-            AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) {
-            return null;
-        }
-
         @Override
         public int size() {
             return size;
         }
 
-        @Override public String getClientPayloadClassName() {
-            return MockPayload.class.getName();
-        }
-
         @Override
         public String toString() {
             return value;
index 378c53c..3b45e11 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.controller.cluster.raft;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 import akka.japi.Procedure;
-import com.google.protobuf.GeneratedMessage.GeneratedExtension;
-import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -90,18 +88,6 @@ public class RaftActorDelegatingPersistentDataProviderTest {
     }
 
     static class TestNonPersistentPayload extends Payload {
-        @SuppressWarnings("rawtypes")
-        @Override
-        public <T> Map<GeneratedExtension, T> encode() {
-            return null;
-        }
-
-        @Override
-        public Payload decode(
-                org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload) {
-            return null;
-        }
-
         @Override
         public int size() {
             return 0;
index b61b276..1dae675 100644 (file)
@@ -11,15 +11,10 @@ package org.opendaylight.controller.cluster.raft.protobuff.client.messages;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.protobuf.ByteString;
-import com.google.protobuf.GeneratedMessage;
 import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.UnknownFieldSet;
 import java.io.IOException;
 import java.io.Serializable;
 import java.lang.ref.SoftReference;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,39 +40,6 @@ public class CompositeModificationByteStringPayload extends Payload implements
         this.byteString = Preconditions.checkNotNull(byteString, "byteString should not be null");
     }
 
-
-    @Override
-    public Map<GeneratedMessage.GeneratedExtension<?, ?>, PersistentMessages.CompositeModification> encode() {
-        Preconditions.checkState(byteString!=null);
-        Map<GeneratedMessage.GeneratedExtension<?, ?>, PersistentMessages.CompositeModification> map = new HashMap<>();
-        map.put(org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification,
-                getModificationInternal());
-        return map;
-    }
-
-    @Override
-    public Payload decode(
-            AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload) {
-        PersistentMessages.CompositeModification modification = payload
-                .getExtension(
-                        org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification);
-
-        // The extension was put in the unknown field.
-        // This is because extensions need to be registered
-        // see org.opendaylight.controller.mdsal.CompositeModificationPayload.registerAllExtensions
-        // also see https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/ExtensionRegistry
-        // If that is not done then on the other end the extension shows up as an unknown field
-        // Need to figure out a better way to do this
-        if(payload.getUnknownFields().hasField(2)){
-            UnknownFieldSet.Field field =
-                    payload.getUnknownFields().getField(2);
-
-            return new CompositeModificationByteStringPayload(field.getLengthDelimitedList().get(0));
-        }
-
-        return new CompositeModificationByteStringPayload(modification);
-    }
-
     public Object getModification(){
         return getModificationInternal();
     }
index cef20af..bcb45d3 100644 (file)
@@ -9,13 +9,7 @@
 package org.opendaylight.controller.cluster.raft.protobuff.client.messages;
 
 import com.google.common.base.Preconditions;
-import com.google.protobuf.GeneratedMessage;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.UnknownFieldSet;
 import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 
 @Deprecated
@@ -31,44 +25,6 @@ public class CompositeModificationPayload extends Payload implements
         this.modification = (PersistentMessages.CompositeModification) Preconditions.checkNotNull(modification, "modification should not be null");
     }
 
-    @Override public Map<GeneratedMessage.GeneratedExtension<?, ?>, PersistentMessages.CompositeModification> encode() {
-        Preconditions.checkState(modification!=null);
-        Map<GeneratedMessage.GeneratedExtension<?, ?>, PersistentMessages.CompositeModification> map = new HashMap<>();
-        map.put(
-            org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification, this.modification);
-        return map;
-    }
-
-    @Override public Payload decode(
-        AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload) {
-        PersistentMessages.CompositeModification modification = payload
-            .getExtension(
-                org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification);
-
-
-
-        // The extension was put in the unknown field.
-        // This is because extensions need to be registered
-        // see org.opendaylight.controller.mdsal.CompositeModificationPayload.registerAllExtensions
-        // also see https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/ExtensionRegistry
-        // If that is not done then on the other end the extension shows up as an unknown field
-        // Need to figure out a better way to do this
-        if(payload.getUnknownFields().hasField(2)){
-            UnknownFieldSet.Field field =
-                payload.getUnknownFields().getField(2);
-
-            try {
-                modification =
-                    PersistentMessages.CompositeModification
-                        .parseFrom(field.getLengthDelimitedList().get(0));
-            } catch (InvalidProtocolBufferException e) {
-
-            }
-        }
-
-        return new CompositeModificationPayload(modification);
-    }
-
     public Object getModification(){
         return this.modification;
     }
index d721494..bd48f1f 100644 (file)
@@ -9,9 +9,6 @@
 package org.opendaylight.controller.cluster.raft.protobuff.client.messages;
 
 
-import com.google.protobuf.GeneratedMessage;
-import java.util.Map;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
 
 /**
  * An instance of a Payload class is meant to be used as the Payload for
@@ -22,60 +19,7 @@ import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntries
  * must pass an instance of the Payload class. Similarly when state needs to
  * be applied to the derived RaftActor it will be passed an instance of the
  * Payload class.
- * <p>
- *
- * To define your own payload do the following,
- * <ol>
- *     <li>Create your own protocol buffer message which extends the AppendEntries Payload</li>
- *     <li>Extend this Payload class</li>
- *     <li>Implement encode</li>
- *     <li>Implement decode</li>
- * </ol>
- *
- * Your own protocol buffer message can be create like so, <br/>
- * <pre>
- * {@code
- *
- * import "AppendEntriesMessages.proto";
- *
- * package org.opendaylight.controller.cluster.raft;
- *
- * option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
- * option java_outer_classname = "MockPayloadMessages";
- *
- * extend AppendEntries.ReplicatedLogEntry.Payload {
- *      optional string value = 2;
- * }
- * }
- * </pre>
- *
  */
 public abstract class Payload {
-
-    public String getClientPayloadClassName() {
-        return this.getClass().getName();
-    }
-
-    /**
-     * Encode the payload data as a protocol buffer extension.
-     * <p>
-     * TODO: Add more meat in here
-     * @param <T>
-     * @return Map of <GeneratedMessage.GeneratedExtension, T>
-     */
-    @Deprecated
-    public abstract <T extends Object> Map<GeneratedMessage.GeneratedExtension, T> encode();
-
-    /**
-     * Decode the protocol buffer payload into a specific Payload as defined
-     * by the class extending RaftActor
-     *
-     * @param payload The payload in protocol buffer format
-     * @return
-     */
-    @Deprecated
-    public abstract Payload decode(
-        AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload);
-
     public abstract int size();
 }
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/CompositeModificationPayload.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/shard/CompositeModificationPayload.java
deleted file mode 100644 (file)
index 5a9cb9d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: CompositeModificationPayload.proto
-
-package org.opendaylight.controller.protobuff.messages.shard;
-
-public final class CompositeModificationPayload {
-  private CompositeModificationPayload() {}
-  public static void registerAllExtensions(
-      com.google.protobuf.ExtensionRegistry registry) {
-    registry.add(org.opendaylight.controller.protobuff.messages.shard.CompositeModificationPayload.modification);
-  }
-  public static final int MODIFICATION_FIELD_NUMBER = 2;
-  /**
-   * <code>extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... }</code>
-   */
-  public static final
-    com.google.protobuf.GeneratedMessage.GeneratedExtension<
-      org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
-      org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification> modification = com.google.protobuf.GeneratedMessage
-          .newFileScopedGeneratedExtension(
-        org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.class,
-        org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.getDefaultInstance());
-
-  public static com.google.protobuf.Descriptors.FileDescriptor
-      getDescriptor() {
-    return descriptor;
-  }
-  private static com.google.protobuf.Descriptors.FileDescriptor
-      descriptor;
-  static {
-    java.lang.String[] descriptorData = {
-      "\n\"CompositeModificationPayload.proto\022!or" +
-      "g.opendaylight.controller.mdsal\032\033AppendE" +
-      "ntriesMessages.proto\032\014Common.proto\032\020Pers" +
-      "istent.proto:\242\001\n\014modification\022R.org.open" +
-      "daylight.controller.cluster.raft.AppendE" +
-      "ntries.ReplicatedLogEntry.Payload\030\002 \001(\0132" +
-      "8.org.opendaylight.controller.mdsal.Comp" +
-      "ositeModificationB6\n4org.opendaylight.co" +
-      "ntroller.protobuff.messages.shard"
-    };
-    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
-      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
-        public com.google.protobuf.ExtensionRegistry assignDescriptors(
-            com.google.protobuf.Descriptors.FileDescriptor root) {
-          descriptor = root;
-          modification.internalInit(descriptor.getExtensions().get(0));
-          return null;
-        }
-      };
-    com.google.protobuf.Descriptors.FileDescriptor
-      .internalBuildGeneratedFileFrom(descriptorData,
-        new com.google.protobuf.Descriptors.FileDescriptor[] {
-          org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.getDescriptor(),
-          org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(),
-          org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.getDescriptor(),
-        }, assigner);
-  }
-
-  // @@protoc_insertion_point(outer_class_scope)
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/resources/CompositeModificationPayload.proto b/opendaylight/md-sal/sal-clustering-commons/src/main/resources/CompositeModificationPayload.proto
deleted file mode 100644 (file)
index e824e9e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.opendaylight.controller.mdsal;
-
-import "AppendEntriesMessages.proto";
-import "Common.proto";
-import "Persistent.proto";
-
-option java_package = "org.opendaylight.controller.protobuff.messages.shard";
-
-extend org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload {
-    optional CompositeModification modification=2;
-}
-
-
index 4bd098a..5df291f 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.io.ByteArrayDataInput;
 import com.google.common.io.ByteArrayDataOutput;
 import com.google.common.io.ByteStreams;
-import com.google.protobuf.GeneratedMessage.GeneratedExtension;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -19,13 +18,11 @@ import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -214,19 +211,6 @@ final class DataTreeCandidatePayload extends Payload implements Externalizable {
         return parseCandidate(ByteStreams.newDataInput(serialized));
     }
 
-    @Override
-    @Deprecated
-    @SuppressWarnings("rawtypes")
-    public <T> Map<GeneratedExtension, T> encode() {
-        return null;
-    }
-
-    @Override
-    @Deprecated
-    public Payload decode(final AppendEntries.ReplicatedLogEntry.Payload payload) {
-        return null;
-    }
-
     @Override
     public int size() {
         return serialized.length;