Search in sources :

Example 6 with Version

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);
    }
}
Also used : Version(org.apache.geode.internal.Version)

Example 7 with Version

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;
}
Also used : Version(org.apache.geode.internal.Version) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException)

Example 8 with Version

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);
        }
    }
}
Also used : GatewayReceiverCommand(org.apache.geode.internal.cache.tier.sockets.command.GatewayReceiverCommand) GetEntryCommand(org.apache.geode.internal.cache.tier.sockets.command.GetEntryCommand) TXSynchronizationCommand(org.apache.geode.internal.cache.tier.sockets.command.TXSynchronizationCommand) RollbackCommand(org.apache.geode.internal.cache.tier.sockets.command.RollbackCommand) CommitCommand(org.apache.geode.internal.cache.tier.sockets.command.CommitCommand) GetClientPartitionAttributesCommand(org.apache.geode.internal.cache.tier.sockets.command.GetClientPartitionAttributesCommand) TXFailoverCommand(org.apache.geode.internal.cache.tier.sockets.command.TXFailoverCommand) Command(org.apache.geode.internal.cache.tier.Command) GetClientPRMetadataCommand(org.apache.geode.internal.cache.tier.sockets.command.GetClientPRMetadataCommand) Version(org.apache.geode.internal.Version) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 9 with Version

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Version(org.apache.geode.internal.Version) InternalGemFireException(org.apache.geode.InternalGemFireException) EOFException(java.io.EOFException) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) DataInputStream(java.io.DataInputStream) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) InternalGemFireException(org.apache.geode.InternalGemFireException) GatewayConfigurationException(org.apache.geode.cache.GatewayConfigurationException) EOFException(java.io.EOFException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException)

Example 10 with Version

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++;
}
Also used : SerializationException(org.apache.geode.SerializationException) Version(org.apache.geode.internal.Version) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) IOException(java.io.IOException)

Aggregations

Version (org.apache.geode.internal.Version)40 IOException (java.io.IOException)16 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)10 ByteArrayDataInput (org.apache.geode.internal.ByteArrayDataInput)8 UnsupportedVersionException (org.apache.geode.cache.UnsupportedVersionException)6 EntryVersionsList (org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList)6 DiskAccessException (org.apache.geode.cache.DiskAccessException)5 DataInputStream (java.io.DataInputStream)4 EOFException (java.io.EOFException)4 InterruptedIOException (java.io.InterruptedIOException)4 DataOutputStream (java.io.DataOutputStream)3 FileInputStream (java.io.FileInputStream)3 CancelException (org.apache.geode.CancelException)3 VersionedDataInputStream (org.apache.geode.internal.VersionedDataInputStream)3 VersionedDataOutputStream (org.apache.geode.internal.VersionedDataOutputStream)3 PutAllEntryData (org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)3 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 SocketAddress (java.net.SocketAddress)2