ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [41/50] [abbrv] ignite git commit: io test
Date Mon, 10 Oct 2016 12:13:37 GMT
io test


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

Branch: refs/heads/ignite-gg-8-io2-selNow
Commit: 3d2e47c9c599928f83ae3c8b912b7ec5453c1514
Parents: 8b9c54d
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Oct 4 15:03:33 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Oct 4 15:03:33 2016 +0300

----------------------------------------------------------------------
 .../managers/communication/GridIoManager.java   |  12 +-
 .../communication/IgniteIoTestMessage.java      | 155 ++++++++++++++++++-
 .../internal/util/nio/GridDirectParser.java     |   5 +
 .../ignite/internal/util/nio/GridNioServer.java |  14 ++
 .../cache/IgniteIoTestSendAllBenchmark.java     |  63 +++++++-
 .../cache/IgniteIoTestSendRandomBenchmark.java  |  85 +++++++++-
 6 files changed, 325 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index bfed190..c79c7ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -372,9 +372,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                 IgniteIoTestMessage msg0 = (IgniteIoTestMessage)msg;
 
                 if (msg0.request()) {
-                    IgniteIoTestMessage res = new IgniteIoTestMessage(msg0.id(), false, null);
-
-                    res.flags(msg0.flags());
+                    IgniteIoTestMessage res = IgniteIoTestMessage.createResponse(msg0);
 
                     try {
                         send(node, GridTopic.TOPIC_IO_TEST, res, GridIoPolicy.SYSTEM_POOL);
@@ -384,12 +382,14 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                     }
                 }
                 else {
+                    msg0.responseTime();
+
                     IoTestFuture fut = ioTestMap().get(msg0.id());
 
                     if (fut == null)
                         U.warn(log, "Failed to find IO test future [msg=" + msg0 + ']');
                     else
-                        fut.onResponse();
+                        fut.onResponse(msg0);
                 }
             }
         });
@@ -2787,7 +2787,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         /**
          *
          */
