X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft-example%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fexample%2Fmessages%2FKeyValue.java;h=78eea5cd862a8f26dd7d1b73df156266f58fe8e3;hb=HEAD;hp=87a77b271bb0a8780ba40fd9c903b6c627e35da7;hpb=5db894b0b79b4d111768c3643efa1330f8fbee84;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java index 87a77b271b..78eea5cd86 100644 --- a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java +++ b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java @@ -5,24 +5,20 @@ * 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.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; +import org.opendaylight.controller.cluster.raft.messages.Payload; -public class KeyValue extends Payload implements Serializable { +public final class KeyValue extends Payload { private static final long serialVersionUID = 1L; + private String key; private String value; public KeyValue() { } - public KeyValue(String key, String value){ + public KeyValue(final String key, final String value) { this.key = key; this.value = value; } @@ -35,34 +31,24 @@ public class KeyValue extends Payload implements Serializable { return value; } - public void setKey(String key) { - this.key = key; - } - - public void setValue(String value) { - this.value = value; - } - - @Override public String toString() { - return "KeyValue{" + - "key='" + key + '\'' + - ", value='" + value + '\'' + - '}'; + @Override + public int size() { + return value.length() + key.length(); } - // override this method to return the protobuff related extension fields and their values - @Override public Map, String> encode() { - return null; + @Override + public int serializedSize() { + // Should be a better estimate + return size(); } - // override this method to assign the values from protobuff - @Override public Payload decode(AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) { - return null; + @Override + public String toString() { + return "KeyValue{" + "key='" + key + '\'' + ", value='" + value + '\'' + '}'; } @Override - public int size() { - return this.value.length() + this.key.length(); + protected Object writeReplace() { + return new KVv1(value, key); } - }