use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class HandShake method write.
/**
* client-to-server handshake. Nothing is sent to the server prior to invoking this method.
*/
private byte write(DataOutputStream dos, DataInputStream dis, byte communicationMode, int replyCode, int readTimeout, List ports, Properties p_credentials, DistributedMember member, boolean isCallbackConnection) throws IOException {
HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT);
byte acceptanceCode = -1;
try {
hdos.writeByte(communicationMode);
if (overrideClientVersion > 0) {
// for testing
Version.writeOrdinal(hdos, overrideClientVersion, true);
} else {
Version.writeOrdinal(hdos, currentClientVersion.ordinal(), true);
}
hdos.writeByte(replyCode);
if (ports != null) {
hdos.writeInt(ports.size());
for (int i = 0; i < ports.size(); i++) {
hdos.writeInt(Integer.parseInt((String) ports.get(i)));
}
} else {
hdos.writeInt(readTimeout);
}
// we do not know the receiver's version at this point, but the on-wire
// form of InternalDistributedMember changed in 9.0, so we must serialize
// it using the previous version
DataOutput idOut = new VersionedDataOutputStream(hdos, Version.GFE_82);
DataSerializer.writeObject(this.id, idOut);
if (currentClientVersion.compareTo(Version.GFE_603) >= 0) {
for (int bytes = 0; bytes < this.overrides.length; bytes++) {
hdos.writeByte(this.overrides[bytes]);
}
} else {
// write the client conflation setting byte
if (setClientConflationForTesting) {
hdos.writeByte(clientConflationForTesting);
} else {
hdos.writeByte(this.clientConflation);
}
}
if (isCallbackConnection || communicationMode == Acceptor.GATEWAY_TO_GATEWAY) {
if (isCallbackConnection && this.multiuserSecureMode && communicationMode != Acceptor.GATEWAY_TO_GATEWAY) {
hdos.writeByte(SECURITY_MULTIUSER_NOTIFICATIONCHANNEL);
hdos.flush();
dos.write(hdos.toByteArray());
dos.flush();
} else {
writeCredentials(dos, dis, p_credentials, ports != null, member, hdos);
}
} else {
String authInitMethod = this.system.getProperties().getProperty(SECURITY_CLIENT_AUTH_INIT);
acceptanceCode = writeCredential(dos, dis, authInitMethod, ports != null, member, hdos);
}
} finally {
hdos.close();
}
return acceptanceCode;
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class Message method serializeAndAddPart.
private void serializeAndAddPart(Object o, boolean zipValues) {
if (zipValues) {
throw new UnsupportedOperationException("zipValues no longer supported");
}
Version v = this.version;
if (this.version.equals(Version.CURRENT)) {
v = null;
}
// do NOT close the HeapDataOutputStream
HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v);
try {
BlobHelper.serializeTo(o, hdos);
} catch (IOException ex) {
throw new SerializationException("failed serializing object", ex);
}
this.messageModified = true;
Part part = this.partsList[this.currentPart];
part.setPartState(hdos, true);
this.currentPart++;
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class ServerConnection method encryptId.
private byte[] encryptId(long id, ServerConnection servConn) throws Exception {
// deserialize this using handshake keys
HeapDataOutputStream hdos = null;
try {
hdos = new HeapDataOutputStream(Version.CURRENT);
hdos.writeLong(id);
return ((HandShake) this.handshake).encryptBytes(hdos.toByteArray());
} finally {
hdos.close();
}
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class OffHeapStoredObject method sendAsByteArray.
@Override
public void sendAsByteArray(DataOutput out) throws IOException {
if (!isCompressed() && out instanceof HeapDataOutputStream) {
ByteBuffer bb = createDirectByteBuffer();
if (bb != null) {
HeapDataOutputStream hdos = (HeapDataOutputStream) out;
InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
hdos.write(bb);
return;
}
}
super.sendAsByteArray(out);
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class PdxInstanceEnum method toBytes.
public byte[] toBytes() throws IOException {
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
sendTo(hdos);
return hdos.toByteArray();
}
Aggregations