Ark container startup process

Updated at:

The following figure describes the overall startup process of an Ark application.

image.png

When an Ark package is started with a java -jar command or an Ark application is started by SofaArkBootstrap.launch in the IDE, the corresponding Launcher entry is responsible for starting the application. The entry of the call ArkContainer is reflected, the ArkService is initialized, and then the pipeline is executed in sequence to complete the startup of the entire Ark application.

ArkService

Ark Serivce is a service in an Ark container. The underlying layer uses Guice to manage the service. It also provides lifecycle interface com.alipay.sofa.ark.spi.service.ArkService for services.

    public interface ArkService{

/**
 * Ark Service init
 * @throws ArkException
 */
        void init() throws ArkException;

/**
 * Ark Service dispose
 * @throws ArkException
 */
        void dispose() throws ArkException;

    }

If the service implements the preceding interfaces, the corresponding lifecycle interfaces are called when the Ark Serivce container starts and stops.

Pipeline service

Pipeline is also a service registered in the Ark Service container. The service itself has no order or priority. In Pipeline, some services are assembled and the entire Ark container is started. The process is as follows:

  1. Parse Archive.

    At the beginning of the pipeline, the running fatjar is parsed into the models required by the run time, including the Ark plug-in model and the Ark business model, and these models are registered with the PluginManagerService and BizManagerService in the Ark Service.

  2. Initialize the environment.

    Set some default parameters that run time need. For example, set the log4j.ignoreTCL to true to initialize the log4j/log4j2 so that the log does not look for configuration files from the ThreadContextClassloader. For more information, see Proper way to switch TCCL.

  3. Register Container Service.

    Some services are published in the Ark container for other plug-ins to use. For example, in the release BizDeployer, SOFAArk official plug-in sofa-jarslink complete the dynamic loading and unloading of Biz.

  4. Deploy the Ark plug-in.

    Obtain all Ark plug-ins from the PluginManagerService and follow the plug-in priority order:

    • ClassloaderService prepare a map of plug-in export classes.

    • PluginDeployService the com.alipay.sofa.ark.spi.service.PluginActivator to start the plug-in.

  5. Start the Ark business.

    Obtain all Ark services from the BizManagerService and execute the entry main function provided in the MANIFEST.MF property Main-Class for service configuration.