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 InstallSnapshotReply extends AbstractRaftRPC {
16 private static final long serialVersionUID = 642227896390779503L;
18 // The followerId - this will be used to figure out which follower is
20 private final String followerId;
21 private final int chunkIndex;
22 private final boolean success;
24 public InstallSnapshotReply(final long term, final String followerId, final int chunkIndex, final boolean success) {
26 this.followerId = followerId;
27 this.chunkIndex = chunkIndex;
28 this.success = success;
31 public String getFollowerId() {
35 public int getChunkIndex() {
39 public boolean isSuccess() {
44 public String toString() {
45 return "InstallSnapshotReply [term=" + getTerm()
46 + ", followerId=" + followerId
47 + ", chunkIndex=" + chunkIndex
48 + ", success=" + success + "]";
52 Object writeReplace() {
56 @Deprecated(since = "7.0.0", forRemoval = true)
57 private static class Proxy implements Externalizable {
59 private static final long serialVersionUID = 1L;
61 private InstallSnapshotReply installSnapshotReply;
63 // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
64 // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
65 @SuppressWarnings("checkstyle:RedundantModifier")
69 Proxy(final InstallSnapshotReply installSnapshotReply) {
70 this.installSnapshotReply = installSnapshotReply;
74 public void writeExternal(final ObjectOutput out) throws IOException {
75 out.writeLong(installSnapshotReply.getTerm());
76 out.writeObject(installSnapshotReply.followerId);
77 out.writeInt(installSnapshotReply.chunkIndex);
78 out.writeBoolean(installSnapshotReply.success);
82 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
83 long term = in.readLong();
84 String followerId = (String) in.readObject();
85 int chunkIndex = in.readInt();
86 boolean success = in.readBoolean();
88 installSnapshotReply = new InstallSnapshotReply(term, followerId, chunkIndex, success);
92 private Object readResolve() {
93 return installSnapshotReply;