You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/09/05 13:18:41 UTC

[14/20] ignite git commit: IGNITE-2974: ODBC: Added "socketSendBufferSize" and "socketReceiveBufferSize" configuration parameters. This closes #994.

IGNITE-2974: ODBC: Added "socketSendBufferSize" and "socketReceiveBufferSize" configuration parameters. This closes #994.


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

Branch: refs/heads/ignite-3611-1
Commit: d65228e42ec9c84182b8c9c9c8d06a0056d5eed2
Parents: a760918
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Mon Sep 5 11:20:26 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Sep 5 11:20:26 2016 +0300

----------------------------------------------------------------------
 .../ignite/configuration/OdbcConfiguration.java | 64 ++++++++++++++++++++
 .../internal/processors/odbc/OdbcProcessor.java |  8 +--
 .../odbc/OdbcProcessorValidationSelfTest.java   | 21 ++++++-
 3 files changed, 86 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d65228e4/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
index 3746995..c098e09 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.configuration;
 
+import org.apache.ignite.internal.util.typedef.internal.S;
+
 /**
  * ODBC configuration.
  */
@@ -30,12 +32,21 @@ public class OdbcConfiguration {
     /** Default maximum TCP port range value. */
     public static final int DFLT_TCP_PORT_TO = 10810;
 
+    /** Default socket send and receive buffer size. */
+    public static final int DFLT_SOCK_BUF_SIZE = 0;
+
     /** Default max number of open cursors per connection. */
     public static final int DFLT_MAX_OPEN_CURSORS = 128;
 
     /** Endpoint address. */
     private String endpointAddr;
 
+    /** Socket send buffer size. */
+    private int sockSndBufSize = DFLT_SOCK_BUF_SIZE;
+
+    /** Socket receive buffer size. */
+    private int sockRcvBufSize = DFLT_SOCK_BUF_SIZE;
+
     /** Max number of opened cursors per connection. */
     private int maxOpenCursors = DFLT_MAX_OPEN_CURSORS;
 
@@ -57,6 +68,8 @@ public class OdbcConfiguration {
 
         endpointAddr = cfg.getEndpointAddress();
         maxOpenCursors = cfg.getMaxOpenCursors();
+        sockRcvBufSize = cfg.getSocketReceiveBufferSize();
+        sockSndBufSize = cfg.getSocketSendBufferSize();
     }
 
     /**
@@ -115,4 +128,55 @@ public class OdbcConfiguration {
 
         return this;
     }
+
+    /**
+     * Gets socket send buffer size. When set to zero, operation system default will be used.
+     * <p>
+     * Defaults to {@link #DFLT_SOCK_BUF_SIZE}
+     *
+     * @return Socket send buffer size in bytes.
+     */
+    public int getSocketSendBufferSize() {
+        return sockSndBufSize;
+    }
+
+    /**
+     * Sets socket send buffer size. See {@link #getSocketSendBufferSize()} for more information.
+     *
+     * @param sockSndBufSize Socket send buffer size in bytes.
+     * @return This instance for chaining.
+     */
+    public OdbcConfiguration setSocketSendBufferSize(int sockSndBufSize) {
+        this.sockSndBufSize = sockSndBufSize;
+
+        return this;
+    }
+
+    /**
+     * Gets socket receive buffer size. When set to zero, operation system default will be used.
+     * <p>
+     * Defaults to {@link #DFLT_SOCK_BUF_SIZE}.
+     *
+     * @return Socket receive buffer size in bytes.
+     */
+    public int getSocketReceiveBufferSize() {
+        return sockRcvBufSize;
+    }
+
+    /**
+     * Sets socket receive buffer size. See {@link #getSocketReceiveBufferSize()} for more information.
+     *
+     * @param sockRcvBufSize Socket receive buffer size in bytes.
+     * @return This instance for chaining.
+     */
+    public OdbcConfiguration setSocketReceiveBufferSize(int sockRcvBufSize) {
+        this.sockRcvBufSize = sockRcvBufSize;
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(OdbcConfiguration.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d65228e4/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
index ead8901..adfdc22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
@@ -46,9 +46,6 @@ public class OdbcProcessor extends GridProcessorAdapter {
     /** Default TCP direct buffer flag. */
     private static final boolean DFLT_TCP_DIRECT_BUF = false;
 
-    /** Default socket send and receive buffer size. */
-    private static final int DFLT_SOCK_BUF_SIZE = 32 * 1024;
-
     /** Busy lock. */
     private final GridSpinBusyLock busyLock = new GridSpinBusyLock();
 
@@ -113,11 +110,10 @@ public class OdbcProcessor extends GridProcessorAdapter {
                             .tcpNoDelay(DFLT_TCP_NODELAY)
                             .directBuffer(DFLT_TCP_DIRECT_BUF)
                             .byteOrder(ByteOrder.nativeOrder())
-                            .socketSendBufferSize(DFLT_SOCK_BUF_SIZE)
-                            .socketReceiveBufferSize(DFLT_SOCK_BUF_SIZE)
+                            .socketSendBufferSize(odbcCfg.getSocketSendBufferSize())
+                            .socketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize())
                             .filters(new GridNioCodecFilter(new OdbcBufferedParser(), log, false))
                             .directMode(false)
-                            .idleTimeout(Long.MAX_VALUE)
                             .build();
 
                         srv0.start();

http://git-wip-us.apache.org/repos/asf/ignite/blob/d65228e4/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java
index 751f0ae..bb08c6c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java
@@ -94,7 +94,7 @@ public class OdbcProcessorValidationSelfTest extends GridCommonAbstractTest {
     /**
      * Test start with invalid address format.
      *
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testAddressInvalidFormat() throws Exception {
         check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:"), false);
@@ -115,6 +115,25 @@ public class OdbcProcessorValidationSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Test connection parameters: sendBufferSize, receiveBufferSize, connectionTimeout.
+     *
+     * @throws Exception If failed.
+     */
+    public void testConnectionParams() throws Exception {
+        check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+            .setSocketSendBufferSize(4 * 1024), true);
+
+        check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+            .setSocketReceiveBufferSize(4 * 1024), true);
+
+        check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+            .setSocketSendBufferSize(-64 * 1024), false);
+
+        check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+            .setSocketReceiveBufferSize(-64 * 1024), false);
+    }
+
+    /**
      * Perform check.
      *
      * @param odbcCfg ODBC configuration.