X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2Fpersisted%2FSimpleReplicatedLogEntry.java;h=4c07e6b812e254ad026e6d49211e4e22b97f5b6b;hb=d0f46920468c8e4b67c68bd9058572b2d10d75f1;hp=85fa51e93f0b4fc8e5ce95eb2a3925671a050e2e;hpb=e7512222d7d9e3149feb6a90eeb726e9391887fa;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java index 85fa51e93f..4c07e6b812 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java @@ -5,10 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.persisted; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; @@ -39,6 +39,11 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria this.replicatedLogEntry = replicatedLogEntry; } + static int estimatedSerializedSize(final ReplicatedLogEntry replicatedLogEntry) { + return 8 /* index */ + 8 /* term */ + replicatedLogEntry.getData().size() + + 400 /* estimated extra padding for class info */; + } + @Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeLong(replicatedLogEntry.getIndex()); @@ -70,10 +75,10 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria * @param term the term * @param payload the payload */ - public SimpleReplicatedLogEntry(long index, long term, Payload payload) { + public SimpleReplicatedLogEntry(final long index, final long term, final Payload payload) { this.index = index; this.term = term; - this.payload = Preconditions.checkNotNull(payload); + this.payload = requireNonNull(payload); } @Override @@ -102,7 +107,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria } @Override - public void setPersistencePending(boolean pending) { + public void setPersistencePending(final boolean pending) { persistencePending = pending; } @@ -110,6 +115,10 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria return new Proxy(this); } + public int estimatedSerializedSize() { + return Proxy.estimatedSerializedSize(this); + } + @Override public int hashCode() { final int prime = 31; @@ -121,7 +130,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; }