This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git
commit 19a51f373d21aff5905b1bfa5b17eff2796d84c6 Author: Wu Sheng <[email protected]> AuthorDate: Wed Feb 18 18:18:11 2026 +0800 Add code style enforcement, use Lombok @Slf4j across modules - Copy checkStyle.xml from skywalking submodule to apm-checkstyle/ - Copy codeStyle.xml (IntelliJ IDEA) from skywalking submodule - Add oap-graalvm-server and oap-graalvm-native module POMs with Lombok dependency - Replace manual Logger/LoggerFactory with Lombok @Slf4j in GraalVMOAPServerStartUp and ModuleWiringBridge - All modules pass checkstyle validation Co-Authored-By: Claude Opus 4.6 <[email protected]> --- apm-checkstyle/checkStyle.xml | 118 ++++++++++ codeStyle.xml | 100 +++++++++ oap-graalvm-native/pom.xml | 45 ++++ oap-graalvm-server/pom.xml | 250 +++++++++++++++++++++ .../server/graalvm/GraalVMOAPServerStartUp.java | 240 ++++++++++++++++++++ .../server/library/module/FixedModuleManager.java | 70 ++++++ .../server/library/module/ModuleWiringBridge.java | 120 ++++++++++ 7 files changed, 943 insertions(+) diff --git a/apm-checkstyle/checkStyle.xml b/apm-checkstyle/checkStyle.xml new file mode 100755 index 0000000..096680e --- /dev/null +++ b/apm-checkstyle/checkStyle.xml @@ -0,0 +1,118 @@ +<?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. + ~ + --> + +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://checkstyle.org/dtds/configuration_1_3.dtd"> +<module name="Checker"> + + <property name="localeLanguage" value="en"/> + + <module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="System\.out\.println"/> + <property name="message" value="Prohibit invoking System.out.println in source code !"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="^\s*\*\s*@author"/> + <property name="minimum" value="0"/> + <property name="maximum" value="0"/> + <property name="message" value="ASF project doesn't allow @author copyright."/> + </module> + + <module name="RegexpSingleline"> + <property name="format" + value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/> + <property name="message" value="Not allow chinese character !"/> + </module> + + <module name="FileLength"> + <property name="max" value="3000"/> + </module> + + <module name="TreeWalker"> + + <module name="UnusedImports"/> + <module name="RedundantImport"/> + <module name="AvoidStarImport"/> + + <module name="NonEmptyAtclauseDescription"/> + + <!--Checks that classes that override equals() also override hashCode()--> + <module name="EqualsHashCode"/> + <!--Checks for over-complicated boolean expressions. Currently finds code like if (topic == true), topic || true, !false, etc.--> + <module name="SimplifyBooleanExpression"/> + <module name="OneStatementPerLine"/> + <module name="UnnecessaryParentheses"/> + <!--Checks for over-complicated boolean return statements. For example the following code--> + <module name="SimplifyBooleanReturn"/> + + <!--Check that the default is after all the cases in producerGroup switch statement--> + <module name="DefaultComesLast"/> + <!--Detects empty statements (standalone ";" semicolon)--> + <module name="EmptyStatement"/> + <!--Checks that long constants are defined with an upper ell--> + <module name="UpperEll"/> + <module name="ConstantName"> + <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/> + </module> + <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property--> + <module name="LocalVariableName"/> + <!--Validates identifiers for local, final variables, including catch parameters--> + <module name="LocalFinalVariableName"/> + <!--Validates identifiers for non-static fields--> + <module name="MemberName"/> + <!--Validates identifiers for class type parameters--> + <module name="ClassTypeParameterName"> + <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/> + </module> + <!--Validates identifiers for method type parameters--> + <module name="MethodTypeParameterName"> + <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/> + </module> + <module name="PackageName"> + <property name="format" value="^(org|test)\.apache\.skywalking(\.[a-zA-Z][a-zA-Z0-9]*)+$"/> + </module> + <module name="ParameterName"/> + <module name="StaticVariableName"> + <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/> + </module> + <module name="TypeName"> + <property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/> + </module> + <module name="MissingOverride"/> + + <!--whitespace--> + <module name="GenericWhitespace"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"/> + <module name="MethodParamPad"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="EmptyLineSeparator"> + <property name="allowNoEmptyLineBetweenFields" value="true"/> + <property name="allowMultipleEmptyLines" value="false"/> + <property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/> + </module> + </module> +</module> diff --git a/codeStyle.xml b/codeStyle.xml new file mode 100644 index 0000000..0db1200 --- /dev/null +++ b/codeStyle.xml @@ -0,0 +1,100 @@ +<code_scheme name="sky-walking" version="173"> + <option name="OTHER_INDENT_OPTIONS"> + <value> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </value> + </option> + <JavaCodeStyleSettings> + <option name="GENERATE_FINAL_LOCALS" value="true" /> + <option name="GENERATE_FINAL_PARAMETERS" value="true" /> + <option name="CLASS_NAMES_IN_JAVADOC" value="3" /> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> + <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> + <value /> + </option> + <option name="IMPORT_LAYOUT_TABLE"> + <value> + <package name="" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="true" /> + </value> + </option> + <option name="JD_P_AT_EMPTY_LINES" value="false" /> + <option name="JD_PRESERVE_LINE_FEEDS" value="true" /> + </JavaCodeStyleSettings> + <ADDITIONAL_INDENT_OPTIONS fileType="haml"> + <option name="INDENT_SIZE" value="2" /> + </ADDITIONAL_INDENT_OPTIONS> + <codeStyleSettings language="Groovy"> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="SPACE_AFTER_TYPE_CAST" value="false" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="HOCON"> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + </codeStyleSettings> + <codeStyleSettings language="JAVA"> + <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" /> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="BLANK_LINES_BEFORE_PACKAGE" value="1" /> + <option name="WHILE_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="CALL_PARAMETERS_WRAP" value="1" /> + <option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" /> + <option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" /> + <option name="METHOD_PARAMETERS_WRAP" value="5" /> + <option name="METHOD_CALL_CHAIN_WRAP" value="5" /> + <option name="ARRAY_INITIALIZER_WRAP" value="2" /> + <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" /> + <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" /> + <option name="WRAP_COMMENTS" value="true" /> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="JSON"> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + </codeStyleSettings> + <codeStyleSettings language="Scala"> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="WHILE_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <indentOptions> + <option name="INDENT_SIZE" value="4" /> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + <option name="TAB_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="XML"> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> +</code_scheme> \ No newline at end of file diff --git a/oap-graalvm-native/pom.xml b/oap-graalvm-native/pom.xml new file mode 100644 index 0000000..b91e86e --- /dev/null +++ b/oap-graalvm-native/pom.xml @@ -0,0 +1,45 @@ +<?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>skywalking-graalvm-distro</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + + <artifactId>oap-graalvm-native</artifactId> + <name>OAP GraalVM Native</name> + <description>GraalVM native-image build: Feature class, substitutions, and metadata</description> + + <dependencies> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>oap-graalvm-server</artifactId> + </dependency> + <dependency> + <groupId>org.graalvm.sdk</groupId> + <artifactId>nativeimage</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> +</project> \ No newline at end of file diff --git a/oap-graalvm-server/pom.xml b/oap-graalvm-server/pom.xml new file mode 100644 index 0000000..dfc7881 --- /dev/null +++ b/oap-graalvm-server/pom.xml @@ -0,0 +1,250 @@ +<?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>skywalking-graalvm-distro</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + + <artifactId>oap-graalvm-server</artifactId> + <name>OAP GraalVM Server</name> + <description>SkyWalking OAP server with fixed module wiring for GraalVM (JVM mode)</description> + + <dependencies> + <!-- Core --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>server-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>oal-rt</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>mqe-rt</artifactId> + </dependency> + + <!-- Storage: BanyanDB --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>storage-banyandb-plugin</artifactId> + </dependency> + + <!-- Cluster: Standalone --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>cluster-standalone-plugin</artifactId> + </dependency> + <!-- Cluster: Kubernetes --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>cluster-kubernetes-plugin</artifactId> + </dependency> + + <!-- Configuration: Kubernetes --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>configuration-k8s-configmap</artifactId> + </dependency> + + <!-- Analyzers --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>agent-analyzer</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>meter-analyzer</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>log-analyzer</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>event-analyzer</artifactId> + </dependency> + + <!-- Receivers --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-sharing-server-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-trace-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-management-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-jvm-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-mesh-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-meter-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-browser-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-log-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-event-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-profile-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-clr-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-ebpf-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-async-profiler-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-pprof-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-telegraf-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>skywalking-zabbix-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>zipkin-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>envoy-metrics-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>otel-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>configuration-discovery-receiver-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>aws-firehose-receiver</artifactId> + </dependency> + + <!-- Fetchers --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>kafka-fetcher-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>cilium-fetcher-plugin</artifactId> + </dependency> + + <!-- Query --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>query-graphql-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>promql-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>logql-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>zipkin-query-plugin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>status-query-plugin</artifactId> + </dependency> + + <!-- Alarm --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>server-alarm-plugin</artifactId> + </dependency> + + <!-- Telemetry: Prometheus --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>telemetry-prometheus</artifactId> + </dependency> + + <!-- Exporter --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>exporter</artifactId> + </dependency> + + <!-- Health Checker --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>server-health-checker</artifactId> + </dependency> + + <!-- AI Pipeline --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>ai-pipeline</artifactId> + </dependency> + + <!-- Server Starter (for ApplicationConfigLoader) --> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>server-starter</artifactId> + </dependency> + + <!-- Lombok --> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/graalvm/GraalVMOAPServerStartUp.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/graalvm/GraalVMOAPServerStartUp.java new file mode 100644 index 0000000..4771254 --- /dev/null +++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/graalvm/GraalVMOAPServerStartUp.java @@ -0,0 +1,240 @@ +/* + * 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.graalvm; + +import lombok.extern.slf4j.Slf4j; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.CoreModuleProvider; +import org.apache.skywalking.oap.server.core.RunningMode; +import org.apache.skywalking.oap.server.core.alarm.AlarmModule; +import org.apache.skywalking.oap.server.core.alarm.provider.AlarmModuleProvider; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.core.exporter.ExporterModule; +import org.apache.skywalking.oap.server.core.query.QueryModule; +import org.apache.skywalking.oap.server.core.status.ServerStatusService; +import org.apache.skywalking.oap.server.core.storage.StorageModule; +import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration; +import org.apache.skywalking.oap.server.library.module.FixedModuleManager; +import org.apache.skywalking.oap.server.library.module.TerminalFriendlyTable; +import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader; + +import static org.apache.skywalking.oap.server.library.module.TerminalFriendlyTable.Row; + +// Storage +import org.apache.skywalking.oap.server.storage.plugin.banyandb.BanyanDBStorageProvider; +// Cluster +import org.apache.skywalking.oap.server.cluster.plugin.standalone.ClusterModuleStandaloneProvider; +import org.apache.skywalking.oap.server.cluster.plugin.kubernetes.ClusterModuleKubernetesProvider; +// Configuration +import org.apache.skywalking.oap.server.configuration.api.ConfigurationModule; +import org.apache.skywalking.oap.server.configuration.configmap.ConfigmapConfigurationProvider; +// Telemetry +import org.apache.skywalking.oap.server.telemetry.TelemetryModule; +import org.apache.skywalking.oap.server.telemetry.prometheus.PrometheusTelemetryProvider; +// Analyzers +import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule; +import org.apache.skywalking.oap.server.analyzer.provider.AnalyzerModuleProvider; +import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule; +import org.apache.skywalking.oap.log.analyzer.provider.LogAnalyzerModuleProvider; +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerModule; +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerModuleProvider; +// Receivers +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule; +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModuleProvider; +import org.apache.skywalking.oap.server.receiver.register.module.RegisterModule; +import org.apache.skywalking.oap.server.receiver.register.provider.RegisterModuleProvider; +import org.apache.skywalking.oap.server.receiver.trace.module.TraceModule; +import org.apache.skywalking.oap.server.receiver.trace.provider.TraceModuleProvider; +import org.apache.skywalking.oap.server.receiver.jvm.module.JVMModule; +import org.apache.skywalking.oap.server.receiver.jvm.provider.JVMModuleProvider; +import org.apache.skywalking.oap.server.receiver.clr.module.CLRModule; +import org.apache.skywalking.oap.server.receiver.clr.provider.CLRModuleProvider; +import org.apache.skywalking.oap.server.receiver.profile.module.ProfileModule; +import org.apache.skywalking.oap.server.receiver.profile.provider.ProfileModuleProvider; +import org.apache.skywalking.oap.server.receiver.asyncprofiler.module.AsyncProfilerModule; +import org.apache.skywalking.oap.server.receiver.asyncprofiler.provider.AsyncProfilerModuleProvider; +import org.apache.skywalking.oap.server.receiver.pprof.module.PprofModule; +import org.apache.skywalking.oap.server.receiver.pprof.provider.PprofModuleProvider; +import org.apache.skywalking.oap.server.receiver.zabbix.module.ZabbixReceiverModule; +import org.apache.skywalking.oap.server.receiver.zabbix.provider.ZabbixReceiverProvider; +import org.apache.skywalking.aop.server.receiver.mesh.MeshReceiverModule; +import org.apache.skywalking.aop.server.receiver.mesh.MeshReceiverProvider; +import org.apache.skywalking.oap.server.receiver.envoy.EnvoyMetricReceiverModule; +import org.apache.skywalking.oap.server.receiver.envoy.EnvoyMetricReceiverProvider; +import org.apache.skywalking.oap.server.receiver.meter.module.MeterReceiverModule; +import org.apache.skywalking.oap.server.receiver.meter.provider.MeterReceiverProvider; +import org.apache.skywalking.oap.server.receiver.otel.OtelMetricReceiverModule; +import org.apache.skywalking.oap.server.receiver.otel.OtelMetricReceiverProvider; +import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinReceiverModule; +import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinReceiverProvider; +import org.apache.skywalking.oap.server.receiver.browser.module.BrowserModule; +import org.apache.skywalking.oap.server.receiver.browser.provider.BrowserModuleProvider; +import org.apache.skywalking.oap.server.receiver.log.module.LogModule; +import org.apache.skywalking.oap.server.receiver.log.provider.LogModuleProvider; +import org.apache.skywalking.oap.server.receiver.event.EventModule; +import org.apache.skywalking.oap.server.receiver.event.EventModuleProvider; +import org.apache.skywalking.oap.server.receiver.ebpf.module.EBPFReceiverModule; +import org.apache.skywalking.oap.server.receiver.ebpf.provider.EBPFReceiverProvider; +import org.apache.skywalking.oap.server.receiver.telegraf.module.TelegrafReceiverModule; +import org.apache.skywalking.oap.server.receiver.telegraf.provider.TelegrafReceiverProvider; +import org.apache.skywalking.oap.server.receiver.aws.firehose.AWSFirehoseReceiverModule; +import org.apache.skywalking.oap.server.receiver.aws.firehose.AWSFirehoseReceiverModuleProvider; +import org.apache.skywalking.oap.server.receiver.configuration.discovery.ConfigurationDiscoveryModule; +import org.apache.skywalking.oap.server.receiver.configuration.discovery.ConfigurationDiscoveryProvider; +// Fetchers +import org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherModule; +import org.apache.skywalking.oap.server.analyzer.agent.kafka.provider.KafkaFetcherProvider; +import org.apache.skywalking.oap.server.fetcher.cilium.CiliumFetcherModule; +import org.apache.skywalking.oap.server.fetcher.cilium.CiliumFetcherProvider; +// Query +import org.apache.skywalking.oap.query.graphql.GraphQLQueryProvider; +import org.apache.skywalking.oap.query.zipkin.ZipkinQueryModule; +import org.apache.skywalking.oap.query.zipkin.ZipkinQueryProvider; +import org.apache.skywalking.oap.query.promql.PromQLModule; +import org.apache.skywalking.oap.query.promql.PromQLProvider; +import org.apache.skywalking.oap.query.logql.LogQLModule; +import org.apache.skywalking.oap.query.logql.LogQLProvider; +import org.apache.skywalking.oap.query.debug.StatusQueryModule; +import org.apache.skywalking.oap.query.debug.StatusQueryProvider; +// Exporter +import org.apache.skywalking.oap.server.exporter.provider.ExporterProvider; +// Health Checker +import org.apache.skywalking.oap.server.health.checker.module.HealthCheckerModule; +import org.apache.skywalking.oap.server.health.checker.provider.HealthCheckerProvider; +// AI Pipeline +import org.apache.skywalking.oap.server.ai.pipeline.AIPipelineModule; +import org.apache.skywalking.oap.server.ai.pipeline.AIPipelineProvider; + +/** + * GraalVM-optimized OAP server startup with fixed module wiring. + * No ServiceLoader/SPI discovery — all modules and providers are directly constructed. + */ +@Slf4j +public class GraalVMOAPServerStartUp { + + public static void main(String[] args) { + start(); + } + + public static void start() { + FixedModuleManager manager = new FixedModuleManager("SkyWalking GraalVM OAP"); + final TerminalFriendlyTable bootingParameters = manager.getBootingParameters(); + + String mode = System.getProperty("mode"); + RunningMode.setMode(mode); + + ApplicationConfigLoader configLoader = new ApplicationConfigLoader(bootingParameters); + + bootingParameters.addRow(new Row("Running Mode", mode)); + bootingParameters.addRow(new Row("Distro", "GraalVM")); + + try { + ApplicationConfiguration configuration = configLoader.load(); + + // Register all modules with their fixed providers + registerAllModules(manager, configuration); + + // Initialize (prepare -> start -> notifyAfterCompleted) + manager.initFixed(configuration); + + manager.find(CoreModule.NAME) + .provider() + .getService(ServerStatusService.class) + .bootedNow(configLoader.getResolvedConfigurations(), System.currentTimeMillis()); + + if (RunningMode.isInitMode()) { + log.info("OAP starts up in init mode successfully, exit now..."); + System.exit(0); + } + } catch (Throwable t) { + log.error(t.getMessage(), t); + System.exit(1); + } finally { + log.info(bootingParameters.toString()); + } + } + + private static void registerAllModules(FixedModuleManager manager, ApplicationConfiguration configuration) { + // Core + manager.register(new CoreModule(), new CoreModuleProvider()); + // Cluster: standalone or kubernetes, selected by config + ApplicationConfiguration.ModuleConfiguration clusterConfig = configuration.getModuleConfiguration("cluster"); + if (clusterConfig != null && clusterConfig.has("kubernetes")) { + manager.register(new ClusterModule(), new ClusterModuleKubernetesProvider()); + } else { + manager.register(new ClusterModule(), new ClusterModuleStandaloneProvider()); + } + // Storage: BanyanDB + manager.register(new StorageModule(), new BanyanDBStorageProvider()); + // Configuration: Kubernetes ConfigMap + manager.register(new ConfigurationModule(), new ConfigmapConfigurationProvider()); + // Telemetry: Prometheus + manager.register(new TelemetryModule(), new PrometheusTelemetryProvider()); + + // Analyzers + manager.register(new AnalyzerModule(), new AnalyzerModuleProvider()); + manager.register(new LogAnalyzerModule(), new LogAnalyzerModuleProvider()); + manager.register(new EventAnalyzerModule(), new EventAnalyzerModuleProvider()); + + // Receivers + manager.register(new SharingServerModule(), new SharingServerModuleProvider()); + manager.register(new RegisterModule(), new RegisterModuleProvider()); + manager.register(new TraceModule(), new TraceModuleProvider()); + manager.register(new JVMModule(), new JVMModuleProvider()); + manager.register(new CLRModule(), new CLRModuleProvider()); + manager.register(new ProfileModule(), new ProfileModuleProvider()); + manager.register(new AsyncProfilerModule(), new AsyncProfilerModuleProvider()); + manager.register(new PprofModule(), new PprofModuleProvider()); + manager.register(new ZabbixReceiverModule(), new ZabbixReceiverProvider()); + manager.register(new MeshReceiverModule(), new MeshReceiverProvider()); + manager.register(new EnvoyMetricReceiverModule(), new EnvoyMetricReceiverProvider()); + manager.register(new MeterReceiverModule(), new MeterReceiverProvider()); + manager.register(new OtelMetricReceiverModule(), new OtelMetricReceiverProvider()); + manager.register(new ZipkinReceiverModule(), new ZipkinReceiverProvider()); + manager.register(new BrowserModule(), new BrowserModuleProvider()); + manager.register(new LogModule(), new LogModuleProvider()); + manager.register(new EventModule(), new EventModuleProvider()); + manager.register(new EBPFReceiverModule(), new EBPFReceiverProvider()); + manager.register(new TelegrafReceiverModule(), new TelegrafReceiverProvider()); + manager.register(new AWSFirehoseReceiverModule(), new AWSFirehoseReceiverModuleProvider()); + manager.register(new ConfigurationDiscoveryModule(), new ConfigurationDiscoveryProvider()); + + // Fetchers + manager.register(new KafkaFetcherModule(), new KafkaFetcherProvider()); + manager.register(new CiliumFetcherModule(), new CiliumFetcherProvider()); + + // Query + manager.register(new QueryModule(), new GraphQLQueryProvider()); + manager.register(new ZipkinQueryModule(), new ZipkinQueryProvider()); + manager.register(new PromQLModule(), new PromQLProvider()); + manager.register(new LogQLModule(), new LogQLProvider()); + manager.register(new StatusQueryModule(), new StatusQueryProvider()); + + // Alarm + manager.register(new AlarmModule(), new AlarmModuleProvider()); + + // Exporter + manager.register(new ExporterModule(), new ExporterProvider()); + + // Health Checker + manager.register(new HealthCheckerModule(), new HealthCheckerProvider()); + + // AI Pipeline + manager.register(new AIPipelineModule(), new AIPipelineProvider()); + } +} diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/FixedModuleManager.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/FixedModuleManager.java new file mode 100644 index 0000000..a4915d9 --- /dev/null +++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/FixedModuleManager.java @@ -0,0 +1,70 @@ +/* + * 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.library.module; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * A ModuleManager that uses fixed module wiring instead of ServiceLoader discovery. + * Modules and providers are explicitly registered before initialization. + */ +public class FixedModuleManager extends ModuleManager { + + private final Map<String, ModuleWiringBridge.ModuleBinding> bindings = new LinkedHashMap<>(); + private final Map<String, ModuleDefine> loadedModules = new LinkedHashMap<>(); + + public FixedModuleManager(String description) { + super(description); + } + + /** + * Register a module with its chosen provider. + * The module name is derived from {@link ModuleDefine#name()}. + */ + public void register(ModuleDefine moduleDefine, ModuleProvider provider) { + bindings.put(moduleDefine.name(), new ModuleWiringBridge.ModuleBinding(moduleDefine, provider)); + } + + /** + * Initialize all registered modules using fixed wiring (no ServiceLoader). + */ + public void initFixed(ApplicationConfiguration configuration) + throws ModuleNotFoundException, ProviderNotFoundException, ServiceNotProvidedException, + CycleDependencyException, ModuleConfigException, ModuleStartException { + ModuleWiringBridge.initAll(this, bindings, configuration); + // Populate our loaded modules map for find()/has() lookups + for (Map.Entry<String, ModuleWiringBridge.ModuleBinding> entry : bindings.entrySet()) { + loadedModules.put(entry.getKey(), entry.getValue().moduleDefine()); + } + } + + @Override + public boolean has(String moduleName) { + return loadedModules.containsKey(moduleName); + } + + @Override + public ModuleProviderHolder find(String moduleName) throws ModuleNotFoundRuntimeException { + ModuleDefine module = loadedModules.get(moduleName); + if (module != null) { + return module; + } + throw new ModuleNotFoundRuntimeException(moduleName + " missing."); + } +} diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleWiringBridge.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleWiringBridge.java new file mode 100644 index 0000000..f0ddb28 --- /dev/null +++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleWiringBridge.java @@ -0,0 +1,120 @@ +/* + * 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.library.module; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedHashMap; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; + +import static org.apache.skywalking.oap.server.library.util.YamlConfigLoaderUtils.copyProperties; + +/** + * Bridge class in the same package as ModuleDefine/ModuleProvider to access + * package-private APIs. Used by the fixed-wiring starter to bypass SPI discovery. + */ +@Slf4j +public class ModuleWiringBridge { + + /** + * Wire a ModuleDefine with a specific ModuleProvider directly, bypassing ServiceLoader. + * Replicates the logic in {@link ModuleDefine#prepare} but with a pre-selected provider. + */ + public static void wireAndPrepare(ModuleManager moduleManager, + ModuleDefine module, + ModuleProvider provider, + ApplicationConfiguration.ModuleConfiguration configuration, + TerminalFriendlyTable bootingParameters) + throws ModuleConfigException, ModuleStartException, ServiceNotProvidedException { + + // Wire provider to module (package-private setters) + provider.setManager(moduleManager); + provider.setModuleDefine(module); + provider.setBootingParameters(bootingParameters); + + log.info("Prepare the {} provider in {} module.", provider.name(), module.name()); + + // Initialize config + try { + final ModuleProvider.ConfigCreator creator = provider.newConfigCreator(); + if (creator != null) { + final Class typeOfConfig = creator.type(); + if (typeOfConfig != null) { + final ModuleConfig config = (ModuleConfig) typeOfConfig.getDeclaredConstructor().newInstance(); + copyProperties( + config, + configuration.getProviderConfiguration(provider.name()), + module.name(), + provider.name() + ); + creator.onInitialized(config); + } + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | + InstantiationException e) { + throw new ModuleConfigException( + module.name() + " module config transport to config bean failure.", e); + } + + // Prepare the provider + provider.prepare(); + } + + /** + * Initialize all fixed-wired modules: prepare, start, and notify in dependency order. + * + * @param moduleManager the module manager + * @param moduleBindings ordered map of module name -> (ModuleDefine, ModuleProvider) pairs + * @param configuration the application configuration + */ + public static void initAll(ModuleManager moduleManager, + Map<String, ModuleBinding> moduleBindings, + ApplicationConfiguration configuration) + throws ModuleNotFoundException, ProviderNotFoundException, ServiceNotProvidedException, + CycleDependencyException, ModuleConfigException, ModuleStartException { + + Map<String, ModuleDefine> loadedModules = new LinkedHashMap<>(); + TerminalFriendlyTable bootingParameters = moduleManager.getBootingParameters(); + + // Phase 1: Prepare all modules + for (Map.Entry<String, ModuleBinding> entry : moduleBindings.entrySet()) { + String moduleName = entry.getKey(); + ModuleBinding binding = entry.getValue(); + + wireAndPrepare( + moduleManager, + binding.moduleDefine(), + binding.provider(), + configuration.getModuleConfiguration(moduleName), + bootingParameters + ); + loadedModules.put(moduleName, binding.moduleDefine()); + } + + // Phase 2: Start and notify (using BootstrapFlow for dependency ordering) + BootstrapFlow bootstrapFlow = new BootstrapFlow(loadedModules); + bootstrapFlow.start(moduleManager); + bootstrapFlow.notifyAfterCompleted(); + } + + /** + * A binding of a ModuleDefine to its chosen ModuleProvider. + */ + public record ModuleBinding(ModuleDefine moduleDefine, ModuleProvider provider) { + } +}
