简要描述
- 该接口用于批量查询应用并发数,查询某个应用的并发数,查询某工作区间的并发数,某服务器的并发数,某组别下的并发数,各个服务器的并发数。需要注意的是,当传递appliIdArr参数时,其他参数失效
请求URL
{{adminHost:8181}}/taskInfo/getRunningCnt
请求方式
- get
请求Query参数
参数名 | 示例值 | 必选 | 类型 | 说明 |
---|---|---|---|---|
appliIdArr | 1196452726221832192,1196464974600339456 | 否 | array | 应用ID列表(应用id以逗号分割形式传递),用于前端一览页面获取多个应用的运行数量,不与其他参数同时使用,仅在页面加载初始调用一次,后面通过websocket动态更新(详细说明请参见备注) |
appliId | 1196452726221832192 | 否 | long | 应用ID,不为空时返回特定应用的运行数量 |
serverId | c255ced0be4451c5ba5524b926a53816 | 否 | string | 渲染节点ID,不为空时返回特定节点上运行数量 |
wsId | LbuVvNUK | 否 | string | 工作空间ID,不为空时返回特定wsId上运行数量 |
groupId | 1194226279482654720 | 否 | long | 组别ID,不为空时返回特定组别上运行数量 |
includeServerRunCntList | true | 否 | boolean | 是否包含服务器各个节点的运行数量,默认为false,若开启,该接口的响应时间比较长 |
成功返回示例
{
"code": 1000,
"message": "Success",
"result": {
"runCntOnAppliList": [
{
"appliId": "1196452726221832192",
"runCnt": 0
},
{
"appliId": "1196464974600339456",
"runCnt": 0
},
{
"appliId": "1199762458126843904",
"runCnt": 0
}
],
"runCntOnAppli": {
"appliId": "1196452726221832192",
"runCnt": 0
},
"total": "0",
"runCntOnGroup": {
"groupId": "1194226279482654720",
"runCnt": 0
},
"runCntOnSvrList": [],
"runCntOnWsId": {
"runCnt": 0
},
"runCntOnSvr": {
"serverId": "c255ced0be4451c5ba5524b926a53816",
"runCnt": 0
}
}
}
成功返回示例的参数说明
参数名 | 类型 | 说明 |
---|---|---|
code | string | 无 |
message | string | 无 |
result | object | 无 |
runCntOnAppliList | array | appliIdArr不为空时,筛选出应用运行数 |
runCntOnAppliList.appliId | string | 应用Id |
runCntOnAppliList.runCnt | string | 应用运行数 |
runCntOnAppli | object | 参数appliId不为空时,筛选出该应用的当前运行数 |
runCntOnAppli.appliId | string | 应用Id |
runCntOnAppli.runCnt | string | 应用运行数 |
total | string | 系统总并发数 |
runCntOnGroup | object | 参数groupId不为空时,筛选出该组别的当前运行数 |
runCntOnGroup.groupId | string | 组别Id |
runCntOnGroup.runCnt | string | 运行数 |
runCntOnSvrList | array | includeServerRunCntList为true时,筛选出各个服务器的并发数 |
runCntOnWsId | object | 参数wsId不为空时,筛选出该工作空间的当前运行数 |
runCntOnWsId.runCnt | string | 运行数 |
runCntOnSvr | object | 参数serverId不为空时,筛选出该服务器的当前运行数 |
runCntOnSvr.serverId | string | 服务器Id |
runCntOnSvr.runCnt | string | 运行数 |
备注
如何通过websocket动态更新应用并发数?
//Index.vue
步骤一:创建wsUrl
let wsUrl = “http://192.168.0.28:8181/websocket/imServer“;
步骤二:创建websocket请求
this.websocketServer = IMServer(wsUrl, {
onInit: this.initIMServer,
onMessage: this.IMServerMessage
})
//给页面ws赋值,用于离开页面后关闭ws
initIMServer(ws) {
this.ws = ws;
},
//监听ws消息
IMServerMessage(e) {
let data = JSON.parse(e.data);
if (data.type == “001”) {
let runCntOnAppli = data.runCntInfo.runCntOnAppli;
this.$set(this.RunCntInfos, runCntOnAppli.appliId, runCntOnAppli);
}
},
//卸载事件
beforeDestroy() {
window.removeEventListener(‘beforeunload’, e => this.closeWebsocket(e))
}
//关闭ws
closeWebsocket: function () {
this.ws.close();
}
//IMServer.js
export const IMServer = (url, config) => {
let socket = new WebSocket(url);
socket.onopen = function (ev) {
if (config.onMessage && typeof config.onMessage == ‘function’) {
config.onInit(socket);
}
}
socket.onmessage = function (ev) {
if (config.onMessage && typeof config.onMessage == ‘function’) {
config.onMessage(ev);
}
};
socket.onclose = function (ev) {
}
}