public boolean isPre65() { return compareTo(Version.GFE_65) < 0; }
/** * Constructs a DSFIDNotFoundException object with message string. * * @param msg exception message */ public DSFIDNotFoundException(String msg, int dsfid) { super(msg); this.dsfid = dsfid; this.versionOrdinal = Version.CURRENT.ordinal(); }
private boolean verifyAllCurrentVersion(Set<DistributedMember> members) { return members.stream().allMatch( member -> ((InternalDistributedMember) member).getVersionObject().equals(Version.CURRENT)); }
public static String toString(short ordinal) { if (ordinal <= CURRENT.ordinal) { try { return fromOrdinal(ordinal, false).toString(); } catch (UnsupportedVersionException uve) { // ignored in toString() } } return "UNKNOWN[ordinal=" + ordinal + ']'; }
/** * 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 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); }
/** * 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); }
DataOutputStream dos = new DataOutputStream(out); DataInputStream dis; if (clientVersion.compareTo(Version.CURRENT) < 0) { dis = new VersionedDataInputStream(in, clientVersion); dos = new VersionedDataOutputStream(dos, clientVersion); Version.writeOrdinal(dos, currentServerVersion.ordinal(), true); if (!communicationMode.isWAN() && this.clientVersion.compareTo(Version.GFE_61) >= 0) { dos.writeBoolean(((InternalDistributedSystem) this.system).getConfig().getDeltaPropagation()); if (communicationMode.isWAN() && this.clientVersion.compareTo(Version.GFE_66) >= 0 && currentServerVersion.compareTo(Version.GFE_66) >= 0) { dos.writeByte(((InternalDistributedSystem) this.system).getDistributionManager() .getDistributedSystemId()); if ((communicationMode.isWAN()) && this.clientVersion.compareTo(Version.GFE_80) >= 0 && currentServerVersion.compareTo(Version.GFE_80) >= 0) { int pdxSize = PeerTypeRegistration.getPdxRegistrySize(); dos.writeInt(pdxSize);
private void compare(Version later, Version earlier) { assertTrue(later.compareTo(earlier) > 0); assertTrue(later.equals(later)); assertTrue(later.compareTo(later) == 0); assertTrue(earlier.compareTo(later) < 0); assertTrue(later.compareTo(earlier.ordinal()) > 0); assertTrue(later.compareTo(later.ordinal()) == 0); assertTrue(earlier.compareTo(later.ordinal()) < 0); }
private void _readEssentialData(DataInput in) throws IOException, ClassNotFoundException { this.isPartial = true; InetAddress inetAddr = DataSerializer.readInetAddress(in); int port = in.readInt(); this.hostName = SocketCreator.resolve_dns ? SocketCreator.getHostName(inetAddr) : inetAddr.getHostAddress(); int flags = in.readUnsignedByte(); boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0; boolean elCoord = (flags & COORD_ENABLED_BIT) != 0; int vmKind = in.readUnsignedByte(); int vmViewId = -1; if (vmKind == ClusterDistributionManager.LONER_DM_TYPE) { this.uniqueTag = DataSerializer.readString(in); } else { String str = DataSerializer.readString(in); if (str != null) { // backward compatibility from earlier than 6.5 vmViewId = Integer.parseInt(str); } } String name = DataSerializer.readString(in); MemberAttributes attr = new MemberAttributes(-1, -1, vmKind, vmViewId, name, null, null); netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, InternalDataSerializer.getVersionForDataStream(in).ordinal(), attr); if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFE_90) == 0) { netMbr.readAdditionalData(in); } }
private short readVersion(int flags, DataInput in) throws IOException { if ((flags & VERSION_BIT) != 0) { short version = Version.readOrdinal(in); this.versionObj = Version.fromOrdinalNoThrow(version, false); return version; } else { // prior to 7.1 member IDs did not serialize their version information Version v = InternalDataSerializer.getVersionForDataStreamOrNull(in); if (v != null) { this.versionObj = v; return v.ordinal(); } return Version.CURRENT_ORDINAL; } }
short clientVersionOrdinal = Version.readOrdinal(dis); Version clientVersion = null; try { clientVersion = Version.fromOrdinal(clientVersionOrdinal, true); if (logger.isDebugEnabled()) { logger.debug("{}: Registering client with version: {}", this, clientVersion); if (Version.GFE_57.compareTo(clientVersion) <= 0) { if (Version.CURRENT.compareTo(clientVersion) > 0) { dis = new VersionedDataInputStream(dis, clientVersion); dos = new VersionedDataOutputStream(dos, clientVersion);
if (Version.GFE_71.compareTo(serverVersion) > 0) { gossipVersion = TcpServer.getOldGossipVersion(); out = new VersionedDataOutputStream(out, Version.fromOrdinalNoThrow(serverVersion, false)); in = new VersionedDataInputStream(in, Version.fromOrdinal(serverVersion, false)); try { Object response = DataSerializer.readObject(in);
InternalDistributedMember mbr = internalDistributedMemberLongEntry.getKey(); Version itsVersion = mbr.getVersionObject(); if (itsVersion != null && version.compareTo(itsVersion) < 0) { version = itsVersion; if (itsVersion != null && itsVersion.compareTo(version) < 0) { version = mbr.getVersionObject(); disableMulticastForRollingUpgrade = !version.equals(Version.CURRENT);
@Override public String getUniqueId() { StringBuilder sb = new StringBuilder(); addFixedToString(sb); // add version if not current short version = netMbr.getVersionOrdinal(); if (version != Version.CURRENT.ordinal()) { sb.append("(version:").append(Version.toString(version)).append(')'); } if (SHOW_NETMEMBER) { sb.append("[[").append(netMbr.getUniqueId()).append("]]"); } return sb.toString(); }
private void sendOKHandshakeReply() throws IOException, ConnectionException { ByteBuffer my_okHandshakeBuf; if (this.isReceiver) { DistributionConfig cfg = owner.getConduit().config; ByteBuffer bb; if (Buffers.useDirectBuffers) { bb = ByteBuffer.allocateDirect(128); } else { bb = ByteBuffer.allocate(128); } bb.putInt(0); // reserve first 4 bytes for packet length bb.put((byte) NORMAL_MSG_TYPE); bb.putShort(MsgIdGenerator.NO_MSG_ID); bb.put(REPLY_CODE_OK_WITH_ASYNC_INFO); bb.putInt(cfg.getAsyncDistributionTimeout()); bb.putInt(cfg.getAsyncQueueTimeout()); bb.putInt(cfg.getAsyncMaxQueueSize()); // write own product version Version.writeOrdinal(bb, Version.CURRENT.ordinal(), true); // now set the msg length into position 0 bb.putInt(0, calcHdrSize(bb.position() - MSG_HEADER_BYTES)); my_okHandshakeBuf = bb; bb.flip(); } else { my_okHandshakeBuf = okHandshakeBuf; } my_okHandshakeBuf.position(0); writeFully(getSocket().getChannel(), my_okHandshakeBuf, false, null); }
if (Version.GFE_71.compareTo(versionOrdinal) <= 0) { + Version.fromOrdinal(versionOrdinal, false)); input = new VersionedDataInputStream(input, Version.fromOrdinal(versionOrdinal, false)); request = DataSerializer.readObject(input); if (log.isDebugEnabled()) { if (versionOrdinal != Version.CURRENT_ORDINAL) { output = new VersionedDataOutputStream(output, Version.fromOrdinal(versionOrdinal, false));
public void readEssentialData(DataInput in) throws IOException, ClassNotFoundException { this.versionOrdinal = Version.readOrdinal(in); int flags = in.readShort(); this.networkPartitionDetectionEnabled = (flags & NPD_ENABLED_BIT) != 0; this.preferredForCoordinator = (flags & PREFERRED_FOR_COORD_BIT) != 0; this.inetAddr = DataSerializer.readInetAddress(in); this.udpPort = in.readInt(); this.vmViewId = in.readInt(); this.uuidMSBs = in.readLong(); this.uuidLSBs = in.readLong(); if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GEODE_120) >= 0) { this.vmKind = in.readByte(); } }
public void writeEssentialData(DataOutput out) throws IOException { Version.writeOrdinal(out, this.versionOrdinal, true); int flags = 0; if (networkPartitionDetectionEnabled) flags |= NPD_ENABLED_BIT; if (preferredForCoordinator) flags |= PREFERRED_FOR_COORD_BIT; out.writeShort(flags); DataSerializer.writeInetAddress(inetAddr, out); out.writeInt(udpPort); out.writeInt(vmViewId); out.writeLong(uuidMSBs); out.writeLong(uuidLSBs); if (InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GEODE_120) >= 0) { out.writeByte(vmKind); } }
socket.setSoTimeout(timeout); InputStream is = socket.getInputStream(); short clientVersionOrdinal = Version.readOrdinalFromInputStream(is); if (clientVersionOrdinal == -1) { throw new EOFException( clientVersion = Version.fromOrdinal(clientVersionOrdinal, true); } catch (UnsupportedVersionException uve) { if (!clientVersion.compatibleWith(currentServerVersion)) { throw new IncompatibleVersionException(clientVersion, currentServerVersion);
private Version readProductVersionRecord(DataInput dis, File f) throws IOException { Version recoveredGFVersion; short ver = Version.readOrdinal(dis); try { recoveredGFVersion = Version.fromOrdinal(ver, false); } catch (UnsupportedVersionException e) { throw new DiskAccessException( String.format("Unknown version ordinal %s found when recovering Oplogs", ver), e, getParent()); } if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY_VERBOSE)) { logger.trace(LogMarker.PERSIST_RECOVERY_VERBOSE, "version={}", recoveredGFVersion); } readEndOfRecord(dis); return recoveredGFVersion; }