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 2020/05/08 10:09:35 UTC
[ignite] branch master updated: IGNITE-12990 Remove static thread
group from IgniteSpiThread and add test - Fixes #7780.
This is an automated email from the ASF dual-hosted git repository.
agoncharuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 3bba34a IGNITE-12990 Remove static thread group from IgniteSpiThread and add test - Fixes #7780.
3bba34a is described below
commit 3bba34ad61086f71d3846d80d14e5b8d9a3570e1
Author: Alexey Goncharuk <al...@gmail.com>
AuthorDate: Fri May 8 13:08:24 2020 +0300
IGNITE-12990 Remove static thread group from IgniteSpiThread and add test - Fixes #7780.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
---
.../org/apache/ignite/spi/IgniteSpiThread.java | 5 +-
.../org/apache/ignite/thread/IgniteThread.java | 10 ++++
.../internal/IgniteThreadGroupNodeRestartTest.java | 59 ++++++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 5 +-
4 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiThread.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiThread.java
index 754049b..33e3c51 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiThread.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiThread.java
@@ -31,9 +31,6 @@ import org.apache.ignite.thread.IgniteThread;
* </ul>
*/
public abstract class IgniteSpiThread extends IgniteThread {
- /** Default thread's group. */
- public static final ThreadGroup DFLT_GRP = new ThreadGroup("ignite-spi");
-
/** Number of all system threads in the system. */
private static final AtomicLong cntr = new AtomicLong();
@@ -48,7 +45,7 @@ public abstract class IgniteSpiThread extends IgniteThread {
* @param log Grid logger to use.
*/
protected IgniteSpiThread(String igniteInstanceName, String name, IgniteLogger log) {
- super(igniteInstanceName, DFLT_GRP, createName(cntr.incrementAndGet(), name, igniteInstanceName));
+ super(igniteInstanceName, createName(cntr.incrementAndGet(), name, igniteInstanceName));
assert log != null;
diff --git a/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java b/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java
index f9d1eb2..515feec 100644
--- a/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java
+++ b/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java
@@ -73,6 +73,16 @@ public class IgniteThread extends Thread {
*
* @param igniteInstanceName Name of the Ignite instance this thread is created for.
* @param threadName Name of thread.
+ */
+ public IgniteThread(String igniteInstanceName, String threadName) {
+ this(igniteInstanceName, threadName, null);
+ }
+
+ /**
+ * Creates grid thread with given name for a given Ignite instance.
+ *
+ * @param igniteInstanceName Name of the Ignite instance this thread is created for.
+ * @param threadName Name of thread.
* @param r Runnable to execute.
*/
public IgniteThread(String igniteInstanceName, String threadName, Runnable r) {
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteThreadGroupNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteThreadGroupNodeRestartTest.java
new file mode 100644
index 0000000..a828b9a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteThreadGroupNodeRestartTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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 java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class IgniteThreadGroupNodeRestartTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception if failed.
+ */
+ @Test
+ public void testNodeRestartInsideThreadGroup() throws Exception {
+ ThreadGroup tg = new ThreadGroup("test group");
+
+ AtomicReference<Exception> err = new AtomicReference<>();
+
+ Thread t = new Thread(tg, () -> {
+ try {
+ startGrid(0);
+
+ stopGrid(0);
+ }
+ catch (Exception e) {
+ err.set(e);
+ }
+ });
+
+ t.start();
+ t.join(getTestTimeout());
+
+ if (err.get() != null)
+ throw err.get();
+
+ tg.destroy();
+
+ startGrid(0);
+ stopGrid(0);
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 2cb5f51..c0e7822 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -46,6 +46,7 @@ import org.apache.ignite.internal.GridStartStopSelfTest;
import org.apache.ignite.internal.GridStopWithCancelSelfTest;
import org.apache.ignite.internal.IgniteLocalNodeMapBeforeStartTest;
import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest;
+import org.apache.ignite.internal.IgniteThreadGroupNodeRestartTest;
import org.apache.ignite.internal.MarshallerContextLockingSelfTest;
import org.apache.ignite.internal.TransactionsMXBeanImplTest;
import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesMultipleConnectionsTest;
@@ -293,7 +294,9 @@ import org.junit.runners.Suite;
IgniteStandardMXBeanTest.class,
- ClusterActivationStartedEventTest.class
+ ClusterActivationStartedEventTest.class,
+
+ IgniteThreadGroupNodeRestartTest.class
})
public class IgniteBasicTestSuite {
}