Support monitor grizzly thread pool (#533)
diff --git a/.github/workflows/plugins-jdk17-test.0.yaml b/.github/workflows/plugins-jdk17-test.0.yaml
index a4e7684..556214b 100644
--- a/.github/workflows/plugins-jdk17-test.0.yaml
+++ b/.github/workflows/plugins-jdk17-test.0.yaml
@@ -61,6 +61,7 @@
- jetty-thread-pool-scenario
- jetty-11.x-thread-pool-scenario
- grizzly-2.3.x-4.x-scenario
+ - grizzly-2.3.x-4.x-workthreadpool-scenario
steps:
- uses: actions/checkout@v2
with:
diff --git a/CHANGES.md b/CHANGES.md
index 9392da0..b87d8aa 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,6 +17,7 @@
* Change the classloader to locate the agent path in AgentPackagePath, from `SystemClassLoader` to AgentPackagePath's loader.
* Support Grizzly Trace
* Fix possible IllegalStateException when using Micrometer.
+* Support Grizzly Work ThreadPool Metric Monitor
#### Documentation
diff --git a/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/pom.xml
new file mode 100644
index 0000000..c6a01c3
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>apm-sdk-plugin</artifactId>
+ <version>8.16.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>apm-grizzly-2.x-4.x-work-threadpool-plugin</artifactId>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <grizzly.version>2.4.0</grizzly.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish.grizzly</groupId>
+ <artifactId>grizzly-framework</artifactId>
+ <version>${grizzly.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/TransportInterceptor.java b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/TransportInterceptor.java
new file mode 100644
index 0000000..5845736
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/TransportInterceptor.java
@@ -0,0 +1,74 @@
+/*
+ * 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.skywalking.apm.plugin.grizzly.workthreadpool;
+
+import org.apache.skywalking.apm.agent.core.meter.MeterFactory;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.glassfish.grizzly.threadpool.AbstractThreadPool;
+import org.glassfish.grizzly.threadpool.GrizzlyExecutorService;
+import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class TransportInterceptor implements InstanceMethodsAroundInterceptor {
+
+ private static final String METER_NAME = "thread_pool";
+ private static final String METRIC_POOL_NAME_TAG_NAME = "pool_name";
+ private static final String THREAD_POOL_NAME = "grizzly_execute_pool";
+ private static final String METRIC_TYPE_TAG_NAME = "metric_type";
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
+ GrizzlyExecutorService executorServices = (GrizzlyExecutorService) allArguments[0];
+ // reflect get private field just once
+ Field poolField = GrizzlyExecutorService.class.getDeclaredField("pool");
+ poolField.setAccessible(true);
+ AbstractThreadPool abstractThreadPool = (AbstractThreadPool) poolField.get(executorServices);
+ ThreadPoolConfig threadPoolConfig = abstractThreadPool.getConfig();
+ MeterFactory.gauge(METER_NAME, () -> (double) threadPoolConfig.getCorePoolSize())
+ .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME)
+ .tag(METRIC_TYPE_TAG_NAME, "core_pool_size")
+ .build();
+ MeterFactory.gauge(METER_NAME, () -> (double) threadPoolConfig.getMaxPoolSize())
+ .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME)
+ .tag(METRIC_TYPE_TAG_NAME, "max_pool_size")
+ .build();
+ MeterFactory.gauge(METER_NAME, () -> (double) abstractThreadPool.getSize())
+ .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME)
+ .tag(METRIC_TYPE_TAG_NAME, "pool_size")
+ .build();
+ MeterFactory.gauge(METER_NAME, () -> (double) abstractThreadPool.getQueue().size())
+ .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME)
+ .tag(METRIC_TYPE_TAG_NAME, "queue_size")
+ .build();
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/AbstractWitnessInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/AbstractWitnessInstrumentation.java
new file mode 100644
index 0000000..a18ea31
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/AbstractWitnessInstrumentation.java
@@ -0,0 +1,37 @@
+/*
+ * 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.skywalking.apm.plugin.grizzly.workthreadpool.define;
+
+import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+
+import java.util.Collections;
+import java.util.List;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+public abstract class AbstractWitnessInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected List<WitnessMethod> witnessMethods() {
+ return Collections.singletonList(new WitnessMethod(
+ "org.glassfish.grizzly.http.server.HttpHandler",
+ named("runService")
+ ));
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/TransportInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/TransportInstrumentation.java
new file mode 100644
index 0000000..a3ca30e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/grizzly/workthreadpool/define/TransportInstrumentation.java
@@ -0,0 +1,66 @@
+/*
+ * 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.skywalking.apm.plugin.grizzly.workthreadpool.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+public class TransportInstrumentation extends AbstractWitnessInstrumentation {
+ private static final String ENHANCE_CLASS = "org.glassfish.grizzly.AbstractTransport";
+
+ private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.grizzly.workthreadpool.TransportInterceptor";
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[]{
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named("setWorkerThreadPool0");
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPTOR_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000..3aa8274
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grizzly-2.3.x-4.x-work-threadpool-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,17 @@
+# 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.
+
+grizzly-2.3.x-4.x-threadpool=org.apache.skywalking.apm.plugin.grizzly.workthreadpool.define.TransportInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml
index 2f31e72..d8673df 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -130,6 +130,7 @@
<module>jersey-2.x-plugin</module>
<module>jersey-3.x-plugin</module>
<module>grizzly-2.3.x-4.x-plugin</module>
+ <module>grizzly-2.3.x-4.x-work-threadpool-plugin</module>
</modules>
<packaging>pom</packaging>
diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md
index 6121cb6..92beac6 100644
--- a/docs/en/setup/service-agent/java-agent/Plugin-list.md
+++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md
@@ -162,3 +162,4 @@
- jersey-2.x
- jersey-3.x
- grizzly-2.3.x-4.x
+- grizzly-2.3.x-4.x-threadpool
diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md
index 77abc6a..d6e71f4 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -158,6 +158,7 @@
* [Tomcat](https://github.com/apache/tomcat) 7.0.x -> 10.0.x
* [Dubbo](https://github.com/apache/dubbo) 2.5.x -> 2.7.x
* [Jetty](https://github.com/eclipse/jetty.project) 9.1.x -> 11.x
+ * [Grizzly](https://github.com/eclipse-ee4j/grizzly) 2.3.x -> 4.x
___
¹Due to license incompatibilities/restrictions these plugins are hosted and released in 3rd part repository,
go to [SkyAPM java plugin extension repository](https://github.com/SkyAPM/java-plugin-extensions) to get these.
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/bin/startup.sh b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/bin/startup.sh
new file mode 100644
index 0000000..be26f8c
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/bin/startup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# 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.
+
+home="$(cd "$(dirname $0)"; pwd)"
+
+java -jar ${agent_opts} ${home}/../libs/grizzly-2.3.x-4.x-workthreadpool-scenario.jar &
\ No newline at end of file
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/config/expectedData.yaml b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/config/expectedData.yaml
new file mode 100644
index 0000000..da0f47c
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/config/expectedData.yaml
@@ -0,0 +1,43 @@
+# 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.
+meterItems:
+ - serviceName: grizzly-2.3.x-4.x-workthreadpool-scenario
+ meterSize: 4
+ meters:
+ - meterId:
+ name: thread_pool
+ tags:
+ - {name: metric_type, value: core_pool_size}
+ - {name: pool_name, value: grizzly_execute_pool}
+ singleValue: ge 1
+ - meterId:
+ name: thread_pool
+ tags:
+ - {name: metric_type, value: max_pool_size}
+ - {name: pool_name, value: grizzly_execute_pool}
+ singleValue: ge 1
+ - meterId:
+ name: thread_pool
+ tags:
+ - {name: metric_type, value: pool_size}
+ - {name: pool_name, value: grizzly_execute_pool}
+ singleValue: ge 0
+ - meterId:
+ name: thread_pool
+ tags:
+ - {name: metric_type, value: queue_size}
+ - {name: pool_name, value: grizzly_execute_pool}
+ singleValue: ge 0
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/configuration.yml b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/configuration.yml
new file mode 100644
index 0000000..6fd3dc6
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/configuration.yml
@@ -0,0 +1,22 @@
+# 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.
+
+type: jvm
+entryService: http://localhost:18181/grizzly-2.3.x-4.x-workthreadpool-scenario/case/grizzly-2.3.x-4.x-workthreadpool-scenario
+healthCheck: http://localhost:18181/grizzly-2.3.x-4.x-workthreadpool-scenario/case/healthCheck
+startScript: ./bin/startup.sh
+environment:
+dependencies:
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/pom.xml b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/pom.xml
new file mode 100644
index 0000000..b6b10fe
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <groupId>test.apache.skywalking.apm.testcase</groupId>
+ <artifactId>grizzly-2.3.x-4.x-workthreadpool-scenario</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <compiler.version>1.8</compiler.version>
+ <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
+
+ <test.framework.version>4.0.0</test.framework.version>
+
+ <log4j.version>2.6.2</log4j.version>
+ </properties>
+
+ <name>skywalking-grizzly-2.3.x-4.x-workthreadpool-scenario</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish.grizzly</groupId>
+ <artifactId>grizzly-http-server</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <finalName>grizzly-2.3.x-4.x-workthreadpool-scenario</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>
+ test.apache.skywalking.apm.testcase.grizzly.workthreadpool.Application
+ </mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${compiler.version}</source>
+ <target>${compiler.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ <outputDirectory>./target/</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..f52cdfa
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>./bin</directory>
+ <fileMode>0775</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${project.build.directory}/grizzly-2.3.x-4.x-workthreadpool-scenario.jar</source>
+ <outputDirectory>./libs</outputDirectory>
+ <fileMode>0775</fileMode>
+ </file>
+ </files>
+</assembly>
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/Application.java b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/Application.java
new file mode 100644
index 0000000..95d0de9
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/Application.java
@@ -0,0 +1,61 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.grizzly.workthreadpool;
+
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.grizzly.http.server.NetworkListener;
+import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
+import org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder;
+import org.glassfish.grizzly.strategies.SameThreadIOStrategy;
+import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
+import test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller.CaseHandler;
+import test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller.HealCheckHandler;
+import test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller.ReceiveContextHandler;
+
+import java.io.IOException;
+
+public class Application {
+
+ public static void main(String[] args) throws IOException, InterruptedException {
+ HttpServer server = new HttpServer();
+ NetworkListener networkListener = new NetworkListener("grizzly-scenariotest",
+ "0.0.0.0", 18181);
+ final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
+ TCPNIOTransport transport = builder
+ .setIOStrategy(SameThreadIOStrategy.getInstance())
+ .setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig()
+ .setPoolName("Grizzly-worker")
+ .setCorePoolSize(100)
+ .setMaxPoolSize(100)
+ .setMemoryManager(builder.getMemoryManager()))
+ .build();
+ networkListener.setTransport(transport);
+ server.addListener(networkListener);
+ server.getServerConfiguration().addHttpHandler(new CaseHandler(),
+ "/grizzly-2.3.x-4.x-workthreadpool-scenario/case/grizzly-2.3.x-4.x-workthreadpool-scenario");
+ server.getServerConfiguration()
+ .addHttpHandler(new HealCheckHandler(),
+ "/grizzly-2.3.x-4.x-workthreadpool-scenario/case/healthCheck");
+ server.getServerConfiguration().addHttpHandler(new ReceiveContextHandler(),
+ "/grizzly-2.3.x-4.x-workthreadpool-scenario/case/receive-context");
+ server.start();
+ Thread.sleep(10000);
+ System.in.read();
+ }
+}
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/CaseHandler.java b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/CaseHandler.java
new file mode 100644
index 0000000..30a7826
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/CaseHandler.java
@@ -0,0 +1,45 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller;
+
+import com.squareup.okhttp.OkHttpClient;
+import java.io.IOException;
+import org.glassfish.grizzly.http.server.HttpHandler;
+import org.glassfish.grizzly.http.server.Request;
+import org.glassfish.grizzly.http.server.Response;
+
+public class CaseHandler extends HttpHandler {
+
+ @Override
+ public void service(Request request, Response response) throws Exception {
+
+ com.squareup.okhttp.Request okhttpRequest = new com.squareup.okhttp.Request.Builder().url(
+ "http://127.0.0.1:18181/grizzly-2.3.x-4.x-workthreadpool-scenario/case/receive-context")
+ .build();
+ try {
+ new OkHttpClient().newCall(okhttpRequest).execute();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ String hello = "hello";
+ response.setContentType("text/plain");
+ response.setContentLength(hello.length());
+ response.getWriter().write(hello);
+ }
+}
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/HealCheckHandler.java b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/HealCheckHandler.java
new file mode 100644
index 0000000..8ee3963
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/HealCheckHandler.java
@@ -0,0 +1,34 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller;
+
+import org.glassfish.grizzly.http.server.HttpHandler;
+import org.glassfish.grizzly.http.server.Request;
+import org.glassfish.grizzly.http.server.Response;
+
+public class HealCheckHandler extends HttpHandler {
+
+ @Override
+ public void service(Request request, Response response) throws Exception {
+ String hello = "hello";
+ response.setContentType("text/plain");
+ response.setContentLength(hello.length());
+ response.getWriter().write(hello);
+ }
+}
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/ReceiveContextHandler.java b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/ReceiveContextHandler.java
new file mode 100644
index 0000000..c1d37c2
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/src/main/java/test/apache/skywalking/apm/testcase/grizzly/workthreadpool/controller/ReceiveContextHandler.java
@@ -0,0 +1,34 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.grizzly.workthreadpool.controller;
+
+import org.glassfish.grizzly.http.server.HttpHandler;
+import org.glassfish.grizzly.http.server.Request;
+import org.glassfish.grizzly.http.server.Response;
+
+public class ReceiveContextHandler extends HttpHandler {
+
+ @Override
+ public void service(Request request, Response response) throws Exception {
+ String hello = "hello";
+ response.setContentType("text/plain");
+ response.setContentLength(hello.length());
+ response.getWriter().write(hello);
+ }
+}
diff --git a/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/support-version.list b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/support-version.list
new file mode 100644
index 0000000..c39f58f
--- /dev/null
+++ b/test/plugin/scenarios/grizzly-2.3.x-4.x-workthreadpool-scenario/support-version.list
@@ -0,0 +1,20 @@
+# 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.
+
+2.3.35
+2.4.4
+3.0.1
+4.0.0