Search in sources :

Example 1 with Version

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

the class OldClientSupportProvider method processOutgoingClassName.

@Override
public String processOutgoingClassName(String name, DataOutput out) {
    // tcpserver was moved to a different package
    String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver";
    String newPackage = "org.apache.geode.distributed.internal.tcpserver";
    if (name.startsWith(newPackage)) {
        return oldPackage + name.substring(newPackage.length());
    }
    if (ALWAYS_CONVERT_CLASSES) {
        return processClassName(name, GEODE, GEMFIRE, newClassNamesToOld);
    }
    // if the client is old then it needs com.gemstone.gemfire package names
    if (out instanceof VersionedDataOutputStream) {
        VersionedDataOutputStream vout = (VersionedDataOutputStream) out;
        Version version = vout.getVersion();
        if (version != null && version.compareTo(Version.GFE_90) < 0) {
            return processClassName(name, GEODE, GEMFIRE, newClassNamesToOld);
        }
    }
    return name;
}
Also used : Version(org.apache.geode.internal.Version) VersionedDataOutputStream(org.apache.geode.internal.VersionedDataOutputStream)

Example 2 with Version

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

the class RemoveAllPRMessage method fromData.

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    super.fromData(in);
    this.bucketId = Integer.valueOf((int) InternalDataSerializer.readSignedVL(in));
    if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
        this.bridgeContext = DataSerializer.readObject(in);
    }
    Version sourceVersion = InternalDataSerializer.getVersionForDataStream(in);
    this.callbackArg = DataSerializer.readObject(in);
    this.removeAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
    this.removeAllPRData = new RemoveAllEntryData[removeAllPRDataSize];
    if (this.removeAllPRDataSize > 0) {
        final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
        final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
        for (int i = 0; i < this.removeAllPRDataSize; i++) {
            this.removeAllPRData[i] = new RemoveAllEntryData(in, null, i, version, bytesIn);
        }
        boolean hasTags = in.readBoolean();
        if (hasTags) {
            EntryVersionsList versionTags = EntryVersionsList.create(in);
            for (int i = 0; i < this.removeAllPRDataSize; i++) {
                this.removeAllPRData[i].versionTag = versionTags.get(i);
            }
        }
    }
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) Version(org.apache.geode.internal.Version) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput)

Example 3 with Version

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

the class ServerHandShakeProcessor method readClientVersion.

private static Version readClientVersion(ServerConnection connection) throws IOException, VersionException {
    Socket socket = connection.getSocket();
    int timeout = connection.getHandShakeTimeout();
    int soTimeout = -1;
    try {
        soTimeout = socket.getSoTimeout();
        socket.setSoTimeout(timeout);
        InputStream is = socket.getInputStream();
        short clientVersionOrdinal = Version.readOrdinalFromInputStream(is);
        if (clientVersionOrdinal == -1) {
            throw new EOFException(LocalizedStrings.ServerHandShakeProcessor_HANDSHAKEREADER_EOF_REACHED_BEFORE_CLIENT_VERSION_COULD_BE_READ.toLocalizedString());
        }
        Version clientVersion = null;
        try {
            clientVersion = Version.fromOrdinal(clientVersionOrdinal, true);
        } catch (UnsupportedVersionException uve) {
            // Allows higher version of wan site to connect to server
            if (connection.getCommunicationMode() == Acceptor.GATEWAY_TO_GATEWAY && !(clientVersionOrdinal == Version.NOT_SUPPORTED_ORDINAL)) {
                return Acceptor.VERSION;
            } else {
                SocketAddress sa = socket.getRemoteSocketAddress();
                String sInfo = "";
                if (sa != null) {
                    sInfo = " Client: " + sa.toString() + ".";
                }
                throw new UnsupportedVersionException(uve.getMessage() + sInfo);
            }
        }
        if (!clientVersion.compatibleWith(Acceptor.VERSION)) {
            // we can throw this
            throw new IncompatibleVersionException(clientVersion, Acceptor.VERSION);
        // to restrict
        }
        // Backward Compatibilty Support to limited no of versions
        return clientVersion;
    } finally {
        if (soTimeout != -1) {
            try {
                socket.setSoTimeout(soTimeout);
            } catch (IOException ignore) {
            }
        }
    }
}
Also used : Version(org.apache.geode.internal.Version) InputStream(java.io.InputStream) IncompatibleVersionException(org.apache.geode.cache.IncompatibleVersionException) EOFException(java.io.EOFException) IOException(java.io.IOException) SocketAddress(java.net.SocketAddress) Socket(java.net.Socket) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException)

Example 4 with Version

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

the class GMSLocator method recoverFromFile.

/* package */
boolean recoverFromFile(File file) throws InternalGemFireException {
    if (!file.exists()) {
        logger.info("recovery file not found: " + file.getAbsolutePath());
        return false;
    }
    logger.info("Peer locator recovering from " + file.getAbsolutePath());
    try (ObjectInput ois = new ObjectInputStream(new FileInputStream(file))) {
        if (ois.readInt() != LOCATOR_FILE_STAMP) {
            return false;
        }
        ObjectInput ois2 = ois;
        int version = ois2.readInt();
        if (version != Version.CURRENT_ORDINAL) {
            Version geodeVersion = Version.fromOrdinalNoThrow((short) version, false);
            logger.info("Peer locator found that persistent view was written with {}", geodeVersion);
            ois2 = new VersionedObjectInput(ois2, geodeVersion);
        }
        Object o = DataSerializer.readObject(ois2);
        this.view = (NetView) o;
        logger.info("Peer locator initial membership is " + view);
        return true;
    } catch (Exception e) {
        String msg = LOCATOR_UNABLE_TO_RECOVER_VIEW.toLocalizedString(file.toString());
        logger.warn(msg, e);
        if (!file.delete() && file.exists()) {
            logger.warn("Peer locator was unable to recover from or delete " + file);
            this.viewFile = null;
        }
        throw new InternalGemFireException(msg, e);
    }
}
Also used : VersionedObjectInput(org.apache.geode.internal.VersionedObjectInput) Version(org.apache.geode.internal.Version) InternalGemFireException(org.apache.geode.InternalGemFireException) VersionedObjectInput(org.apache.geode.internal.VersionedObjectInput) ObjectInput(java.io.ObjectInput) FileInputStream(java.io.FileInputStream) InternalGemFireException(org.apache.geode.InternalGemFireException) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 5 with Version

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

the class PutAllPRMessage method fromData.

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    super.fromData(in);
    this.bucketId = (int) InternalDataSerializer.readSignedVL(in);
    if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
        this.bridgeContext = DataSerializer.readObject(in);
    }
    this.callbackArg = DataSerializer.readObject(in);
    this.putAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
    this.putAllPRData = new PutAllEntryData[putAllPRDataSize];
    if (this.putAllPRDataSize > 0) {
        final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
        final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
        for (int i = 0; i < this.putAllPRDataSize; i++) {
            this.putAllPRData[i] = new PutAllEntryData(in, null, i, version, bytesIn);
        }
        boolean hasTags = in.readBoolean();
        if (hasTags) {
            EntryVersionsList versionTags = EntryVersionsList.create(in);
            for (int i = 0; i < this.putAllPRDataSize; i++) {
                this.putAllPRData[i].versionTag = versionTags.get(i);
            }
        }
    }
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) Version(org.apache.geode.internal.Version) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput) PutAllEntryData(org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)

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