From e625d7dd65edcbabaf30a7ddcf34274ef6c0033e Mon Sep 17 00:00:00 2001 From: 003822 Date: Tue, 6 Jul 2021 10:06:13 +0800 Subject: [PATCH 1/5] Add statistics on the total number of topics, the maximum number of subscriptions, and the maximum number of unacknowledged subscriptions --- .../management/topics/partitionedTopic.vue | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/front-end/src/views/management/topics/partitionedTopic.vue b/front-end/src/views/management/topics/partitionedTopic.vue index 82772314..90c21210 100644 --- a/front-end/src/views/management/topics/partitionedTopic.vue +++ b/front-end/src/views/management/topics/partitionedTopic.vue @@ -17,6 +17,7 @@
+ @@ -32,6 +33,7 @@ +
@@ -56,6 +58,7 @@
+ + + +

{{ $t('topic.subscription.subscriptions') }}

+ + +

{{ $t('topic.policy.authentication') }} @@ -269,6 +278,7 @@
{{ $t('topic.deleteTopic') }} + @@ -311,6 +321,7 @@ import { fetchTenants } from '@/api/tenants' import { fetchNamespaces, getClusters } from '@/api/namespaces' import { + fetchTopicStatsInternal, fetchPartitionTopicStats, deletePartitionTopicOnCluster, expireMessagesAllSubscriptionsOnCluster, @@ -457,6 +468,7 @@ export default { } }, initTopicStats() { + // get topic stat detail fetchPartitionTopicStats(this.postForm.persistent, this.tenantNamespaceTopic, true).then(response => { if (!response.data) return this.partitionTopicStats = [] @@ -464,11 +476,18 @@ export default { inMsg: numberFormatter(response.data.msgRateIn, 2), outMsg: numberFormatter(response.data.msgRateOut, 2), inBytes: formatBytes(response.data.msgThroughputIn), - outBytes: formatBytes(response.data.msgThroughputOut) + outBytes: formatBytes(response.data.msgThroughputOut), + // The total number of topics + numberOfEntries: 0, + // Max backlog + msgBacklog: 0, + // Max number of messages without ACK + unackedMessages: 0 }) var prefix = this.postForm.persistent + '://' + this.tenantNamespaceTopic var tempPartitionsList = Object.keys(response.data.partitions) this.partitionsList = [] + // Traverse each partition for (var i = 0; i < tempPartitionsList.length; i++) { var key = prefix + '-partition-' + i if (response.data.partitions.hasOwnProperty(key)) { @@ -488,6 +507,15 @@ export default { 'storageSize': formatBytes(response.data.partitions[key].storageSize, 0), 'partitionTopicLink': '/management/topics/' + this.postForm.persistent + '/' + this.tenantNamespaceTopic + '-partition-' + i + '/topic' }) + + // Calculate the sum of each partition message + fetchTopicStatsInternal(this.postForm.persistent, this.postForm.tenant + '/' + this.postForm.namespace + '/' + partition).then(response => { + if (!response.data) return + // is number + if (typeof response.data.numberOfEntries === 'number' && !isNaN(response.data.numberOfEntries)) { + this.partitionTopicStats[0].numberOfEntries = this.partitionTopicStats[0].numberOfEntries + response.data.numberOfEntries + } + }) } } var index = 0 @@ -497,17 +525,32 @@ export default { var type = 'Exclusive' var children = [] for (var j in response.data.partitions) { + // tenant + namespace + partition var subSplitPartition = j.split('://') + // partition var subPartition = subSplitPartition[1].split('/')[2] if (response.data.partitions[j].hasOwnProperty('subscriptions')) { for (var p in response.data.partitions[j].subscriptions) { if (p === s) { + // msgBacklog is number + if (typeof response.data.partitions[j].subscriptions[p].msgBacklog === 'number' && !isNaN(response.data.partitions[j].subscriptions[p].msgBacklog)) { + if (this.partitionTopicStats[0].msgBacklog < response.data.partitions[j].subscriptions[p].msgBacklog) { + this.partitionTopicStats[0].msgBacklog = response.data.partitions[j].subscriptions[p].msgBacklog + } + } + // unackedMessages is number + if (typeof response.data.partitions[j].subscriptions[p].unackedMessages === 'number' && !isNaN(response.data.partitions[j].subscriptions[p].unackedMessages)) { + if (this.partitionTopicStats[0].unackedMessages < response.data.partitions[j].subscriptions[p].unackedMessages) { + this.partitionTopicStats[0].unackedMessages = response.data.partitions[j].subscriptions[p].unackedMessages + } + } children.push({ 'id': 1000000 * (index + 1) + j, 'subscription': subPartition, 'outMsg': numberFormatter(response.data.partitions[j].subscriptions[p].msgRateOut, 2), 'outBytes': formatBytes(response.data.partitions[j].subscriptions[p].msgThroughputOut), 'msgExpired': numberFormatter(response.data.partitions[j].subscriptions[p].msgRateExpired, 2), + // Backlog of messages in the topic 'backlog': response.data.partitions[j].subscriptions[p].msgBacklog, 'type': response.data.partitions[j].subscriptions[p].type, 'subscriptionLink': '/management/subscriptions/' + this.postForm.persistent + '/' + subSplitPartition[1] + '/' + s + '/subscription', From f92472fa4a5cfb13cc21c7e1d4166e6def64ac17 Mon Sep 17 00:00:00 2001 From: 003822 Date: Tue, 6 Jul 2021 10:13:02 +0800 Subject: [PATCH 2/5] Add statistics on the total number of topics, the maximum number of subscriptions, and the maximum number of unacknowledged subscriptions --- front-end/src/api/topics.js | 16 ++++++++++++++-- front-end/src/lang/en.js | 5 ++++- front-end/src/views/management/topics/topic.vue | 8 ++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/front-end/src/api/topics.js b/front-end/src/api/topics.js index daf99468..e1834cdc 100644 --- a/front-end/src/api/topics.js +++ b/front-end/src/api/topics.js @@ -63,14 +63,26 @@ export function fetchTopicStats(persistent, tenantNamespaceTopic) { method: 'get' }) } - +/** + * topic detail + * @param {*}} persistent + * @param {*} tenantNamespaceTopic + * @returns + */ export function fetchTopicStatsInternal(persistent, tenantNamespaceTopic) { return request({ url: BASE_URL_V2 + `/${persistent}/${tenantNamespaceTopic}/internalStats`, method: 'get' }) } - +/** + * topic stat + * topic stat + * @param {*} persistent + * @param {*} tenantNamespaceTopic + * @param {*} perPartition + * @returns + */ export function fetchPartitionTopicStats(persistent, tenantNamespaceTopic, perPartition) { return request({ url: BASE_URL_V2 + `/${persistent}/${tenantNamespaceTopic}/partitioned-stats?perPartition=${perPartition}`, diff --git a/front-end/src/lang/en.js b/front-end/src/lang/en.js index 6e359dab..360f1513 100644 --- a/front-end/src/lang/en.js +++ b/front-end/src/lang/en.js @@ -295,7 +295,10 @@ export default { outBytes: 'Out Throughput', storageSize: 'Storage Size', enabled: 'Enabled', - disabled: 'Disabled' + disabled: 'Disabled', + msgBacklog: 'Backlog', + numberOfEntries: 'All Entries', + unackedMessages: 'Unack Msg' }, tenant: { label: 'Tenant', diff --git a/front-end/src/views/management/topics/topic.vue b/front-end/src/views/management/topics/topic.vue index f45b53b9..d2784cf8 100644 --- a/front-end/src/views/management/topics/topic.vue +++ b/front-end/src/views/management/topics/topic.vue @@ -50,6 +50,7 @@

+ @@ -344,6 +345,8 @@ + + @@ -461,6 +464,8 @@ + +

{{ $t('topic.policy.authentication') }} @@ -513,6 +518,7 @@
{{ $t('topic.deleteTopic') }} + @@ -826,6 +832,7 @@ export default { this.terminateStatus = response.data.state this.segments = response.data.ledgers.length var lastIndex = this.segments - 1 + console.log('topic.vue: ' + response.data) for (var i in response.data.ledgers) { if (lastIndex === parseInt(i)) { this.segmentsList.push({ @@ -845,6 +852,7 @@ export default { }) } } + // 被跟踪的消息总数 this.entries = numberFormatter(response.data.numberOfEntries, 0) for (var c in response.data.cursors) { this.cursorsList.push({ From 2e21ec23f7a875f525d1b3fcb3132038ed8c1aa9 Mon Sep 17 00:00:00 2001 From: 003822 Date: Tue, 6 Jul 2021 10:51:23 +0800 Subject: [PATCH 3/5] Edit comment --- front-end/src/views/management/topics/topic.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/src/views/management/topics/topic.vue b/front-end/src/views/management/topics/topic.vue index d2784cf8..a33a9638 100644 --- a/front-end/src/views/management/topics/topic.vue +++ b/front-end/src/views/management/topics/topic.vue @@ -852,7 +852,7 @@ export default { }) } } - // 被跟踪的消息总数 + // Total number of messages tracked this.entries = numberFormatter(response.data.numberOfEntries, 0) for (var c in response.data.cursors) { this.cursorsList.push({ From 516b06ae1f14510e673748c88501cb70edfc2f67 Mon Sep 17 00:00:00 2001 From: 003822 Date: Tue, 6 Jul 2021 16:49:07 +0800 Subject: [PATCH 4/5] =?UTF-8?q?The=20logic=20of=20peek=20message=20when=20?= =?UTF-8?q?modifying'persistent'=20and'non-persistent'=20themes.=20Change?= =?UTF-8?q?=20to=20a=20more=20selective=20=E2=80=98partition=E2=80=99=20wh?= =?UTF-8?q?en=20the=20subject=20is'persistent',=20and=20check=20the=20sele?= =?UTF-8?q?cted=20partition=20message=20with=20=E2=80=98subscription=20nam?= =?UTF-8?q?e=E2=80=99;=20check=20the=20subject=20message=20directly=20when?= =?UTF-8?q?=20the=20subject=20is=20=E2=80=9Cnon-persistent=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-end/src/api/subscriptions.js | 10 +++++++++- front-end/src/api/topics.js | 18 ++++++++++++++++-- .../management/subscriptions/subscription.vue | 9 ++++++++- .../src/views/management/topics/topic.vue | 1 - 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/front-end/src/api/subscriptions.js b/front-end/src/api/subscriptions.js index 72aa641f..b288c248 100644 --- a/front-end/src/api/subscriptions.js +++ b/front-end/src/api/subscriptions.js @@ -59,7 +59,15 @@ export function deleteSubscriptionOnCluster(cluster, persistent, tenantNamespace method: 'delete' }) } - +/** + * peek message from cluster + * @param {*} cluster + * @param {*} persistent + * @param {*} tenantNamespaceTopic + * @param {*} subName + * @param {*} messagePosition + * @returns + */ export function peekMessagesOnCluster(cluster, persistent, tenantNamespaceTopic, subName, messagePosition) { return request({ headers: { diff --git a/front-end/src/api/topics.js b/front-end/src/api/topics.js index e1834cdc..77108f93 100644 --- a/front-end/src/api/topics.js +++ b/front-end/src/api/topics.js @@ -245,7 +245,14 @@ export function unloadOnCluster(cluster, persistent, tenantNamespaceTopic) { method: 'put' }) } - +/** + * skip message + * @param {*} persistent + * @param {*} tenantNamespaceTopic + * @param {*} subName + * @param {*} numMessages + * @returns + */ export function skip(persistent, tenantNamespaceTopic, subName, numMessages) { return request({ url: BASE_URL_V2 + `/${persistent}/${tenantNamespaceTopic}/subscription/${subName}/skip/${numMessages}`, @@ -310,7 +317,14 @@ export function expireMessagesAllSubscriptionsOnCluster(cluster, persistent, ten method: 'post' }) } - +/** + * peek message + * @param {*} persistent + * @param {*} tenantNamespaceTopic + * @param {*} subName + * @param {*} messagePosition + * @returns + */ export function peekMessages(persistent, tenantNamespaceTopic, subName, messagePosition) { return request({ url: BASE_URL_V2 + `/${persistent}/${tenantNamespaceTopic}/subscription/${subName}/position/${messagePosition}`, diff --git a/front-end/src/views/management/subscriptions/subscription.vue b/front-end/src/views/management/subscriptions/subscription.vue index 2feab851..ed3bbe9b 100644 --- a/front-end/src/views/management/subscriptions/subscription.vue +++ b/front-end/src/views/management/subscriptions/subscription.vue @@ -471,10 +471,17 @@ export default { }) return } + // If it is a partition topic, you can only view the messages under one of the partitions. For the specific reason, see'Pulsar PR[8181]'. + var tenantNamespaceTopic = this.tenantNamespaceTopic + if (this.postForm.persistent === 'persistent' && parseInt(this.postForm.partition) !== -1) { + tenantNamespaceTopic = tenantNamespaceTopic + '-partition-' + this.postForm.partition + } + console.log('tenantNamespaceTopic: ' + tenantNamespaceTopic + '; -1 partition :' + this.postForm.partition) + console.log('partition:' + (parseInt(this.postForm.partition) !== -1) + '--' + (parseInt(this.postForm.partition) + 1)) peekMessagesOnCluster( this.getCurrentCluster(), this.postForm.persistent, - this.tenantNamespaceTopic, + tenantNamespaceTopic, this.postForm.subscription, this.form.peekNumMessages).then(response => { if (!response.data) return diff --git a/front-end/src/views/management/topics/topic.vue b/front-end/src/views/management/topics/topic.vue index a33a9638..c210f82c 100644 --- a/front-end/src/views/management/topics/topic.vue +++ b/front-end/src/views/management/topics/topic.vue @@ -832,7 +832,6 @@ export default { this.terminateStatus = response.data.state this.segments = response.data.ledgers.length var lastIndex = this.segments - 1 - console.log('topic.vue: ' + response.data) for (var i in response.data.ledgers) { if (lastIndex === parseInt(i)) { this.segmentsList.push({ From 9952d9864d6b9174735a53e2a69b8811eac0c78e Mon Sep 17 00:00:00 2001 From: 003822 Date: Tue, 6 Jul 2021 16:54:33 +0800 Subject: [PATCH 5/5] Edit notes. --- front-end/src/views/management/subscriptions/subscription.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/front-end/src/views/management/subscriptions/subscription.vue b/front-end/src/views/management/subscriptions/subscription.vue index ed3bbe9b..96568816 100644 --- a/front-end/src/views/management/subscriptions/subscription.vue +++ b/front-end/src/views/management/subscriptions/subscription.vue @@ -476,8 +476,6 @@ export default { if (this.postForm.persistent === 'persistent' && parseInt(this.postForm.partition) !== -1) { tenantNamespaceTopic = tenantNamespaceTopic + '-partition-' + this.postForm.partition } - console.log('tenantNamespaceTopic: ' + tenantNamespaceTopic + '; -1 partition :' + this.postForm.partition) - console.log('partition:' + (parseInt(this.postForm.partition) !== -1) + '--' + (parseInt(this.postForm.partition) + 1)) peekMessagesOnCluster( this.getCurrentCluster(), this.postForm.persistent,