SOFAArk 2.0

Updated at:

This topic describes the SOFAArk 2.0 version and how to upgrade the SOFAArk 2.0 version.

Background information

The SOFAArk framework contains three concepts: Ark Container, Ark Plugin, and Ark Biz. Based on the three concepts, a complex class loading mechanism is derived, as shown in the following figure: image

Note

For more information, see Ark container class loading mechanism.

The above mechanisms cause the following problems:

  • Due to the existence of Ark plug-ins, plug-ins have strong control at the dependency level, causing the following problems:

    • The dependencies used by the service are exported by the plug-in control, but the version exported by the plug-in control does not match the actual version expected by the service (for example, the version of the plug-in control is 1.0, but the service needs 2.0).

    • Plug-ins have strong control over dependencies, which directly blocks the way for business to extend the capabilities of plug-ins. There are also some dependencies. When a business is introduced, an error will be reported directly (its package is exported, but the dependency is not in the plug-in), so the business can only wait for the framework release to solve the problem.

    • Business access costs and learning costs are high, and troubleshooting is difficult. You need to be very familiar with the Ark class loading mechanism.

    • Due to the growth of control dependencies, the Ark Plugin is difficult to maintain continuously.

  • Difficulties in R&D and O&M

    Because Ark Container starts before Master Biz, the startup portal of Master Biz is inconsistent with Spring Boot and SOFABoot. As a result, the startup of Ark Master Biz requires custom images and startup portals during R&D and O&M, which makes R&D and O&M difficult.

In response to the above problems, Ant Group tried to optimize the three-tier structure from the framework level and precipitated the SOFAArk 2.0 solution. The overall optimization idea and principle of the solution is to Ark Master Biz consistent with the native Spring Boot and SOFABoot, weaken the complex Ark Plugin class control mechanism, and merge Ark Plugin with Master Biz. The SOFAArk 2.0 solution has the following overall optimization points:

  • Weakens the Ark Plugin layer and replaces it with a common pom dependency.

  • The Ark Master Biz and native Spring Boot and SOFABoot application startup and class loading methods are consistent.

  • Optimized Ark Biz startup speed.

Upgrade method

Version upgrade

The first bit of the SOFAArk version number is the major version number. If it is 1.x.x, it is SOFAArk 1.0. If it is 2.x.x, it is SOFAArk 2.0. The current 2.0 version has been officially released. For release notes, see Release-Notes.

When you upgrade the version, you only need to configure the following:

<properties>
    <sofa.ark.version>1.1.6</sofa.ark.version>
</properties>

Change to:

<properties>
    <sofa.ark.version>2.0.0</sofa.ark.version>
</properties>

Package a plug-in

Use sofa-ark-maven-plugin packaging in SOFAArk 1.0, and use Spring Boot native packaging plug-in spring-boot-maven-plugin SOFAArk 2.0.

<build>
    <plugins>
        <plugin>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>sofa-ark-maven-plugin</artifactId>
            <version>${sofa.ark.version}</version>
            <executions>
                <execution>
                    <id>default-cli</id>

                    <!--goal executed to generate executable-ark-jar -->
                    <goals>
                        <goal>repackage</goal>
                    </goals>

                    <configuration>
                        <!--specify destination where executable-ark-jar will be saved, default saved to ${project.build.directory}-->
                        <outputDirectory>./target</outputDirectory>

                        <!--default none-->
                        <arkClassifier>executable-ark</arkClassifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Replace with:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.6.6</version>

            <configuration>
                <outputDirectory>target</outputDirectory>
                <classifier>ark-biz</classifier>
            </configuration>
            <executions>
                <execution>
                    <id>package</id>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Running Ark Applications

Method 1: Launching via IDEA

Local startup needs to add startup parameters:

-Dsofa.ark.embed.enable=true -Dcom.alipay.sofa.ark.master.biz=${bizName}

Method 2: Command Line Launch

Ark packages are executable JARs that can be started directly using Java -jar:

  1. First use mvn clean package to package, package to get ${bizName}-${bizVersion}-ark-biz.jar.

  2. Command line startup.

    java -jar -Dsofa.ark.embed.enable=true -Dcom.alipay.sofa.ark.master.biz=${bizName} ${bizName}-${bizVersion}-ark-biz.jar

Sample project

For more information about how to access SOFAArk 1.0, see SOFAArk 1.0 sample project.

For more information about how to access SOFAArk 2.0, see SOFAArk 2.0 sample project.