Skip to content

Commit dec1de5

Browse files
author
dushixiang
committed
upgrade antd to 5.x
upgrade react-router-dom to 6.x change cra to vite add broker config
1 parent f541f39 commit dec1de5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+6861
-84
lines changed

.mvn/wrapper/maven-wrapper.jar

57.4 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

graalvm/reflect-config.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"name": "com.github.benmanes.caffeine.cache.PSW",
4+
"allDeclaredConstructors": true
5+
},
6+
{
7+
"name": "com.github.benmanes.caffeine.cache.PSWMS",
8+
"allDeclaredConstructors": true
9+
},
10+
{
11+
"name": "com.github.benmanes.caffeine.cache.SSLA",
12+
"allDeclaredConstructors": true
13+
},
14+
{
15+
"name": "com.github.benmanes.caffeine.cache.SSLMSW",
16+
"allDeclaredConstructors": true
17+
},
18+
{
19+
"name": "com.github.benmanes.caffeine.cache.SSMSW",
20+
"allDeclaredConstructors": true
21+
},
22+
{
23+
"name": "com.github.benmanes.caffeine.cache.SSLMSA",
24+
"allDeclaredConstructors": true
25+
},
26+
{
27+
"name": "com.github.benmanes.caffeine.cache.PSAMS",
28+
"allDeclaredConstructors": true
29+
}
30+
]

pom.xml

Lines changed: 25 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5+
56
<parent>
67
<groupId>org.springframework.boot</groupId>
78
<artifactId>spring-boot-starter-parent</artifactId>
89
<version>3.0.0</version>
910
<relativePath/> <!-- lookup parent from repository -->
1011
</parent>
12+
1113
<groupId>cn.typesafe</groupId>
1214
<artifactId>kafka-map</artifactId>
13-
<version>1.2.3</version>
15+
<version>1.3.0</version>
1416
<name>kafka-map</name>
1517
<description>a simple kafka manager</description>
18+
1619
<properties>
1720
<java.version>17</java.version>
18-
<frontend-src-dir>${project.basedir}/src/main/web</frontend-src-dir>
19-
<node.version>v16.13.0</node.version>
20-
<yarn.version>v1.22.4</yarn.version>
21-
<frontend-maven-plugin.version>1.11.3</frontend-maven-plugin.version>
2221
</properties>
22+
2323
<dependencies>
2424
<dependency>
2525
<groupId>org.springframework.boot</groupId>
@@ -67,7 +67,7 @@
6767
<scope>compile</scope>
6868
<groupId>com.github.ben-manes.caffeine</groupId>
6969
<artifactId>caffeine</artifactId>
70-
<version>3.1.1</version>
70+
<version>3.1.2</version>
7171
</dependency>
7272
<dependency>
7373
<scope>compile</scope>
@@ -86,10 +86,29 @@
8686
<groupId>org.springframework.boot</groupId>
8787
<artifactId>spring-boot-starter-webflux</artifactId>
8888
</dependency>
89+
8990
</dependencies>
9091

92+
<repositories>
93+
<repository>
94+
<id>spring-repo</id>
95+
<name>Spring Repository</name>
96+
<url>https://repo.spring.io/release</url>
97+
</repository>
98+
</repositories>
99+
91100
<build>
92101
<plugins>
102+
<plugin>
103+
<groupId>org.graalvm.buildtools</groupId>
104+
<artifactId>native-maven-plugin</artifactId>
105+
<configuration>
106+
<skip>false</skip>
107+
<buildArgs>
108+
-H:ReflectionConfigurationFiles=./graalvm/reflect-config.json
109+
</buildArgs>
110+
</configuration>
111+
</plugin>
93112
<plugin>
94113
<groupId>org.springframework.boot</groupId>
95114
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -102,72 +121,6 @@
102121
<target>17</target>
103122
</configuration>
104123
</plugin>
105-
106-
<plugin>
107-
<groupId>com.github.eirslett</groupId>
108-
<artifactId>frontend-maven-plugin</artifactId>
109-
<version>${frontend-maven-plugin.version}</version>
110-
111-
<configuration>
112-
<nodeVersion>${node.version}</nodeVersion>
113-
<yarnVersion>${yarn.version}</yarnVersion>
114-
<workingDirectory>${frontend-src-dir}</workingDirectory>
115-
<installDirectory>${project.build.directory}</installDirectory>
116-
</configuration>
117-
118-
<executions>
119-
<execution>
120-
<id>install-frontend-tools</id>
121-
<goals>
122-
<goal>install-node-and-yarn</goal>
123-
</goals>
124-
</execution>
125-
126-
<execution>
127-
<id>yarn-install</id>
128-
<goals>
129-
<goal>yarn</goal>
130-
</goals>
131-
<configuration>
132-
<arguments>install</arguments>
133-
</configuration>
134-
</execution>
135-
136-
<execution>
137-
<id>build-frontend</id>
138-
<goals>
139-
<goal>yarn</goal>
140-
</goals>
141-
<phase>prepare-package</phase>
142-
<configuration>
143-
<arguments>build</arguments>
144-
</configuration>
145-
</execution>
146-
</executions>
147-
</plugin>
148-
149-
<plugin>
150-
<artifactId>maven-resources-plugin</artifactId>
151-
<version>3.0.1</version>
152-
<executions>
153-
<execution>
154-
<id>position-react-build</id>
155-
<goals>
156-
<goal>copy-resources</goal>
157-
</goals>
158-
<phase>prepare-package</phase>
159-
<configuration>
160-
<outputDirectory>${project.build.outputDirectory}/static</outputDirectory>
161-
<resources>
162-
<resource>
163-
<directory>${frontend-src-dir}/build</directory>
164-
<filtering>false</filtering>
165-
</resource>
166-
</resources>
167-
</configuration>
168-
</execution>
169-
</executions>
170-
</plugin>
171124
</plugins>
172125
</build>
173126

