Add custom SPI blocking queue type support

pull/1612/head
mingri31164 11 months ago
parent 5e97e3a8e5
commit 9f08423b5b

@ -22,7 +22,6 @@ import cn.hippo4j.common.executor.ThreadPoolExecutorRegistry;
import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.BlockingQueueManager; import cn.hippo4j.common.executor.support.BlockingQueueManager;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
import cn.hippo4j.common.extension.enums.EnableEnum; import cn.hippo4j.common.extension.enums.EnableEnum;
import cn.hippo4j.common.model.ThreadPoolParameter; import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo; import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -106,6 +106,8 @@ export default {
capacityAlarm: 'Capacity Alarm', capacityAlarm: 'Capacity Alarm',
customRejectedHandler: 'Custom Rejected Handler', customRejectedHandler: 'Custom Rejected Handler',
customRejectedHandlerTip: 'Please enter a custom SPI Deny Policy ID', customRejectedHandlerTip: 'Please enter a custom SPI Deny Policy ID',
customQueueType: 'Custom Queue Type',
customQueueTypeTip: 'Please enter a custom SPI Queue ID',
threadsNumErrorTip: 'The maximum thread must be greater than or equal to the core thread', threadsNumErrorTip: 'The maximum thread must be greater than or equal to the core thread',
}, },

@ -104,6 +104,8 @@ export default {
capacityAlarm: '容量报警', capacityAlarm: '容量报警',
customRejectedHandler: '自定义拒绝策略', customRejectedHandler: '自定义拒绝策略',
customRejectedHandlerTip: '请输入自定义 SPI 拒绝策略标识', customRejectedHandlerTip: '请输入自定义 SPI 拒绝策略标识',
customQueueType: '自定义队列类型',
customQueueTypeTip: '请输入自定义 SPI 队列标识',
threadsNumErrorTip: '最大线程必须大于等于核心线程', threadsNumErrorTip: '最大线程必须大于等于核心线程',
}, },

@ -459,6 +459,8 @@ export default {
return 'PriorityBlockingQueue'; return 'PriorityBlockingQueue';
} else if ('9' == type) { } else if ('9' == type) {
return 'ResizableLinkedBlockingQueue'; return 'ResizableLinkedBlockingQueue';
} else {
return 'CustomBlockingQueue_' + type;
} }
}, },
@ -516,6 +518,7 @@ export default {
key: 9, key: 9,
display_name: 'ResizableLinkedBlockingQueue (动态修改队列大小)', display_name: 'ResizableLinkedBlockingQueue (动态修改队列大小)',
}, },
{ key: 99, display_name: 'CustomBlockingQueue(自定义 SPI 队列)' },
], ],
rejectedOptions: [ rejectedOptions: [
{ key: 1, display_name: 'CallerRunsPolicy' }, { key: 1, display_name: 'CallerRunsPolicy' },

@ -426,6 +426,8 @@ export default {
return 'PriorityBlockingQueue'; return 'PriorityBlockingQueue';
} else if ('9' == type) { } else if ('9' == type) {
return 'ResizableLinkedBlockingQueue'; return 'ResizableLinkedBlockingQueue';
} else {
return 'CustomBlockingQueue_' + type;
} }
}, },
} }

