ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [31/50] ignite git commit: IGNITE-2767: Cont. query remote filter requires to be in client nodes class path. Reviewed and merged by Denis Magda.
Date Mon, 20 Jun 2016 12:53:11 GMT
IGNITE-2767: Cont. query remote filter requires to be in client nodes class path.
Reviewed and merged by Denis Magda.


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

Branch: refs/heads/ignite-3341
Commit: 377b387eff8d678f85f9d49c1a351e72cccfe105
Parents: 1cb291c
Author: Vladislav Pyatkov <vldpyatkov@gmail.com>
Authored: Wed Jun 15 17:18:27 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Wed Jun 15 17:18:27 2016 +0300

----------------------------------------------------------------------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   7 +-
 ...yRemoteFilterMissingInClassPathSelfTest.java | 237 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite3.java         |   2 +
 3 files changed, 245 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/377b387e/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 73b541f..308830e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -51,6 +51,7 @@ import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.AddressResolver;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.GridComponent;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
@@ -1713,7 +1714,11 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
                 data0.put(entry.getKey(), compData);
             }
             catch (IgniteCheckedException e) {
-                U.error(log, "Failed to unmarshal discovery data for component: "  + entry.getKey(),
e);
+                if (GridComponent.DiscoveryDataExchangeType.CONTINUOUS_PROC.ordinal() ==
entry.getKey() &&
+                    X.hasCause(e, ClassNotFoundException.class) && locNode.isClient())
+                    U.warn(log, "Failed to unmarshal continuous query remote filter on client
node. Can be ignored.");
+                else
+                    U.error(log, "Failed to unmarshal discovery data for component: "  +
entry.getKey(), e);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/377b387e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
new file mode 100644
index 0000000..37f4e01
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
@@ -0,0 +1,237 @@
+/*
+ * 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.query.continuous;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridStringLogger;
+import org.apache.ignite.testframework.config.GridTestProperties;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ *
+ */
+public class ContinuousQueryRemoteFilterMissingInClassPathSelfTest extends GridCommonAbstractTest
{
+    /** URL of classes. */
+    private static final URL[] URLS;
+
+    static {
+        try {
+            URLS = new URL[] {new URL(GridTestProperties.getProperty("p2p.uri.cls"))};
+        }
+        catch (MalformedURLException e) {
+            throw new RuntimeException("Define property p2p.uri.cls", e);
+        }
+    }
+
+    /** */
+    private GridStringLogger log;
+
+    /** */
+    private boolean clientMode;
+
+    /** */
+    private boolean setExternalLoader;
+
+    /** */
+    private ClassLoader ldr;
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String name) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(name);
+
+        cfg.setClientMode(clientMode);
+
+        CacheConfiguration cacheCfg = new CacheConfiguration();
+
+        cacheCfg.setName("simple");
+
+        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        if (setExternalLoader)
+            cfg.setClassLoader(ldr);
+        else
+            cfg.setGridLogger(log);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If fail.
+     */
+    public void testWarningMessageOnClientNode() throws Exception {
+        ldr = new URLClassLoader(URLS, getClass().getClassLoader());
+
+        clientMode = false;
+        setExternalLoader = true;
+        final Ignite ignite0 = startGrid(1);
+
+        executeContiniouseQuery(ignite0.cache("simple"));
+
+        log = new GridStringLogger();
+        clientMode = true;
+        setExternalLoader = false;
+
+        startGrid(2);
+
+        assertTrue(log.toString().contains("Failed to unmarshal continuous query remote filter
on client node. " +
+            "Can be ignored."));
+    }
+
+    /**
+     * @throws Exception If fail.
+     */
+    public void testNoWarningMessageOnClientNode() throws Exception {
+        ldr = new URLClassLoader(URLS, getClass().getClassLoader());
+
+        setExternalLoader = true;
+
+        clientMode = false;
+        final Ignite ignite0 = startGrid(1);
+
+        executeContiniouseQuery(ignite0.cache("simple"));
+
+        log = new GridStringLogger();
+        clientMode = true;
+
+        startGrid(2);
+
+        assertTrue(!log.toString().contains("Failed to unmarshal continuous query remote
filter on client node. " +
+            "Can be ignored."));
+    }
+
+    /**
+     * @throws Exception If fail.
+     */
+    public void testExceptionOnServerNode() throws Exception {
+        ldr = new URLClassLoader(URLS, getClass().getClassLoader());
+
+        clientMode = false;
+
+        setExternalLoader = true;
+        final Ignite ignite0 = startGrid(1);
+
+        executeContiniouseQuery(ignite0.cache("simple"));
+
+        log = new GridStringLogger();
+        setExternalLoader = false;
+
+        startGrid(2);
+
+        assertTrue(log.toString().contains("class org.apache.ignite.IgniteCheckedException:
" +
+            "Failed to find class with given class loader for unmarshalling"));
+    }
+
+    /**
+     * @throws Exception If fail.
+     */
+    public void testNoExceptionOnServerNode() throws Exception {
+        ldr = new URLClassLoader(URLS, getClass().getClassLoader());
+
+        clientMode = false;
+
+        setExternalLoader = true;
+        final Ignite ignite0 = startGrid(1);
+
+        executeContiniouseQuery(ignite0.cache("simple"));
+
+        log = new GridStringLogger();
+
+        startGrid(2);
+
+        assertTrue(!log.toString().contains("class org.apache.ignite.IgniteCheckedException:
" +
+            "Failed to find class with given class loader for unmarshalling"));
+    }
+
+    /**
+     * @param cache Ignite cache.
+     * @throws Exception If fail.
+     */
+    private void executeContiniouseQuery(IgniteCache cache) throws Exception {
+        ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
+
+        qry.setLocalListener(
+            new CacheEntryUpdatedListener<Integer, String>() {
+                @Override public void onUpdated(Iterable<CacheEntryEvent<? extends
Integer, ? extends String>> events)
+                    throws CacheEntryListenerException {
+                    for (CacheEntryEvent<? extends Integer, ? extends String> event
: events)
+                        System.out.println("Key = " + event.getKey() + ", Value = " + event.getValue());
+                }
+            }
+        );
+
+        final Class<CacheEntryEventSerializableFilter> remoteFilterClass = (Class<CacheEntryEventSerializableFilter>)
+            ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCacheEntryEventSerializableFilter");
+
+        qry.setRemoteFilterFactory(new ClassFilterFactory(remoteFilterClass));
+
+        cache.query(qry);
+
+        for (int i = 0; i < 100; i++)
+            cache.put(i, "Message " + i);
+    }
+
+    /**
+     *
+     */
+    private static class ClassFilterFactory implements Factory<CacheEntryEventFilter<Integer,
String>> {
+        /** */
+        private Class<CacheEntryEventSerializableFilter> cls;
+
+        /**
+         * @param cls Class.
+         */
+        public ClassFilterFactory(Class<CacheEntryEventSerializableFilter> cls) {
+            this.cls = cls;
+        }
+
+        /** {@inheritDoc} */
+        @Override public CacheEntryEventSerializableFilter<Integer, String> create()
{
+            try {
+                return cls.newInstance();
+            }
+            catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/377b387e/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
index dbef1fb..7ad7ad5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBin
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationStoreEnabledTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationSwapEnabledTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryRemoteFilterMissingInClassPathSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapTieredTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapValuesTest;
@@ -112,6 +113,7 @@ public class IgniteCacheQuerySelfTestSuite3 extends TestSuite {
         suite.addTestSuite(CacheContinuousBatchForceServerModeAckTest.class);
         suite.addTestSuite(CacheContinuousQueryExecuteInPrimaryTest.class);
         suite.addTestSuite(CacheContinuousQueryLostPartitionTest.class);
+        suite.addTestSuite(ContinuousQueryRemoteFilterMissingInClassPathSelfTest.class);
         suite.addTestSuite(IgniteCacheContinuousQueryImmutableEntryTest.class);
         suite.addTestSuite(CacheKeepBinaryIterationTest.class);
         suite.addTestSuite(CacheKeepBinaryIterationStoreEnabledTest.class);


Mime
View raw message