function yarnTab(cluster, title, queueNames = 'default', searchName = undefined) {
return {
title: `${title} 集群`,
tab: [
{
id: `${cluster}-yarn-service`,
name: `${cluster}-yarn-service`,
type: 'service',
body: [
{
type: 'tpl',
tpl: '集群资源',
},
{
type: 'crud',
api: {
method: 'get',
url: '${base}/yarn/queue_list',
data: {
clusters: `${cluster}`,
names: '${queueName|default:undefined}'
},
},
affixHeader: false,
defaultParams: {
queueName: queueNames,
},
interval: 10000,
syncLocation: false,
silentPolling: true,
headerToolbar: [
"reload",
],
columns: [
{
name: 'queueName',
label: '队列名称',
width: 130,
type: 'tooltip-wrapper',
body: '${TRUNCATE(queueName, 20)}',
content: '${queueName}',
},
{
label: '当前容量',
type: 'progress',
value: '${ROUND((absoluteUsedCapacity * 100 / absoluteMaxCapacity), 0)}',
stripe: true,
animate: true,
showLabel: false,
map: [
{
value: 30,
color: "#28a745"
}, {
value: 90,
color: "#007bff"
},
{
value: 100,
color: "#dc3545"
}
]
},
{
label: '进度',
width: 35,
align: 'center',
type: 'tpl',
tpl: '${ROUND((absoluteUsedCapacity * 100 / absoluteMaxCapacity), 0)}%',
},
{
type: "operation",
label: "操作",
width: 100,
fixed: 'right',
buttons: [
{
label: "详情",
type: "button",
level: "link",
tooltip: '查看队列详情',
visibleOn: '${!root}',
actionType: 'dialog',
dialog: {
closeOnEsc: true,
closeOnOutside: true,
size: 'md',
close: true,
title: '队列详情',
body: {
type: 'property',
items: [
{label: 'CPU', content: '${resourcesUsed.vCores}'},
// 有空看看这个值的单位
{label: '内存', content: '${resourcesUsed.memory}', span: 2},
{label: '容量(%)', content: '${capacity}'},
{label: '最大容量(%)', content: '${maxCapacity}'},
{label: '已用容量(%)', content: '${usedCapacity}'},
{label: '绝对容量(%)', content: '${absoluteCapacity}'},
{label: '绝对最大容量(%)', content: '${absoluteMaxCapacity}'},
{label: '绝对已用容量(%)', content: '${absoluteUsedCapacity}'},
{label: '应用数量', content: '${numApplications}', span: 3},
{label: '最大应用数量', content: '${maxApplications}'},
{label: '活跃应用数量', content: '${numActiveApplications}'},
{label: '等待应用数量', content: '${numPendingApplications}'},
{label: '容器数量', content: '${numContainers}', span: 3},
{label: '已分配容器数量', content: '${numApplications}'},
{label: '预留容器数量数量', content: '${numApplications}'},
{label: '等待容器数量', content: '${numApplications}'},
]
},
actions: []
}
},
{
visibleOn: "${webUrl}",
label: "管理页面",
type: "action",
level: "link",
tooltip: '打开管理页面',
actionType: 'url',
url: '${webUrl}',
blank: true,
}
]
}
]
},
{
type: 'tpl',
tpl: '集群任务',
// className: 'mb-2 block',
},
{
type: 'crud',
api: {
method: 'get',
url: '${base}/yarn/job_list',
data: {
clusters: `${cluster}`,
page: '${page|default:undefined}',
count: '${perPage|default:undefined}',
order: '${orderBy|default:undefined}',
direction: '${orderDir|default:undefined}',
filter_state: '${state|default:undefined}',
filter_final_status: '${finalStatus|default:undefined}',
search_id: '${id|default:undefined}',
search_name: '${name|default:undefined}',
}
},
defaultParams: {
name: searchName
},
interval: 10000,
affixHeader: false,
syncLocation: false,
silentPolling: true,
itemBadge: {
text: 'Hudi',
mode: 'ribbon',
position: 'top-left',
level: 'info',
visibleOn: 'this.hudiApplication'
},
filter: {
mode: 'inline',
title: '任务筛选',
body: [
{
type: 'group',
body: [
{
type: 'input-text',
name: 'id',
label: 'ID',
clearable: true,
placeholder: '通过 ID 搜索',
size: 'md'
},
{
type: 'input-text',
name: 'name',
label: '名称',
clearable: true,
placeholder: '通过名称搜索',
size: 'md'
},
]
},
],
actions: [
{
type: "submit",
level: "primary",
label: "查询",
},
{
type: "reset",
label: "重置",
},
]
},
filterTogglable: true,
filterDefaultVisible: false,
stopAutoRefreshWhenModalIsOpen: true,
resizable: false,
perPage: 20,
headerToolbar: [
"reload",
'filter-toggler',
{
type: "tpl",
tpl: "共 ${total|default:0} 个任务,其中 ${running|default:0} 个任务运行中,${unRunning|default:0} 个任务处于非运行状态"
},
{
type: 'pagination',
layout: ['pager', 'perPage'],
maxButtons: 8,
showPageInput: false,
}
],
footerToolbar: [
{
type: 'pagination',
layout: ['pager', 'perPage'],
maxButtons: 8,
showPageInput: false,
}
],
columns: yarnCrudColumns(),
}
]
}
]
}
}