use of org.apache.geode.internal.Version in project geode by apache.
the class Oplog method writeGemfireVersionRecord.
private void writeGemfireVersionRecord(OplogFile olf) throws IOException {
if (this.gfversion == null) {
this.gfversion = Version.CURRENT;
}
Version dataVersion = getDataVersionIfOld();
if (dataVersion == null) {
dataVersion = Version.CURRENT;
}
// if gfversion and dataVersion are not same, then write a special token
// version and then write both, else write gfversion as before
// this is for backward compatibility with 7.0
this.opState = new OpState();
if (this.gfversion == dataVersion) {
writeProductVersionRecord(this.gfversion, olf);
} else {
writeProductVersionRecord(Version.TOKEN, olf);
clearOpState();
writeProductVersionRecord(this.gfversion, olf);
clearOpState();
writeProductVersionRecord(dataVersion, olf);
}
}
use of org.apache.geode.internal.Version in project geode by apache.
the class ClientUpdateMessageImpl method getMessage.
/**
* Returns a <code>Message</code> generated from the fields of this
* <code>ClientUpdateMessage</code>.
*
* @param latestValue Object containing the latest value to use. This could be the original value
* if conflation is not enabled, or it could be a conflated value if conflation is enabled.
* @return a <code>Message</code> generated from the fields of this
* <code>ClientUpdateMessage</code>
* @throws IOException
* @see org.apache.geode.internal.cache.tier.sockets.Message
*/
protected Message getMessage(CacheClientProxy proxy, byte[] latestValue) throws IOException {
Version clientVersion = proxy.getVersion();
byte[] serializedValue = null;
Message message = null;
boolean conflation = false;
conflation = (proxy.clientConflation == HandShake.CONFLATION_ON) || (proxy.clientConflation == HandShake.CONFLATION_DEFAULT && this.shouldBeConflated());
if (latestValue != null) {
serializedValue = latestValue;
} else {
/**
* This means latestValue is instance of Delta, and its delta has already been extracted and
* put into deltaBytes. We serialize the value.
*/
if (this.deltaBytes == null || isCreate()) {
// Delta could not be extracted. We would need to send full value.
// OR A CREATE operation has a value which has delta. But we send full value for CREATE.
// So serialize it.
this._value = serializedValue = CacheServerHelper.serialize(latestValue);
}
}
if (clientVersion.compareTo(Version.GFE_70) >= 0) {
message = getGFE70Message(proxy, serializedValue, conflation, clientVersion);
} else if (clientVersion.compareTo(Version.GFE_65) >= 0) {
message = getGFE65Message(proxy, serializedValue, conflation, clientVersion);
} else if (clientVersion.compareTo(Version.GFE_61) >= 0) {
message = getGFE61Message(proxy, serializedValue, conflation, clientVersion);
} else if (clientVersion.compareTo(Version.GFE_57) >= 0) {
message = getGFEMessage(proxy.getProxyID(), latestValue, clientVersion);
} else {
throw new IOException("Unsupported client version for server-to-client message creation: " + clientVersion);
}
return message;
}
use of org.apache.geode.internal.Version in project geode by apache.
the class CommandInitializer method registerCommand.
/**
* Register a new command with the system.
*
* @param messageType - An ordinal for this message. This must be something defined in MessageType
* that has not already been allocated to a different command.
* @param versionToNewCommand The command to register, for different versions. The key is the
* earliest version for which this command class is valid (starting with GFE_57). The value
* is the command object for clients starting with that version.
*/
public static void registerCommand(int messageType, Map<Version, Command> versionToNewCommand) {
Command command = null;
// add a command to the map for that version
for (Map.Entry<Version, Map<Integer, Command>> entry : ALL_COMMANDS.entrySet()) {
Version version = entry.getKey();
// Get the current set of commands for this version.
Map<Integer, Command> commandMap = entry.getValue();
// See if we have a new command to insert into this map. Otherwise, keep using the command we
// have
// already read
Command newerVersion = versionToNewCommand.get(version);
if (newerVersion != null) {
command = newerVersion;
}
if (command != null) {
Command oldCommand = commandMap.get(messageType);
if (oldCommand != null && oldCommand != command) {
throw new InternalGemFireError("Command is already defined int the map for message Type " + MessageType.getString(messageType) + ". Old Value=" + commandMap.get(messageType) + ", newValue=" + command + ", version=" + version);
}
commandMap.put(messageType, command);
}
}
}
use of org.apache.geode.internal.Version in project geode by apache.
the class HandShake method readServerMember.
protected DistributedMember readServerMember(DataInputStream p_dis) throws IOException {
byte[] memberBytes = DataSerializer.readByteArray(p_dis);
ByteArrayInputStream bais = new ByteArrayInputStream(memberBytes);
DataInputStream dis = new DataInputStream(bais);
Version v = InternalDataSerializer.getVersionForDataStreamOrNull(p_dis);
if (v != null) {
dis = new VersionedDataInputStream(dis, v);
}
try {
return DataSerializer.readObject(dis);
} catch (EOFException e) {
throw e;
} catch (Exception e) {
throw new InternalGemFireException(LocalizedStrings.HandShake_UNABLE_TO_DESERIALIZE_MEMBER.toLocalizedString(), e);
}
}
use of org.apache.geode.internal.Version 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++;
}
Aggregations