Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

arklet 0.3 #71

Merged
merged 69 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
f641ae2
add arklet demo
Aug 13, 2023
9b26382
Merge branch 'sofastack:feature.arklet_v1' into feature.arklet_v1
Lunarscave Aug 14, 2023
d86e223
fix bug
Aug 13, 2023
58736a6
Merge remote-tracking branch 'origin/feature.arklet_v1' into feature.…
Aug 14, 2023
2f7181f
delete demo
Aug 14, 2023
dcbcd77
add arklet springboot demo
Aug 14, 2023
bf7d7b4
Merge pull request #23 from ColdClear/feature.arklet_v1
TomorJM Aug 16, 2023
336754f
Merge branch 'master' into feature.arklet_v1
TomorJM Aug 21, 2023
b6f13d6
support biz ops lock
TomorJM Aug 21, 2023
bc379fe
remove not use code
TomorJM Aug 21, 2023
92e741e
optimize code
TomorJM Aug 23, 2023
ed3455e
remove pom in sofa-serverless root dir
TomorJM Aug 23, 2023
095a645
uninstallBiz bugfix
TomorJM Aug 25, 2023
8d038ae
update pom.xml
Aug 25, 2023
78dbb12
add actuator project
Aug 25, 2023
385a40a
Merge branch 'master' into feature.arklet_v1
TomorJM Aug 26, 2023
ddf2615
install biz from bizUrl
TomorJM Aug 26, 2023
5cf5466
actuator can run :)
Aug 26, 2023
8e0d299
actuator can run :)
Aug 27, 2023
57c903d
optimize health model
Aug 28, 2023
aeea98f
change version to 0.0.1-SNAPSHOT
yuanyuan2021 Aug 28, 2023
0ab73c9
add arklet command
Aug 28, 2023
f5268c0
add endpoint
Aug 30, 2023
5a49ed6
add readme
Aug 30, 2023
fbe15ad
install/switch/uninstall response result optimize
TomorJM Aug 30, 2023
18e5b8b
code optimize
TomorJM Aug 30, 2023
fd75aaf
Merge remote-tracking branch 'origin/feature.arklet_v1' into feature.…
Aug 30, 2023
f5f1d40
merged
Aug 30, 2023
090e7ce
Merge branch 'master' into feature.arklet_v1
TomorJM Aug 30, 2023
f89c527
update arklet actuator structure
Aug 31, 2023
68d24d1
Merge branch 'sofastack:feature.arklet_v1' into feature.arklet_v1
Lunarscave Aug 31, 2023
16c2b84
append doc
TomorJM Sep 1, 2023
0d13b1d
optimized arklet healthManager
Sep 2, 2023
afb73c7
Merge remote-tracking branch 'origin/feature.arklet_v1' into feature.…
Sep 2, 2023
8b2a40a
Merge remote-tracking branch 'origin/feature.arklet_v1' into feature.…
Sep 2, 2023
83d67fa
Merge pull request #69 from Lunarscave/feature.arklet_v1
TomorJM Sep 4, 2023
a6bef37
doc optimize
TomorJM Sep 4, 2023
ac66b50
merge master into feature.arklet_v1
TomorJM Sep 4, 2023
d63ca19
append doc
TomorJM Sep 4, 2023
fc35e7a
biz lock bugfix and unit test
TomorJM Sep 4, 2023
d0be5a6
code format
TomorJM Sep 4, 2023
cc04bd7
test bugfix
TomorJM Sep 4, 2023
209ba4e
biz ops handler supports asynchronous execution
yuanyuan2021 Sep 4, 2023
b8ff87f
support query biz ops record
yuanyuan2021 Sep 5, 2023
702cb2b
Merge branch 'feature.arklet_v1' into feat/async_command
yuanyuan2021 Sep 5, 2023
a5136a4
resolve conflict
yuanyuan2021 Sep 5, 2023
7e1c36e
commandService bugfix
TomorJM Sep 5, 2023
44b6160
fix QueryBizOpsHandler
yuanyuan2021 Sep 5, 2023
e18b3cb
OKMerge branch 'feature.arklet_v1' of github.com:sofastack/sofa-serve…
yuanyuan2021 Sep 5, 2023
7e8fdd8
fix processrecord
yuanyuan2021 Sep 5, 2023
3c8a9c0
add ut
yuanyuan2021 Sep 5, 2023
f11c12b
Merge branch 'master' into feature.arklet_v1
yuanyuan2021 Sep 5, 2023
a520639
adjust pom
yuanyuan2021 Sep 5, 2023
254baf1
adjust pom
yuanyuancin Sep 5, 2023
13add48
rm log-codes
yuanyuancin Sep 5, 2023
62b592c
append ut
TomorJM Sep 5, 2023
c593228
append ut
TomorJM Sep 6, 2023
01f9343
code optimize
TomorJM Sep 6, 2023
58378b0
merge master into feature.arklet_v1
TomorJM Sep 6, 2023
ab86722
rename BizModel to BizInfo
TomorJM Sep 7, 2023
97b4353
append doc
TomorJM Sep 7, 2023
ee2e8b0
mod doc
TomorJM Sep 7, 2023
20b639a
optimized arklet healthService
Sep 9, 2023
8eac006
optimized arklet healthService
Sep 9, 2023
289d507
add HealthTests
Sep 10, 2023
c4615a9
Merge remote-tracking branch 'origin/feature.arklet_v1' into feature.…
Sep 10, 2023
2248bb9
Merge pull request #86 from Lunarscave/feature.arklet_v1
TomorJM Sep 11, 2023
40945aa
Merge branch 'master' into feature.arklet_v1
TomorJM Sep 11, 2023
77b7075
bugfix and append doc
TomorJM Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 315 additions & 12 deletions arklet/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
# API
# Overview

