When back-end developers use Linkis, they can not only directly use the execution engine that Linkis has developed, but also use the framework to develop their own applications according to their own needs.
Linkis can be abstracted into Entrance, EngineManager and Engine modules. Among them, the role and architecture of the Entrance, EngineManager and Engine three modules can be viewed in the UJES architecture design document.
Users only need to implement the necessary interfaces of the three modules to implement their own Linkis engine.
<dependency> <groupId>com.webank.wedatasphere.linkis</groupId> <artifactId>linkis-ujes-entrance</artifactId> <version>0.5.0</version> </dependency>
Entrance has no interfaces that must be instantiated. The following interfaces can be implemented as needed:
<dependency> <groupId>com.webank.wedatasphere.linkis</groupId> <artifactId>linkis-ujes-enginemanager</artifactId> <version>0.5.0</version> </dependency>
EngineManager needs to implement the following interfaces as needed:
Here, ProcessEngineBuilder has provided a JavaProcessEngineBuilder class by default, this class is an abstract class, and the necessary classpath, JavaOpts, GC file path, log file The path, and the opening of the DEBUG port in the test mode have been completed.
Now JavaProcessEngineBuilder, you only need to add additional classpath and JavaOpts.
For specific examples, please refer to the implementation of Hive EngineManager.
<dependency> <groupId>com.webank.wedatasphere.linkis</groupId> <artifactId>Linkis-ujes-engine</artifactId> <version>0.5.0</version> </dependency>
This section will provide a reference example by introducing the writing of the hive engine.
According to the description in the second section, Entrance has no interfaces that must be implemented, the code in linkis-0.5.0, and the entry of hive only have two classes. It is only used for error code extension.
-1. Implementation of EngineCreator interface
From the above figure, we can see that there is a HiveEngineCreator class in the HiveEM module, which inherits the AbstractEngineCreator class, and also implements the createProcessEngineBuilder method, returning a HiveQLProcessBuilder.
-2.HiveQLProcessBuilder implementation
HiveEngineManager has a HiveQLProcessBuilder class in this module, which inherits from JavaProcessEngineBuilder. This class implements a number of necessary interfaces and also overrides the build method. In fact, the parent The build method of the class is complete enough. HiveQLProcessBuilder overrides the build method to obtain the parameters passed in by the user and then add them to the startup command.
-3. AbstractEngineResourceFactory interface implementation
In this instance, we can notify the ResourceManager of the number of CPU cores, memory size, and number of instances that the user wants to obtain each time the user requests the engine
-4. Injection of resources and hooks bean
From the figure above, we can see that by injecting a Spring configuration
Configuration, inject two beans, resources and hooks, UJES framework itself will provide @ConditionalMissingBean annotation to inject default beans, developers can inject their own entity beans according to their own needs. In this class instance bean, the user can register the total memory of EngineManager service, the total number of CPU cores, and the total number of instances that can be created in RM.
-1. EngineExecutorFactory interface implementation
There is a HiveEngineExecutorFactory in the HiveEngine module. At the end of the createExecutor method, the HiveEngineExecutor is returned.
-2.EngineExecutor interface implementation
where executeLine is an interface that must be implemented, which is to pass in a line of script separated by CodeParser and return ExecuteResponse (success or failure).
In addition, executeCompletely also needs to be implemented, which is called when executeLine returns IncompleteReponse.
Engine has some common methods when performing operations, such as close kill pause progress and other methods that can be implemented according to your needs.
Welcome to add group questions.