ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-comm-balance
Date Tue, 06 Dec 2016 08:23:56 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-comm-balance-master f11bb6bcd -> 8f45a3bbb


ignite-comm-balance


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

Branch: refs/heads/ignite-comm-balance-master
Commit: 8f45a3bbb95f7a572926f9d038de3df48eea7452
Parents: f11bb6b
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Dec 6 11:23:49 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Dec 6 11:23:49 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/nio/GridNioServer.java | 18 ++++++++-
 .../communication/tcp/TcpCommunicationSpi.java  | 41 +++-----------------
 2 files changed, 22 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8f45a3bb/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 61c438f..e1a57b1 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
@@ -250,6 +250,7 @@ public class GridNioServer<T> {
      * @param writerFactory Writer factory.
      * @param skipRecoveryPred Skip recovery predicate.
      * @param msgQueueLsnr Message queue size listener.
+     * @param balancing Balancing flag.
      * @param filters Filters for this server.
      * @throws IgniteCheckedException If failed.
      */
@@ -274,6 +275,7 @@ public class GridNioServer<T> {
         GridNioMessageWriterFactory writerFactory,
         IgnitePredicate<Message> skipRecoveryPred,
         IgniteBiInClosure<GridNioSession, Integer> msgQueueLsnr,
+        boolean balancing,
         GridNioFilter... filters
     ) throws IgniteCheckedException {
         if (port != -1)
@@ -357,7 +359,7 @@ public class GridNioServer<T> {
 
         IgniteRunnable balancer0 = null;
 
-        if (balancePeriod > 0) {
+        if (balancing && balancePeriod > 0) {
             boolean rndBalance = IgniteSystemProperties.getBoolean(IGNITE_IO_BALANCE_RANDOM_BALANCE,
false);
 
             balancer0 = rndBalance ? new RandomBalancer() : new SizeBasedBalancer(balancePeriod);
@@ -3122,6 +3124,9 @@ public class GridNioServer<T> {
         /** */
         private long selectorSpins;
 
+        /** */
+        private boolean balancing;
+
         /**
          * Finishes building the instance.
          *
@@ -3150,6 +3155,7 @@ public class GridNioServer<T> {
                 writerFactory,
                 skipRecoveryPred,
                 msgQueueLsnr,
+                balancing,
                 filters != null ? Arrays.copyOf(filters, filters.length) : EMPTY_FILTERS
             );
 
@@ -3163,6 +3169,16 @@ public class GridNioServer<T> {
         }
 
         /**
+         * @param balancing Balancing flag.
+         * @return This for chaining.
+         */
+        public Builder<T> balancing(boolean balancing) {
+            this.balancing = balancing;
+
+            return this;
+        }
+
+        /**
          * @param addr Local address.
          * @return This for chaining.
          */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8f45a3bb/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 675f414..d8a6344 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
@@ -1754,43 +1754,11 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         }
 
         if (connectionsPerNode > 1) {
-            int idxMode = IgniteSystemProperties.getInteger("CONN_IDX_MODE", 0);
-
-            switch (idxMode) {
-                case 0: {
-                    connPlc = new ConnectionPolicy() {
-                        @Override public int connectionIndex() {
-                            return (int)(Thread.currentThread().getId() % connectionsPerNode);
-                        }
-                    };
-
-                    break;
-                }
-
-                case 1: {
-                    connPlc = new ConnectionPolicy() {
-                        @Override public int connectionIndex() {
-                            Integer threadIdx = threadConnIdx.get();
-
-                            if (threadIdx != null)
-                                return threadIdx;
-
-                            for (;;) {
-                                int idx = connIdx.get();
-                                int nextIdx = idx == connectionsPerNode - 1 ? 0 : idx + 1;
-
-                                if (connIdx.compareAndSet(idx, nextIdx)) {
-                                    threadConnIdx.set(idx);
-
-                                    return idx;
-                                }
-                            }
-                        }
-                    };
-
-                    break;
+            connPlc = new ConnectionPolicy() {
+                @Override public int connectionIndex() {
+                    return (int)(Thread.currentThread().getId() % connectionsPerNode);
                 }
-            }
+            };
         }
         else {
             connPlc = new ConnectionPolicy() {
@@ -2075,6 +2043,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                         .writerFactory(writerFactory)
                         .skipRecoveryPredicate(skipRecoveryPred)
                         .messageQueueSizeListener(queueSizeMonitor)
+                        .balancing(usePairedConnections)
                         .build();
 
                 boundTcpPort = port;


Mime
View raw message