ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [42/50] [abbrv] ignite git commit: IGNITE-2190 ScanQuery without a filter triggers object's deserialization on the server side
Date Fri, 28 Jul 2017 12:07:54 GMT
IGNITE-2190 ScanQuery without a filter triggers object's deserialization on the server side


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

Branch: refs/heads/ignite-5658
Commit: 2941392213d2d3d9632a30d1726502d31a12e938
Parents: 7a6af69
Author: Nikolay Izhikov <NIzhikov.dev@gmail.com>
Authored: Thu Jul 27 19:00:08 2017 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Thu Jul 27 19:00:08 2017 +0300

----------------------------------------------------------------------
 .../eventstorage/GridEventStorageManager.java   | 14 +++++++++
 .../cache/query/GridCacheQueryManager.java      | 24 ++++++++++++----
 .../IgniteCacheBinaryObjectsScanSelfTest.java   |  9 +++++-
 ...acheBinaryObjectsScanWithEventsSelfTest.java | 30 ++++++++++++++++++++
 .../IgniteBinaryCacheQueryTestSuite.java        |  2 ++
 5 files changed, 73 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/29413922/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 944420f..2b9a5ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -534,6 +534,20 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
     }
 
     /**
+     * Checks whether this event type has any listener.
+     *
+     * @param type Event type to check.
+     * @return Whether or not this event type has any listener.
+     */
+    public boolean hasListener(int type) {
+        assert type > 0 : "Invalid event type: " + type;
+
+        Listeners listeners = lsnrs.get(type);
+
+        return (listeners != null) && (!F.isEmpty(listeners.highPriorityLsnrs) ||
!F.isEmpty(listeners.lsnrs));
+    }
+
+    /**
      * Checks whether all provided events are user-recordable.
      * <p>
      * Note that this method supports only predefined Ignite events.

http://git-wip-us.apache.org/repos/asf/ignite/blob/29413922/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 0f47b7f..f107038 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -103,6 +103,7 @@ import org.apache.ignite.internal.util.typedef.T3;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiPredicate;
@@ -118,6 +119,7 @@ import org.apache.ignite.spi.indexing.IndexingSpi;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_QUIET;
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ;
@@ -1015,7 +1017,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                         metrics.addGetTimeNanos(System.nanoTime() - start);
                     }
 
-                    if (readEvt) {
+                    if (readEvt && cctx.gridEvents().hasListener(EVT_CACHE_QUERY_OBJECT_READ))
{
                         cctx.gridEvents().record(new CacheQueryReadEvent<K, V>(
                             cctx.localNode(),
                             "SQL fields query result set row read.",
@@ -1135,6 +1137,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
             boolean rmvIter = true;
 
+            GridCacheQueryAdapter<?> qry = qryInfo.query();
+
             try {
                 // Preparing query closures.
                 IgniteClosure<Cache.Entry<K, V>, Object> trans =
@@ -1145,8 +1149,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 injectResources(trans);
                 injectResources(rdc);
 
-                GridCacheQueryAdapter<?> qry = qryInfo.query();
-
                 int pageSize = qry.pageSize();
 
                 boolean incBackups = qry.includeBackups();
@@ -1245,7 +1247,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                     K key0 = null;
                     V val0 = null;
 
-                    if (readEvt) {
+                    if (readEvt && cctx.gridEvents().hasListener(EVT_CACHE_QUERY_OBJECT_READ))
{
                         key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
                         val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
 
@@ -1372,6 +1374,18 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 }
             }
             catch (Throwable e) {
+                if (X.hasCause(e, ClassNotFoundException.class) && !qry.keepBinary()
&& cctx.binaryMarshaller() &&
+                    !cctx.localNode().isClient() && !log.isQuiet()) {
+                    LT.warn(log, "Suggestion for the cause of ClassNotFoundException");
+                    LT.warn(log, "To disable, set -D" + IGNITE_QUIET + "=true");
+                    LT.warn(log, "  ^-- Ignite configured to use BinaryMarshaller but keepBinary
is false for " +
+                        "request");
+                    LT.warn(log, "  ^-- Server node need to load definition of data classes.
" +
+                        "It can be reason of ClassNotFoundException(consider IgniteCache.withKeepBinary
to fix)");
+                    LT.warn(log, "Refer this page for detailed information: " +
+                        "https://apacheignite.readme.io/docs/binary-marshaller");
+                }
+
                 if (!X.hasCause(e, GridDhtUnreservedPartitionException.class))
                     U.error(log, "Failed to run query [qry=" + qryInfo + ", node=" + cctx.nodeId()
+ "]", e);
 
@@ -1471,7 +1485,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                         metrics.addGetTimeNanos(System.nanoTime() - start);
                     }
 
-                    if (readEvt) {
+                    if (readEvt && cctx.gridEvents().hasListener(EVT_CACHE_QUERY_OBJECT_READ))
{
                         cctx.gridEvents().record(new CacheQueryReadEvent<>(
                             cctx.localNode(),
                             "Scan query entry read.",

http://git-wip-us.apache.org/repos/asf/ignite/blob/29413922/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
index e0da1f6..f18aebe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
@@ -75,7 +75,7 @@ public class IgniteCacheBinaryObjectsScanSelfTest extends GridCommonAbstractTest
         discoSpi.setIpFinder(IP_FINDER);
 
         cfg.setDiscoverySpi(discoSpi);
-        cfg.setIncludeEventTypes(new int[0]);
+        cfg.setIncludeEventTypes(getIncludeEventTypes());
 
         cfg.setMarshaller(null);
         cfg.setPeerClassLoadingEnabled(false);
@@ -90,6 +90,13 @@ public class IgniteCacheBinaryObjectsScanSelfTest extends GridCommonAbstractTest
     }
 
     /**
+     * @return EventTypes to record.
+     */
+    protected int[] getIncludeEventTypes() {
+        return new int[0];
+    }
+
+    /**
      * @param ldr Class loader.
      * @throws Exception If failed.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/29413922/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanWithEventsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanWithEventsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanWithEventsSelfTest.java
new file mode 100644
index 0000000..5746a34
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanWithEventsSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.events.EventType;
+
+/**
+ *
+ */
+public class IgniteCacheBinaryObjectsScanWithEventsSelfTest extends IgniteCacheBinaryObjectsScanSelfTest
{
+    /** {@inheritDoc} */
+    @Override protected int[] getIncludeEventTypes() {
+        return EventType.EVTS_ALL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/29413922/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index 1cfb345..8164fe0 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanWithEventsSelfTest;
 
 /**
  * Cache query suite with binary marshaller.
@@ -37,6 +38,7 @@ public class IgniteBinaryCacheQueryTestSuite extends TestSuite {
         suite.addTestSuite(BinarySerializationQuerySelfTest.class);
         suite.addTestSuite(BinarySerializationQueryWithReflectiveSerializerSelfTest.class);
         suite.addTestSuite(IgniteCacheBinaryObjectsScanSelfTest.class);
+        suite.addTestSuite(IgniteCacheBinaryObjectsScanWithEventsSelfTest.class);
 
         //Should be adjusted. Not ready to be used with BinaryMarshaller.
         //suite.addTestSuite(GridCacheBinarySwapScanQuerySelfTest.class);


Mime
View raw message