Skip to content

Commit c5d62cb

Browse files
authored
Support forkjoinpool plugin in JDK11 (#656)
1 parent fdc1e97 commit c5d62cb

13 files changed

Lines changed: 540 additions & 4 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
name: Test
18+
19+
on:
20+
pull_request:
21+
paths:
22+
- '.github/workflows/plugins-*.yaml'
23+
- 'apm-application-toolkit/**'
24+
- 'apm-commons/**'
25+
- 'apm-protocol/**'
26+
- 'apm-sniffer/**'
27+
- 'test/plugin/**'
28+
- '**/pom.xml'
29+
- '!**.md'
30+
31+
concurrency:
32+
group: plugins-jdk11-3-${{ github.event.pull_request.number || github.ref }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
build:
37+
name: Build
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 30
40+
steps:
41+
- uses: actions/checkout@v2
42+
with:
43+
submodules: true
44+
- name: Build
45+
uses: ./.github/actions/build
46+
with:
47+
base_image_java: eclipse-temurin:11-jdk
48+
49+
test:
50+
needs: [ build ]
51+
name: ${{ matrix.case }}
52+
runs-on: ubuntu-latest
53+
timeout-minutes: 90
54+
strategy:
55+
matrix:
56+
case:
57+
- jdk11-forkjoinpool-scenario
58+
steps:
59+
- uses: actions/checkout@v2
60+
with:
61+
submodules: true
62+
- uses: actions/setup-java@v2
63+
with:
64+
distribution: temurin
65+
java-version: 11
66+
- name: Run Plugin Test
67+
uses: ./.github/actions/run
68+
with:
69+
test_case: ${{ matrix.case }}

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Release Notes.
55
9.2.0
66
------------------
77

8-
* Fix NoSuchMethodError in mvc-annotation-commons and change deprecated method
9-
8+
* Fix NoSuchMethodError in mvc-annotation-commons and change deprecated method.
9+
* fix forkjoinpool plugin in JDK11。
1010

1111
#### Documentation
1212

apm-sniffer/bootstrap-plugins/jdk-forkjoinpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/forkjoinpool/define/ForkJoinWorkerQueueInstrumentation.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.skywalking.apm.plugin.jdk.forkjoinpool.define;
2020

21-
import static net.bytebuddy.matcher.ElementMatchers.named;
21+
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
2222

2323
import net.bytebuddy.description.method.MethodDescription;
2424
import net.bytebuddy.matcher.ElementMatcher;
@@ -33,6 +33,17 @@ public class ForkJoinWorkerQueueInstrumentation extends ClassInstanceMethodsEnha
3333
private static final String FORK_JOIN_WORKER_QUEUE_CLASS = "java.util.concurrent.ForkJoinPool$WorkQueue";
3434

3535
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD = "runTask";
36+
37+
/**
38+
* The runWorker method is one of the core methods of ForkJoinPool,
39+
* responsible for retrieving tasks from the work queue and executing them.
40+
* <p>
41+
* Within the runWorker method, it calls the scan method to search and execute tasks.
42+
* <p>
43+
* in java11+ ForkJoinPool. scan calls WorkQueue.topLevelExec, in JAVA8 it calls WorkQueue.runTask.
44+
*/
45+
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_JDK11 = "topLevelExec";
46+
3647
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jdk.forkjoinpool.ForkJoinWorkerQueueMethodInterceptor";
3748

3849
@Override
@@ -51,7 +62,7 @@ public InstanceMethodsInterceptV2Point[] getInstanceMethodsInterceptV2Points() {
5162
new InstanceMethodsInterceptV2Point() {
5263
@Override
5364
public ElementMatcher<MethodDescription> getMethodsMatcher() {
54-
return named(FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD);
65+
return namedOneOf(FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD, FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_JDK11);
5566
}
5667

5768
@Override
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
home="$(cd "$(dirname $0)"; pwd)"
20+
21+
java -jar ${agent_opts} ${home}/../libs/jdk11-forkjoinpool-scenario.jar &
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
segmentItems:
17+
- serviceName: jdk11-forkjoinpool-scenario
18+
segmentSize: ge 3
19+
segments:
20+
- segmentId: not null
21+
spans:
22+
- operationName: '/apache/skywalking'
23+
parentSpanId: 0
24+
spanId: 1
25+
spanLayer: Http
26+
startTime: nq 0
27+
endTime: nq 0
28+
componentId: 13
29+
isError: false
30+
spanType: Exit
31+
peer: 'github.com:443'
32+
tags:
33+
- {key: url, value: 'https://github.com/apache/skywalking'}
34+
- {key: http.method, value: GET}
35+
- {key: http.status_code, value: '200'}
36+
skipAnalysis: 'false'
37+
- operationName: 'ForkJoinPool/java.util.concurrent.ForkJoinPool$WorkQueue/topLevelExec'
38+
parentSpanId: -1
39+
spanId: 0
40+
spanLayer: Unknown
41+
startTime: nq 0
42+
endTime: nq 0
43+
componentId: 80
44+
isError: false
45+
spanType: Local
46+
peer: ''
47+
refs:
48+
- {parentEndpoint: 'GET:/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario', networkAddress: '', refType: CrossThread,
49+
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
50+
null, parentService: jdk11-forkjoinpool-scenario, traceId: not null}
51+
skipAnalysis: 'false'
52+
- segmentId: not null
53+
spans:
54+
- operationName: '/apache/skywalking'
55+
parentSpanId: 0
56+
spanId: 1
57+
spanLayer: Http
58+
startTime: nq 0
59+
endTime: nq 0
60+
componentId: 13
61+
isError: false
62+
spanType: Exit
63+
peer: 'github.com:443'
64+
tags:
65+
- {key: url, value: 'https://github.com/apache/skywalking'}
66+
- {key: http.method, value: GET}
67+
- {key: http.status_code, value: '200'}
68+
skipAnalysis: 'false'
69+
- operationName: 'GET:/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario'
70+
parentSpanId: -1
71+
spanId: 0
72+
spanLayer: Http
73+
startTime: nq 0
74+
endTime: nq 0
75+
componentId: 1
76+
isError: false
77+
spanType: Entry
78+
tags:
79+
- {key: url, value: 'http://localhost:8080/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario'}
80+
- {key: http.method, value: GET}
81+
- {key: http.status_code, value: '200'}
82+
peer: ''
83+
skipAnalysis: 'false'
84+
85+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
type: jvm
18+
entryService: http://localhost:8080/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario
19+
healthCheck: http://localhost:8080/jdk11-forkjoinpool-scenario/case/healthCheck
20+
runningMode: with_bootstrap
21+
withPlugins: apm-jdk-forkjoinpool-plugin-*.jar
22+
startScript: ./bin/startup.sh
23+
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
23+
<groupId>org.apache.skywalking.apm.testcase</groupId>
24+
<artifactId>jdk11-forkjoinpool-scenario</artifactId>
25+
<version>1.0.0</version>
26+
<packaging>jar</packaging>
27+
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<properties>
31+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32+
<compiler.version>11</compiler.version>
33+
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
34+
<test.framework.version>YOUR VERSION</test.framework.version>
35+
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
36+
<lombok.version>1.18.20</lombok.version>
37+
</properties>
38+
39+
<name>skywalking-jdk11-forkjoinpool-scenario</name>
40+
41+
<dependencyManagement>
42+
<dependencies>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-dependencies</artifactId>
46+
<version>${spring.boot.version}</version>
47+
<type>pom</type>
48+
<scope>import</scope>
49+
</dependency>
50+
</dependencies>
51+
</dependencyManagement>
52+
53+
<dependencies>
54+
<dependency>
55+
<groupId>org.springframework.boot</groupId>
56+
<artifactId>spring-boot-starter-web</artifactId>
57+
<exclusions>
58+
<exclusion>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-starter-logging</artifactId>
61+
</exclusion>
62+
</exclusions>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.springframework.boot</groupId>
66+
<artifactId>spring-boot-starter-log4j2</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.projectlombok</groupId>
70+
<artifactId>lombok</artifactId>
71+
<version>${lombok.version}</version>
72+
<scope>provided</scope>
73+
</dependency>
74+
</dependencies>
75+
76+
<build>
77+
<finalName>jdk11-forkjoinpool-scenario</finalName>
78+
<plugins>
79+
<plugin>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-maven-plugin</artifactId>
82+
<version>${spring.boot.version}</version>
83+
<executions>
84+
<execution>
85+
<goals>
86+
<goal>repackage</goal>
87+
</goals>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
<plugin>
92+
<artifactId>maven-compiler-plugin</artifactId>
93+
<version>${maven-compiler-plugin.version}</version>
94+
<configuration>
95+
<source>${compiler.version}</source>
96+
<target>${compiler.version}</target>
97+
<encoding>${project.build.sourceEncoding}</encoding>
98+
</configuration>
99+
</plugin>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-assembly-plugin</artifactId>
103+
<executions>
104+
<execution>
105+
<id>assemble</id>
106+
<phase>package</phase>
107+
<goals>
108+
<goal>single</goal>
109+
</goals>
110+
<configuration>
111+
<descriptors>
112+
<descriptor>src/main/assembly/assembly.xml</descriptor>
113+
</descriptors>
114+
<outputDirectory>./target/</outputDirectory>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
</plugins>
120+
</build>
121+
</project>

0 commit comments

Comments
 (0)