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;
11 import com.google.common.base.Preconditions;
12 import java.io.Serializable;
13 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
16 * A {@link ReplicatedLogEntry} implementation.
18 * @deprecated Use {@link org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry} instead.
21 public class ReplicatedLogImplEntry implements ReplicatedLogEntry, Serializable {
22 private static final long serialVersionUID = -9085798014576489130L;
24 private final long index;
25 private final long term;
26 private final Payload payload;
27 private transient boolean persistencePending = false;
30 * Constructs an instance.
32 * @param index the index
33 * @param term the term
34 * @param payload the payload
36 public ReplicatedLogImplEntry(final long index, final long term, final Payload payload) {
39 this.payload = Preconditions.checkNotNull(payload);
43 public Payload getData() {
48 public long getTerm() {
53 public long getIndex() {
59 return getData().size();
62 private Object readResolve() {
63 return org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry.createMigrated(
64 index, term, payload);
68 public boolean isPersistencePending() {
69 return persistencePending;
73 public void setPersistencePending(boolean pending) {
74 persistencePending = pending;
78 public int hashCode() {
81 result = prime * result + payload.hashCode();
82 result = prime * result + (int) (index ^ index >>> 32);
83 result = prime * result + (int) (term ^ term >>> 32);
88 public boolean equals(Object obj) {
97 if (getClass() != obj.getClass()) {
101 ReplicatedLogImplEntry other = (ReplicatedLogImplEntry) obj;
102 if (payload == null) {
103 if (other.payload != null) {
106 } else if (!payload.equals(other.payload)) {
110 if (index != other.index) {
114 if (term != other.term) {
122 public String toString() {
123 return "Entry{index=" + index + ", term=" + term + '}';