ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/16] ignite git commit: Added more logging for direct message read errors.
Date Fri, 15 Jan 2016 12:09:20 GMT
Added more logging for direct message read errors.


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

Branch: refs/heads/ignite-1811
Commit: 8b0c59a25822e69bd2fe896685be5e921b859e26
Parents: b409b8d
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Jan 14 16:42:46 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Jan 14 16:42:46 2016 +0300

----------------------------------------------------------------------
 .../internal/direct/DirectMessageReader.java    | 11 +++++
 .../internal/direct/DirectMessageWriter.java    | 13 +++++
 .../direct/state/DirectMessageState.java        | 10 ++++
 .../stream/v1/DirectByteBufferStreamImplV1.java |  8 +++
 .../stream/v2/DirectByteBufferStreamImplV2.java |  8 +++
 .../internal/util/nio/GridDirectParser.java     | 52 +++++++++++++-------
 .../communication/tcp/TcpCommunicationSpi.java  |  9 +++-
 7 files changed, 92 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
index e0b7b22..10bc7e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
 import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -373,6 +374,11 @@ public class DirectMessageReader implements MessageReader {
         state.reset();
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageReader.class, this);
+    }
+
     /**
      */
     private static class StateItem implements DirectMessageStateItem {
@@ -407,5 +413,10 @@ public class DirectMessageReader implements MessageReader {
         @Override public void reset() {
             state = 0;
         }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return S.toString(StateItem.class, this);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
index 085cf68..730f9bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
@@ -27,6 +27,8 @@ import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
 import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -39,6 +41,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public class DirectMessageWriter implements MessageWriter {
     /** State. */
+    @GridToStringInclude
     private final DirectMessageState<StateItem> state;
 
     /**
@@ -327,6 +330,11 @@ public class DirectMessageWriter implements MessageWriter {
         state.reset();
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageWriter.class, this);
+    }
+
     /**
      */
     private static class StateItem implements DirectMessageStateItem {
@@ -364,5 +372,10 @@ public class DirectMessageWriter implements MessageWriter {
             state = 0;
             hdrWritten = false;
         }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return S.toString(StateItem.class, this);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
b/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
index a61bb30..8ad7fe0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
@@ -18,6 +18,9 @@
 package org.apache.ignite.internal.direct.state;
 
 import java.lang.reflect.Array;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 
 /**
@@ -28,9 +31,11 @@ public class DirectMessageState<T extends DirectMessageStateItem>
{
     private static final int INIT_SIZE = 10;
 
     /** Item factory. */
+    @GridToStringExclude
     private final IgniteOutClosure<T> factory;
 
     /** Stack array. */
+    @GridToStringInclude
     private T[] stack;
 
     /** Current position. */
@@ -95,4 +100,9 @@ public class DirectMessageState<T extends DirectMessageStateItem>
{
 
         stack[0].reset();
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageState.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
index ad8671d..5292f35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
@@ -28,6 +28,8 @@ import java.util.NoSuchElementException;
 import java.util.UUID;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -217,6 +219,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream
{
     private static final Object NULL = new Object();
 
     /** */
+    @GridToStringExclude
     private final MessageFactory msgFactory;
 
     /** */
@@ -1347,6 +1350,11 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream
{
         };
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectByteBufferStreamImplV1.class, this);
+    }
+
     /**
      * Array creator.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index 89c9cc6..ed3eb7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -29,6 +29,8 @@ import java.util.RandomAccess;
 import java.util.UUID;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -218,6 +220,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream
{
     private static final Object NULL = new Object();
 
     /** */
+    @GridToStringExclude
     private final MessageFactory msgFactory;
 
     /** */
@@ -1570,6 +1573,11 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream
{
         }
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectByteBufferStreamImplV2.class, this);
+    }
+
     /**
      * Array creator.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/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 aa88808..76e7d4d 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
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+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;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -37,19 +39,24 @@ public class GridDirectParser implements GridNioParser {
     private static final int READER_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
 
     /** */
+    private final IgniteLogger log;
+
+    /** */
     private final MessageFactory msgFactory;
 
     /** */
     private final GridNioMessageReaderFactory readerFactory;
 
     /**
+     * @param log Logger.
      * @param msgFactory Message factory.
      * @param readerFactory Message reader factory.
      */
-    public GridDirectParser(MessageFactory msgFactory, GridNioMessageReaderFactory readerFactory)
{
+    public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMessageReaderFactory
readerFactory) {
         assert msgFactory != null;
         assert readerFactory != null;
 
+        this.log = log;
         this.msgFactory = msgFactory;
         this.readerFactory = readerFactory;
     }
@@ -64,28 +71,39 @@ public class GridDirectParser implements GridNioParser {
 
         Message msg = ses.removeMeta(MSG_META_KEY);
 
-        if (msg == null && buf.hasRemaining())
-            msg = msgFactory.create(buf.get());
+        try {
+            if (msg == null && buf.hasRemaining())
+                msg = msgFactory.create(buf.get());
 
-        boolean finished = false;
+            boolean finished = false;
 
-        if (buf.hasRemaining()) {
-            if (reader != null)
-                reader.setCurrentReadClass(msg.getClass());
+            if (buf.hasRemaining()) {
+                if (reader != null)
+                    reader.setCurrentReadClass(msg.getClass());
 
-            finished = msg.readFrom(buf, reader);
-        }
+                finished = msg.readFrom(buf, reader);
+            }
 
-        if (finished) {
-            if (reader != null)
-                reader.reset();
+            if (finished) {
+                if (reader != null)
+                    reader.reset();
 
-            return msg;
-        }
-        else {
-            ses.addMeta(MSG_META_KEY, msg);
+                return msg;
+            }
+            else {
+                ses.addMeta(MSG_META_KEY, msg);
 
-            return null;
+                return null;
+            }
+        }
+        catch (Throwable e) {
+            U.error(log, "Failed to read message [msg=" + msg +
+                ", buf=" + buf +
+                ", reader=" + reader +
+                ", ses=" + ses + "]",
+                e);
+
+            throw e;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/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 6cdfe9a..918bc83 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
@@ -1611,7 +1611,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     }
                 };
 
-                GridDirectParser parser = new GridDirectParser(msgFactory, readerFactory);
+                GridDirectParser parser = new GridDirectParser(log.getLogger(GridDirectParser.class),
+                    msgFactory,
+                    readerFactory);
 
                 IgnitePredicate<Message> skipRecoveryPred = new IgnitePredicate<Message>()
{
                     @Override public boolean apply(Message msg) {
@@ -2983,7 +2985,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     endpoint,
                     srvLsnr,
                     writerFactory,
-                    new GridNioCodecFilter(new GridDirectParser(msgFactory, readerFactory),
log, true),
+                    new GridNioCodecFilter(
+                        new GridDirectParser(log.getLogger(GridDirectParser.class),msgFactory,
readerFactory),
+                        log,
+                        true),
                     new GridConnectionBytesVerifyFilter(log)
                 );
 


Mime
View raw message