当前位置:网站首页>Microkernel structure understanding
Microkernel structure understanding
2022-07-06 03:36:00 【m0_ sixty million seven hundred and twenty-five thousand two hu】
Catalog
The basic structure
Microkernel architecture consists of two types of components : The core system (core system) And plug-in modules (plug-in modules). The core system is responsible for general functions unrelated to specific business functions , For example, module loading 、 Inter module communication, etc ; The plug-in module is responsible for implementing specific business logic .
The architectural essence of microkernel is Encapsulate the changes in the plug-in , So as to achieve the purpose of rapid and flexible expansion , Without affecting the stability of the overall system .
Key points of design
The key technologies of the core system design of microkernel are : Plug-in management 、 Plug in connection and plug-in communication
Plug-in management
The core system needs to know which plug-ins are currently available , How to load these plug-ins , When to load the plug-in . The common implementation method is the plug-in registry mechanism , The core system provides plug-in registry ( It can be a configuration file , It can also be code , It can also be a database ), The plug-in registry contains information about each plug-in module , Including its name 、 Location 、 Loading time ( Start loading , Load on demand ) etc. .
The plug-in connection
Generally speaking , The core system must formulate the connection specifications between plug-ins and core systems , Then the plug-in is implemented according to the specification , The core system can be loaded according to the specification .
Common connection mechanisms are OSGi(Eclipse Use )、 Message schema 、 Dependency injection (Spring Use ), Even using distributed protocols is possible , such as RPC perhaps HTTP Web The way .
Plug in communication
Plug ins are completely decoupled when designing , But in the process of actual business operation , There will be a business process that requires the cooperation of multiple plug-ins , So the core system needs to provide plug-in communication mechanism .
OSGI
OSGi Is a plug-in standard , Instead of a working framework ,Eclipse Adopted OSGi The framework is called Equinox, Similar implementations include Apache Of Felix、Spring Of Spring DM.
Plug-in management
The module layer implements the plug-in management function .OSGi in , The plug-in is called Bundle, Every Bundle It's a Java Of JAR file , Every Bundle It contains a metadata file MANIFEST.MF, This file contains Bundle Basic information of .
Such as ,Bundle The name of 、 describe 、 developers 、classpath, And the packages that need to be imported and exported ,OSGi The core system will load this information into the system for subsequent use :
// MANIFEST.MF
Bundle-ManifestVersion: 2
Bundle-Name:UserRegister
Bundle-SymbolicName: com.test.userregister
Bundle-Version: 1.0
Bundle-Activator: com.test.UserRegisterActivator
Import-Package: org.log4j;version="2.0",
.....
Export-Package: com.test.userregister;version="1.0",
The plug-in connection
The life cycle layer implements the plug-in connection function , Provides execution time module management 、 Module to the bottom OSGi Framework access . The lifecycle layer precisely defines Bundle Life cycle operations ( install 、 to update 、 start-up 、 stop it 、 uninstall ),Bundle Each operation must be implemented according to the specification .
public class UserRegisterActivator implements BundleActivator {
public void start(BundleContext context) {
UserRegister.instance = new UserRegister ();
}
public void stop(BundleContext context) {
UserRegister.instance = null;
}
}
Plug in communication
The service layer realizes the function of plug-in communication .OSGi It provides a function of service registration , It is used by plug-ins to register the services they can provide to OSGi Core service registry , If a service wants to use other services , Then you can search the available service centers directly in the service registry .
// Registration service
public class UserRegisterActivator implements BundleActivator {
// stay start() of use BundleContext.registerService() Registration service
public void start(BundleContext context) {
context.registerService(UserRegister.class.getName(), new UserRegisterImpl(), null);
}
// No need to stop() Log out of service , because Bundle When it stops, it will automatically log out of the Bundle Registered services in
public void stop(BundleContext context) {
}
}
// Retrieval service
public class Client implements BundleActivator {
public void start(BundleContext context) {
// 1. Retrieve indirect from the service registry “ The service reference ”
ServiceReference ref = context.getServiceReference(UserRegister.class.getName());
// 2. Use “ The service reference ” To access the instance of the service object
((UserRegister) context.getService(ref)).register();
}
public void stop(BundleContext context) {
}
}
The service registration here is not the plug-in registration in the plug-in management function , In fact, it is the mechanism of communication between plug-ins .
Rules engine
The rule engine also belongs to a specific implementation of micro kernel architecture from the perspective of structure , The execution engine can be regarded as a microkernel , The execution engine parses the configured business flow , Implement the conditions and rules , In this way to support the flexibility of the business .
The rule engine is charging 、 insurance 、 Promotion and other business areas are widely used .
Open source JBoss Drools
Compare the design key points of micro kernel architecture :
Plug-in management
The rules in the rule engine are the plug-ins of the microkernel architecture , The engine is the kernel of the microkernel architecture . Rules can be loaded and executed by the engine . Rule engine architecture , Rules are generally saved in the rule base , A database is usually used to store .
The plug-in connection
The rule engine specifies the language of rule development , Business people need to write rule files based on rule language , Then the rule engine loads and executes the rule file to complete the business function , therefore , The plug-in connection implementation mechanism of rule engine is actually rule language .
Plug in communication
The rules of the rule engine communicate with each other through data flow and event flow , Because a single rule does not need to rely on other rules , Therefore, there is no active communication between rules , Rules only need to output data or events , The engine passes data or events to the next rule .
-------- source 《 Geek course 》∙ Study summary
边栏推荐
- SD卡報錯“error -110 whilst initialising SD card
- 简述C语言中的符号和链接库
- js凡客banner轮播图js特效
- pytorch加载数据
- [risc-v] external interrupt
- How to do function test well
- 2.1 rtthread pin设备详解
- Leetcode problem solving -- 99 Restore binary search tree
- An article about liquid template engine
- Python implementation of maddpg - (1) openai maddpg environment configuration
猜你喜欢
BUAA喜鹊筑巢
ASU & OSU | model based regularized off-line meta reinforcement learning
Mysqldump data backup
Performance test method of bank core business system
IPv6 comprehensive experiment
EDCircles: A real-time circle detector with a false detection control 翻译
Problems encountered in 2022 work IV
Explore pointers and pointer types in depth
1. New project
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
随机推荐
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
Derivation of anti Park transform and anti Clarke transform formulas for motor control
Microsoft Research, UIUC & Google research | antagonistic training actor critic based on offline training reinforcement learning
[slam] orb-slam3 parsing - track () (3)
Explore pointers and pointer types in depth
Handwriting database client
3.2 rtthread 串口设备(V2)详解
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
The solution of permission denied (750 permissions should be used with caution)
Item 10: Prefer scoped enums to unscoped enums.
ASU & OSU | model based regularized off-line meta reinforcement learning
Pelosi: Congress will soon have legislation against members' stock speculation
SAP ALV颜色代码对应颜色(整理)
SAP ALV单元格级别设置颜色
3857 Mercator coordinate system converted to 4326 (WGS84) longitude and latitude coordinates
3.1 rtthread 串口设备(V1)详解
Tidb ecological tools (backup, migration, import / export) collation
2.2 STM32 GPIO操作
深入刨析的指针(题解)
Problems encountered in 2022 work IV