Arklet provides an operational interface for delivery of SofaArk bases and modules. With Arklet, the release and operation of Ark Biz can be easily and flexibly operated.

Arklet is internally constructed by **ArkletComponent**

![image](https://github.com/sofastack/sofa-serverless/assets/11410549/a2740422-569e-4dd3-9c9a-1503996bd2f1)
- ApiClient: The core components responsible for interacting with the outside world
- CommandService: Arklet exposes capability instruction definition and extension
- OperationService: Ark Biz interacts with SofaArk to add, delete, modify, and encapsulate basic capabilities
- HealthService: Based on health and stability, base, Biz, system and other indicators are calculated

The collaboration between them is shown in the figure
![overview](https://user-images.githubusercontent.com/11410549/266193839-7865e417-6909-4e89-bd48-c926162eaf83.jpg)


Of course, you can also extend Arklet's component capabilities by implementing the **ArkletComponent** interface

# Command Extension
The Arklet exposes the instruction API externally and handles the instruction internally through a CommandHandler mapped from each API.
> CommandHandler related extensions belong to the unified management of the CommandService component

You can customize extension commands by inheriting **AbstractCommandHandler**

## Build-in Command API

All of the following instruction apis access the arklet using the POST(application/json) request format

The http protocol is enabled and the default port is 1238
> You can set `sofa.serverless.arklet.http.port` JVM startup parameters override the default port


## Query the supported commands
- URL: 127.0.0.1:1238/help
Expand Down Expand Up @@ -46,23 +72,46 @@ The http protocol is enabled and the default port is 1238
{
"bizName": "test",
"bizVersion": "1.0.0",
"arkBizFilePath": "/Users/jaimezhang/workspace/github/sofa-ark-dynamic-guides/dynamic-provider/target/dynamic-provider-1.0.0-ark-biz.jar"
// local path should start with file://, alse support remote url which can be downloaded
"bizUrl": "file:///Users/jaimezhang/workspace/github/sofa-ark-dynamic-guides/dynamic-provider/target/dynamic-provider-1.0.0-ark-biz.jar"
}
```
- output sample:

- output sample(success):
```json
{
"code":"SUCCESS",
"data":[
{
"bizName":"dynamic-provider",
"bizVersion":"1.0.0",
...
}
]
"data":{
"bizInfos":[
{
"bizName":"dynamic-provider",
"bizState":"ACTIVATED",
"bizVersion":"1.0.0",
"declaredMode":true,
"identity":"dynamic-provider:1.0.0",
"mainClass":"io.sofastack.dynamic.provider.ProviderApplication",
"priority":100,
"webContextPath":"provider"
}
],
"code":"SUCCESS",
"message":"Install Biz: dynamic-provider:1.0.0 success, cost: 1092 ms, started at: 16:07:47,769"
}
}
```

- output sample(failed):
```json
{
"code":"FAILED",
"data":{
"code":"REPEAT_BIZ",
"message":"Biz: dynamic-provider:1.0.0 has been installed or registered."
}
}
```


## Uninstall a biz
- URL: 127.0.0.1:1238/uninstallBiz
- input sample:
Expand All @@ -72,13 +121,24 @@ The http protocol is enabled and the default port is 1238
"bizVersion":"1.0.0"
}
```
- output sample:
- output sample(success):
```json
{
"code":"SUCCESS"
}
```

- output sample(failed):
```json
{
"code":"FAILED",
"data":{
"code":"NOT_FOUND_BIZ",
"message":"Uninstall biz: test:1.0.0 not found."
}
}
```

## Switch a biz
- URL: 127.0.0.1:1238/switchBiz
- input sample:
Expand Down Expand Up @@ -122,4 +182,247 @@ The http protocol is enabled and the default port is 1238
}
]
}
```
```

