新增客户端限流菜单页.
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: xuxd
|
||||||
|
* @date: 2023/1/10 20:12
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class AlterClientQuotaDTO {
|
||||||
|
|
||||||
|
private List<String> types;
|
||||||
|
|
||||||
|
private List<String> names;
|
||||||
|
|
||||||
|
private String consumerRate;
|
||||||
|
|
||||||
|
private String producerRate;
|
||||||
|
|
||||||
|
private String requestPercentage;
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.QueryClientQuotaDTO;
|
import com.xuxd.kafka.console.beans.dto.QueryClientQuotaDTO;
|
||||||
import com.xuxd.kafka.console.service.ClientQuotaService;
|
import com.xuxd.kafka.console.service.ClientQuotaService;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -25,4 +28,14 @@ public class ClientQuotaController {
|
|||||||
public Object getClientQuotaConfigs(@RequestBody QueryClientQuotaDTO request) {
|
public Object getClientQuotaConfigs(@RequestBody QueryClientQuotaDTO request) {
|
||||||
return clientQuotaService.getClientQuotaConfigs(request.getTypes(), request.getNames());
|
return clientQuotaService.getClientQuotaConfigs(request.getTypes(), request.getNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Object alterClientQuotaConfigs(@RequestBody AlterClientQuotaDTO request) {
|
||||||
|
if (CollectionUtils.isEmpty(request.getTypes())
|
||||||
|
|| CollectionUtils.isEmpty(request.getNames())
|
||||||
|
|| request.getTypes().size() != request.getNames().size()) {
|
||||||
|
return ResponseData.create().failed("types length and names length is invalid.");
|
||||||
|
}
|
||||||
|
return clientQuotaService.alterClientQuotaConfigs(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xuxd.kafka.console.service;
|
package com.xuxd.kafka.console.service;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
||||||
import com.xuxd.kafka.console.beans.vo.ClientQuotaEntityVO;
|
import com.xuxd.kafka.console.beans.vo.ClientQuotaEntityVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -10,4 +11,6 @@ import java.util.List;
|
|||||||
public interface ClientQuotaService {
|
public interface ClientQuotaService {
|
||||||
|
|
||||||
List<ClientQuotaEntityVO> getClientQuotaConfigs(List<String> types, List<String> names);
|
List<ClientQuotaEntityVO> getClientQuotaConfigs(List<String> types, List<String> names);
|
||||||
|
|
||||||
|
Object alterClientQuotaConfigs(AlterClientQuotaDTO request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.xuxd.kafka.console.service.impl;
|
package com.xuxd.kafka.console.service.impl;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
||||||
import com.xuxd.kafka.console.beans.vo.ClientQuotaEntityVO;
|
import com.xuxd.kafka.console.beans.vo.ClientQuotaEntityVO;
|
||||||
import com.xuxd.kafka.console.service.ClientQuotaService;
|
import com.xuxd.kafka.console.service.ClientQuotaService;
|
||||||
import kafka.console.ClientQuotaConsole;
|
import kafka.console.ClientQuotaConsole;
|
||||||
@@ -57,4 +59,10 @@ public class ClientQuotaServiceImpl implements ClientQuotaService {
|
|||||||
return voList.stream().filter(e -> names.get(1).equals(e.getClient())).collect(Collectors.toList());
|
return voList.stream().filter(e -> names.get(1).equals(e.getClient())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object alterClientQuotaConfigs(AlterClientQuotaDTO request) {
|
||||||
|
|
||||||
|
return ResponseData.create().failed();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ClientQuotaConsoleTest {
|
public class ClientQuotaConsoleTest {
|
||||||
|
|
||||||
String bootstrapServer = "127.0.0.1:9092";
|
String bootstrapServer = "10.1.18.222:9092";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetClientQuotasConfigs() {
|
void testGetClientQuotasConfigs() {
|
||||||
@@ -38,8 +38,8 @@ public class ClientQuotaConsoleTest {
|
|||||||
Map<String, String> configsToBeAddedMap = new HashMap<>();
|
Map<String, String> configsToBeAddedMap = new HashMap<>();
|
||||||
configsToBeAddedMap.put(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG, "1024000000");
|
configsToBeAddedMap.put(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG, "1024000000");
|
||||||
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList("user-test"), configsToBeAddedMap);
|
// console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList("user-test"), configsToBeAddedMap);
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList(""), configsToBeAddedMap);
|
// console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList(""), configsToBeAddedMap);
|
||||||
console.deleteQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList(""), Arrays.asList(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG));
|
console.deleteQuotaConfigs(Arrays.asList(ClientQuotaEntity.CLIENT_ID), Arrays.asList(""), Arrays.asList(QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
<span>|</span
|
<span>|</span
|
||||||
><router-link to="/message-page" class="pad-l-r">消息</router-link>
|
><router-link to="/message-page" class="pad-l-r">消息</router-link>
|
||||||
<span>|</span
|
<span>|</span
|
||||||
|
><router-link to="/client-quota-page" class="pad-l-r">限流</router-link>
|
||||||
|
<span>|</span
|
||||||
><router-link to="/acl-page" class="pad-l-r">Acl</router-link>
|
><router-link to="/acl-page" class="pad-l-r">Acl</router-link>
|
||||||
<span>|</span
|
<span>|</span
|
||||||
><router-link to="/op-page" class="pad-l-r">运维</router-link>
|
><router-link to="/op-page" class="pad-l-r">运维</router-link>
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ const routes = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "cluster" */ "../views/message/Message.vue"),
|
import(/* webpackChunkName: "cluster" */ "../views/message/Message.vue"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/client-quota-page",
|
||||||
|
name: "ClientQuota",
|
||||||
|
component: () =>
|
||||||
|
import(/* webpackChunkName: "cluster" */ "../views/quota/ClientQuota.vue"),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
|||||||
@@ -293,3 +293,14 @@ export const KafkaMessageApi = {
|
|||||||
method: "delete",
|
method: "delete",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const KafkaClientQuotaApi = {
|
||||||
|
getClientQuotaConfigs: {
|
||||||
|
url: "/client/quota/list",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
|
alterClientQuotaConfigs: {
|
||||||
|
url: "/client/quota",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
|
};
|
||||||
57
ui/src/views/quota/ClientQuota.vue
Normal file
57
ui/src/views/quota/ClientQuota.vue
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-tabs default-active-key="1" size="large" tabPosition="top">
|
||||||
|
<a-tab-pane key="1" tab="客户端ID">
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="2" tab="用户">
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="3" tab="客户端ID和用户">
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="4" tab="IP">
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="5" tab="使用说明">
|
||||||
|
</a-tab-pane>
|
||||||
|
</a-tabs>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import request from "@/utils/request";
|
||||||
|
import {KafkaTopicApi} from "@/utils/api";
|
||||||
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ClientQuota",
|
||||||
|
components: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
topicList: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getTopicNameList() {
|
||||||
|
request({
|
||||||
|
url: KafkaTopicApi.getTopicNameList.url,
|
||||||
|
method: KafkaTopicApi.getTopicNameList.method,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.topicList = res.data;
|
||||||
|
} else {
|
||||||
|
notification.error({
|
||||||
|
message: "error",
|
||||||
|
description: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getTopicNameList();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
Reference in New Issue
Block a user