Skip to content

Commit b008d1b

Browse files
committed
WIP
1 parent 04b4b19 commit b008d1b

File tree

4 files changed

+86
-39
lines changed

4 files changed

+86
-39
lines changed

.dev/dev.yaml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,6 @@ name: "kafbat-ui-dev"
33

44
services:
55

6-
kafbat-ui:
7-
container_name: kafbat-ui
8-
image: ghcr.io/kafbat/kafka-ui:latest
9-
ports:
10-
- 8080:8080
11-
depends_on:
12-
- kafka0
13-
- schema-registry0
14-
- kafka-connect0
15-
- ksqldb0
16-
environment:
17-
KAFKA_CLUSTERS_0_NAME: local
18-
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka0:29092
19-
KAFKA_CLUSTERS_0_METRICS_PORT: 9997
20-
KAFKA_CLUSTERS_0_SCHEMAREGISTRY: http://schema-registry0:8085
21-
KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: first
22-
KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: http://kafka-connect0:8083
23-
KAFKA_CLUSTERS_0_KSQLDBSERVER: http://ksqldb0:8088
24-
DYNAMIC_CONFIG_ENABLED: 'true'
25-
KAFKA_CLUSTERS_0_AUDIT_TOPICAUDITENABLED: 'true'
26-
KAFKA_CLUSTERS_0_AUDIT_CONSOLEAUDITENABLED: 'true'
27-
286
kafka0:
297
image: confluentinc/cp-kafka:7.8.0
308
hostname: kafka0
@@ -48,8 +26,8 @@ services:
4826
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
4927
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
5028
KAFKA_JMX_PORT: 9997
51-
# KAFKA_JMX_HOSTNAME: localhost # uncomment this line and comment the next one if running with kafka-ui as a jar
52-
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
29+
KAFKA_JMX_HOSTNAME: localhost # uncomment this line and comment the next one if running with kafka-ui as a jar
30+
# KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
5331
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
5432

5533
schema-registry0:
@@ -91,7 +69,9 @@ services:
9169
CONNECT_INTERNAL_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
9270
CONNECT_INTERNAL_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
9371
CONNECT_REST_ADVERTISED_HOST_NAME: kafka-connect0
94-
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components,/usr/local/share/kafka/plugins,/usr/share/filestream-connectors"
72+
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components,/usr/share/filestream-connectors,/tmp/connectors"
73+
volumes:
74+
- /tmp/connectors:/tmp/connectors
9575

9676
ksqldb0:
9777
image: confluentinc/cp-ksqldb-server:7.8.0

api/src/main/java/io/kafbat/ui/service/app/ConfigReloadService.java

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,29 @@
1313
import java.nio.file.WatchEvent;
1414
import java.nio.file.WatchKey;
1515
import java.nio.file.WatchService;
16+
import java.util.Arrays;
17+
import java.util.HashMap;
18+
import java.util.Iterator;
19+
import java.util.Map;
20+
import java.util.Objects;
21+
import java.util.stream.Collectors;
1622
import lombok.RequiredArgsConstructor;
1723
import lombok.extern.slf4j.Slf4j;
1824
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25+
import org.springframework.boot.env.OriginTrackedMapPropertySource;
26+
import org.springframework.boot.origin.Origin;
27+
import org.springframework.boot.origin.OriginLookup;
28+
import org.springframework.context.ApplicationContext;
29+
import org.springframework.core.env.AbstractEnvironment;
30+
import org.springframework.core.env.ConfigurableEnvironment;
31+
import org.springframework.core.env.EnumerablePropertySource;
32+
import org.springframework.core.env.MapPropertySource;
33+
import org.springframework.core.env.PropertySource;
1934
import org.springframework.stereotype.Service;
35+
import org.stringtemplate.v4.ST;
2036