src/main/java/cn/typesafe/km/KafkaMapApplication.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22

33
import cn.typesafe.km.service.ClusterService;
44
import cn.typesafe.km.service.UserService;
5+
import jakarta.annotation.Resource;
56
import lombok.SneakyThrows;
67
import lombok.extern.slf4j.Slf4j;
78
import org.springframework.boot.CommandLineRunner;
89
import org.springframework.boot.SpringApplication;
910
import org.springframework.boot.autoconfigure.SpringBootApplication;
11+
import org.springframework.context.annotation.Configuration;
1012
import org.springframework.scheduling.annotation.EnableScheduling;
1113

12-
import jakarta.annotation.Resource;
1314
import java.nio.file.Files;
1415
import java.nio.file.Path;
1516
import java.nio.file.Paths;
1617

18+
@Configuration
19+
//@RegisterReflectionForBinding({SQLiteDialect.class,})
1720
@Slf4j
1821
@EnableScheduling
1922
@SpringBootApplication

src/main/java/cn/typesafe/km/controller/BrokerController.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import cn.typesafe.km.service.BrokerService;
44
import cn.typesafe.km.service.dto.Broker;
5-
import org.springframework.web.bind.annotation.GetMapping;
6-
import org.springframework.web.bind.annotation.RequestMapping;
7-
import org.springframework.web.bind.annotation.RequestParam;
8-
import org.springframework.web.bind.annotation.RestController;
5+
import cn.typesafe.km.service.dto.ServerConfig;
6+
import org.springframework.web.bind.annotation.*;
97

108
import jakarta.annotation.Resource;
119
import java.util.List;
10+
import java.util.Map;
1211
import java.util.concurrent.ExecutionException;
1312

