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;
13 import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
18 * An instance of a Payload class is meant to be used as the Payload for
22 * When an actor which is derived from RaftActor attempts to persistData it
23 * must pass an instance of the Payload class. Similarly when state needs to
24 * be applied to the derived RaftActor it will be passed an instance of the
28 * To define your own payload do the following,
30 * <li>Create your own protocol buffer message which extends the AppendEntries Payload</li>
31 * <li>Extend this Payload class</li>
32 * <li>Implement encode</li>
33 * <li>Implement decode</li>
36 * Your own protocol buffer message can be create like so, <br/>
40 * import "AppendEntriesMessages.proto";
42 * package org.opendaylight.controller.cluster.raft;
44 * option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
45 * option java_outer_classname = "MockPayloadMessages";
47 * extend AppendEntries.ReplicatedLogEntry.Payload {
48 * optional string value = 2;
54 public abstract class Payload {
55 private String clientPayloadClassName;
57 public String getClientPayloadClassName() {
58 return this.getClass().getName();
61 public void setClientPayloadClassName(String clientPayloadClassName) {
62 this.clientPayloadClassName = clientPayloadClassName;
66 * Encode the payload data as a protocol buffer extension.
68 * TODO: Add more meat in here
70 * @return Map of <GeneratedMessage.GeneratedExtension, T>
72 public abstract <T extends Object> Map<GeneratedMessage.GeneratedExtension, T> encode();
75 * Decode the protocol buffer payload into a specific Payload as defined
76 * by the class extending RaftActor
78 * @param payload The payload in protocol buffer format
81 public abstract Payload decode(
82 AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payload);