2 * Copyright (c) 2016 Brocade Communications 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.persisted;
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.io.Serializable;
17 * Internal message that is stored in the akka's persistent journal to delete journal entries.
19 * @author Thomas Pantelis
21 public class DeleteEntries implements Serializable, MigratedSerializable {
22 private static final class Proxy implements Externalizable {
23 private static final long serialVersionUID = 1L;
25 private DeleteEntries deleteEntries;
31 Proxy(final DeleteEntries deleteEntries) {
32 this.deleteEntries = deleteEntries;
36 public void writeExternal(final ObjectOutput out) throws IOException {
37 out.writeLong(deleteEntries.fromIndex);
41 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
42 deleteEntries = new DeleteEntries(in.readLong());
45 private Object readResolve() {
50 private static final long serialVersionUID = 1L;
52 private final long fromIndex;
53 private final boolean migrated;
55 private DeleteEntries(final long fromIndex, final boolean migrated) {
56 this.fromIndex = fromIndex;
57 this.migrated = migrated;
60 public DeleteEntries(final long fromIndex) {
61 this(fromIndex, false);
64 public long getFromIndex() {
69 public boolean isMigrated() {
74 public Object writeReplace() {
75 return new Proxy(this);
79 public static DeleteEntries createMigrated(final long fromIndex) {
80 return new DeleteEntries(fromIndex, true);
84 public String toString() {
85 return "DeleteEntries [fromIndex=" + fromIndex + "]";