You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/12/05 14:41:24 UTC
[02/50] [abbrv] ignite git commit: finalizing changes
finalizing changes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1d781fb7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1d781fb7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1d781fb7
Branch: refs/heads/ignite-comm-balance-master
Commit: 1d781fb7b289c9897caabaf76dec2e28ee78c12f
Parents: ec24857
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri Oct 28 21:11:16 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Fri Oct 28 21:11:16 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 9 +++-
.../ignite/internal/util/nio/GridNioServer.java | 48 ++++++++++++--------
.../communication/tcp/TcpCommunicationSpi.java | 5 +-
3 files changed, 41 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d781fb7/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 d775060..8a1f557 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -431,11 +431,18 @@ public final class IgniteSystemProperties {
/**
* Defines how many non-blocking {@code selector.selectNow()} should be made before
- * falling into {@code selector.select(long)} in NIO server.
+ * falling into {@code selector.select(long)} in NIO server. Long value. Default is {@code 0}.
+ * Can be set to {@code Long.MAX_VALUE} so selector thread will never block.
*/
public static final String IGNITE_SELECTOR_SPINS = "IGNITE_SELECTOR_SPINS";
/**
+ * When {@code true} writer workers in {@code GridNioServer} should use only {@code Selector.select()},
+ * otherwise use {@code LockSupport.park()} when possible. Default is {@code false}.
+ */
+ public static final String IGNITE_DISABLE_SELECTOR_PARK = "IGNITE_DISABLE_SELECTOR_PARK";
+
+ /**
* 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/1d781fb7/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 58b41f9..75db9fc 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
@@ -94,9 +94,6 @@ public class GridNioServer<T> {
/** */
public static final String IGNITE_IO_BALANCE_RANDOM_BALANCE = "IGNITE_IO_BALANCE_RANDOM_BALANCER";
- /** */
- private static final boolean DISABLE_PARK = IgniteSystemProperties.getBoolean("DISABLE_PARK", false);
-
/** Default session write timeout. */
public static final int DFLT_SES_WRITE_TIMEOUT = 5000;
@@ -119,17 +116,10 @@ public class GridNioServer<T> {
private static final boolean DISABLE_KEYSET_OPTIMIZATION =
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_NO_SELECTOR_OPTS);
- /** */
- private static final int SELECTOR_SPINS =
- IgniteSystemProperties.getInteger(IgniteSystemProperties.IGNITE_SELECTOR_SPINS, 128);
-
/**
*
*/
static {
- // TODO
- System.out.println(">>> Disable park: " + DISABLE_PARK);
-
// This is a workaround for JDK bug (NPE in Selector.open()).
// http://bugs.sun.com/view_bug.do?bug_id=6427854
try {
@@ -140,6 +130,14 @@ public class GridNioServer<T> {
}
}
+ /** */
+ private final long selectorSpins =
+ IgniteSystemProperties.getInteger(IgniteSystemProperties.IGNITE_SELECTOR_SPINS, 0);
+
+ /** */
+ private final boolean disablePark =
+ IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_DISABLE_SELECTOR_PARK, false);
+
/** Accept worker thread. */
@GridToStringExclude
private final IgniteThread acceptThread;
@@ -443,6 +441,20 @@ public class GridNioServer<T> {
}
/**
+ * @return {@code True} if park is disabled.
+ */
+ public boolean parkDisabled() {
+ return disablePark;
+ }
+
+ /**
+ * @return Selector spins.
+ */
+ public long selectorSpins() {
+ return selectorSpins;
+ }
+
+ /**
* @param ses Session to close.
* @return Future for operation.
*/
@@ -1051,7 +1063,7 @@ public class GridNioServer<T> {
GridNioRecoveryDescriptor desc = null;
- if (!DISABLE_PARK && writer) {
+ if (!disablePark && writer) {
desc = ((GridSelectorNioSessionImpl)key.attachment()).outRecoveryDescriptor();
if (desc != null)
@@ -1110,7 +1122,7 @@ public class GridNioServer<T> {
close(ses, e);
}
- if (!DISABLE_PARK && pendingAcks0 != -1) {
+ if (!disablePark && pendingAcks0 != -1) {
assert desc != null;
pendingAcks -= pendingAcks0 - (desc.messagesRequests().size() % desc.ackSendThreshold());
@@ -1128,7 +1140,7 @@ public class GridNioServer<T> {
GridNioRecoveryDescriptor desc = null;
- if (!DISABLE_PARK && writer) {
+ if (!disablePark && writer) {
desc = ((GridSelectorNioSessionImpl)key.attachment()).outRecoveryDescriptor();
if (desc != null)
@@ -1140,7 +1152,7 @@ public class GridNioServer<T> {
else
processWrite0(key);
- if (!DISABLE_PARK && pendingAcks0 != -1) {
+ if (!disablePark && pendingAcks0 != -1) {
assert desc != null;
pendingAcks += (desc.messagesRequests().size() % desc.ackSendThreshold()) - pendingAcks0;
@@ -1661,7 +1673,7 @@ public class GridNioServer<T> {
if (select)
selector.wakeup();
- else if (!DISABLE_PARK && park)
+ else if (!disablePark && park)
LockSupport.unpark(clientThreads[idx]);
}
@@ -1847,7 +1859,7 @@ public class GridNioServer<T> {
}
}
- if (!DISABLE_PARK && writer && writeSesCnt == 0 && pendingAcks == 0) {
+ if (!disablePark && writer && writeSesCnt == 0 && pendingAcks == 0) {
park = true;
try {
@@ -1861,7 +1873,7 @@ public class GridNioServer<T> {
int res = 0;
- for (int i = 0; i < SELECTOR_SPINS && res == 0; i++)
+ for (long i = 0; i < selectorSpins && res == 0; i++)
res = selector.selectNow();
if (res > 0) {
@@ -1873,7 +1885,7 @@ public class GridNioServer<T> {
}
if (!changeReqs.isEmpty() ||
- (!DISABLE_PARK && writer && pendingAcks == 0 && SELECTOR_SPINS != 0))
+ (!disablePark && writer && pendingAcks == 0 && selectorSpins != 0))
continue;
select = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d781fb7/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 930f32b..3dec928 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -2018,8 +2018,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
// Ack Port the TCP server was bound to.
if (log.isInfoEnabled())
- log.info("Successfully bound communication NIO server to TCP port [port=" + boundTcpPort +
- ", locHost=" + locHost + ", selectorsCnt=" + selectorsCnt + ']');
+ log.info("Successfully bound communication NIO server to TCP port " +
+ "[port=" + boundTcpPort + ", locHost=" + locHost + ", selectorsCnt=" + selectorsCnt +
+ ", parkDisabled=" + srvr.parkDisabled() + ", selectorSpins=" + srvr.selectorSpins() + ']');
srvr.idleTimeout(idleConnTimeout);