ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [12/18] ignite git commit: IGNITE-4812 - Disabled EventStorageSpi by default. This fixes #1623.
Date Mon, 10 Apr 2017 14:13:40 GMT
IGNITE-4812 - Disabled EventStorageSpi by default. This fixes #1623.


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

Branch: refs/heads/ignite-4929
Commit: 139efb10aac41fa0ba242793fc5d922cee31a9d5
Parents: 512b7af
Author: Valentin Kulichenko <valentin.lulichenko@gmail.com>
Authored: Sun Apr 9 14:22:52 2017 +0200
Committer: Valentin Kulichenko <valentin.lulichenko@gmail.com>
Committed: Sun Apr 9 14:22:52 2017 +0200

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      |  4 +-
 .../ignite/internal/IgniteEventsImpl.java       |  8 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  4 +-
 .../eventstorage/GridEventStorageManager.java   | 12 ++-
 .../spi/eventstorage/NoopEventStorageSpi.java   | 53 +++++++++++
 .../GridEventStorageDefaultExceptionTest.java   | 94 ++++++++++++++++++++
 .../testframework/junits/GridAbstractTest.java  |  3 +
 .../testsuites/IgniteComputeGridTestSuite.java  |  2 +
 .../ignite/internal/GridFactorySelfTest.java    |  3 +
 9 files changed, 175 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index b8e718d..49ae9bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -66,7 +66,7 @@ import org.apache.ignite.spi.deployment.local.LocalDeploymentSpi;
 import org.apache.ignite.spi.discovery.DiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.eventstorage.EventStorageSpi;
-import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
+import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi;
 import org.apache.ignite.spi.failover.FailoverSpi;
 import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi;
 import org.apache.ignite.spi.indexing.IndexingSpi;
