This is an automated email from the ASF dual-hosted git repository. bschuchardt pushed a commit to branch feature/GEODE_5027 in repository https://gitbox.apache.org/repos/asf/geode.git
commit d211d7e2883adb78ee58ee947ed18479784766fa Author: Bruce Schuchardt <bschucha...@pivotal.io> AuthorDate: Fri Apr 6 11:53:48 2018 -0700 GEODE-5027 Bump version to 1.6.0 * I removed junk in Version.java that hasn't been used since the SQLFire/GFX days. * I also removed AcceptorImpl.VERSION which seemed to serve no good purpose. * I added a unit test to make sure that folks update the CommandInitializer table when adding a new Version. * I changed CommandInitializer to not create new maps unless necessary. --- .../java/org/apache/geode/internal/Version.java | 57 ++----------- .../apache/geode/internal/cache/tier/Acceptor.java | 7 -- .../geode/internal/cache/tier/ConnectionProxy.java | 2 +- .../tier/sockets/ClientDataSerializerMessage.java | 2 +- .../cache/tier/sockets/ClientTombstoneMessage.java | 2 +- .../cache/tier/sockets/CommandInitializer.java | 95 ++++++---------------- .../tier/sockets/ServerSideHandshakeFactory.java | 2 +- .../apache/geode/internal/VersionJUnitTest.java | 8 ++ 8 files changed, 44 insertions(+), 131 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/Version.java b/geode-core/src/main/java/org/apache/geode/internal/Version.java index d01f9ec..5c67838 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/Version.java +++ b/geode-core/src/main/java/org/apache/geode/internal/Version.java @@ -51,15 +51,10 @@ public class Version implements Comparable<Version> { private final byte release; private final byte patch; - /** - * Set to non-null if the underlying GemFire version is different from product version - */ - private Version gemfireVersion; - /** byte used as ordinal to represent this <code>Version</code> */ private final short ordinal; - public static final int HIGHEST_VERSION = 80; + public static final int HIGHEST_VERSION = 85; private static final Version[] VALUES = new Version[HIGHEST_VERSION + 1]; @@ -218,6 +213,8 @@ public class Version implements Comparable<Version> { public static final Version GEODE_160 = new Version("GEODE", "1.6.0", (byte) 1, (byte) 6, (byte) 0, (byte) 0, GEODE_160_ORDINAL); + /* NOTE: when adding a new version bump the ordinal by 5. Ordinals can be short ints */ + /** * This constant must be set to the most current version of the product. !!! NOTE: update * HIGHEST_VERSION when changing CURRENT !!! @@ -249,21 +246,11 @@ public class Version implements Comparable<Version> { this.ordinal = ordinal; this.methodSuffix = this.productName + "_" + this.majorVersion + "_" + this.minorVersion + "_" + this.release + "_" + this.patch; - this.gemfireVersion = null; if (ordinal != TOKEN_ORDINAL) { VALUES[this.ordinal] = this; } } - /** - * Creates a new instance of <code>Version</code> with a different underlying GemFire version - */ - private Version(String product, String name, byte major, byte minor, byte release, byte patch, - byte ordinal, Version gemfireVersion) { - this(product, name, major, minor, release, patch, ordinal); - this.gemfireVersion = gemfireVersion; - } - /** Return the <code>Version</code> represented by specified ordinal */ public static Version fromOrdinal(short ordinal, boolean forGFEClients) throws UnsupportedVersionException { @@ -341,26 +328,6 @@ public class Version implements Comparable<Version> { } /** - * Fixed number of bytes required for serializing this version when "compressed" flag is false in - * {@link #writeOrdinal(DataOutput, boolean)}. - */ - public static int uncompressedSize() { - return 3; - } - - /** - * Fixed number of bytes required for serializing this version when "compressed" flag is true in - * {@link #writeOrdinal(DataOutput, boolean)}. - */ - public int compressedSize() { - if (ordinal <= Byte.MAX_VALUE) { - return 1; - } else { - return 3; - } - } - - /** * Write the given ordinal (result of {@link #ordinal()}) to given {@link ByteBuffer}. This keeps * the serialization of ordinal compatible with previous versions writing a single byte to * DataOutput when possible, and a token with 2 bytes if it is large. @@ -370,8 +337,7 @@ public class Version implements Comparable<Version> { * @param compressed if true, then use single byte for ordinal < 128, and three bytes for beyond * that, else always use three bytes where the first byte is {@link #TOKEN_ORDINAL} */ - public static void writeOrdinal(ByteBuffer buffer, short ordinal, boolean compressed) - throws IOException { + public static void writeOrdinal(ByteBuffer buffer, short ordinal, boolean compressed) { if (compressed && ordinal <= Byte.MAX_VALUE) { buffer.put((byte) ordinal); } else { @@ -452,18 +418,10 @@ public class Version implements Comparable<Version> { } } - public Version getGemFireVersion() { - return this.gemfireVersion != null ? this.gemfireVersion : this; - } - public String getMethodSuffix() { return this.methodSuffix; } - public String getProductName() { - return this.productName; - } - public String getName() { return this.name; } @@ -488,6 +446,7 @@ public class Version implements Comparable<Version> { return this.ordinal; } + /** * Returns whether this <code>Version</code> is compatible with the input <code>Version</code> * @@ -538,11 +497,7 @@ public class Version implements Comparable<Version> { */ @Override public String toString() { - if (this.gemfireVersion == null) { - return this.productName + " " + this.name; - } else { - return this.productName + " " + this.name + '[' + this.gemfireVersion.toString() + ']'; - } + return this.productName + " " + this.name; } public static String toString(short ordinal) { diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java index 22a5e43..6705f60 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java @@ -28,13 +28,6 @@ import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier; public interface Acceptor { /** - * The GFE version of the server. - * - * @since GemFire 5.7 - */ - Version VERSION = Version.CURRENT.getGemFireVersion(); - - /** * Listens for a client to connect and establishes a connection to that client. */ void accept() throws Exception; diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/ConnectionProxy.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/ConnectionProxy.java index 7de068b..3321c67 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/ConnectionProxy.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/ConnectionProxy.java @@ -29,5 +29,5 @@ public interface ConnectionProxy { * * @since GemFire 5.7 */ - Version VERSION = Version.CURRENT.getGemFireVersion(); + Version VERSION = Version.CURRENT; } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientDataSerializerMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientDataSerializerMessage.java index 326af57..bf00657 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientDataSerializerMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientDataSerializerMessage.java @@ -217,7 +217,7 @@ public class ClientDataSerializerMessage extends ClientUpdateMessageImpl { @Override public boolean isClientInterested(ClientProxyMembershipID clientId) { - return AcceptorImpl.VERSION.compareTo(Version.GFE_61) >= 0; + return true; } @Override diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientTombstoneMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientTombstoneMessage.java index be2b766..1a63c57 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientTombstoneMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientTombstoneMessage.java @@ -155,7 +155,7 @@ public class ClientTombstoneMessage extends ClientUpdateMessageImpl { @Override public boolean isClientInterested(ClientProxyMembershipID clientId) { - return Acceptor.VERSION.compareTo(Version.GFE_70) >= 0; + return true; } @Override diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java index 6ad1bb3..c0b7f99 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java @@ -292,74 +292,38 @@ public class CommandInitializer { gfe70Commands.put(MessageType.GET_PDX_ENUMS, GetPdxEnums70.getCommand()); gfe70Commands.put(MessageType.EXECUTE_FUNCTION, ExecuteFunction70.getCommand()); - Map<Integer, Command> gfe701Commands = new HashMap<Integer, Command>(); - gfe701Commands.putAll(gfe70Commands); - ALL_COMMANDS.put(Version.GFE_701, gfe701Commands); - - Map<Integer, Command> gfe71Commands = new HashMap<Integer, Command>(); - gfe71Commands.putAll(ALL_COMMANDS.get(Version.GFE_701)); - ALL_COMMANDS.put(Version.GFE_71, gfe71Commands); + ALL_COMMANDS.put(Version.GFE_701, gfe70Commands); + ALL_COMMANDS.put(Version.GFE_71, gfe70Commands); Map<Integer, Command> gfe80Commands = new HashMap<Integer, Command>(); gfe80Commands.putAll(ALL_COMMANDS.get(Version.GFE_71)); + ALL_COMMANDS.put(Version.GFE_80, gfe80Commands); // PutAll is changed to chunk responses back to the client gfe80Commands.put(MessageType.PUTALL, PutAll80.getCommand()); - ALL_COMMANDS.put(Version.GFE_80, gfe80Commands); - Map<Integer, Command> gfe8009Commands = new HashMap<Integer, Command>(); - gfe8009Commands.putAll(ALL_COMMANDS.get(Version.GFE_80)); - ALL_COMMANDS.put(Version.GFE_8009, gfe8009Commands); - - { - Map<Integer, Command> gfe81Commands = new HashMap<Integer, Command>(); - gfe81Commands.putAll(ALL_COMMANDS.get(Version.GFE_80)); - gfe81Commands.put(MessageType.GET_ALL_WITH_CALLBACK, GetAllWithCallback.getCommand()); - gfe81Commands.put(MessageType.PUT_ALL_WITH_CALLBACK, PutAllWithCallback.getCommand()); - gfe81Commands.put(MessageType.REMOVE_ALL, RemoveAll.getCommand()); - ALL_COMMANDS.put(Version.GFE_81, gfe81Commands); - } - { - Map<Integer, Command> gfe82Commands = new HashMap<Integer, Command>(); - gfe82Commands.putAll(ALL_COMMANDS.get(Version.GFE_81)); - ALL_COMMANDS.put(Version.GFE_82, gfe82Commands); - } - { - Map<Integer, Command> gfe90Commands = new HashMap<Integer, Command>(); - gfe90Commands.putAll(ALL_COMMANDS.get(Version.GFE_82)); - ALL_COMMANDS.put(Version.GFE_90, gfe90Commands); - gfe90Commands.put(MessageType.QUERY_WITH_PARAMETERS, QueryWithParametersGeode10.getCommand()); - gfe90Commands.put(MessageType.QUERY, QueryGeode10.getCommand()); - } - { - Map<Integer, Command> geode110Commands = new HashMap<Integer, Command>(); - geode110Commands.putAll(ALL_COMMANDS.get(Version.GFE_90)); - ALL_COMMANDS.put(Version.GEODE_110, geode110Commands); - } - { - Map<Integer, Command> geode111Commands = new HashMap<Integer, Command>(); - geode111Commands.putAll(ALL_COMMANDS.get(Version.GEODE_110)); - ALL_COMMANDS.put(Version.GEODE_111, geode111Commands); - } - { - Map<Integer, Command> commands = new HashMap<Integer, Command>(); - commands.putAll(ALL_COMMANDS.get(Version.GEODE_111)); - ALL_COMMANDS.put(Version.GEODE_120, commands); - } - { - Map<Integer, Command> commands = new HashMap<Integer, Command>(); - commands.putAll(ALL_COMMANDS.get(Version.GEODE_120)); - ALL_COMMANDS.put(Version.GEODE_130, commands); - } - { - Map<Integer, Command> commands = new HashMap<Integer, Command>(); - commands.putAll(ALL_COMMANDS.get(Version.GEODE_130)); - ALL_COMMANDS.put(Version.GEODE_140, commands); - } - { - Map<Integer, Command> commands = new HashMap<Integer, Command>(); - commands.putAll(ALL_COMMANDS.get(Version.GEODE_140)); - ALL_COMMANDS.put(Version.GEODE_150, commands); - } + ALL_COMMANDS.put(Version.GFE_8009, gfe80Commands); + + Map<Integer, Command> gfe81Commands = new HashMap<Integer, Command>(); + gfe81Commands.putAll(gfe80Commands); + gfe81Commands.put(MessageType.GET_ALL_WITH_CALLBACK, GetAllWithCallback.getCommand()); + gfe81Commands.put(MessageType.PUT_ALL_WITH_CALLBACK, PutAllWithCallback.getCommand()); + gfe81Commands.put(MessageType.REMOVE_ALL, RemoveAll.getCommand()); + + ALL_COMMANDS.put(Version.GFE_81, gfe81Commands); + ALL_COMMANDS.put(Version.GFE_82, gfe81Commands); + + Map<Integer, Command> commands = new HashMap<Integer, Command>(); + commands.putAll(ALL_COMMANDS.get(Version.GFE_82)); + ALL_COMMANDS.put(Version.GFE_90, commands); + commands.put(MessageType.QUERY_WITH_PARAMETERS, QueryWithParametersGeode10.getCommand()); + commands.put(MessageType.QUERY, QueryGeode10.getCommand()); + + ALL_COMMANDS.put(Version.GEODE_110, commands); + ALL_COMMANDS.put(Version.GEODE_111, commands); + ALL_COMMANDS.put(Version.GEODE_120, commands); + ALL_COMMANDS.put(Version.GEODE_130, commands); + ALL_COMMANDS.put(Version.GEODE_140, commands); + ALL_COMMANDS.put(Version.GEODE_150, commands); } @@ -370,11 +334,4 @@ public class CommandInitializer { public static Map<Integer, Command> getCommands(ServerConnection connection) { return getCommands(connection.getClientVersion()); } - - /** - * A method used by tests for Backward compatibility - */ - public static void testSetCommands(Map<Integer, Command> testCommands) { - ALL_COMMANDS.put(Version.TEST_VERSION, testCommands); - } } diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerSideHandshakeFactory.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerSideHandshakeFactory.java index fcea191..9f760bc 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerSideHandshakeFactory.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerSideHandshakeFactory.java @@ -36,7 +36,7 @@ import org.apache.geode.internal.security.SecurityService; class ServerSideHandshakeFactory { private static final Logger logger = LogService.getLogger(); - static final Version currentServerVersion = Acceptor.VERSION; + static final Version currentServerVersion = Version.CURRENT; ServerSideHandshake readHandshake(Socket socket, int timeout, CommunicationMode communicationMode, DistributedSystem system, SecurityService securityService) throws Exception { diff --git a/geode-core/src/test/java/org/apache/geode/internal/VersionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/VersionJUnitTest.java index ef0e0bc..48572fc 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/VersionJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/VersionJUnitTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.apache.geode.internal.cache.tier.sockets.CommandInitializer; import org.apache.geode.test.junit.categories.UnitTest; @Category(UnitTest.class) @@ -59,4 +60,11 @@ public class VersionJUnitTest { assertFalse(Version.GFE_65.isPre65()); assertFalse(Version.GFE_70.isPre65()); } + + @Test + public void testCommandMapContainsCurrentVersion() { + org.junit.Assert.assertNotNull( + "Please add a commnd set for the new version of Geode to CommandInitializer", + CommandInitializer.getCommands(Version.CURRENT)); + } } -- To stop receiving notification emails like this one, please contact bschucha...@apache.org.