/** * Return the <code>Version</code> reading from given {@link DataInput} as * serialized by {@link #writeOrdinal(DataOutput, boolean)}. * * If the incoming ordinal is greater than or equal to current ordinal then * this will return null or {@link #CURRENT} indicating that version is same * as that of {@link #CURRENT} assuming that peer will support this JVM. * * This method is not meant to be used for client-server protocol since * servers cannot support higher version clients, rather is only meant for * P2P/JGroups messaging where a mixed version of servers can be running at * the same time. Similarly cannot be used when recovering from disk since * higher version data cannot be read. * * @param in * the {@link DataInput} to read the version from * @param returnNullForCurrent * if true then return null if incoming version >= {@link #CURRENT} * else return {@link #CURRENT} */ public static Version readVersion(DataInput in, boolean returnNullForCurrent) throws IOException { return fromOrdinalNoThrow(readOrdinal(in), returnNullForCurrent); }
int version = ois2.readInt(); if (version != Version.CURRENT_ORDINAL) { Version geodeVersion = Version.fromOrdinalNoThrow((short)version, false); logger.info("Peer locator found that persistent view was written with {}", geodeVersion); ois2 = new VersionedObjectInput(ois2, geodeVersion);
/** * Finds the Version instance corresponding to the given ordinal and returns * the result of compareTo(Version) * @param other the ordinal of the other Version object * @return negative if this version is older, positive if this version is newer, 0 if this is the same version */ public final int compareTo(short other) { // first try to find the actual Version object Version v = fromOrdinalNoThrow(other, false); if (v == null) { // failing that we use the old method of comparing Versions: return this.ordinal() - other; } return compareTo(v); }
private void readVersion(int flags, DataInput in) throws IOException { if ((flags & VERSION_MASK) != 0) { this.version = Version.readOrdinal(in); this.versionObj = Version.fromOrdinalNoThrow(this.version, false); } else { // prior to 7.1 member IDs did not serialize their version information Version v = InternalDataSerializer.getVersionForDataStreamOrNull(in); if (v != null) { this.versionObj = v; this.version = v.ordinal(); } } }
out = new VersionedDataOutputStream(out, Version.fromOrdinalNoThrow(serverVersion, false));
dis = new VersionedDataInputStream(dis, Version.fromOrdinalNoThrow( ordinal, true));