未验证 提交 e575701f 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Support JDK 16 and 17. (#8005)

上级 a5685cb1
......@@ -33,7 +33,7 @@ jobs:
timeout-minutes: 90
strategy:
matrix:
jdk: [ 8, 11, 12, 13, 14, 15 ]
jdk: [ 8, 11, 12, 13, 14, 15, 16 ]
env:
SW_AGENT_JDK_VERSION: ${{ matrix.jdk }}
SW_OAP_BASE_IMAGE: adoptopenjdk/openjdk${{ matrix.jdk }}:alpine-jre
......
......@@ -24,6 +24,7 @@ Release Notes.
- Profile
- Kafka: Base, Meter, Log, Profile
- Client-JS
* Support JDK 16 and 17.
#### OAP Server
......
......@@ -15,7 +15,7 @@ SkyWalking's backend distribution package consists of the following parts:
## Requirements and default settings
Requirement: **JDK8 to JDK12 are tested**. Other versions are not tested and may or may not work.
Requirement: **JDK8 to JDK17 are tested**. Other versions are not tested and may or may not work.
Before you start, you should know that the main purpose of quickstart is to help you obtain a basic configuration for previews/demo. Performance and long-term running are not our goals.
......
......@@ -49,6 +49,8 @@ import javassist.bytecode.annotation.IntegerMemberValue;
import javassist.bytecode.annotation.StringMemberValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oal.rt.output.AllDispatcherContext;
import org.apache.skywalking.oal.rt.output.DispatcherContext;
......@@ -65,6 +67,9 @@ import org.apache.skywalking.oap.server.core.analysis.StreamAnnotationListener;
import org.apache.skywalking.oap.server.core.oal.rt.OALCompileException;
import org.apache.skywalking.oap.server.core.oal.rt.OALDefine;
import org.apache.skywalking.oap.server.core.oal.rt.OALEngine;
import org.apache.skywalking.oap.server.core.source.oal.rt.dispatcher.DispatcherClassPackageHolder;
import org.apache.skywalking.oap.server.core.source.oal.rt.metrics.MetricClassPackageHolder;
import org.apache.skywalking.oap.server.core.source.oal.rt.metrics.builder.MetricBuilderClassPackageHolder;
import org.apache.skywalking.oap.server.core.storage.StorageBuilderFactory;
import org.apache.skywalking.oap.server.core.storage.StorageException;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
......@@ -295,7 +300,8 @@ public class OALRuntime implements OALEngine {
constPool, AnnotationsAttribute.visibleTag);
Annotation streamAnnotation = new Annotation(Stream.class.getName(), constPool);
streamAnnotation.addMemberValue("name", new StringMemberValue(metricsStmt.getTableName(), constPool));
streamAnnotation.addMemberValue("scopeId", new IntegerMemberValue(constPool, metricsStmt.getFrom().getSourceScopeId()));
streamAnnotation.addMemberValue(
"scopeId", new IntegerMemberValue(constPool, metricsStmt.getFrom().getSourceScopeId()));
streamAnnotation.addMemberValue(
"builder", new ClassMemberValue(metricsBuilderClassName(metricsStmt, true), constPool));
streamAnnotation.addMemberValue("processor", new ClassMemberValue(METRICS_STREAM_PROCESSOR, constPool));
......@@ -305,7 +311,11 @@ public class OALRuntime implements OALEngine {
Class targetClass;
try {
targetClass = metricsClass.toClass(currentClassLoader, null);
if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) {
targetClass = metricsClass.toClass(currentClassLoader, null);
} else {
targetClass = metricsClass.toClass(MetricClassPackageHolder.class);
}
} catch (CannotCompileException e) {
log.error("Can't compile/load " + className + ".", e);
throw new OALCompileException(e.getMessage(), e);
......@@ -359,7 +369,11 @@ public class OALRuntime implements OALEngine {
}
try {
metricsBuilderClass.toClass(currentClassLoader, null);
if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) {
metricsBuilderClass.toClass(currentClassLoader, null);
} else {
metricsBuilderClass.toClass(MetricBuilderClassPackageHolder.class);
}
} catch (CannotCompileException e) {
log.error("Can't compile/load " + className + ".", e);
throw new OALCompileException(e.getMessage(), e);
......@@ -437,7 +451,11 @@ public class OALRuntime implements OALEngine {
Class targetClass;
try {
targetClass = dispatcherClass.toClass(currentClassLoader, null);
if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) {
targetClass = dispatcherClass.toClass(currentClassLoader, null);
} else {
targetClass = dispatcherClass.toClass(DispatcherClassPackageHolder.class);
}
} catch (CannotCompileException e) {
log.error("Can't compile/load " + className + ".", e);
throw new OALCompileException(e.getMessage(), e);
......
/*
* 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.oap.server.core.source.oal.rt.dispatcher;
/**
* DispatcherClassPackageHolder holds the package for generated metric classes.
*
* @since 8.9.0 for adopting JDK16+ to avoid `--add-opens java.base/java.lang=ALL-UNNAMED`
*/
public class DispatcherClassPackageHolder {
}
/*
* 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.oap.server.core.source.oal.rt.metrics;
/**
* MetricClassPackageHolder holds the package for generated metric classes.
*
* @since 8.9.0 for adopting JDK16+ to avoid `--add-opens java.base/java.lang=ALL-UNNAMED`
*/
public class MetricClassPackageHolder {
}
/*
* 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.oap.server.core.source.oal.rt.metrics.builder;
/**
* MetricBuilderClassPackageHolder holds the package for generated metric builder classes.
*
* @since 8.9.0 for adopting JDK16+ to avoid `--add-opens java.base/java.lang=ALL-UNNAMED`
*/
public class MetricBuilderClassPackageHolder {
}
......@@ -36,9 +36,12 @@ import javassist.NotFoundException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.apache.skywalking.oap.server.core.UnexpectedException;
import org.apache.skywalking.oap.server.core.analysis.StreamDefinition;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.meter.dynamic.MeterClassPackageHolder;
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
......@@ -103,8 +106,8 @@ public class MeterSystem implements Service {
* @throws UnexpectedException if binary code manipulation fails or stream core failure.
*/
public synchronized <T> void create(String metricsName,
String functionName,
ScopeType type) throws IllegalArgumentException {
String functionName,
ScopeType type) throws IllegalArgumentException {
final Class<? extends AcceptableValue> meterFunction = functionRegister.get(functionName);
if (meterFunction == null) {
......@@ -138,9 +141,9 @@ public class MeterSystem implements Service {
* @throws UnexpectedException if binary code manipulation fails or stream core failure.
*/
public synchronized <T> void create(String metricsName,
String functionName,
ScopeType type,
Class<T> dataType) throws IllegalArgumentException {
String functionName,
ScopeType type,
Class<T> dataType) throws IllegalArgumentException {
/**
* Create a new meter class dynamically.
*/
......@@ -191,11 +194,13 @@ public class MeterSystem implements Service {
*/
try {
CtClass existingMetric = classPool.get(METER_CLASS_PACKAGE + className);
if (existingMetric.getSuperclass() != parentClass || type != meterPrototypes.get(metricsName).getScopeType()) {
throw new IllegalArgumentException(metricsName + " has been defined, but calculate function or/are scope type is/are different.");
if (existingMetric.getSuperclass() != parentClass || type != meterPrototypes.get(metricsName)
.getScopeType()) {
throw new IllegalArgumentException(
metricsName + " has been defined, but calculate function or/are scope type is/are different.");
}
log.info("Metric {} is already defined, so skip the metric creation.", metricsName);
return ;
return;
} catch (NotFoundException e) {
}
......@@ -230,7 +235,11 @@ public class MeterSystem implements Service {
Class targetClass;
try {
targetClass = metricsClass.toClass(MeterSystem.class.getClassLoader(), null);
if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) {
targetClass = metricsClass.toClass(MeterSystem.class.getClassLoader(), null);
} else {
targetClass = metricsClass.toClass(MeterClassPackageHolder.class);
}
AcceptableValue prototype = (AcceptableValue) targetClass.newInstance();
meterPrototypes.put(metricsName, new MeterDefinition(type, prototype, dataType));
......
/*
* 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.oap.server.core.analysis.meter.dynamic;
/**
* MeterClassPackageHolder holds the package for generated meter classes.
*
* @since 8.9.0 for adopting JDK16+ to avoid `--add-opens java.base/java.lang=ALL-UNNAMED`
*/
public class MeterClassPackageHolder {
}
......@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.oal.rt;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oap.server.core.Const;
import static java.util.Objects.requireNonNull;
......@@ -32,18 +33,28 @@ import static java.util.Objects.requireNonNull;
@EqualsAndHashCode
public abstract class OALDefine {
protected OALDefine(final String configFile,
final String sourcePackage) {
this(configFile, sourcePackage, sourcePackage);
final String sourcePackage) {
this(configFile, sourcePackage, Const.EMPTY_STRING);
}
/**
* Define the booting parameters for OAL engine
*
* @param configFile OAL script file path
* @param sourcePackage the package path of source(s) used in given config OAL script file
* @param catalog of metrics defined through given OAL script file. Be used as prefix of generated dispatcher
* class name.
*/
protected OALDefine(final String configFile,
final String sourcePackage,
final String dispatcherPackage) {
final String catalog) {
this.configFile = requireNonNull(configFile);
this.sourcePackage = appendPoint(requireNonNull(sourcePackage));
this.dynamicMetricsClassPackage = appendPoint(sourcePackage + ".oal.rt.metrics");
this.dynamicMetricsBuilderClassPackage = appendPoint(sourcePackage + ".oal.rt.metrics.builder");
this.dynamicDispatcherClassPackage = appendPoint(dispatcherPackage + ".oal.rt.dispatcher");
this.dynamicMetricsClassPackage = "org.apache.skywalking.oap.server.core.source.oal.rt.metrics.";
this.dynamicMetricsBuilderClassPackage = "org.apache.skywalking.oap.server.core.source.oal.rt.metrics.builder.";
this.dynamicDispatcherClassPackage = StringUtil.isBlank(catalog) ?
"org.apache.skywalking.oap.server.core.source.oal.rt.dispatcher." :
"org.apache.skywalking.oap.server.core.source.oal.rt.dispatcher." + catalog;
}
private final String configFile;
......
......@@ -29,7 +29,7 @@ public class TCPOALDefine extends OALDefine {
super(
"oal/tcp.oal",
"org.apache.skywalking.oap.server.core.source",
"org.apache.skywalking.oap.server.core.source.tcp"
"EnvoyTCP"
);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册