X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fconcepts%2FLocalHistoryIdentifier.java;fp=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fconcepts%2FLocalHistoryIdentifier.java;h=4eb26270c4e078b099f32b9f0d2e721e5e03e810;hb=a06a30a33507689464c736cb37c26445f232280e;hp=330362e6aeccf11df77e798d1210c0d30f8c3fa2;hpb=5e3f2ec4601913dd39aa1b044090ecbd1609b760;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java index 330362e6ae..4eb26270c4 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java @@ -9,6 +9,8 @@ package org.opendaylight.controller.cluster.access.concepts; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; +import java.io.DataInput; +import java.io.DataOutput; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; @@ -18,53 +20,61 @@ import org.opendaylight.yangtools.concepts.Identifier; /** * Globally-unique identifier of a local history. * - * @param Frontend type - * * @author Robert Varga */ -public final class LocalHistoryIdentifier implements Identifier { - private static final class Proxy implements Externalizable { +public final class LocalHistoryIdentifier implements Identifier, WritableObject { + private static final class Proxy implements Externalizable { private static final long serialVersionUID = 1L; - private ClientIdentifier clientId; + private ClientIdentifier clientId; private long historyId; public Proxy() { // For Externalizable } - Proxy(final ClientIdentifier frontendId, final long historyId) { + Proxy(final ClientIdentifier frontendId, final long historyId) { this.clientId = Preconditions.checkNotNull(frontendId); this.historyId = historyId; } @Override public void writeExternal(final ObjectOutput out) throws IOException { - out.writeObject(clientId); - out.writeLong(historyId); + clientId.writeTo(out); + WritableObjects.writeLong(out, historyId); } - @SuppressWarnings("unchecked") @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - clientId = (ClientIdentifier) in.readObject(); - historyId = in.readLong(); + clientId = ClientIdentifier.readFrom(in); + historyId = WritableObjects.readLong(in); } private Object readResolve() { - return new LocalHistoryIdentifier<>(clientId, historyId); + return new LocalHistoryIdentifier(clientId, historyId); } } private static final long serialVersionUID = 1L; - private final ClientIdentifier clientId; + private final ClientIdentifier clientId; private final long historyId; - public LocalHistoryIdentifier(final ClientIdentifier frontendId, final long historyId) { + public LocalHistoryIdentifier(final ClientIdentifier frontendId, final long historyId) { this.clientId = Preconditions.checkNotNull(frontendId); this.historyId = historyId; } - public ClientIdentifier getClienId() { + public static LocalHistoryIdentifier readFrom(final DataInput in) throws IOException { + final ClientIdentifier clientId = ClientIdentifier.readFrom(in); + return new LocalHistoryIdentifier(clientId, WritableObjects.readLong(in)); + } + + @Override + public void writeTo(final DataOutput out) throws IOException { + clientId.writeTo(out); + WritableObjects.writeLong(out, historyId); + } + + public ClientIdentifier getClientId() { return clientId; } @@ -86,7 +96,7 @@ public final class LocalHistoryIdentifier implements Ide return false; } - final LocalHistoryIdentifier other = (LocalHistoryIdentifier) o; + final LocalHistoryIdentifier other = (LocalHistoryIdentifier) o; return historyId == other.historyId && clientId.equals(other.clientId); } @@ -97,6 +107,6 @@ public final class LocalHistoryIdentifier implements Ide } private Object writeReplace() { - return new Proxy<>(clientId, historyId); + return new Proxy(clientId, historyId); } }