1413
/**
@@ -26,4 +25,14 @@ public class BrokerController {
2625
public List<Broker> brokers(@RequestParam String clusterId) throws ExecutionException, InterruptedException {
2726
return brokerService.brokers(null, clusterId);
2827
}
28+
29+
@GetMapping("/{id}/configs")
30+
public List<ServerConfig> configs(@PathVariable String id, @RequestParam String clusterId) throws ExecutionException, InterruptedException {
31+
return brokerService.getConfigs(id, clusterId);
32+
}
33+
34+
@PutMapping("/{id}/configs")
35+
public void updateConfigs(@PathVariable String id, @RequestParam String clusterId, @RequestBody Map<String, String> configs) throws ExecutionException, InterruptedException {
36+
brokerService.setConfigs(id, clusterId, configs);
37+
}
2938
}

src/main/java/cn/typesafe/km/controller/TopicController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public long data(@PathVariable String topic, @RequestParam String clusterId, @Re
112112
}
113113

114114
@GetMapping("/{topic}/configs")
115-
public List<TopicConfig> getConfigs(@PathVariable String topic, @RequestParam String clusterId) throws ExecutionException, InterruptedException {
115+
public List<ServerConfig> getConfigs(@PathVariable String topic, @RequestParam String clusterId) throws ExecutionException, InterruptedException {
116116
return topicService.getConfigs(topic, clusterId);
117117
}
118118

src/main/java/cn/typesafe/km/service/BrokerService.java

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package cn.typesafe.km.service;
22

33
import cn.typesafe.km.service.dto.Broker;
4+
import cn.typesafe.km.service.dto.ServerConfig;
45
import jakarta.annotation.Resource;
56
import lombok.extern.slf4j.Slf4j;
6-
import org.apache.kafka.clients.admin.AdminClient;
7-
import org.apache.kafka.clients.admin.DescribeClusterResult;
8-
import org.apache.kafka.clients.admin.TopicDescription;
7+
import org.apache.kafka.clients.admin.*;
98
import org.apache.kafka.common.Node;
109
import org.apache.kafka.common.TopicPartitionInfo;
10+
import org.apache.kafka.common.config.ConfigResource;
1111
import org.springframework.stereotype.Service;
1212
import org.springframework.util.CollectionUtils;
1313

@@ -83,4 +83,44 @@ public List<Broker> brokers(Set<String> topicNames, String clusterId) throws Exe
8383

8484
return brokers;
8585
}
86+
87+
public List<ServerConfig> getConfigs(String id, String clusterId) throws ExecutionException, InterruptedException {
88+
AdminClient adminClient = clusterService.getAdminClient(clusterId);
89+
ConfigResource configResource = new ConfigResource(ConfigResource.Type.BROKER, id);
90+
91+
Config config = adminClient.describeConfigs(Collections.singletonList(configResource)).all().get().get(configResource);
92+
93+
return config.entries()
94+
.stream()
95+
.map(entry -> {
96+
ServerConfig topicConfig = new ServerConfig();
97+
topicConfig.setName(entry.name());
98+
topicConfig.setValue(entry.value());
99+
topicConfig.set_default(entry.isDefault());
100+
topicConfig.setReadonly(entry.isReadOnly());
101+
topicConfig.setSensitive(entry.isSensitive());
102+
return topicConfig;
103+
})
104+
.collect(Collectors.toList());
105+
}
106+
107+
public void setConfigs(String id, String clusterId, Map<String, String> configs) throws ExecutionException, InterruptedException {
108+
AdminClient adminClient = clusterService.getAdminClient(clusterId);
109+
ConfigResource configResource = new ConfigResource(ConfigResource.Type.BROKER, id);
110+
111+
List<AlterConfigOp> alterConfigOps = configs.entrySet()
112+
.stream()
113+
.map(e -> {
114+
String key = e.getKey();
115+
String value = e.getValue();
116+
ConfigEntry configEntry = new ConfigEntry(key, value);
117+
return new AlterConfigOp(configEntry, AlterConfigOp.OpType.SET);
118+
})
119+
.collect(Collectors.toList());
120+
121+
Map<ConfigResource, Collection<AlterConfigOp>> data = new HashMap<>();
122+
data.put(configResource, alterConfigOps);
123+
124+
adminClient.incrementalAlterConfigs(data).all().get();
125+
}
86126
}

src/main/java/cn/typesafe/km/service/ClusterService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.kafka.clients.consumer.KafkaConsumer;
1414
import org.apache.kafka.clients.producer.KafkaProducer;
1515
import org.apache.kafka.clients.producer.ProducerConfig;
16+
import org.apache.kafka.common.config.ConfigResource;
1617
import org.apache.kafka.common.serialization.StringDeserializer;
1718
import org.apache.kafka.common.serialization.StringSerializer;
1819
import org.springframework.stereotype.Service;

src/main/java/cn/typesafe/km/service/TopicService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void createPartitions(String clusterId, String topic, int totalCount) thr
253253
}
254254

255255
@SneakyThrows
256-
public List<TopicConfig> getConfigs(String topic, String clusterId) throws ExecutionException, InterruptedException {
256+
public List<ServerConfig> getConfigs(String topic, String clusterId) throws ExecutionException, InterruptedException {
257257
AdminClient adminClient = clusterService.getAdminClient(clusterId);
258258

259259
ConfigResource configResource = new ConfigResource(ConfigResource.Type.TOPIC, topic);
@@ -262,7 +262,7 @@ public List<TopicConfig> getConfigs(String topic, String clusterId) throws Execu
262262
return config.entries()
263263
.stream()
264264
.map(entry -> {
265-
TopicConfig topicConfig = new TopicConfig();
265+
ServerConfig topicConfig = new ServerConfig();
266266
topicConfig.setName(entry.name());
267267
topicConfig.setValue(entry.value());
268268
topicConfig.set_default(entry.isDefault());

0 commit comments

Comments
 (0)