Search in sources :

Example 21 with Version

use of org.apache.geode.internal.Version in project geode by apache.

the class ReplyProcessor21 method processException.

/**
   * Handle a {@link DSFIDNotFoundException} indicating a message type is not implemented on another
   * server (for example due to different product version). Default implementation logs the
   * exception as severe and moves on.
   * 
   * Rationale for default handling: New operations can have caused changes to other newer versioned
   * GFE JVMs that cannot be reverted. So ignoring exceptions is a conservative way considering such
   * scenarios. It will be upto individual messages to handle differently by overriding the above
   * method.
   */
protected synchronized void processException(DistributionMessage msg, DSFIDNotFoundException ex) {
    final short versionOrdinal = ex.getProductVersionOrdinal();
    String versionStr = null;
    try {
        Version version = Version.fromOrdinal(versionOrdinal, false);
        versionStr = version.toString();
    } catch (UnsupportedVersionException e) {
    }
    if (versionStr == null) {
        versionStr = "Ordinal=" + versionOrdinal;
    }
    logger.fatal(LocalizedMessage.create(LocalizedStrings.ReplyProcessor21_UNKNOWN_DSFID_ERROR, new Object[] { ex.getUnknownDSFID(), msg.getSender(), versionStr }), ex);
}
Also used : Version(org.apache.geode.internal.Version) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException)

Example 22 with Version

use of org.apache.geode.internal.Version in project geode by apache.

the class ServerHandShakeProcessor method writeServerMember.

// Keep the writeServerMember/readServerMember compatible with C++ native
// client
protected static void writeServerMember(DistributedMember member, DataOutputStream dos) throws IOException {
    Version v = Version.CURRENT;
    if (dos instanceof VersionedDataStream) {
        v = ((VersionedDataStream) dos).getVersion();
    }
    HeapDataOutputStream hdos = new HeapDataOutputStream(v);
    DataSerializer.writeObject(member, hdos);
    DataSerializer.writeByteArray(hdos.toByteArray(), dos);
    hdos.close();
}
Also used : Version(org.apache.geode.internal.Version) VersionedDataStream(org.apache.geode.internal.VersionedDataStream) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream)

Example 23 with Version

use of org.apache.geode.internal.Version in project geode by apache.

the class ServerHandShakeProcessor method readHandShake.

public static boolean readHandShake(ServerConnection connection) {
    boolean validHandShake = false;
    Version clientVersion = null;
    try {
        // Read the version byte from the socket
        clientVersion = readClientVersion(connection);
    } catch (IOException e) {
        // Only log an exception if the server is still running.
        if (connection.getAcceptor().isRunning()) {
            // Server logging
            logger.warn("{} {}", connection.getName(), e.getMessage(), e);
        }
        connection.stats.incFailedConnectionAttempts();
        connection.cleanup();
        validHandShake = false;
    } catch (UnsupportedVersionException uve) {
        // Server logging
        logger.warn("{} {}", connection.getName(), uve.getMessage(), uve);
        // Client logging
        connection.refuseHandshake(uve.getMessage(), REPLY_REFUSED);
        connection.stats.incFailedConnectionAttempts();
        connection.cleanup();
        validHandShake = false;
    } catch (Exception e) {
        // Server logging
        logger.warn("{} {}", connection.getName(), e.getMessage(), e);
        // Client logging
        connection.refuseHandshake(LocalizedStrings.ServerHandShakeProcessor_0_SERVERS_CURRENT_VERSION_IS_1.toLocalizedString(new Object[] { e.getMessage(), Acceptor.VERSION.toString() }), REPLY_REFUSED);
        connection.stats.incFailedConnectionAttempts();
        connection.cleanup();
        validHandShake = false;
    }
    if (clientVersion != null) {
        if (logger.isDebugEnabled())
            logger.debug("Client version: {}", clientVersion);
        // Read the appropriate handshake
        if (clientVersion.compareTo(Version.GFE_57) >= 0) {
            validHandShake = readGFEHandshake(connection, clientVersion);
        } else {
            connection.refuseHandshake("Unsupported version " + clientVersion + "Server's current version " + Acceptor.VERSION, REPLY_REFUSED);
        }
    }
    return validHandShake;
}
Also used : Version(org.apache.geode.internal.Version) IOException(java.io.IOException) VersionException(org.apache.geode.cache.VersionException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException) EOFException(java.io.EOFException) IncompatibleVersionException(org.apache.geode.cache.IncompatibleVersionException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException)

Example 24 with Version

use of org.apache.geode.internal.Version in project geode by apache.

the class Message method serializeAndAddPartNoCopying.

private void serializeAndAddPartNoCopying(Object o) {
    Version v = this.version;
    if (this.version.equals(Version.CURRENT)) {
        v = null;
    }
    // Create the HDOS with a flag telling it that it can keep any byte[] or ByteBuffers/ByteSources
    // passed to it. Do NOT close the HeapDataOutputStream!
    HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v, true);
    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)

Example 25 with Version

use of org.apache.geode.internal.Version in project geode by apache.

the class ClientInstantiatorMessage method getMessage.

@Override
protected Message getMessage(CacheClientProxy proxy, byte[] latestValue) throws IOException {
    Version clientVersion = proxy.getVersion();
    Message message = null;
    if (clientVersion.compareTo(Version.GFE_57) >= 0) {
        message = getGFEMessage(proxy.getProxyID(), null, 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) 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