2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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 org.opendaylight.controller.cluster.raft.messages.Payload;
15 import org.opendaylight.yangtools.concepts.WritableObjects;
18 * Serialization proxy for {@link SimpleReplicatedLogEntry}.
20 final class LE implements Externalizable {
22 private static final long serialVersionUID = 1L;
28 @SuppressWarnings("checkstyle:RedundantModifier")
33 LE(final SimpleReplicatedLogEntry logEntry) {
34 index = logEntry.getIndex();
35 term = logEntry.getTerm();
36 data = logEntry.getData();
40 public void writeExternal(final ObjectOutput out) throws IOException {
41 WritableObjects.writeLongs(out, index, term);
42 out.writeObject(data);
46 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
47 final byte hdr = WritableObjects.readLongHeader(in);
48 index = WritableObjects.readFirstLong(in, hdr);
49 term = WritableObjects.readSecondLong(in, hdr);
50 data = (Payload) in.readObject();
54 private Object readResolve() {
55 return new SimpleReplicatedLogEntry(index, term, data);