@@ -1591,7 +1591,7 @@ public class IgniteConfiguration {
 
     /**
      * Should return fully configured event SPI implementation. If not provided,
-     * {@link MemoryEventStorageSpi} will be used.
+     * {@link NoopEventStorageSpi} will be used.
      *
      * @return Grid event SPI implementation or {@code null} to use default implementation.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
index 9acccab..030e2db 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
@@ -78,8 +78,7 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents>
implemen
     }
 
     /** {@inheritDoc} */
-    @Override public <T extends Event> List<T> remoteQuery(IgnitePredicate<T>
p, long timeout,
-        @Nullable int... types) {
+    @Override public <T extends Event> List<T> remoteQuery(IgnitePredicate<T>
p, long timeout, @Nullable int... types) {
         A.notNull(p, "p");
 
         guard();
@@ -248,6 +247,9 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents>
implemen
         try {
             return ctx.event().localEvents(compoundPredicate(p, types));
         }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
+        }
         finally {
             unguard();
         }
@@ -400,4 +402,4 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents>
implemen
     protected Object readResolve() throws ObjectStreamException {
         return prj.events();
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 1b8f920..7e99c77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -93,7 +93,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.deployment.local.LocalDeploymentSpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
-import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
+import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi;
 import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi;
 import org.apache.ignite.spi.indexing.noop.NoopIndexingSpi;
 import org.apache.ignite.spi.loadbalancing.LoadBalancingSpi;
@@ -2184,7 +2184,7 @@ public class IgnitionEx {
                 cfg.setDeploymentSpi(new LocalDeploymentSpi());
 
             if (cfg.getEventStorageSpi() == null)
-                cfg.setEventStorageSpi(new MemoryEventStorageSpi());
+                cfg.setEventStorageSpi(new NoopEventStorageSpi());
 
             if (cfg.getCheckpointSpi() == null)
                 cfg.setCheckpointSpi(new NoopCheckpointSpi());

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/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 77bd7d4..d49463e 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
@@ -61,6 +61,8 @@ import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.security.SecurityPermission;
 import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.eventstorage.EventStorageSpi;
+import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi;
+import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
@@ -954,9 +956,17 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
      * @return Collection of grid events.
      */
     @SuppressWarnings("unchecked")
-    public <T extends Event> Collection<T> localEvents(IgnitePredicate<T>
p) {
+    public <T extends Event> Collection<T> localEvents(IgnitePredicate<T>
p) throws IgniteCheckedException {
         assert p != null;
 
+        if (getSpi() instanceof NoopEventStorageSpi) {
+            throw new IgniteCheckedException(
+                "Failed to query events because default no-op event storage SPI is used.
" +
+                "Consider configuring " + MemoryEventStorageSpi.class.getSimpleName() + "
or another " +
+                EventStorageSpi.class.getSimpleName() + " implementation via " +
+                "IgniteConfiguration.setEventStorageSpi() configuration property.");
+        }
+
         if (p instanceof PlatformEventFilterListener) {
             PlatformEventFilterListener p0 = (PlatformEventFilterListener)p;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/NoopEventStorageSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/NoopEventStorageSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/NoopEventStorageSpi.java
new file mode 100644
index 0000000..41cf7f6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/NoopEventStorageSpi.java
@@ -0,0 +1,53 @@
+/*
+ * 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.spi.eventstorage;
+
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.IgniteSpiMultipleInstancesSupport;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * No-op implementation of {@link EventStorageSpi}.
+ */
+@IgniteSpiMultipleInstancesSupport(true)
+public class NoopEventStorageSpi extends IgniteSpiAdapter implements EventStorageSpi {
+    /** {@inheritDoc} */
+    @Override public <T extends Event> Collection<T> localEvents(IgnitePredicate<T>
p) {
+        return Collections.emptyList();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void record(Event evt) throws IgniteSpiException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void spiStop() throws IgniteSpiException {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java
new file mode 100644
index 0000000..2cf727e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Event storage tests with default no-op spi.
+ */
+@GridCommonTest(group = "Kernal Self")
+public class GridEventStorageDefaultExceptionTest  extends GridCommonAbstractTest {
+    /** */
+    public GridEventStorageDefaultExceptionTest() {
+        super(/*start grid*/true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(final String gridName) throws
Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setEventStorageSpi(new NoopEventStorageSpi());
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testLocalNodeEventStorage() throws Exception {
+        try {
+            grid().events().localQuery(F.<Event>alwaysTrue());
+
+            assert false : "Exception must be thrown.";
+        }
+        catch (IgniteException e) {
+            assertTrue(
+                "Wrong exception message: " + e.getMessage(),
+                e.getMessage().startsWith("Failed to query events because default no-op event
storage SPI is used."));
+        }
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoteNodeEventStorage() throws Exception {
+        try {
+            grid().events().remoteQuery(F.<Event>alwaysTrue(), 0);
+
+            assert false : "Exception should be thrown";
+        }
+        catch (IgniteException e) {
+            assertTrue(
+                "Wrong exception message: " + e.getMessage(),
+                e.getMessage().startsWith("Failed to query events due to exception on remote
node."));
+
+            boolean found = false;
+
+            Throwable t = e;
+
+            while ((t = t.getCause()) != null) {
+                if (t instanceof IgniteCheckedException && t.getMessage().startsWith(
+                        "Failed to query events because default no-op event storage SPI is
used.")) {
+                    found = true;
+
+                    break;
+                }
+            }
+
+            assertTrue("Incorrect exception thrown.", found);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 1bb4540..bfdf635 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -90,6 +90,7 @@ import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.config.GridTestProperties;
 import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
@@ -1498,6 +1499,8 @@ public abstract class GridAbstractTest extends TestCase {
 
         cfg.setCheckpointSpi(cpSpi);
 
+        cfg.setEventStorageSpi(new MemoryEventStorageSpi());
+
         cfg.setIncludeEventTypes(EventType.EVTS_ALL);
 
         return cfg;

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
index 810c488..41042f1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.GridCollisionJobsContextSelfTest;
 import org.apache.ignite.internal.GridDeploymentMultiThreadedSelfTest;
 import org.apache.ignite.internal.GridDeploymentSelfTest;
 import org.apache.ignite.internal.GridEventStorageCheckAllEventsSelfTest;
+import org.apache.ignite.internal.GridEventStorageDefaultExceptionTest;
 import org.apache.ignite.internal.GridEventStorageRuntimeConfigurationSelfTest;
 import org.apache.ignite.internal.GridEventStorageSelfTest;
 import org.apache.ignite.internal.GridFailoverCustomTopologySelfTest;
@@ -141,6 +142,7 @@ public class IgniteComputeGridTestSuite {
         suite.addTestSuite(GridTaskNameAnnotationSelfTest.class);
         suite.addTestSuite(GridJobCheckpointCleanupSelfTest.class);
         suite.addTestSuite(GridEventStorageSelfTest.class);
+        suite.addTestSuite(GridEventStorageDefaultExceptionTest.class);
         suite.addTestSuite(GridFailoverTaskWithPredicateSelfTest.class);
         suite.addTestSuite(GridProjectionLocalJobMultipleArgumentsSelfTest.class);
         suite.addTestSuite(GridAffinitySelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/139efb10/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
index 7764d46..75128fc 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
@@ -59,6 +59,7 @@ import org.apache.ignite.spi.collision.CollisionSpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.config.GridTestProperties;
 import org.apache.ignite.testframework.http.GridEmbeddedHttpServer;
@@ -317,6 +318,8 @@ public class GridFactorySelfTest extends GridCommonAbstractTest {
         cfg.setLifecycleBeans(bean1, bean2);
         cfg.setIgniteInstanceName(igniteInstanceName);
 
+        cfg.setEventStorageSpi(new MemoryEventStorageSpi());
+
         cfg.setConnectorConfiguration(null);
 
         try (Ignite g = IgniteSpring.start(cfg, new GenericApplicationContext())) {


Mime
View raw message