2137
@Service
22-
@ConditionalOnProperty(value = "dynamic.config.autoreload", havingValue = "true")
38+
//@ConditionalOnProperty(value = "dynamic.config.autoreload", havingValue = "true")
2339
@RequiredArgsConstructor
2440
@Slf4j
2541
public class ConfigReloadService {
@@ -34,8 +50,69 @@ public class ConfigReloadService {
3450
private WatchService watchService;
3551
private Thread watcherThread;
3652

53+
private final ApplicationContext context;
54+
private final ConfigurableEnvironment environment;
55+
3756
@PostConstruct
3857
public void init() {
58+
59+
/* environment.getPropertySources()
60+
.stream()
61+
.filter(ps -> ps instanceof OriginTrackedMapPropertySource)
62+
.map(ps -> (OriginTrackedMapPropertySource)ps)
63+
.map(ps -> ps.getSource())
64+
.map(source -> source.values())
65+
.map(values -> {
66+
return (HashMap<String, String>) values;
67+
})
68+
// .map(sourceValues -> sourceValues.)
69+
.collect(Collectors.toUnmodifiableList());*/
70+
71+
72+
// =============
73+
74+
/* environment.getPropertySources().stream()
75+
.filter(ps -> ps instanceof EnumerablePropertySource)
76+
.filter(ps -> ps instanceof OriginLookup)
77+
.flatMap(ps -> {
78+
EnumerablePropertySource<?> eps = (EnumerablePropertySource<?>) ps;
79+
OriginLookup<String> lookup = (OriginLookup<String>) ps;
80+
return Arrays.stream(eps.getPropertyNames())
81+
.map(name -> {
82+
Origin origin = lookup.getOrigin(name);
83+
return origin != null ? origin.toString() : null;
84+
});
85+
})
86+
.filter(Objects::nonNull)
87+
.distinct()
88+
.collect(Collectors.toUnmodifiableList());*/
89+
90+
// ===============
91+
92+
/* Map<String, Object> map = new HashMap();
93+
for(Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) {
94+
PropertySource propertySource = (PropertySource) it.next();
95+
if (propertySource instanceof MapPropertySource) {
96+
map.putAll(((MapPropertySource) propertySource).getSource());
97+
}
98+
}*/
99+
100+
// ====
101+
102+
SpringConfigurableEnvironment properties = new SpringConfigurableEnvironment(springEnv);
103+
SpringConfigurableEnvironment.PropertyInfo info = properties.get("profile.env");
104+
assertEquals("default", properties.get(info.getValue());
105+
assertEquals(
106+
"Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'",
107+
info.getSourceList.get(0));
108+
109+
110+
111+
112+
System.out.println();
113+
// environment.getPropertySources()
114+
// .stream()
115+
39116
var configPath = dynamicConfigOperations.dynamicConfigFilePath();
40117
if (!Files.exists(configPath) || !Files.isReadable(configPath)) {
41118
log.warn("Dynamic config file {} doesnt exist or is not readable. Auto reload is disabled", configPath);

api/src/main/resources/application-local.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ spring:
2222
user-filter-search-filter: "(&(uid={0})(objectClass=inetOrgPerson))"
2323
group-filter-search-base: "ou=people,dc=planetexpress,dc=com"
2424

25-
kafka:
25+
26+
kaf1ka:
2627
clusters:
2728
- name: local
2829
bootstrapServers: localhost:9092
@@ -81,7 +82,7 @@ auth:
8182
type: github
8283

8384
rbac:
84-
roles:
85+
ro1les:
8586
- name: "memelords"
8687
clusters:
8788
- local

frontend/build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,3 @@ tasks.register('generateContract', PnpmTask) {
2727
outputs.dir(project.layout.projectDirectory.dir("src/generated-sources"))
2828
args = ['gen:sources']
2929
}
30-
31-
tasks.register('buildFrontend', PnpmTask) {
32-
dependsOn generateContract
33-
inputs.files(fileTree("src/"))
34-
outputs.dir(project.layout.buildDirectory.dir("vite/static"))
35-
args = ['build']
36-
environment = System.getenv() + [
37-
"VITE_TAG" : project.version,
38-
"VITE_COMMIT": "git rev-parse --short HEAD".execute().text.trim()
39-
]
40-
}

0 commit comments

Comments
 (0)