use of org.apache.geode.internal.VersionedDataInputStream in project geode by apache.
the class GMSMemberJUnitTest method testGMSMemberBackwardCompatibility.
/**
* <p>
* GEODE-2875 - adds vmKind to on-wire form of GMSMember.writeEssentialData
* </p>
* <p>
* This must be backward-compatible with Geode 1.0 (Version.GFE_90)
* </p>
*
* @throws Exception
*/
@Test
public void testGMSMemberBackwardCompatibility() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
MemberAttributes attributes = new MemberAttributes(10, 20, 1, 2, "member", null, null);
GMSMember member = new GMSMember();
member.setAttributes(attributes);
DataOutput dataOutput = new DataOutputStream(baos);
member.writeEssentialData(dataOutput);
// vmKind should be transmitted to a member with the current version
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DataInput dataInput = new DataInputStream(bais);
GMSMember newMember = new GMSMember();
newMember.readEssentialData(dataInput);
assertEquals(1, newMember.getVmKind());
// vmKind should not be transmitted to a member with version GFE_90 or earlier
dataOutput = new HeapDataOutputStream(Version.GFE_90);
member.writeEssentialData(dataOutput);
bais = new ByteArrayInputStream(baos.toByteArray());
dataInput = new VersionedDataInputStream(new DataInputStream(bais), Version.GFE_90);
newMember = new GMSMember();
newMember.readEssentialData(dataInput);
assertEquals(0, newMember.getVmKind());
}
use of org.apache.geode.internal.VersionedDataInputStream in project geode by apache.
the class HandShake method accept.
public void accept(OutputStream out, InputStream in, byte epType, int qSize, byte communicationMode, Principal principal) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
DataInputStream dis;
if (clientVersion.compareTo(Version.CURRENT) < 0) {
dis = new VersionedDataInputStream(in, clientVersion);
dos = new VersionedDataOutputStream(dos, clientVersion);
} else {
dis = new DataInputStream(in);
}
// Write ok reply
if (communicationMode == Acceptor.GATEWAY_TO_GATEWAY && principal != null) {
dos.writeByte(REPLY_WAN_CREDENTIALS);
} else {
// byte 59
dos.writeByte(REPLY_OK);
}
// additional byte of wan site needs to send for Gateway BC
if (communicationMode == Acceptor.GATEWAY_TO_GATEWAY) {
Version.writeOrdinal(dos, ServerHandShakeProcessor.currentServerVersion.ordinal(), true);
}
dos.writeByte(epType);
dos.writeInt(qSize);
// Write the server's member
DistributedMember member = this.system.getDistributedMember();
ServerHandShakeProcessor.writeServerMember(member, dos);
// Write no message
dos.writeUTF("");
// Write delta-propagation property value if this is not WAN.
if (communicationMode != Acceptor.GATEWAY_TO_GATEWAY && this.clientVersion.compareTo(Version.GFE_61) >= 0) {
dos.writeBoolean(((InternalDistributedSystem) this.system).getConfig().getDeltaPropagation());
}
// and principal not equal to null then send the credentials also
if (communicationMode == Acceptor.GATEWAY_TO_GATEWAY && principal != null) {
sendCredentialsForWan(dos, dis);
}
// on the remote side of the gateway
if (communicationMode == Acceptor.GATEWAY_TO_GATEWAY && this.clientVersion.compareTo(Version.GFE_66) >= 0 && ServerHandShakeProcessor.currentServerVersion.compareTo(Version.GFE_66) >= 0) {
dos.writeByte(((InternalDistributedSystem) this.system).getDistributionManager().getDistributedSystemId());
}
if ((communicationMode == Acceptor.GATEWAY_TO_GATEWAY) && this.clientVersion.compareTo(Version.GFE_80) >= 0 && ServerHandShakeProcessor.currentServerVersion.compareTo(Version.GFE_80) >= 0) {
int pdxSize = PeerTypeRegistration.getPdxRegistrySize();
dos.writeInt(pdxSize);
}
// Flush
dos.flush();
}
use of org.apache.geode.internal.VersionedDataInputStream in project geode by apache.
the class GatewaySenderEventImpl method fromData.
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
short version = in.readShort();
if (version != VERSION) {
// warning?`
}
this.isInitialized = true;
this.action = in.readInt();
this.numberOfParts = in.readInt();
// this._id = in.readUTF();
if (version < 0x11 && (in instanceof InputStream) && InternalDataSerializer.getVersionForDataStream(in) == Version.CURRENT) {
in = new VersionedDataInputStream((InputStream) in, Version.GFE_701);
}
this.id = (EventID) DataSerializer.readObject(in);
// TODO:Asif ; Check if this violates Barry's logic of not assiging VM
// specific Token.FROM_GATEWAY
// and retain the serialized Token.FROM_GATEWAY
// this._id.setFromGateway(false);
this.regionPath = DataSerializer.readString(in);
this.valueIsObject = in.readByte();
deserializeKey(in);
this.value = DataSerializer.readByteArray(in);
this.callbackArgument = (GatewaySenderEventCallbackArgument) DataSerializer.readObject(in);
this.possibleDuplicate = in.readBoolean();
this.creationTime = in.readLong();
this.bucketId = in.readInt();
this.shadowKey = in.readLong();
this.versionTimeStamp = in.readLong();
// TODO should this call initializeKey()?
}
Aggregations