变更副本信息
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ReplicaAssignment;
|
||||||
import com.xuxd.kafka.console.beans.dto.AddPartitionDTO;
|
import com.xuxd.kafka.console.beans.dto.AddPartitionDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.NewTopicDTO;
|
import com.xuxd.kafka.console.beans.dto.NewTopicDTO;
|
||||||
import com.xuxd.kafka.console.beans.enums.TopicType;
|
import com.xuxd.kafka.console.beans.enums.TopicType;
|
||||||
@@ -71,8 +72,14 @@ public class TopicController {
|
|||||||
|
|
||||||
return topicService.addPartitions(topic, addNum, assignment);
|
return topicService.addPartitions(topic, addNum, assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/replica/assignment")
|
@GetMapping("/replica/assignment")
|
||||||
public Object getCurrentReplicaAssignment(@RequestParam String topic) {
|
public Object getCurrentReplicaAssignment(@RequestParam String topic) {
|
||||||
return topicService.getCurrentReplicaAssignment(topic);
|
return topicService.getCurrentReplicaAssignment(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/replica/assignment")
|
||||||
|
public Object updateReplicaAssignment(@RequestBody ReplicaAssignment assignment) {
|
||||||
|
return "topicService.getCurrentReplicaAssignment(topic)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,10 @@ export const KafkaTopicApi = {
|
|||||||
url: "/topic/replica/assignment",
|
url: "/topic/replica/assignment",
|
||||||
method: "get",
|
method: "get",
|
||||||
},
|
},
|
||||||
|
updateReplicaAssignment: {
|
||||||
|
url: "/topic/replica/assignment",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const KafkaConsumerApi = {
|
export const KafkaConsumerApi = {
|
||||||
|
|||||||
@@ -5,17 +5,29 @@
|
|||||||
:width="1200"
|
:width="1200"
|
||||||
:mask="false"
|
:mask="false"
|
||||||
:destroyOnClose="true"
|
:destroyOnClose="true"
|
||||||
:footer="null"
|
|
||||||
:maskClosable="false"
|
:maskClosable="false"
|
||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
|
okText="确认"
|
||||||
|
cancelText="取消"
|
||||||
|
@ok="handleOk"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<a-spin :spinning="loading">
|
<a-spin :spinning="loading">
|
||||||
|
<div class="replica-box">
|
||||||
|
<label>副本数:</label
|
||||||
|
><a-input-number
|
||||||
|
id="inputNumber"
|
||||||
|
v-model="replicaNums"
|
||||||
|
:min="1"
|
||||||
|
:max="brokerSize"
|
||||||
|
@change="onChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<a-table
|
<a-table
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data-source="data.partitions"
|
:data-source="data.partitions"
|
||||||
bordered
|
bordered
|
||||||
:rowKey="
|
:rowKey="
|
||||||
(record, index) => {
|
(record, index) => {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@@ -23,13 +35,10 @@
|
|||||||
>
|
>
|
||||||
<div slot="replicas" slot-scope="text">
|
<div slot="replicas" slot-scope="text">
|
||||||
<span v-for="i in text" :key="i">
|
<span v-for="i in text" :key="i">
|
||||||
{{
|
{{ i }}
|
||||||
i
|
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a-table>
|
</a-table>
|
||||||
|
|
||||||
</a-spin>
|
</a-spin>
|
||||||
</div>
|
</div>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
@@ -37,7 +46,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { KafkaTopicApi } from "@/utils/api";
|
import { KafkaClusterApi, KafkaTopicApi } from "@/utils/api";
|
||||||
import notification from "ant-design-vue/lib/notification";
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -59,12 +68,16 @@ export default {
|
|||||||
data: {},
|
data: {},
|
||||||
loading: false,
|
loading: false,
|
||||||
form: this.$form.createForm(this, { name: "coordinated" }),
|
form: this.$form.createForm(this, { name: "coordinated" }),
|
||||||
|
brokerSize: 0,
|
||||||
|
replicaNums: 0,
|
||||||
|
defaultReplicaNums: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
visible(v) {
|
visible(v) {
|
||||||
this.show = v;
|
this.show = v;
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
|
this.getClusterInfo();
|
||||||
this.getCurrentReplicaAssignment();
|
this.getCurrentReplicaAssignment();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -82,6 +95,10 @@ export default {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.data = res.data;
|
this.data = res.data;
|
||||||
|
if (this.data.partitions.length > 0) {
|
||||||
|
this.replicaNums = this.data.partitions[0].replicas.length;
|
||||||
|
this.defaultReplicaNums = this.replicaNums;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
notification.error({
|
notification.error({
|
||||||
message: "error",
|
message: "error",
|
||||||
@@ -90,14 +107,55 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getClusterInfo() {
|
||||||
|
this.loading = true;
|
||||||
|
request({
|
||||||
|
url: KafkaClusterApi.getClusterInfo.url,
|
||||||
|
method: KafkaClusterApi.getClusterInfo.method,
|
||||||
|
}).then((res) => {
|
||||||
|
this.brokerSize = res.data.nodes.length;
|
||||||
|
});
|
||||||
|
},
|
||||||
handleCancel() {
|
handleCancel() {
|
||||||
this.data = [];
|
this.data = {};
|
||||||
this.$emit("closeUpdateReplicaDialog", { refresh: false });
|
this.$emit("closeUpdateReplicaDialog", { refresh: false });
|
||||||
},
|
},
|
||||||
|
onChange(value) {
|
||||||
|
if (this.data.partitions.length > 0) {
|
||||||
|
this.data.partitions.forEach((p) => {
|
||||||
|
if (value > p.replicas.length) {
|
||||||
|
let num = p.replicas[p.replicas.length - 1];
|
||||||
|
for (let i = p.replicas.length; i < value; i++) {
|
||||||
|
p.replicas.push(++num % this.brokerSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value < p.replicas.length) {
|
||||||
|
p.replicas.pop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleOk() {
|
||||||
|
this.loading = true;
|
||||||
|
request({
|
||||||
|
url: KafkaTopicApi.updateReplicaAssignment.url,
|
||||||
|
method: KafkaTopicApi.updateReplicaAssignment.method,
|
||||||
|
data: this.data,
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success(res.msg);
|
||||||
|
} else {
|
||||||
|
notification.error({
|
||||||
|
message: "error",
|
||||||
|
description: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "Topic",
|
title: "Topic",
|
||||||
@@ -118,4 +176,8 @@ const columns = [
|
|||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
.replica-box {
|
||||||
|
margin-bottom: 1%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user