You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/11/14 12:14:10 UTC
ignite git commit: IGNITE-10235 Do not register cache in QueryManager
twice if parallel caches start is disabled - Fixes #5381.
Repository: ignite
Updated Branches:
refs/heads/master bb3bbb930 -> 00b9e89e7
IGNITE-10235 Do not register cache in QueryManager twice if parallel caches start is disabled - Fixes #5381.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/00b9e89e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/00b9e89e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/00b9e89e
Branch: refs/heads/master
Commit: 00b9e89e7add9c58ed9a996aaba9200267c71961
Parents: bb3bbb9
Author: Sergey Antonov <an...@gmail.com>
Authored: Wed Nov 14 15:12:56 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 14 15:12:56 2018 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 7 +-
.../cache/StartCachesInParallelTest.java | 148 +++++++++++++++++++
...acheWithIndexingAndPersistenceTestSuite.java | 2 +
3 files changed, 154 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/00b9e89e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 7ba4ff9..23c3623 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2195,12 +2195,13 @@ public class GridCacheProcessor extends GridProcessorAdapter {
) throws IgniteCheckedException {
GridCacheContext cacheCtx = prepareCacheContext(startCfg, desc, reqNearCfg, exchTopVer, disabledAfterStart);
- ctx.query().onCacheStart(cacheCtx, desc.schema() != null ? desc.schema() : new QuerySchema(), desc.sql());
-
if (cacheCtx.isRecoveryMode())
finishRecovery(exchTopVer, cacheCtx);
- else
+ else {
+ ctx.query().onCacheStart(cacheCtx, desc.schema() != null ? desc.schema() : new QuerySchema(), desc.sql());
+
onCacheStarted(cacheCtx);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/00b9e89e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
new file mode 100644
index 0000000..e48c294
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.Ignite;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.failure.FailureContext;
+import org.apache.ignite.failure.StopNodeFailureHandler;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_ALLOW_START_CACHES_IN_PARALLEL;
+
+/**
+ * Tests, that cluster could start and activate with all possible values of IGNITE_ALLOW_START_CACHES_IN_PARALLEL.
+ */
+public class StartCachesInParallelTest extends GridCommonAbstractTest {
+ /** IGNITE_ALLOW_START_CACHES_IN_PARALLEL option value before tests. */
+ private String allowParallel;
+
+ /** Test failure handler. */
+ private TestStopNodeFailureHandler failureHnd;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setDataStorageConfiguration(
+ new DataStorageConfiguration()
+ .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
+
+ cfg.setCacheConfiguration(
+ new CacheConfiguration<>()
+ .setName(DEFAULT_CACHE_NAME)
+ .setIndexedTypes(Integer.class, Integer.class));
+
+ failureHnd = new TestStopNodeFailureHandler();
+
+ cfg.setFailureHandler(failureHnd);
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ allowParallel = System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ if (allowParallel != null)
+ System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, allowParallel);
+ else
+ System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
+ }
+
+ /** */
+ public void testWithEnabledOption() throws Exception {
+ doTest("true");
+ }
+
+ /** */
+ public void testWithDisabledOption() throws Exception {
+ doTest("false");
+ }
+
+ /** */
+ public void testWithoutOption() throws Exception {
+ doTest(null);
+ }
+
+ /**
+ * Test routine.
+ *
+ * @param optionVal IGNITE_ALLOW_START_CACHES_IN_PARALLEL value.
+ * @throws Exception If failed.
+ */
+ private void doTest(String optionVal) throws Exception {
+ if (optionVal == null)
+ System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
+ else {
+ Boolean.parseBoolean(optionVal);
+
+ System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, optionVal);
+ }
+
+ assertEquals("Property wasn't set", optionVal, System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL));
+
+ IgniteEx node = startGrid(0);
+
+ node.cluster().active(true);
+
+ assertNull("Node failed with " + failureHnd.lastFailureCtx, failureHnd.lastFailureCtx);
+
+ assertTrue(node.cluster().active());
+ }
+
+ /** */
+ private static class TestStopNodeFailureHandler extends StopNodeFailureHandler {
+ /** Last failure context. */
+ private volatile FailureContext lastFailureCtx;
+
+ /** {@inheritDoc} */
+ @Override public boolean handle(Ignite ignite, FailureContext failureCtx) {
+ lastFailureCtx = failureCtx;
+
+ return super.handle(ignite, failureCtx);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/00b9e89e/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java
index 1bc60f6..2f3ddec 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java
@@ -18,6 +18,7 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.StartCachesInParallelTest;
import org.apache.ignite.util.GridCommandHandlerIndexingTest;
/**
@@ -32,6 +33,7 @@ public class IgniteCacheWithIndexingAndPersistenceTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Cache With Indexing And Persistence Test Suite");
suite.addTestSuite(GridCommandHandlerIndexingTest.class);
+ suite.addTestSuite(StartCachesInParallelTest.class);
return suite;
}