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.raft.protobuff.client.messages;
12 import com.google.protobuf.GeneratedMessage;
14 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
17 * An instance of a Payload class is meant to be used as the Payload for
21 * When an actor which is derived from RaftActor attempts to persistData it
22 * must pass an instance of the Payload class. Similarly when state needs to
23 * be applied to the derived RaftActor it will be passed an instance of the
27 * To define your own payload do the following,
29 * <li>Create your own protocol buffer message which extends the AppendEntries Payload</li>
30 * <li>Extend this Payload class</li>
31 * <li>Implement encode</li>
32 * <li>Implement decode</li>
35 * Your own protocol buffer message can be create like so, <br/>
39 * import "AppendEntriesMessages.proto";
41 * package org.opendaylight.controller.cluster.raft;
43 * option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
44 * option java_outer_classname = "MockPayloadMessages";
46 * extend AppendEntries.ReplicatedLogEntry.Payload {
47 * optional string value = 2;
53 public abstract class Payload {
55 public String getClientPayloadClassName() {
56 return this.getClass().getName();
60 * Encode the payload data as a protocol buffer extension.
62 * TODO: Add more meat in here
64 * @return Map of <GeneratedMessage.GeneratedExtension, T>
67 public abstract <T extends Object> Map<GeneratedMessage.GeneratedExtension, T> encode();
70 * Decode the protocol buffer payload into a specific Payload as defined
71 * by the class extending RaftActor
73 * @param payload The payload in protocol buffer format
77 public abstract Payload decode(
78 AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload);
80 public abstract int size();