IGNITE-5775: Fix bug with delay for compute jobs. This closes #2319.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e285f9db Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e285f9db Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e285f9db Branch: refs/heads/ignite-5658 Commit: e285f9dbebc6fd86e81e52828813be9b9d2633f2 Parents: 02e2507 Author: Andrey V. Mashenkov <andrey.mashen...@gmail.com> Authored: Thu Jul 20 13:24:25 2017 +0300 Committer: Andrey V. Mashenkov <andrey.mashen...@gmail.com> Committed: Thu Jul 20 13:24:25 2017 +0300 ---------------------------------------------------------------------- .../processors/job/GridJobProcessor.java | 10 +-- .../internal/IgniteComputeJobOneThreadTest.java | 75 ++++++++++++++++++++ .../testsuites/IgniteComputeGridTestSuite.java | 3 + 3 files changed, 83 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e285f9db/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java index 7d2073e..cc8d903 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java @@ -1794,6 +1794,11 @@ public class GridJobProcessor extends GridProcessorAdapter { return; } + if (!activeJobs.remove(worker.getJobId(), worker)) + cancelledJobs.remove(worker.getJobId(), worker); + + heldJobs.remove(worker.getJobId()); + try { handleCollisions(); } @@ -1801,11 +1806,6 @@ public class GridJobProcessor extends GridProcessorAdapter { rwLock.readUnlock(); } } - - if (!activeJobs.remove(worker.getJobId(), worker)) - cancelledJobs.remove(worker.getJobId(), worker); - - heldJobs.remove(worker.getJobId()); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/e285f9db/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java new file mode 100644 index 0000000..76f669e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java @@ -0,0 +1,75 @@ +/* + * 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.Ignite; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.lang.IgniteRunnable; +import org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * Test of absence of gaps between jobs in compute + */ +public class IgniteComputeJobOneThreadTest extends GridCommonAbstractTest { + @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { + FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi(); + colSpi.setParallelJobsNumber(1); + + return super.getConfiguration(name) + .setMetricsUpdateFrequency(10000) + .setCollisionSpi(colSpi); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 10000; + } + + /** + * @throws Exception If failed. + */ + public void testNoTimeout() throws Exception { + Ignite ignite = ignite(0); + + IgniteFuture fut = null; + + for (int i = 0; i < 10000; i++) { + fut = ignite.compute().runAsync(new IgniteRunnable() { + @Override public void run() { + + } + }); + } + + fut.get(); + + assertTrue(true); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/e285f9db/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 3f3bc53..ac3de73 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 @@ -65,6 +65,7 @@ import org.apache.ignite.internal.GridTaskNameAnnotationSelfTest; import org.apache.ignite.internal.GridTaskResultCacheSelfTest; import org.apache.ignite.internal.GridTaskTimeoutSelfTest; import org.apache.ignite.internal.IgniteComputeEmptyClusterGroupTest; +import org.apache.ignite.internal.IgniteComputeJobOneThreadTest; import org.apache.ignite.internal.IgniteComputeTopologyExceptionTest; import org.apache.ignite.internal.IgniteExecutorServiceTest; import org.apache.ignite.internal.IgniteExplicitImplicitDeploymentSelfTest; @@ -163,6 +164,8 @@ public class IgniteComputeGridTestSuite { suite.addTestSuite(IgniteComputeCustomExecutorConfigurationSelfTest.class); suite.addTestSuite(IgniteComputeCustomExecutorSelfTest.class); + suite.addTestSuite(IgniteComputeJobOneThreadTest.class); + return suite; } }