ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [02/30] ignite git commit: IGNITE-5162: ODBC: removed unused version-dependent code. simplified version enum.
Date Thu, 11 May 2017 09:56:13 GMT
IGNITE-5162: ODBC: removed unused version-dependent code. simplified version enum.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7f8a4309
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7f8a4309
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7f8a4309

Branch: refs/heads/ignite-5075-cacheStart
Commit: 7f8a430908bcc6cbbd2d3c75afbbe2f500b88a6d
Parents: d70ebff
Author: devozerov <vozerov@gridgain.com>
Authored: Thu May 4 13:12:14 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Thu May 4 13:12:14 2017 +0300

----------------------------------------------------------------------
 .../processors/odbc/OdbcMessageParser.java      |  8 +--
 .../processors/odbc/OdbcProtocolVersion.java    | 73 +++++---------------
 .../processors/odbc/OdbcRequestHandler.java     | 10 ++-
 .../internal/processors/odbc/OdbcUtils.java     |  3 +
 4 files changed, 28 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7f8a4309/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
index ab93f25..a3d7308 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
@@ -83,13 +83,11 @@ public class OdbcMessageParser {
 
                 OdbcProtocolVersion version = res.version();
 
-                if (version.isUnknown())
+                if (version == OdbcProtocolVersion.UNKNOWN)
                     return res;
 
-                if (version.isDistributedJoinsSupported()) {
-                    res.distributedJoins(reader.readBoolean());
-                    res.enforceJoinOrder(reader.readBoolean());
-                }
+                res.distributedJoins(reader.readBoolean());
+                res.enforceJoinOrder(reader.readBoolean());
 
                 return res;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7f8a4309/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
index 57efa02..5c156d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
@@ -14,52 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ignite.internal.processors.odbc;
 
-import java.util.HashMap;
-import java.util.Map;
+package org.apache.ignite.internal.processors.odbc;
 
 /**
  * ODBC protocol version.
  */
 public enum OdbcProtocolVersion {
-    /** First version of the ODBC. Released with Ignite 1.6 */
-    VERSION_1_6_0(1),
-
-    /** Second version of the ODBC. Released with Ignite 1.8 */
-    VERSION_1_8_0(makeVersion(1,8,0)),
+    /** Version 2.1.0. */
+    VER_2_1_0(makeVersion(2, 1, 0), "2.1.0"),
 
     /** Unknown version. */
-    VERSION_UNKNOWN(Long.MIN_VALUE);
+    UNKNOWN(Long.MIN_VALUE, "UNKNOWN");
 
     /** Mask to get 2 lowest bytes of the value and cast to long. */
     private static final long LONG_MASK = 0x000000000000FFFFL;
 
-    /** Long value to enum map. */
-    private static final Map<Long, OdbcProtocolVersion> versions = new HashMap<>();
-
-    /** Enum value to Ignite version map */
-    private static final Map<OdbcProtocolVersion, String> since = new HashMap<>();
-
-    /**
-     * Map long values to version.
-     */
-    static {
-        for (OdbcProtocolVersion version : values())
-            versions.put(version.longValue(), version);
-
-        since.put(VERSION_1_6_0, "1.6.0");
-        since.put(VERSION_1_8_0, "1.8.0");
-    }
-
     /** Long value for version. */
     private final long longVal;
 
+    /** Since string. */
+    private final String since;
+
     /**
+     * Constructor.
+     *
      * @param longVal Long value.
+     * @param since Since string.
      */
-    OdbcProtocolVersion(long longVal) {
+    OdbcProtocolVersion(long longVal, String since) {
         this.longVal = longVal;
+        this.since = since;
     }
 
     /**
@@ -79,16 +64,12 @@ public enum OdbcProtocolVersion {
      * @return Protocol version.
      */
     public static OdbcProtocolVersion fromLong(long longVal) {
-        OdbcProtocolVersion res = versions.get(longVal);
-
-        return res == null ? VERSION_UNKNOWN : res;
-    }
+        for (OdbcProtocolVersion ver : OdbcProtocolVersion.values()) {
+            if (ver.longValue() == longVal)
+                return ver;
+        }
 
-    /**
-     * @return Current version.
-     */
-    public static OdbcProtocolVersion current() {
-        return VERSION_1_8_0;
+        return UNKNOWN;
     }
 
     /**
@@ -99,27 +80,9 @@ public enum OdbcProtocolVersion {
     }
 
     /**
-     * @return {@code true} if this version is unknown.
-     */
-    public boolean isUnknown() {
-        return longVal == VERSION_UNKNOWN.longVal;
-    }
-
-    /**
-     * @return {@code true} if this version supports distributed joins.
-     */
-    public boolean isDistributedJoinsSupported() {
-        assert !isUnknown();
-
-        return longVal >= VERSION_1_8_0.longVal;
-    }
-
-    /**
      * @return Ignite version when introduced.
      */
     public String since() {
-        assert !isUnknown();
-
-        return since.get(this);
+        return since;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7f8a4309/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
index 311d2eb..c17dd63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
@@ -141,22 +141,20 @@ public class OdbcRequestHandler {
         try {
             OdbcProtocolVersion version = req.version();
 
-            if (version.isUnknown()) {
+            if (version == OdbcProtocolVersion.UNKNOWN) {
                 IgniteProductVersion ver = ctx.grid().version();
 
                 String verStr = Byte.toString(ver.major()) + '.' + ver.minor() + '.' + ver.maintenance();
 
-                OdbcHandshakeResult res = new OdbcHandshakeResult(false, OdbcProtocolVersion.current().since(),
verStr);
+                OdbcHandshakeResult res = new OdbcHandshakeResult(false, OdbcUtils.VER_LATEST.since(),
verStr);
 
                 return new OdbcResponse(res);
             }
 
             OdbcHandshakeResult res = new OdbcHandshakeResult(true, null, null);
 
-            if (version.isDistributedJoinsSupported()) {
-                distributedJoins = req.distributedJoins();
-                enforceJoinOrder = req.enforceJoinOrder();
-            }
+            distributedJoins = req.distributedJoins();
+            enforceJoinOrder = req.enforceJoinOrder();
 
             return new OdbcResponse(res);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7f8a4309/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
index d851d13..668ce6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
@@ -23,6 +23,9 @@ import org.apache.ignite.IgniteException;
  * Various ODBC utility methods.
  */
 public class OdbcUtils {
+    /** Latest version. */
+    public static final OdbcProtocolVersion VER_LATEST = OdbcProtocolVersion.VER_2_1_0;
+
     /**
      * Add quotation marks at the beginning and end of the string.
      *


Mime
View raw message