## Query Health
- URL: 127.0.0.1:1238/health

### Query All Health Info
- input sample:
```json
{}
```
- output sample:
```json
{
"code": "SUCCESS",
"data": {
"healthData": {
"jvm": {
"max non heap memory(M)": -9.5367431640625E-7,
"java version": "1.8.0_331",
"max memory(M)": 885.5,
"max heap memory(M)": 885.5,
"used heap memory(M)": 137.14127349853516,
"used non heap memory(M)": 62.54662322998047,
"loaded class count": 10063,
"init non heap memory(M)": 2.4375,
"total memory(M)": 174.5,
"free memory(M)": 37.358726501464844,
"unload class count": 0,
"total class count": 10063,
"committed heap memory(M)": 174.5,
"java home": "****\\jre",
"init heap memory(M)": 64.0,
"committed non heap memory(M)": 66.203125,
"run time(s)": 34.432
},
"cpu": {
"count": 4,
"total used (%)": 131749.0,
"type": "****",
"user used (%)": 9.926451054656962,
"free (%)": 81.46475495070172,
"system used (%)": 6.249762806548817
},
"masterBizInfo": {
"webContextPath": "/",
"bizName": "bookstore-manager",
"bizState": "ACTIVATED",
"bizVersion": "1.0.0"
},
"pluginListInfo": [
{
"artifactId": "web-ark-plugin",
"groupId": "com.alipay.sofa",
"pluginActivator": "com.alipay.sofa.ark.web.embed.WebPluginActivator",
"pluginName": "web-ark-plugin",
"pluginUrl": "file:/****/2.2.3-SNAPSHOT/web-ark-plugin-2.2.3-20230901.090402-2.jar!/",
"pluginVersion": "2.2.3-SNAPSHOT"
},
{
"artifactId": "runtime-sofa-boot-plugin",
"groupId": "com.alipay.sofa",
"pluginActivator": "com.alipay.sofa.runtime.ark.plugin.SofaRuntimeActivator",
"pluginName": "runtime-sofa-boot-plugin",
"pluginUrl": "file:/****/runtime-sofa-boot-plugin-3.11.0.jar!/",
"pluginVersion": "3.11.0"
}
],
"masterBizHealth": {
"readinessState": "ACCEPTING_TRAFFIC"
},
"bizListInfo": [
{
"bizName": "bookstore-manager",
"bizState": "ACTIVATED",
"bizVersion": "1.0.0",
"webContextPath": "/"
}
]
}
}
}
```

