mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Add /cluster/db/map/process endpoint
This commit is contained in:
@@ -65,6 +65,7 @@ type Cluster interface {
|
|||||||
UpdateProcess(origin string, id app.ProcessID, config *app.Config) error
|
UpdateProcess(origin string, id app.ProcessID, config *app.Config) error
|
||||||
SetProcessCommand(origin string, id app.ProcessID, order string) error
|
SetProcessCommand(origin string, id app.ProcessID, order string) error
|
||||||
SetProcessMetadata(origin string, id app.ProcessID, key string, data interface{}) error
|
SetProcessMetadata(origin string, id app.ProcessID, key string, data interface{}) error
|
||||||
|
GetProcessNodeMap() map[string]string
|
||||||
|
|
||||||
IAM(superuser iamidentity.User, jwtRealm, jwtSecret string) (iam.IAM, error)
|
IAM(superuser iamidentity.User, jwtRealm, jwtSecret string) (iam.IAM, error)
|
||||||
ListIdentities() (time.Time, []iamidentity.User)
|
ListIdentities() (time.Time, []iamidentity.User)
|
||||||
|
@@ -1428,7 +1428,12 @@ const docTemplateClusterAPI = `{
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
|
@@ -1420,7 +1420,12 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
|
@@ -228,7 +228,10 @@ definitions:
|
|||||||
description: ip:port
|
description: ip:port
|
||||||
type: string
|
type: string
|
||||||
debug:
|
debug:
|
||||||
type: boolean
|
properties:
|
||||||
|
disable_ffmpeg_check:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
emergency_leader_timeout_sec:
|
emergency_leader_timeout_sec:
|
||||||
description: seconds
|
description: seconds
|
||||||
format: int64
|
format: int64
|
||||||
|
@@ -593,6 +593,7 @@ func (c *cluster) doSynchronize(emergency bool) {
|
|||||||
opStack, _, reality := synchronize(wish, want, have, nodesMap, c.nodeRecoverTimeout)
|
opStack, _, reality := synchronize(wish, want, have, nodesMap, c.nodeRecoverTimeout)
|
||||||
|
|
||||||
if !emergency && len(opStack) != 0 {
|
if !emergency && len(opStack) != 0 {
|
||||||
|
// TODO: only apply a new map if there are actually changes
|
||||||
cmd := &store.Command{
|
cmd := &store.Command{
|
||||||
Operation: store.OpSetProcessNodeMap,
|
Operation: store.OpSetProcessNodeMap,
|
||||||
Data: store.CommandSetProcessNodeMap{
|
Data: store.CommandSetProcessNodeMap{
|
||||||
|
@@ -122,3 +122,7 @@ func (c *cluster) SetProcessMetadata(origin string, id app.ProcessID, key string
|
|||||||
|
|
||||||
return c.applyCommand(cmd)
|
return c.applyCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cluster) GetProcessNodeMap() map[string]string {
|
||||||
|
return c.store.GetProcessNodeMap()
|
||||||
|
}
|
||||||
|
46
docs/docs.go
46
docs/docs.go
@@ -814,6 +814,32 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/v3/cluster/map/process": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"ApiKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Retrieve a map of which process is running on which node",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"v16.?.?"
|
||||||
|
],
|
||||||
|
"summary": "Retrieve a map of which process is running on which node",
|
||||||
|
"operationId": "cluster-3-process-node-map",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.ClusterProcessMap"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/v3/cluster/node": {
|
"/api/v3/cluster/node": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -4453,6 +4479,12 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.ClusterProcessMap": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.ClusterRaft": {
|
"api.ClusterRaft": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4616,7 +4648,12 @@ const docTemplate = `{
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
@@ -6849,7 +6886,12 @@ const docTemplate = `{
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
|
@@ -806,6 +806,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/v3/cluster/map/process": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"ApiKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Retrieve a map of which process is running on which node",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"v16.?.?"
|
||||||
|
],
|
||||||
|
"summary": "Retrieve a map of which process is running on which node",
|
||||||
|
"operationId": "cluster-3-process-node-map",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.ClusterProcessMap"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/v3/cluster/node": {
|
"/api/v3/cluster/node": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -4445,6 +4471,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.ClusterProcessMap": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.ClusterRaft": {
|
"api.ClusterRaft": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4608,7 +4640,12 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
@@ -6841,7 +6878,12 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"type": "boolean"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"disable_ffmpeg_check": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"emergency_leader_timeout_sec": {
|
"emergency_leader_timeout_sec": {
|
||||||
"description": "seconds",
|
"description": "seconds",
|
||||||
|
@@ -160,6 +160,10 @@ definitions:
|
|||||||
ncpu:
|
ncpu:
|
||||||
type: number
|
type: number
|
||||||
type: object
|
type: object
|
||||||
|
api.ClusterProcessMap:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
api.ClusterRaft:
|
api.ClusterRaft:
|
||||||
properties:
|
properties:
|
||||||
server:
|
server:
|
||||||
@@ -267,7 +271,10 @@ definitions:
|
|||||||
description: ip:port
|
description: ip:port
|
||||||
type: string
|
type: string
|
||||||
debug:
|
debug:
|
||||||
type: boolean
|
properties:
|
||||||
|
disable_ffmpeg_check:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
emergency_leader_timeout_sec:
|
emergency_leader_timeout_sec:
|
||||||
description: seconds
|
description: seconds
|
||||||
format: int64
|
format: int64
|
||||||
@@ -1843,7 +1850,10 @@ definitions:
|
|||||||
description: ip:port
|
description: ip:port
|
||||||
type: string
|
type: string
|
||||||
debug:
|
debug:
|
||||||
type: boolean
|
properties:
|
||||||
|
disable_ffmpeg_check:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
emergency_leader_timeout_sec:
|
emergency_leader_timeout_sec:
|
||||||
description: seconds
|
description: seconds
|
||||||
format: int64
|
format: int64
|
||||||
@@ -2916,6 +2926,22 @@ paths:
|
|||||||
summary: Leave the cluster gracefully
|
summary: Leave the cluster gracefully
|
||||||
tags:
|
tags:
|
||||||
- v16.?.?
|
- v16.?.?
|
||||||
|
/api/v3/cluster/map/process:
|
||||||
|
get:
|
||||||
|
description: Retrieve a map of which process is running on which node
|
||||||
|
operationId: cluster-3-process-node-map
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/api.ClusterProcessMap'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: Retrieve a map of which process is running on which node
|
||||||
|
tags:
|
||||||
|
- v16.?.?
|
||||||
/api/v3/cluster/node:
|
/api/v3/cluster/node:
|
||||||
get:
|
get:
|
||||||
description: List of proxy nodes in the cluster
|
description: List of proxy nodes in the cluster
|
||||||
|
@@ -99,3 +99,5 @@ type ClusterKVSValue struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ClusterKVS map[string]ClusterKVSValue
|
type ClusterKVS map[string]ClusterKVSValue
|
||||||
|
|
||||||
|
type ClusterProcessMap map[string]string
|
||||||
|
@@ -1425,3 +1425,18 @@ func (h *ClusterHandler) GetSnapshot(c echo.Context) error {
|
|||||||
|
|
||||||
return c.Stream(http.StatusOK, "application/octet-stream", r)
|
return c.Stream(http.StatusOK, "application/octet-stream", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetProcessNodeMap returns a map of which process is running on which node
|
||||||
|
// @Summary Retrieve a map of which process is running on which node
|
||||||
|
// @Description Retrieve a map of which process is running on which node
|
||||||
|
// @Tags v16.?.?
|
||||||
|
// @ID cluster-3-process-node-map
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} api.ClusterProcessMap
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Router /api/v3/cluster/map/process [get]
|
||||||
|
func (h *ClusterHandler) GetProcessNodeMap(c echo.Context) error {
|
||||||
|
m := h.cluster.GetProcessNodeMap()
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, m)
|
||||||
|
}
|
||||||
|
@@ -700,6 +700,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) {
|
|||||||
v3.GET("/cluster/db/policies", s.v3handler.cluster.ListStorePolicies)
|
v3.GET("/cluster/db/policies", s.v3handler.cluster.ListStorePolicies)
|
||||||
v3.GET("/cluster/db/locks", s.v3handler.cluster.ListStoreLocks)
|
v3.GET("/cluster/db/locks", s.v3handler.cluster.ListStoreLocks)
|
||||||
v3.GET("/cluster/db/kv", s.v3handler.cluster.ListStoreKV)
|
v3.GET("/cluster/db/kv", s.v3handler.cluster.ListStoreKV)
|
||||||
|
v3.GET("/cluster/db/map/process", s.v3handler.cluster.GetProcessNodeMap)
|
||||||
|
|
||||||
v3.GET("/cluster/iam/user", s.v3handler.cluster.ListIdentities)
|
v3.GET("/cluster/iam/user", s.v3handler.cluster.ListIdentities)
|
||||||
v3.GET("/cluster/iam/user/:name", s.v3handler.cluster.ListIdentity)
|
v3.GET("/cluster/iam/user/:name", s.v3handler.cluster.ListIdentity)
|
||||||
|
Reference in New Issue
Block a user