-        void onResponse() {
+        void onResponse(Object res) {
             boolean complete;
 
             synchronized (this) {
@@ -2795,7 +2795,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
             }
 
             if (complete)
-                onDone();
+                onDone(res);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java
index 985cf99..4138d14 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.managers.communication;
 
 import java.nio.ByteBuffer;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -45,6 +46,20 @@ public class IgniteIoTestMessage implements Message {
     /** */
     private byte payload[];
 
+    public long reqSndTime;
+
+    public long reqWriteTime;
+
+    public long reqReadTime;
+
+    public long resSndTime;
+
+    public long resWriteTime;
+
+    public long resReadTime;
+
+    public long resTime;
+
     /**
      *
      */
@@ -52,6 +67,33 @@ public class IgniteIoTestMessage implements Message {
         // No-op.
     }
 
+    public void sendTime() {
+        if (req)
+            reqSndTime = U.currentTimeMillis();
+        else
+            resSndTime = U.currentTimeMillis();
+    }
+
+    public void writeTime() {
+        if (req)
+            reqWriteTime = U.currentTimeMillis();
+        else
+            resWriteTime = U.currentTimeMillis();
+    }
+
+    public void readTime() {
+        if (req)
+            reqReadTime = U.currentTimeMillis();
+        else
+            resReadTime = U.currentTimeMillis();
+    }
+
+    public void responseTime() {
+        assert !req;
+
+        resTime = U.currentTimeMillis();
+    }
+
     /**
      * @param id ID.
      * @param req {@code True} for request.
@@ -63,6 +105,19 @@ public class IgniteIoTestMessage implements Message {
         this.payload = payload;
     }
 
+    public static IgniteIoTestMessage createResponse(IgniteIoTestMessage req) {
+        IgniteIoTestMessage msg = new IgniteIoTestMessage(req.id(), false, null);
+
+        msg.flags = req.flags;
+        msg.reqSndTime = req.reqSndTime;
+        msg.reqWriteTime = req.reqWriteTime;
+        msg.reqReadTime = req.reqReadTime;
+        msg.resSndTime = req.resSndTime;
+        msg.resWriteTime = req.resWriteTime;
+
+        return msg;
+    }
+
     /**
      * @return Process from NIO thread flag.
      */
@@ -161,6 +216,48 @@ public class IgniteIoTestMessage implements Message {
 
                 writer.incrementState();
 
+            case 4:
+                if (!writer.writeLong("reqReadTime", reqReadTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 5:
+                if (!writer.writeLong("reqSndTime", reqSndTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 6:
+                if (!writer.writeLong("reqWriteTime", reqWriteTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 7:
+                if (!writer.writeLong("resReadTime", resReadTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 8:
+                if (!writer.writeLong("resSndTime", resSndTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 9:
+                if (!writer.writeLong("resTime", resTime))
+                    return false;
+
+                writer.incrementState();
+
+            case 10:
+                if (!writer.writeLong("resWriteTime", resWriteTime))
+                    return false;
+
+                writer.incrementState();
+
         }
 
         return true;
@@ -206,6 +303,62 @@ public class IgniteIoTestMessage implements Message {
 
                 reader.incrementState();
 
+            case 4:
+                reqReadTime = reader.readLong("reqReadTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 5:
+                reqSndTime = reader.readLong("reqSndTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 6:
+                reqWriteTime = reader.readLong("reqWriteTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 7:
+                resReadTime = reader.readLong("resReadTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 8:
+                resSndTime = reader.readLong("resSndTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 9:
+                resTime = reader.readLong("resTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 10:
+                resWriteTime = reader.readLong("resWriteTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
         }
 
         return reader.afterMessageRead(IgniteIoTestMessage.class);
@@ -218,7 +371,7 @@ public class IgniteIoTestMessage implements Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 4;
+        return 11;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
index 5a02662..1b73a51 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
@@ -22,6 +22,8 @@ import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.managers.communication.IgniteIoTestMessage;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageFactory;
@@ -85,6 +87,9 @@ public class GridDirectParser implements GridNioParser {
             }
 
             if (finished) {
+                if (msg instanceof GridIoMessage && ((GridIoMessage) msg).message()
instanceof IgniteIoTestMessage)
+                    ((IgniteIoTestMessage)((GridIoMessage) msg).message()).readTime();
+
                 if (reader != null)
                     reader.reset();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/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 ccaacf9..7d8847f 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
@@ -52,6 +52,8 @@ import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.managers.communication.IgniteIoTestMessage;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -471,6 +473,12 @@ public class GridNioServer<T> {
         assert ses != null;
         assert fut != null;
 
+        if (fut.message() instanceof GridIoMessage && ((GridIoMessage) fut.message()).message()
instanceof IgniteIoTestMessage) {
+            IgniteIoTestMessage msg = (IgniteIoTestMessage)((GridIoMessage)fut.message()).message();
+
+            msg.sendTime();
+        }
+
         int msgCnt = sys ? ses.offerSystemFuture(fut) : ses.offerFuture(fut);
 
         IgniteInClosure<IgniteException> ackC;
@@ -1305,6 +1313,9 @@ public class GridNioServer<T> {
                 if (writer != null)
                     writer.setCurrentWriteClass(msg.getClass());
 
+                if (msg instanceof GridIoMessage && ((GridIoMessage) msg).message()
instanceof IgniteIoTestMessage)
+                    ((IgniteIoTestMessage)((GridIoMessage) msg).message()).writeTime();
+
                 finished = msg.writeTo(buf, writer);
 
                 if (finished && writer != null)
@@ -1330,6 +1341,9 @@ public class GridNioServer<T> {
                 if (writer != null)
                     writer.setCurrentWriteClass(msg.getClass());
 
+                if (msg instanceof GridIoMessage && ((GridIoMessage) msg).message()
instanceof IgniteIoTestMessage)
+                    ((IgniteIoTestMessage)((GridIoMessage) msg).message()).writeTime();
+
                 finished = msg.writeTo(buf, writer);
 
                 if (finished && writer != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendAllBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendAllBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendAllBenchmark.java
index d77c4a6..2466615 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendAllBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendAllBenchmark.java
@@ -18,14 +18,75 @@
 package org.apache.ignite.yardstick.cache;
 
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.ignite.internal.managers.communication.IgniteIoTestMessage;
+import org.apache.ignite.internal.util.typedef.F;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
 
 /**
  *
  */
 public class IgniteIoTestSendAllBenchmark extends IgniteIoTestAbstractBenchmark {
+    private final AtomicLong cntr = new AtomicLong();
+    private final AtomicLong sndWrite = new AtomicLong();
+    private final AtomicLong reqWriteRead = new AtomicLong();
+    private final AtomicLong reqReadResSnd = new AtomicLong();
+    private final AtomicLong resSndWrite = new AtomicLong();
+    private final AtomicLong resWriteRead = new AtomicLong();
+    private final AtomicLong resReadProc = new AtomicLong();
+
+    @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        Thread t = new Thread(new Runnable() {
+            @Override public void run() {
+                while (true) {
+                    try {
+                        Thread.sleep(5000);
+
+                        double cntr0 = cntr.getAndSet(0);
+
+                        double sndWriteSum = sndWrite.getAndSet(0) / cntr0;
+                        double reqWriteReadSum = reqWriteRead.getAndSet(0) / cntr0;
+                        double reqReadResSndSum = reqReadResSnd.getAndSet(0) / cntr0;
+                        double resSndWriteSum = resSndWrite.getAndSet(0) / cntr0;
+                        double resWriteReadSum = resWriteRead.getAndSet(0) / cntr0;
+                        double resReadProcSum = resReadProc.getAndSet(0) / cntr0;
+
+                        BenchmarkUtils.println(cfg,
+                            String.format("Time [sndWrite=%f, reqWriteRead=%f, reqReadResSnd=%f,
resSndWrite=%f, resWriteRead=%f, resReadProc=%f]",
+                            sndWriteSum, reqWriteReadSum, reqReadResSndSum, resSndWriteSum,
resWriteReadSum, resReadProcSum));
+                    }
+                    catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        });
+        t.setDaemon(true);
+        t.start();
+    }
+
     /** {@inheritDoc} */
     @Override public boolean test(Map<Object, Object> ctx) throws Exception {
-        ignite.sendIoTest(targetNodes, null, false).get();
+        IgniteIoTestMessage msg0 = (IgniteIoTestMessage)ignite.sendIoTest(targetNodes, null,
false).get();
+
+        long sndWrite = msg0.reqWriteTime - msg0.reqSndTime;
+        long reqWriteRead = msg0.reqReadTime - msg0.reqWriteTime;
+        long reqReadResSnd = msg0.resSndTime - msg0.reqReadTime;
+        long resSndWrite = msg0.resWriteTime - msg0.resSndTime;
+        long resWriteRead = msg0.resReadTime - msg0.resWriteTime;
+        long resReadProc = msg0.resTime - msg0.resReadTime;
+
+        long sndWriteSum = this.sndWrite.addAndGet(sndWrite);
+        long reqWriteReadSum = this.reqWriteRead.addAndGet(reqWriteRead);
+        long reqReadResSndSum = this.reqReadResSnd.addAndGet(reqReadResSnd);
+        long resSndWriteSum = this.resSndWrite.addAndGet(resSndWrite);
+        long resWriteReadSum = this.resWriteRead.addAndGet(resWriteRead);
+        long resReadProcSum = this.resReadProc.addAndGet(resReadProc);
+
+        long cntr = this.cntr.incrementAndGet();
 
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d2e47c9/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendRandomBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendRandomBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendRandomBenchmark.java
index ac3a070..ffeb345 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendRandomBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIoTestSendRandomBenchmark.java
@@ -18,17 +18,100 @@
 package org.apache.ignite.yardstick.cache;
 
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.managers.communication.IgniteIoTestMessage;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
 
 /**
  *
  */
 public class IgniteIoTestSendRandomBenchmark extends IgniteIoTestAbstractBenchmark {
+    private final AtomicLong cntr = new AtomicLong();
+    private final AtomicLong sndWrite = new AtomicLong();
+    private final AtomicLong reqWriteRead = new AtomicLong();
+    private final AtomicLong reqReadResSnd = new AtomicLong();
+    private final AtomicLong resSndWrite = new AtomicLong();
+    private final AtomicLong resWriteRead = new AtomicLong();
+    private final AtomicLong resReadProc = new AtomicLong();
+
+    @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        Thread t = new Thread(new Runnable() {
+            @Override public void run() {
+                double cnt0 = 1;
+
+                double sndWriteSum0 = 0;
+                double reqWriteReadSum0 = 0;
+                double reqReadResSndSum0 = 0;
+                double resSndWriteSum0 = 0;
+                double resWriteReadSum0 = 0;
+                double resReadProcSum0 = 0;
+
+                while (true) {
+                    try {
+                        Thread.sleep(15000);
+
+                        double cntr0 = cntr.getAndSet(0);
+
+                        double sndWriteSum = sndWrite.getAndSet(0) / cntr0;
+                        double reqWriteReadSum = reqWriteRead.getAndSet(0) / cntr0;
+                        double reqReadResSndSum = reqReadResSnd.getAndSet(0) / cntr0;
+                        double resSndWriteSum = resSndWrite.getAndSet(0) / cntr0;
+                        double resWriteReadSum = resWriteRead.getAndSet(0) / cntr0;
+                        double resReadProcSum = resReadProc.getAndSet(0) / cntr0;
+
+                        sndWriteSum0 += sndWriteSum;
+                        reqWriteReadSum0 += reqWriteReadSum;
+                        reqReadResSndSum0 += reqReadResSndSum;
+                        resSndWriteSum0 += resSndWriteSum;
+                        resWriteReadSum0 += resWriteReadSum;
+                        resReadProcSum0 += resReadProcSum;
+
+                        BenchmarkUtils.println(cfg,
+                            String.format("Time [sndWrite=%f (avg=%f), reqWriteRead=%f (avg=%f),
reqReadResSnd=%f (avg=%f), resSndWrite=%f (avg=%f), resWriteRead=%f (avg=%f), resReadProc=%f
(avg=%f)]",
+                                sndWriteSum, sndWriteSum0 / cnt0,
+                                reqWriteReadSum, reqWriteReadSum0 / cnt0,
+                                reqReadResSndSum, reqReadResSndSum0 / cnt0,
+                                resSndWriteSum, resSndWriteSum0 / cnt0,
+                                resWriteReadSum, resWriteReadSum0 / cnt0,
+                                resReadProcSum, resReadProcSum0 / cnt0));
+
+                        cnt0 += 1;
+                    }
+                    catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        });
+        t.setDaemon(true);
+        t.start();
+    }
+
     /** {@inheritDoc} */
     @Override public boolean test(Map<Object, Object> ctx) throws Exception {
         ClusterNode node = targetNodes.get(nextRandom(targetNodes.size()));
 
-        ignite.sendIoTest(node, null, false).get();
+        IgniteIoTestMessage msg0 = (IgniteIoTestMessage)ignite.sendIoTest(node, null, false).get();
+
+        long sndWrite = msg0.reqWriteTime - msg0.reqSndTime;
+        long reqWriteRead = msg0.reqReadTime - msg0.reqWriteTime;
+        long reqReadResSnd = msg0.resSndTime - msg0.reqReadTime;
+        long resSndWrite = msg0.resWriteTime - msg0.resSndTime;
+        long resWriteRead = msg0.resReadTime - msg0.resWriteTime;
+        long resReadProc = msg0.resTime - msg0.resReadTime;
+
+        long sndWriteSum = this.sndWrite.addAndGet(sndWrite);
+        long reqWriteReadSum = this.reqWriteRead.addAndGet(reqWriteRead);
+        long reqReadResSndSum = this.reqReadResSnd.addAndGet(reqReadResSnd);
+        long resSndWriteSum = this.resSndWrite.addAndGet(resSndWrite);
+        long resWriteReadSum = this.resWriteRead.addAndGet(resWriteRead);
+        long resReadProcSum = this.resReadProc.addAndGet(resReadProc);
+
+        long cntr = this.cntr.incrementAndGet();
 
         return true;
     }


Mime
View raw message