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
8 package org.opendaylight.controller.cluster.raft.messages;
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
15 public final class RequestVoteReply extends AbstractRaftRPC {
17 private static final long serialVersionUID = 8427899326488775660L;
19 // true means candidate received vote
20 private final boolean voteGranted;
22 public RequestVoteReply(final long term, final boolean voteGranted) {
24 this.voteGranted = voteGranted;
27 public boolean isVoteGranted() {
32 public String toString() {
33 return "RequestVoteReply [term=" + getTerm() + ", voteGranted=" + voteGranted + "]";
37 Object writeReplace() {
41 @Deprecated(since = "7.0.0", forRemoval = true)
42 private static class Proxy implements Externalizable {
44 private static final long serialVersionUID = 1L;
46 private RequestVoteReply requestVoteReply;
48 // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
49 // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
50 @SuppressWarnings("checkstyle:RedundantModifier")
55 public void writeExternal(final ObjectOutput out) {
56 throw new UnsupportedOperationException();
60 public void readExternal(final ObjectInput in) throws IOException {
61 long term = in.readLong();
62 boolean voteGranted = in.readBoolean();
64 requestVoteReply = new RequestVoteReply(term, voteGranted);
68 private Object readResolve() {
69 return requestVoteReply;