communication opts
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4dda38a7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4dda38a7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4dda38a7 Branch: refs/heads/ignite-comm-balance Commit: 4dda38a7455150e7244c1abb03ee7338e04b20b5 Parents: d45c638 Author: Yakov Zhdanov <[email protected]> Authored: Thu Oct 13 20:38:18 2016 +0300 Committer: Yakov Zhdanov <[email protected]> Committed: Thu Oct 13 20:38:18 2016 +0300 ---------------------------------------------------------------------- .../apache/ignite/IgniteSystemProperties.java | 6 +++ .../ignite/internal/util/nio/GridNioServer.java | 39 +++++++++++++++----- 2 files changed, 36 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4dda38a7/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index ab6403f..4ef3b74 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -430,6 +430,12 @@ public final class IgniteSystemProperties { public static final String IGNITE_NO_SELECTOR_OPTS = "IGNITE_NO_SELECTOR_OPTS"; /** + * Defines how many non-blocking {@code selector.selectNow()} should be made before + * falling into {@code selector.select(long)} in NIO server. + */ + public static final String IGNITE_SELECTOR_SPINS = "IGNITE_SELECTOR_SPINS"; + + /** * System property to specify period in milliseconds between calls of the SQL statements cache cleanup task. * <p> * Cleanup tasks clears cache for terminated threads and for threads which did not perform SQL queries within http://git-wip-us.apache.org/repos/asf/ignite/blob/4dda38a7/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java index 8f231d0..b245565 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java @@ -109,6 +109,10 @@ public class GridNioServer<T> { private static final boolean DISABLE_KEYSET_OPTIMIZATION = IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_NO_SELECTOR_OPTS); + /** */ + private static final int SPIN_COUNT = + IgniteSystemProperties.getInteger(IgniteSystemProperties.IGNITE_SELECTOR_SPINS, 32); + /** * */ @@ -1599,18 +1603,35 @@ public class GridNioServer<T> { } } + int res = 0; + + for (int i = 0; i < SPIN_COUNT && res == 0; i++) + res = selector.selectNow(); + + if (res > 0) { + // Walk through the ready keys collection and process network events. + if (selectedKeys == null) + processSelectedKeys(selector.selectedKeys()); + else + processSelectedKeysOptimized(selectedKeys.flip()); + } + + if (!changeReqs.isEmpty()) + continue; + select = true; try { - if (changeReqs.isEmpty()) { - // Wake up every 2 seconds to check if closed. - if (selector.select(2000) > 0) { - // Walk through the ready keys collection and process network events. - if (selectedKeys == null) - processSelectedKeys(selector.selectedKeys()); - else - processSelectedKeysOptimized(selectedKeys.flip()); - } + if (!changeReqs.isEmpty()) + continue; + + // Wake up every 2 seconds to check if closed. + if (selector.select(2000) > 0) { + // Walk through the ready keys collection and process network events. + if (selectedKeys == null) + processSelectedKeys(selector.selectedKeys()); + else + processSelectedKeysOptimized(selectedKeys.flip()); } } finally {
