Minor issues fixes (#1646)

* Fixed minor issues

* fixed review bug

* fixed bug

Co-authored-by: German Osin <germanosin@Germans-MacBook-Pro.local>
Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
This commit is contained in:
German Osin 2022-02-21 15:13:48 +03:00 committed by GitHub
parent 94b1f4a772
commit 4cc4175ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 316 additions and 272 deletions

View file

@ -6,6 +6,10 @@ import java.util.concurrent.ConcurrentHashMap;
public final class KafkaConnectClients { public final class KafkaConnectClients {
private KafkaConnectClients() {
}
private static final Map<String, KafkaConnectClientApi> CACHE = new ConcurrentHashMap<>(); private static final Map<String, KafkaConnectClientApi> CACHE = new ConcurrentHashMap<>();
public static KafkaConnectClientApi withBaseUrl(String basePath) { public static KafkaConnectClientApi withBaseUrl(String basePath) {

View file

@ -20,7 +20,6 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.util.retry.Retry; import reactor.util.retry.Retry;
import reactor.util.retry.RetryBackoffSpec;
@Slf4j @Slf4j
public class RetryingKafkaConnectClient extends KafkaConnectClientApi { public class RetryingKafkaConnectClient extends KafkaConnectClientApi {
@ -32,7 +31,7 @@ public class RetryingKafkaConnectClient extends KafkaConnectClientApi {
} }
private static Retry conflictCodeRetry() { private static Retry conflictCodeRetry() {
return RetryBackoffSpec return Retry
.fixedDelay(MAX_RETRIES, RETRIES_DELAY) .fixedDelay(MAX_RETRIES, RETRIES_DELAY)
.filter(e -> e instanceof WebClientResponseException.Conflict) .filter(e -> e instanceof WebClientResponseException.Conflict)
.onRetryExhaustedThrow((spec, signal) -> .onRetryExhaustedThrow((spec, signal) ->

View file

@ -61,14 +61,14 @@ public class ClustersProperties {
private void validateClusterNames() { private void validateClusterNames() {
// if only one cluster provided it is ok not to set name // if only one cluster provided it is ok not to set name
if (clusters.size() == 1 && StringUtils.isEmpty(clusters.get(0).getName())) { if (clusters.size() == 1 && !StringUtils.hasText(clusters.get(0).getName())) {
clusters.get(0).setName("Default"); clusters.get(0).setName("Default");
return; return;
} }
Set<String> clusterNames = new HashSet<>(); Set<String> clusterNames = new HashSet<>();
for (Cluster clusterProperties : clusters) { for (Cluster clusterProperties : clusters) {
if (StringUtils.isEmpty(clusterProperties.getName())) { if (!StringUtils.hasText(clusterProperties.getName())) {
throw new IllegalStateException( throw new IllegalStateException(
"Application config isn't valid. " "Application config isn't valid. "
+ "Cluster names should be provided in case of multiple clusters present"); + "Cluster names should be provided in case of multiple clusters present");
@ -79,5 +79,4 @@ public class ClustersProperties {
} }
} }
} }
} }

View file

@ -1,6 +1,5 @@
package com.provectus.kafka.ui.config; package com.provectus.kafka.ui.config;
import com.fasterxml.jackson.databind.Module;
import com.provectus.kafka.ui.model.JmxConnectionInfo; import com.provectus.kafka.ui.model.JmxConnectionInfo;
import com.provectus.kafka.ui.util.JmxPoolFactory; import com.provectus.kafka.ui.util.JmxPoolFactory;
import java.util.Collections; import java.util.Collections;

View file

@ -45,7 +45,7 @@ public class ReadOnlyModeFilter implements WebFilter {
() -> new ClusterNotFoundException( () -> new ClusterNotFoundException(
String.format("No cluster for name '%s'", clusterName))); String.format("No cluster for name '%s'", clusterName)));
if (!kafkaCluster.getReadOnly()) { if (!kafkaCluster.isReadOnly()) {
return chain.filter(exchange); return chain.filter(exchange);
} }

View file

@ -2,7 +2,11 @@ package com.provectus.kafka.ui.config.auth;
abstract class AbstractAuthSecurityConfig { abstract class AbstractAuthSecurityConfig {
public static final String[] AUTH_WHITELIST = { protected AbstractAuthSecurityConfig() {
}
protected static final String[] AUTH_WHITELIST = {
"/css/**", "/css/**",
"/js/**", "/js/**",
"/media/**", "/media/**",

View file

@ -43,7 +43,7 @@ public class LdapSecurityConfig extends AbstractAuthSecurityConfig {
public ReactiveAuthenticationManager authenticationManager(BaseLdapPathContextSource contextSource) { public ReactiveAuthenticationManager authenticationManager(BaseLdapPathContextSource contextSource) {
BindAuthenticator ba = new BindAuthenticator(contextSource); BindAuthenticator ba = new BindAuthenticator(contextSource);
if (ldapUserDnPattern != null) { if (ldapUserDnPattern != null) {
ba.setUserDnPatterns(new String[]{ldapUserDnPattern}); ba.setUserDnPatterns(new String[] {ldapUserDnPattern});
} }
if (userFilterSearchFilter != null) { if (userFilterSearchFilter != null) {
LdapUserSearch userSearch = LdapUserSearch userSearch =

View file

@ -39,14 +39,14 @@ public class OAuthSecurityConfig extends AbstractAuthSecurityConfig {
.authenticated(); .authenticated();
if (IS_OAUTH2_PRESENT && OAuth2ClasspathGuard.shouldConfigure(this.context)) { if (IS_OAUTH2_PRESENT && OAuth2ClasspathGuard.shouldConfigure(this.context)) {
OAuth2ClasspathGuard.configure(this.context, http); OAuth2ClasspathGuard.configure(http);
} }
return http.csrf().disable().build(); return http.csrf().disable().build();
} }
private static class OAuth2ClasspathGuard { private static class OAuth2ClasspathGuard {
static void configure(ApplicationContext context, ServerHttpSecurity http) { static void configure(ServerHttpSecurity http) {
http http
.oauth2Login() .oauth2Login()
.and() .and()

View file

@ -15,8 +15,8 @@ import reactor.core.publisher.Mono;
@Slf4j @Slf4j
public class AuthController { public class AuthController {
@GetMapping(value = "/auth", produces = { "text/html" }) @GetMapping(value = "/auth", produces = {"text/html"})
private Mono<byte[]> getAuth(ServerWebExchange exchange) { public Mono<byte[]> getAuth(ServerWebExchange exchange) {
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty()); Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
return token return token
.map(AuthController::csrfToken) .map(AuthController::csrfToken)

View file

@ -1,13 +1,11 @@
package com.provectus.kafka.ui.controller; package com.provectus.kafka.ui.controller;
import com.provectus.kafka.ui.util.ResourceUtil; import com.provectus.kafka.ui.util.ResourceUtil;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -24,7 +22,7 @@ public class StaticController {
private Resource indexFile; private Resource indexFile;
private final AtomicReference<String> renderedIndexFile = new AtomicReference<>(); private final AtomicReference<String> renderedIndexFile = new AtomicReference<>();
@GetMapping(value = "/index.html", produces = { "text/html" }) @GetMapping(value = "/index.html", produces = {"text/html"})
public Mono<ResponseEntity<String>> getIndex(ServerWebExchange exchange) { public Mono<ResponseEntity<String>> getIndex(ServerWebExchange exchange) {
return Mono.just(ResponseEntity.ok(getRenderedIndexFile(exchange))); return Mono.just(ResponseEntity.ok(getRenderedIndexFile(exchange)));
} }

View file

@ -101,10 +101,9 @@ public class TopicsController extends AbstractController implements TopicsApi {
String clusterName, String topicName, String clusterName, String topicName,
Mono<PartitionsIncreaseDTO> partitionsIncrease, Mono<PartitionsIncreaseDTO> partitionsIncrease,
ServerWebExchange exchange) { ServerWebExchange exchange) {
return partitionsIncrease.flatMap( return partitionsIncrease.flatMap(partitions ->
partitions -> topicsService.increaseTopicPartitions(getCluster(clusterName), topicName, partitions)
topicsService.increaseTopicPartitions(getCluster(clusterName), topicName, partitions)) ).map(ResponseEntity::ok);
.map(ResponseEntity::ok);
} }
@Override @Override

View file

@ -19,7 +19,7 @@ public abstract class AbstractEmitter {
private final RecordSerDe recordDeserializer; private final RecordSerDe recordDeserializer;
private final ConsumingStats consumingStats = new ConsumingStats(); private final ConsumingStats consumingStats = new ConsumingStats();
public AbstractEmitter(RecordSerDe recordDeserializer) { protected AbstractEmitter(RecordSerDe recordDeserializer) {
this.recordDeserializer = recordDeserializer; this.recordDeserializer = recordDeserializer;
} }

View file

@ -17,13 +17,13 @@ class ConsumingStats {
void sendConsumingEvt(FluxSink<TopicMessageEventDTO> sink, void sendConsumingEvt(FluxSink<TopicMessageEventDTO> sink,
ConsumerRecords<Bytes, Bytes> polledRecords, ConsumerRecords<Bytes, Bytes> polledRecords,
long elapsed) { long elapsed) {
for (ConsumerRecord<Bytes, Bytes> record : polledRecords) { for (ConsumerRecord<Bytes, Bytes> rec : polledRecords) {
for (Header header : record.headers()) { for (Header header : rec.headers()) {
bytes += bytes +=
(header.key() != null ? header.key().getBytes().length : 0L) (header.key() != null ? header.key().getBytes().length : 0L)
+ (header.value() != null ? header.value().length : 0L); + (header.value() != null ? header.value().length : 0L);
} }
bytes += record.serializedKeySize() + record.serializedValueSize(); bytes += rec.serializedKeySize() + rec.serializedValueSize();
} }
this.records += polledRecords.count(); this.records += polledRecords.count();
this.elapsed += elapsed; this.elapsed += elapsed;

View file

@ -18,6 +18,9 @@ public class MessageFilters {
private static GroovyScriptEngineImpl GROOVY_ENGINE; private static GroovyScriptEngineImpl GROOVY_ENGINE;
private MessageFilters() {
}
public static Predicate<TopicMessageDTO> createMsgFilter(String query, MessageFilterTypeDTO type) { public static Predicate<TopicMessageDTO> createMsgFilter(String query, MessageFilterTypeDTO type) {
switch (type) { switch (type) {
case STRING_CONTAINS: case STRING_CONTAINS:

View file

@ -1,12 +0,0 @@
package com.provectus.kafka.ui.exception;
public class SchemaTypeIsNotSupportedException extends UnprocessableEntityException {
private static final String REQUIRED_SCHEMA_REGISTRY_VERSION = "5.5.0";
public SchemaTypeIsNotSupportedException() {
super(String.format("Current version of Schema Registry does "
+ "not support provided schema type,"
+ " version %s or later is required here.", REQUIRED_SCHEMA_REGISTRY_VERSION));
}
}

View file

@ -0,0 +1,12 @@
package com.provectus.kafka.ui.exception;
public class SchemaTypeNotSupportedException extends UnprocessableEntityException {
private static final String REQUIRED_SCHEMA_REGISTRY_VERSION = "5.5.0";
public SchemaTypeNotSupportedException() {
super(String.format("Current version of Schema Registry does "
+ "not support provided schema type,"
+ " version %s or later is required here.", REQUIRED_SCHEMA_REGISTRY_VERSION));
}
}

View file

@ -17,6 +17,9 @@ import org.apache.kafka.common.TopicPartition;
public class ConsumerGroupMapper { public class ConsumerGroupMapper {
private ConsumerGroupMapper() {
}
public static ConsumerGroupDTO toDto(InternalConsumerGroup c) { public static ConsumerGroupDTO toDto(InternalConsumerGroup c) {
return convertToConsumerGroup(c, new ConsumerGroupDTO()); return convertToConsumerGroup(c, new ConsumerGroupDTO());
} }
@ -47,7 +50,7 @@ public class ConsumerGroupMapper {
for (TopicPartition topicPartition : member.getAssignment()) { for (TopicPartition topicPartition : member.getAssignment()) {
final ConsumerGroupTopicPartitionDTO partition = partitionMap.computeIfAbsent( final ConsumerGroupTopicPartitionDTO partition = partitionMap.computeIfAbsent(
topicPartition, topicPartition,
(tp) -> new ConsumerGroupTopicPartitionDTO() tp -> new ConsumerGroupTopicPartitionDTO()
.topic(tp.topic()) .topic(tp.topic())
.partition(tp.partition()) .partition(tp.partition())
); );
@ -99,12 +102,18 @@ public class ConsumerGroupMapper {
private static ConsumerGroupStateDTO mapConsumerGroupState( private static ConsumerGroupStateDTO mapConsumerGroupState(
org.apache.kafka.common.ConsumerGroupState state) { org.apache.kafka.common.ConsumerGroupState state) {
switch (state) { switch (state) {
case DEAD: return ConsumerGroupStateDTO.DEAD; case DEAD:
case EMPTY: return ConsumerGroupStateDTO.EMPTY; return ConsumerGroupStateDTO.DEAD;
case STABLE: return ConsumerGroupStateDTO.STABLE; case EMPTY:
case PREPARING_REBALANCE: return ConsumerGroupStateDTO.PREPARING_REBALANCE; return ConsumerGroupStateDTO.EMPTY;
case COMPLETING_REBALANCE: return ConsumerGroupStateDTO.COMPLETING_REBALANCE; case STABLE:
default: return ConsumerGroupStateDTO.UNKNOWN; return ConsumerGroupStateDTO.STABLE;
case PREPARING_REBALANCE:
return ConsumerGroupStateDTO.PREPARING_REBALANCE;
case COMPLETING_REBALANCE:
return ConsumerGroupStateDTO.COMPLETING_REBALANCE;
default:
return ConsumerGroupStateDTO.UNKNOWN;
} }
} }

View file

@ -1,6 +1,5 @@
package com.provectus.kafka.ui.model; package com.provectus.kafka.ui.model;
import com.provectus.kafka.ui.exception.IllegalEntityStateException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -11,24 +10,24 @@ public enum CleanupPolicy {
COMPACT_DELETE(Arrays.asList("compact,delete", "delete,compact")), COMPACT_DELETE(Arrays.asList("compact,delete", "delete,compact")),
UNKNOWN("unknown"); UNKNOWN("unknown");
private final List<String> cleanUpPolicy; private final List<String> policies;
CleanupPolicy(String cleanUpPolicy) { CleanupPolicy(String policy) {
this(Collections.singletonList(cleanUpPolicy)); this(Collections.singletonList(policy));
} }
CleanupPolicy(List<String> cleanUpPolicy) { CleanupPolicy(List<String> policies) {
this.cleanUpPolicy = cleanUpPolicy; this.policies = policies;
} }
public String getCleanUpPolicy() { public String getPolicy() {
return cleanUpPolicy.get(0); return policies.get(0);
} }
public static CleanupPolicy fromString(String string) { public static CleanupPolicy fromString(String string) {
return Arrays.stream(CleanupPolicy.values()) return Arrays.stream(CleanupPolicy.values())
.filter(v -> .filter(v ->
v.cleanUpPolicy.stream().anyMatch( v.policies.stream().anyMatch(
s -> s.equals(string.replace(" ", "") s -> s.equals(string.replace(" ", "")
) )
) )

View file

@ -38,7 +38,7 @@ public class InternalClusterMetrics {
// zk stats // zk stats
@Deprecated //use 'zookeeperStatus' field with enum type instead @Deprecated //use 'zookeeperStatus' field with enum type instead
private final int zooKeeperStatus; private final int zooKeeperStatusEnum;
private final ServerStatusDTO zookeeperStatus; private final ServerStatusDTO zookeeperStatus;
private final Throwable lastZookeeperException; private final Throwable lastZookeeperException;

View file

@ -67,7 +67,7 @@ public class InternalClusterState {
inSyncReplicasCount = partitionsStats.getInSyncReplicasCount(); inSyncReplicasCount = partitionsStats.getInSyncReplicasCount();
outOfSyncReplicasCount = partitionsStats.getOutOfSyncReplicasCount(); outOfSyncReplicasCount = partitionsStats.getOutOfSyncReplicasCount();
underReplicatedPartitionCount = partitionsStats.getUnderReplicatedPartitionCount(); underReplicatedPartitionCount = partitionsStats.getUnderReplicatedPartitionCount();
readOnly = cluster.getReadOnly(); readOnly = cluster.isReadOnly();
} }
} }

View file

@ -65,21 +65,21 @@ public class InternalConsumerGroup {
// removes data for all partitions that are not fit filter // removes data for all partitions that are not fit filter
public InternalConsumerGroup retainDataForPartitions(Predicate<TopicPartition> partitionsFilter) { public InternalConsumerGroup retainDataForPartitions(Predicate<TopicPartition> partitionsFilter) {
var offsets = getOffsets().entrySet().stream() var offsetsMap = getOffsets().entrySet().stream()
.filter(e -> partitionsFilter.test(e.getKey())) .filter(e -> partitionsFilter.test(e.getKey()))
.collect(Collectors.toMap( .collect(Collectors.toMap(
Map.Entry::getKey, Map.Entry::getKey,
Map.Entry::getValue Map.Entry::getValue
)); ));
var members = getMembers().stream() var nonEmptyMembers = getMembers().stream()
.map(m -> filterConsumerMemberTopic(m, partitionsFilter)) .map(m -> filterConsumerMemberTopic(m, partitionsFilter))
.filter(m -> !m.getAssignment().isEmpty()) .filter(m -> !m.getAssignment().isEmpty())
.collect(Collectors.toList()); .collect(Collectors.toList());
return toBuilder() return toBuilder()
.offsets(offsets) .offsets(offsetsMap)
.members(members) .members(nonEmptyMembers)
.build(); .build();
} }

View file

@ -30,6 +30,6 @@ public class KafkaCluster {
private final String protobufMessageName; private final String protobufMessageName;
private final Map<String, String> protobufMessageNameByTopic; private final Map<String, String> protobufMessageNameByTopic;
private final Properties properties; private final Properties properties;
private final Boolean readOnly; private final boolean readOnly;
private final Boolean disableLogDirsCollection; private final boolean disableLogDirsCollection;
} }

View file

@ -2,7 +2,6 @@ package com.provectus.kafka.ui.model.schemaregistry;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.provectus.kafka.ui.model.SchemaTypeDTO; import com.provectus.kafka.ui.model.SchemaTypeDTO;
import com.provectus.kafka.ui.model.SchemaTypeDTO;
import lombok.Data; import lombok.Data;
@Data @Data

View file

@ -14,12 +14,18 @@ public interface RecordSerDe {
@Value @Value
@Builder @Builder
class DeserializedKeyValue { class DeserializedKeyValue {
@Nullable String key; @Nullable
@Nullable String value; String key;
@Nullable MessageFormat keyFormat; @Nullable
@Nullable MessageFormat valueFormat; String value;
@Nullable String keySchemaId; @Nullable
@Nullable String valueSchemaId; MessageFormat keyFormat;
@Nullable
MessageFormat valueFormat;
@Nullable
String keySchemaId;
@Nullable
String valueSchemaId;
} }
DeserializedKeyValue deserialize(ConsumerRecord<Bytes, Bytes> msg); DeserializedKeyValue deserialize(ConsumerRecord<Bytes, Bytes> msg);

View file

@ -6,8 +6,8 @@ import io.confluent.kafka.schemaregistry.avro.AvroSchemaUtils;
import io.confluent.kafka.schemaregistry.client.SchemaMetadata; import io.confluent.kafka.schemaregistry.client.SchemaMetadata;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException; import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
import io.confluent.kafka.serializers.KafkaAvroSerializer; import io.confluent.kafka.serializers.KafkaAvroSerializer;
import io.confluent.kafka.serializers.KafkaAvroSerializerConfig;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.common.serialization.Serializer;
@ -27,8 +27,8 @@ public class AvroMessageReader extends MessageReader<Object> {
serializer.configure( serializer.configure(
Map.of( Map.of(
"schema.registry.url", "wontbeused", "schema.registry.url", "wontbeused",
KafkaAvroSerializerConfig.AUTO_REGISTER_SCHEMAS, false, AbstractKafkaSchemaSerDeConfig.AUTO_REGISTER_SCHEMAS, false,
KafkaAvroSerializerConfig.USE_LATEST_VERSION, true AbstractKafkaSchemaSerDeConfig.USE_LATEST_VERSION, true
), ),
isKey isKey
); );

View file

@ -10,8 +10,8 @@ import io.confluent.kafka.schemaregistry.client.SchemaMetadata;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException; import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
import io.confluent.kafka.schemaregistry.json.JsonSchema; import io.confluent.kafka.schemaregistry.json.JsonSchema;
import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
import io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer; import io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer;
import io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializerConfig;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.common.serialization.Serializer;
@ -33,8 +33,8 @@ public class JsonSchemaMessageReader extends MessageReader<JsonNode> {
serializer.configure( serializer.configure(
Map.of( Map.of(
"schema.registry.url", "wontbeused", "schema.registry.url", "wontbeused",
KafkaJsonSchemaSerializerConfig.AUTO_REGISTER_SCHEMAS, false, AbstractKafkaSchemaSerDeConfig.AUTO_REGISTER_SCHEMAS, false,
KafkaJsonSchemaSerializerConfig.USE_LATEST_VERSION, true AbstractKafkaSchemaSerDeConfig.USE_LATEST_VERSION, true
), ),
isKey isKey
); );
@ -69,10 +69,10 @@ public class JsonSchemaMessageReader extends MessageReader<JsonNode> {
* possible in our case. So, we just skip all infer logic and pass schema directly. * possible in our case. So, we just skip all infer logic and pass schema directly.
*/ */
@Override @Override
public byte[] serialize(String topic, JsonNode record) { public byte[] serialize(String topic, JsonNode rec) {
return super.serializeImpl( return super.serializeImpl(
super.getSubjectName(topic, isKey, record, schema), super.getSubjectName(topic, isKey, rec, schema),
record, rec,
(JsonSchema) schema (JsonSchema) schema
); );
} }

View file

@ -8,8 +8,8 @@ import io.confluent.kafka.schemaregistry.client.SchemaMetadata;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException; import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema; import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema;
import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
import io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializer; import io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializer;
import io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializerConfig;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.common.serialization.Serializer;
@ -28,8 +28,8 @@ public class ProtobufMessageReader extends MessageReader<Message> {
serializer.configure( serializer.configure(
Map.of( Map.of(
"schema.registry.url", "wontbeused", "schema.registry.url", "wontbeused",
KafkaProtobufSerializerConfig.AUTO_REGISTER_SCHEMAS, false, AbstractKafkaSchemaSerDeConfig.AUTO_REGISTER_SCHEMAS, false,
KafkaProtobufSerializerConfig.USE_LATEST_VERSION, true AbstractKafkaSchemaSerDeConfig.USE_LATEST_VERSION, true
), ),
isKey isKey
); );

View file

@ -113,7 +113,7 @@ public class SchemaRegistryAwareRecordSerDe implements RecordSerDe {
DeserializedKeyValueBuilder builder) { DeserializedKeyValueBuilder builder) {
Optional<Integer> schemaId = extractSchemaIdFromMsg(rec, isKey); Optional<Integer> schemaId = extractSchemaIdFromMsg(rec, isKey);
Optional<MessageFormat> format = schemaId.flatMap(this::getMessageFormatBySchemaId); Optional<MessageFormat> format = schemaId.flatMap(this::getMessageFormatBySchemaId);
if (format.isPresent() && schemaRegistryFormatters.containsKey(format.get())) { if (schemaId.isPresent() && format.isPresent() && schemaRegistryFormatters.containsKey(format.get())) {
var formatter = schemaRegistryFormatters.get(format.get()); var formatter = schemaRegistryFormatters.get(format.get());
try { try {
var deserialized = formatter.format(rec.topic(), isKey ? rec.key().get() : rec.value().get()); var deserialized = formatter.format(rec.topic(), isKey ? rec.key().get() : rec.value().get());
@ -135,12 +135,13 @@ public class SchemaRegistryAwareRecordSerDe implements RecordSerDe {
// fallback // fallback
if (isKey) { if (isKey) {
builder.key(FALLBACK_FORMATTER.format(rec.topic(), isKey ? rec.key().get() : rec.value().get())); builder.key(FALLBACK_FORMATTER.format(rec.topic(), rec.key().get()));
builder.keyFormat(FALLBACK_FORMATTER.getFormat()); builder.keyFormat(FALLBACK_FORMATTER.getFormat());
} else { } else {
builder.value(FALLBACK_FORMATTER.format(rec.topic(), isKey ? rec.key().get() : rec.value().get())); builder.value(FALLBACK_FORMATTER.format(rec.topic(), rec.value().get()));
builder.valueFormat(FALLBACK_FORMATTER.getFormat()); builder.valueFormat(FALLBACK_FORMATTER.getFormat());
} }
} }
@Override @Override
@ -202,14 +203,14 @@ public class SchemaRegistryAwareRecordSerDe implements RecordSerDe {
final MessageSchemaDTO keySchema = new MessageSchemaDTO() final MessageSchemaDTO keySchema = new MessageSchemaDTO()
.name(maybeKeySchema.map( .name(maybeKeySchema.map(
(s) -> schemaSubject(topic, true) s -> schemaSubject(topic, true)
).orElse("unknown")) ).orElse("unknown"))
.source(MessageSchemaDTO.SourceEnum.SCHEMA_REGISTRY) .source(MessageSchemaDTO.SourceEnum.SCHEMA_REGISTRY)
.schema(sourceKeySchema); .schema(sourceKeySchema);
final MessageSchemaDTO valueSchema = new MessageSchemaDTO() final MessageSchemaDTO valueSchema = new MessageSchemaDTO()
.name(maybeValueSchema.map( .name(maybeValueSchema.map(
(s) -> schemaSubject(topic, false) s -> schemaSubject(topic, false)
).orElse("unknown")) ).orElse("unknown"))
.source(MessageSchemaDTO.SourceEnum.SCHEMA_REGISTRY) .source(MessageSchemaDTO.SourceEnum.SCHEMA_REGISTRY)
.schema(sourceValueSchema); .schema(sourceValueSchema);

View file

@ -11,7 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.ToIntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -141,18 +141,25 @@ public class ConsumerGroupService {
case NAME: case NAME:
return Comparator.comparing(ConsumerGroupDescription::groupId); return Comparator.comparing(ConsumerGroupDescription::groupId);
case STATE: case STATE:
Function<ConsumerGroupDescription, Integer> statesPriorities = cg -> { ToIntFunction<ConsumerGroupDescription> statesPriorities = cg -> {
switch (cg.state()) { switch (cg.state()) {
case STABLE: return 0; case STABLE:
case COMPLETING_REBALANCE: return 1; return 0;
case PREPARING_REBALANCE: return 2; case COMPLETING_REBALANCE:
case EMPTY: return 3; return 1;
case DEAD: return 4; case PREPARING_REBALANCE:
case UNKNOWN: return 5; return 2;
default: return 100; case EMPTY:
return 3;
case DEAD:
return 4;
case UNKNOWN:
return 5;
default:
return 100;
} }
}; };
return Comparator.comparingInt(statesPriorities::apply); return Comparator.comparingInt(statesPriorities);
case MEMBERS: case MEMBERS:
return Comparator.comparingInt(cg -> -cg.members().size()); return Comparator.comparingInt(cg -> -cg.members().size());
default: default:

View file

@ -44,7 +44,7 @@ public class FeatureService {
if (controller != null) { if (controller != null) {
features.add( features.add(
isTopicDeletionEnabled(cluster, controller) isTopicDeletionEnabled(cluster, controller)
.flatMap(r -> r ? Mono.just(Feature.TOPIC_DELETION) : Mono.empty()) .flatMap(r -> Boolean.TRUE.equals(r) ? Mono.just(Feature.TOPIC_DELETION) : Mono.empty())
); );
} }

View file

@ -30,7 +30,7 @@ class KafkaConfigSanitizer extends Sanitizer {
var keysToSanitize = new HashSet<>( var keysToSanitize = new HashSet<>(
patternsToSanitize.isEmpty() ? DEFAULT_PATTERNS_TO_SANITIZE : patternsToSanitize); patternsToSanitize.isEmpty() ? DEFAULT_PATTERNS_TO_SANITIZE : patternsToSanitize);
keysToSanitize.addAll(kafkaConfigKeysToSanitize()); keysToSanitize.addAll(kafkaConfigKeysToSanitize());
setKeysToSanitize(keysToSanitize.toArray(new String[]{})); setKeysToSanitize(keysToSanitize.toArray(new String[] {}));
} }
} }

View file

@ -103,7 +103,7 @@ public class KafkaConnectService {
} }
private Predicate<FullConnectorInfoDTO> matchesSearchTerm(final String search) { private Predicate<FullConnectorInfoDTO> matchesSearchTerm(final String search) {
return (connector) -> getSearchValues(connector) return connector -> getSearchValues(connector)
.anyMatch(value -> value.contains( .anyMatch(value -> value.contains(
StringUtils.defaultString( StringUtils.defaultString(
search, search,
@ -158,7 +158,7 @@ public class KafkaConnectService {
connector connector
.flatMap(c -> connectorExists(cluster, connectName, c.getName()) .flatMap(c -> connectorExists(cluster, connectName, c.getName())
.map(exists -> { .map(exists -> {
if (exists) { if (Boolean.TRUE.equals(exists)) {
throw new ValidationException( throw new ValidationException(
String.format("Connector with name %s already exists", c.getName())); String.format("Connector with name %s already exists", c.getName()));
} }

View file

@ -60,7 +60,7 @@ public class MetricsService {
} }
private Mono<InternalLogDirStats> getLogDirInfo(KafkaCluster cluster, ReactiveAdminClient c) { private Mono<InternalLogDirStats> getLogDirInfo(KafkaCluster cluster, ReactiveAdminClient c) {
if (cluster.getDisableLogDirsCollection() == null || !cluster.getDisableLogDirsCollection()) { if (!cluster.isDisableLogDirsCollection()) {
return c.describeLogDirs().map(InternalLogDirStats::new); return c.describeLogDirs().map(InternalLogDirStats::new);
} }
return Mono.just(InternalLogDirStats.empty()); return Mono.just(InternalLogDirStats.empty());

View file

@ -5,7 +5,7 @@ import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import com.provectus.kafka.ui.exception.SchemaFailedToDeleteException; import com.provectus.kafka.ui.exception.SchemaFailedToDeleteException;
import com.provectus.kafka.ui.exception.SchemaNotFoundException; import com.provectus.kafka.ui.exception.SchemaNotFoundException;
import com.provectus.kafka.ui.exception.SchemaTypeIsNotSupportedException; import com.provectus.kafka.ui.exception.SchemaTypeNotSupportedException;
import com.provectus.kafka.ui.exception.UnprocessableEntityException; import com.provectus.kafka.ui.exception.UnprocessableEntityException;
import com.provectus.kafka.ui.exception.ValidationException; import com.provectus.kafka.ui.exception.ValidationException;
import com.provectus.kafka.ui.mapper.ClusterMapper; import com.provectus.kafka.ui.mapper.ClusterMapper;
@ -212,7 +212,7 @@ public class SchemaRegistryService {
.onStatus(UNPROCESSABLE_ENTITY::equals, .onStatus(UNPROCESSABLE_ENTITY::equals,
r -> r.bodyToMono(ErrorResponse.class) r -> r.bodyToMono(ErrorResponse.class)
.flatMap(x -> Mono.error(isUnrecognizedFieldSchemaTypeMessage(x.getMessage()) .flatMap(x -> Mono.error(isUnrecognizedFieldSchemaTypeMessage(x.getMessage())
? new SchemaTypeIsNotSupportedException() ? new SchemaTypeNotSupportedException()
: new UnprocessableEntityException(x.getMessage())))) : new UnprocessableEntityException(x.getMessage()))))
.bodyToMono(SubjectIdResponse.class); .bodyToMono(SubjectIdResponse.class);
} }
@ -294,7 +294,9 @@ public class SchemaRegistryService {
} }
public String formatted(String str, Object... args) { public String formatted(String str, Object... args) {
return new Formatter().format(str, args).toString(); try (Formatter formatter = new Formatter()) {
return formatter.format(str, args).toString();
}
} }
private void setBasicAuthIfEnabled(InternalSchemaRegistry schemaRegistry, HttpHeaders headers) { private void setBasicAuthIfEnabled(InternalSchemaRegistry schemaRegistry, HttpHeaders headers) {

View file

@ -206,7 +206,7 @@ public class TopicsService {
.thenReturn(topicName)) .thenReturn(topicName))
.retryWhen(Retry.fixedDelay(recreateMaxRetries, .retryWhen(Retry.fixedDelay(recreateMaxRetries,
Duration.ofSeconds(recreateDelayInSeconds)) Duration.ofSeconds(recreateDelayInSeconds))
.filter(throwable -> throwable instanceof TopicExistsException) .filter(TopicExistsException.class::isInstance)
.onRetryExhaustedThrow((a, b) -> .onRetryExhaustedThrow((a, b) ->
new TopicRecreationException(topicName, new TopicRecreationException(topicName,
recreateMaxRetries * recreateDelayInSeconds))) recreateMaxRetries * recreateDelayInSeconds)))
@ -403,10 +403,11 @@ public class TopicsService {
); );
return ac.createPartitions(newPartitionsMap) return ac.createPartitions(newPartitionsMap)
.then(loadTopic(cluster, topicName)); .then(loadTopic(cluster, topicName));
}) }).map(t -> new PartitionsIncreaseResponseDTO()
.map(t -> new PartitionsIncreaseResponseDTO()
.topicName(t.getName()) .topicName(t.getName())
.totalPartitionsCount(t.getPartitionCount()))); .totalPartitionsCount(t.getPartitionCount())
)
);
} }
public Mono<Void> deleteTopic(KafkaCluster cluster, String topicName) { public Mono<Void> deleteTopic(KafkaCluster cluster, String topicName) {

View file

@ -15,7 +15,6 @@ import org.apache.zookeeper.ZooKeeper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -82,7 +81,8 @@ public class ZookeeperService {
private ZooKeeper createClient(KafkaCluster cluster) { private ZooKeeper createClient(KafkaCluster cluster) {
try { try {
return new ZooKeeper(cluster.getZookeeper(), 60 * 1000, watchedEvent -> {}); return new ZooKeeper(cluster.getZookeeper(), 60 * 1000, watchedEvent -> {
});
} catch (IOException e) { } catch (IOException e) {
log.error("Error while creating a zookeeper client for cluster [{}]", log.error("Error while creating a zookeeper client for cluster [{}]",
cluster.getName()); cluster.getName());

View file

@ -101,7 +101,7 @@ public class KsqlApiClient {
if (parsed.getStatements().size() > 1) { if (parsed.getStatements().size() > 1) {
throw new ValidationException("Only single statement supported now"); throw new ValidationException("Only single statement supported now");
} }
if (parsed.getStatements().size() == 0) { if (parsed.getStatements().isEmpty()) {
throw new ValidationException("No valid ksql statement found"); throw new ValidationException("No valid ksql statement found");
} }
if (KsqlGrammar.isSelect(parsed.getStatements().get(0))) { if (KsqlGrammar.isSelect(parsed.getStatements().get(0))) {

View file

@ -18,6 +18,9 @@ import org.antlr.v4.runtime.atn.PredictionMode;
class KsqlGrammar { class KsqlGrammar {
private KsqlGrammar() {
}
@Value @Value
static class KsqlStatements { static class KsqlStatements {
List<KsqlGrammarParser.SingleStatementContext> statements; List<KsqlGrammarParser.SingleStatementContext> statements;

View file

@ -12,6 +12,9 @@ import java.util.stream.StreamSupport;
class DynamicParser { class DynamicParser {
private DynamicParser() {
}
static KsqlResponseTable parseArray(String tableName, JsonNode array) { static KsqlResponseTable parseArray(String tableName, JsonNode array) {
return parseArray(tableName, getFieldNamesFromArray(array), array); return parseArray(tableName, getFieldNamesFromArray(array), array);
} }

View file

@ -14,6 +14,9 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
public class ResponseParser { public class ResponseParser {
private ResponseParser() {
}
public static Optional<KsqlApiClient.KsqlResponseTable> parseSelectResponse(JsonNode jsonNode) { public static Optional<KsqlApiClient.KsqlResponseTable> parseSelectResponse(JsonNode jsonNode) {
// in response we getting either header record or row data // in response we getting either header record or row data
if (arrayFieldNonEmpty(jsonNode, "header")) { if (arrayFieldNonEmpty(jsonNode, "header")) {

View file

@ -18,6 +18,9 @@ import org.apache.kafka.common.utils.Bytes;
@Slf4j @Slf4j
public class ClusterUtil { public class ClusterUtil {
private ClusterUtil() {
}
private static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC"); private static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC");
public static int convertToIntServerStatus(ServerStatusDTO serverStatus) { public static int convertToIntServerStatus(ServerStatusDTO serverStatus) {

View file

@ -21,7 +21,7 @@ public class JmxPoolFactory extends BaseKeyedPooledObjectFactory<JmxConnectionIn
public JMXConnector create(JmxConnectionInfo info) throws Exception { public JMXConnector create(JmxConnectionInfo info) throws Exception {
Map<String, Object> env = new HashMap<>(); Map<String, Object> env = new HashMap<>();
if (StringUtils.isNotEmpty(info.getUsername()) && StringUtils.isNotEmpty(info.getPassword())) { if (StringUtils.isNotEmpty(info.getUsername()) && StringUtils.isNotEmpty(info.getPassword())) {
env.put("jmx.remote.credentials", new String[]{info.getUsername(), info.getPassword()}); env.put("jmx.remote.credentials", new String[] {info.getUsername(), info.getPassword()});
} }
if (info.isSsl()) { if (info.isSsl()) {

View file

@ -30,20 +30,21 @@ import java.util.Map;
public final class KafkaConstants { public final class KafkaConstants {
private static final String LONG_MAX_STRING = Long.valueOf(Long.MAX_VALUE).toString();
public static final Map<String, String> TOPIC_DEFAULT_CONFIGS = Map.ofEntries( public static final Map<String, String> TOPIC_DEFAULT_CONFIGS = Map.ofEntries(
new AbstractMap.SimpleEntry<>(CLEANUP_POLICY_CONFIG, CLEANUP_POLICY_DELETE), new AbstractMap.SimpleEntry<>(CLEANUP_POLICY_CONFIG, CLEANUP_POLICY_DELETE),
new AbstractMap.SimpleEntry<>(COMPRESSION_TYPE_CONFIG, "producer"), new AbstractMap.SimpleEntry<>(COMPRESSION_TYPE_CONFIG, "producer"),
new AbstractMap.SimpleEntry<>(DELETE_RETENTION_MS_CONFIG, "86400000"), new AbstractMap.SimpleEntry<>(DELETE_RETENTION_MS_CONFIG, "86400000"),
new AbstractMap.SimpleEntry<>(FILE_DELETE_DELAY_MS_CONFIG, "60000"), new AbstractMap.SimpleEntry<>(FILE_DELETE_DELAY_MS_CONFIG, "60000"),
new AbstractMap.SimpleEntry<>(FLUSH_MESSAGES_INTERVAL_CONFIG, "9223372036854775807"), new AbstractMap.SimpleEntry<>(FLUSH_MESSAGES_INTERVAL_CONFIG, LONG_MAX_STRING),
new AbstractMap.SimpleEntry<>(FLUSH_MS_CONFIG, "9223372036854775807"), new AbstractMap.SimpleEntry<>(FLUSH_MS_CONFIG, LONG_MAX_STRING),
new AbstractMap.SimpleEntry<>("follower.replication.throttled.replicas", ""), new AbstractMap.SimpleEntry<>("follower.replication.throttled.replicas", ""),
new AbstractMap.SimpleEntry<>(INDEX_INTERVAL_BYTES_CONFIG, "4096"), new AbstractMap.SimpleEntry<>(INDEX_INTERVAL_BYTES_CONFIG, "4096"),
new AbstractMap.SimpleEntry<>("leader.replication.throttled.replicas", ""), new AbstractMap.SimpleEntry<>("leader.replication.throttled.replicas", ""),
new AbstractMap.SimpleEntry<>(MAX_COMPACTION_LAG_MS_CONFIG, "9223372036854775807"), new AbstractMap.SimpleEntry<>(MAX_COMPACTION_LAG_MS_CONFIG, LONG_MAX_STRING),
new AbstractMap.SimpleEntry<>(MAX_MESSAGE_BYTES_CONFIG, "1000012"), new AbstractMap.SimpleEntry<>(MAX_MESSAGE_BYTES_CONFIG, "1000012"),
new AbstractMap.SimpleEntry<>(MESSAGE_TIMESTAMP_DIFFERENCE_MAX_MS_CONFIG, new AbstractMap.SimpleEntry<>(MESSAGE_TIMESTAMP_DIFFERENCE_MAX_MS_CONFIG, LONG_MAX_STRING),
"9223372036854775807"),
new AbstractMap.SimpleEntry<>(MESSAGE_TIMESTAMP_TYPE_CONFIG, "CreateTime"), new AbstractMap.SimpleEntry<>(MESSAGE_TIMESTAMP_TYPE_CONFIG, "CreateTime"),
new AbstractMap.SimpleEntry<>(MIN_CLEANABLE_DIRTY_RATIO_CONFIG, "0.5"), new AbstractMap.SimpleEntry<>(MIN_CLEANABLE_DIRTY_RATIO_CONFIG, "0.5"),
new AbstractMap.SimpleEntry<>(MIN_COMPACTION_LAG_MS_CONFIG, "0"), new AbstractMap.SimpleEntry<>(MIN_COMPACTION_LAG_MS_CONFIG, "0"),

View file

@ -51,7 +51,7 @@ public class OffsetsSeekBackward extends OffsetsSeek {
consumerPosition.getSeekTo().entrySet().stream() consumerPosition.getSeekTo().entrySet().stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
Map.Entry::getKey, Map.Entry::getKey,
e -> e.getValue() Map.Entry::getValue
)); ));
Map<TopicPartition, Long> offsetsForTimestamps = consumer.offsetsForTimes(timestampsToSearch) Map<TopicPartition, Long> offsetsForTimestamps = consumer.offsetsForTimes(timestampsToSearch)
.entrySet().stream() .entrySet().stream()

View file

@ -59,7 +59,8 @@ public class AvroJsonSchemaConverter implements JsonSchemaConverter<Schema> {
} }
case ARRAY: case ARRAY:
return createArraySchema(name, schema, definitions); return createArraySchema(name, schema, definitions);
default: throw new RuntimeException("Unknown type"); default:
throw new RuntimeException("Unknown type");
} }
} else { } else {
return createUnionSchema(schema, definitions); return createUnionSchema(schema, definitions);
@ -138,14 +139,18 @@ public class AvroJsonSchemaConverter implements JsonSchemaConverter<Schema> {
case BYTES: case BYTES:
case STRING: case STRING:
return new SimpleJsonType(JsonType.Type.STRING); return new SimpleJsonType(JsonType.Type.STRING);
case NULL: return new SimpleJsonType(JsonType.Type.NULL); case NULL:
case ARRAY: return new SimpleJsonType(JsonType.Type.ARRAY); return new SimpleJsonType(JsonType.Type.NULL);
case ARRAY:
return new SimpleJsonType(JsonType.Type.ARRAY);
case FIXED: case FIXED:
case FLOAT: case FLOAT:
case DOUBLE: case DOUBLE:
return new SimpleJsonType(JsonType.Type.NUMBER); return new SimpleJsonType(JsonType.Type.NUMBER);
case BOOLEAN: return new SimpleJsonType(JsonType.Type.BOOLEAN); case BOOLEAN:
default: return new SimpleJsonType(JsonType.Type.STRING); return new SimpleJsonType(JsonType.Type.BOOLEAN);
default:
return new SimpleJsonType(JsonType.Type.STRING);
} }
} }
} }

View file

@ -8,7 +8,7 @@ public abstract class JsonType {
protected final Type type; protected final Type type;
public JsonType(Type type) { protected JsonType(Type type) {
this.type = type; this.type = type;
} }

View file

@ -2,10 +2,7 @@ package com.provectus.kafka.ui.util.jsonschema;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;