@ -231,6 +231,17 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item
v-if="isQueueShow"
:label="$t('threadPool.customQueueType')"
prop="customQueueType"
>
<el-input
v-model="temp.customQueueType"
:placeholder="$t('threadPool.customQueueTypeTip')"
@input="onInput()"
/>
</el-form-item>
<el-form-item :label="$t('threadPool.queueCapacity')" prop="capacity"> <el-form-item :label="$t('threadPool.queueCapacity')" prop="capacity">
<el-input-number <el-input-number
v-model="temp.capacity" v-model="temp.capacity"
@ -406,6 +417,8 @@ export default {
return 'PriorityBlockingQueue'; return 'PriorityBlockingQueue';
} else if ('9' == type) { } else if ('9' == type) {
return 'ResizableLinkedBlockingQueue'; return 'ResizableLinkedBlockingQueue';
} else {
return 'CustomBlockingQueue_' + type;
} }
}, },
rejectedTypeFilter(type) { rejectedTypeFilter(type) {
@ -429,6 +442,7 @@ export default {
data() { data() {
return { return {
isRejectShow: false, // 是否显示spi拒绝策略 isRejectShow: false, // 是否显示spi拒绝策略
isQueueShow: false, // 是否显示spi自定义队列
isEdit: false, isEdit: false,
list: null, list: null,
listLoading: true, listLoading: true,
@ -457,6 +471,7 @@ export default {
{ key: 5, display_name: 'LinkedTransferQueue' }, { key: 5, display_name: 'LinkedTransferQueue' },
{ key: 6, display_name: 'PriorityBlockingQueue' }, { key: 6, display_name: 'PriorityBlockingQueue' },
{ key: 9, display_name: 'ResizableLinkedBlockingQueue (动态修改队列大小)' }, { key: 9, display_name: 'ResizableLinkedBlockingQueue (动态修改队列大小)' },
{ key: 99, display_name: 'CustomBlockingQueue(自定义 SPI 队列)' },
], ],
rejectedOptions: [ rejectedOptions: [
{ key: 1, display_name: 'CallerRunsPolicy' }, { key: 1, display_name: 'CallerRunsPolicy' },
@ -487,6 +502,8 @@ export default {
itemId: '', itemId: '',
rejectedType: null, rejectedType: null,
customRejectedType: null, customRejectedType: null,
queueType: null,
customQueueType: null,
coreSize: 4, coreSize: 4,
maxSize: 8, maxSize: 8,
}, },
@ -585,6 +602,7 @@ export default {
}, },
resetTemp() { resetTemp() {
this.isRejectShow = false; this.isRejectShow = false;
this.isQueueShow = false;
this.isEdit = false; this.isEdit = false;
this.temp = { this.temp = {
id: undefined, id: undefined,
@ -592,6 +610,8 @@ export default {
itemId: '', itemId: '',
rejectedType: null, rejectedType: null,
customRejectedType: null, customRejectedType: null,
queueType: null,
customQueueType: null,
isAlarm: '', isAlarm: '',
allowCoreThreadTimeOut: '', allowCoreThreadTimeOut: '',
livenessAlarm: '', livenessAlarm: '',
@ -636,6 +656,13 @@ export default {
this.temp.rejectedType = this.temp.customRejectedType; this.temp.rejectedType = this.temp.customRejectedType;
} }
} }
if (this.isQueueShow) {
if (this.temp.customQueueType == null) {
this.temp.queueType = 9;
} else {
this.temp.queueType = this.temp.customQueueType;
}
}
threadPoolApi.created(this.temp).then(() => { threadPoolApi.created(this.temp).then(() => {
this.fetchData(); this.fetchData();
this.dialogFormVisible = false; this.dialogFormVisible = false;
@ -666,6 +693,25 @@ export default {
} else { } else {
this.isRejectShow = false; this.isRejectShow = false;
} }
// 处理自定义队列类型
let queueType = this.temp.queueType;
if (
queueType != 1 &&
queueType != 2 &&
queueType != 3 &&
queueType != 4 &&
queueType != 5 &&
queueType != 6 &&
queueType != 9
) {
this.isQueueShow = true;
this.temp.customQueueType = this.temp.queueType;
this.temp.queueType = 99;
} else {
this.isQueueShow = false;
}
this.dialogStatus = 'update'; this.dialogStatus = 'update';
this.dialogFormVisible = true; this.dialogFormVisible = true;
this.isEdit = false; this.isEdit = false;
@ -697,6 +743,23 @@ export default {
this.temp.rejectedType = this.temp.customRejectedType; this.temp.rejectedType = this.temp.customRejectedType;
} }
} }
// 处理自定义队列类型
let queueType = this.temp.queueType;
if (
queueType != 1 &&
queueType != 2 &&
queueType != 3 &&
queueType != 4 &&
queueType != 5 &&
queueType != 6 &&
queueType != 9
) {
if (this.temp.customQueueType != null) {
this.temp.queueType = this.temp.customQueueType;
}
}
const tempData = Object.assign({}, this.temp); const tempData = Object.assign({}, this.temp);
threadPoolApi.updated(tempData).then(() => { threadPoolApi.updated(tempData).then(() => {
this.fetchData(); this.fetchData();
@ -743,6 +806,8 @@ export default {
} else if (value === 5) { } else if (value === 5) {
this.temp.capacity = 2147483647; this.temp.capacity = 2147483647;
} }
// 判断是否显示自定义队列输入框
this.isQueueShow = value === 99 ? true : false;
this.$forceUpdate(); this.$forceUpdate();
}, },

@ -351,6 +351,8 @@ export default {
return 'PriorityBlockingQueue'; return 'PriorityBlockingQueue';
} else if ('9' == type) { } else if ('9' == type) {
return 'ResizableLinkedBlockingQueue'; return 'ResizableLinkedBlockingQueue';
} else {
return 'CustomBlockingQueue_' + type;
} }
}, },
rejectedTypeFilter(type) { rejectedTypeFilter(type) {

Loading…
Cancel
Save