### Query System Health Info
- input sample:

```json
{
"type": "system",
// [OPTIONAL] if metrics is null -> query all system health info
"metrics": ["cpu", "jvm"]
}
```
- output sample:
```json
{
"code": "SUCCESS",
"data": {
"healthData": {
"jvm": {...},
"cpu": {...},
// "masterBizHealth": {...}
}
}
}
```

### Query Biz Health Info
- input sample:

```json
{
"type": "biz",
// [OPTIONAL] if moduleName is null and moduleVersion is null -> query all biz
"moduleName": "bookstore-manager",
// [OPTIONAL] if moduleVersion is null -> query all biz named moduleName
"moduleVersion": "1.0.0"
}
```
- output sample:
```json
{
"code": "SUCCESS",
"data": {
"healthData": {
"bizInfo": {
"bizName": "bookstore-manager",
"bizState": "ACTIVATED",
"bizVersion": "1.0.0",
"webContextPath": "/"
}
// "bizListInfo": [
// {
// "bizName": "bookstore-manager",
// "bizState": "ACTIVATED",
// "bizVersion": "1.0.0",
// "webContextPath": "/"
// }
// ]
}
}
}
```

### Query Plugin Health Info
- input sample:

```json
{
"type": "plugin",
// [OPTIONAL] if moduleName is null -> query all biz
"moduleName": "web-ark-plugin"
}
```
- output sample:
```json
{
"code": "SUCCESS",
"data": {
"healthData": {
"pluginListInfo": [
{
"artifactId": "web-ark-plugin",
"groupId": "com.alipay.sofa",
"pluginActivator": "com.alipay.sofa.ark.web.embed.WebPluginActivator",
"pluginName": "web-ark-plugin",
"pluginUrl": "file:/****/web-ark-plugin-2.2.3-20230901.090402-2.jar!/",
"pluginVersion": "2.2.3-SNAPSHOT"
}
]
}
}
}
```

### Query Health Using Endpoint

use endpoint for k8s module to get helath info

**default config**
* endpoints exposure include: `*`
* endpoints base path: `/`
* endpoints sever port: `8080`

**http code result**
* `HEALTHY(200)`: get health if all health indicator is healthy
* `UNHEALTHY(400)`: get health once a health indicator is unhealthy
* `ENDPOINT_NOT_FOUND(404)`: endpoint path or params not found
* `ENDPOINT_PROCESS_INTERNAL_ERROR(500)`: get health process throw an error

### query all health info
- url: 127.0.0.1:8080/arkletHealth
- method: GET
- output sample

```json
{
"healthy": true,
"code": 200,
"codeType": "HEALTHY",
"data": {
"jvm": {...},
"masterBizHealth": {...},
"cpu": {...},
"masterBizInfo": {...},
"bizListInfo": [...],
"pluginListInfo": [...]
}
}
```
### query all biz/plugin health info
- url: 127.0.0.1:8080/arkletHealth/{moduleType} (moduleType must in ['biz', 'plugin'])
- method: GET
- output sample
```json
{
"healthy": true,
"code": 200,
"codeType": "HEALTHY",
"data": {
"bizListInfo": [...],
// "pluginListInfo": [...]
}
}
```
### query single biz/plugin health info
- url: 127.0.0.1:8080/arkletHealth/{moduleType}/moduleName/moduleVersion (moduleType must in ['biz', 'plugin'])
- method: GET
- output sample

```json
{
"healthy": true,
"code": 200,
"codeType": "HEALTHY",
"data": {
"bizInfo": {...},
// "pluginInfo": {...}
}
}
```



16 changes: 16 additions & 0 deletions arklet/arklet-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<artifactId>sofa-ark-api</artifactId>
</dependency>

<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand Down Expand Up @@ -63,6 +68,17 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>

</project>
Loading
Loading