|
@@ -5,6 +5,7 @@ import com.provectus.kafka.ui.model.KafkaCluster;
|
|
import com.provectus.kafka.ui.model.Statistics;
|
|
import com.provectus.kafka.ui.model.Statistics;
|
|
import com.provectus.kafka.ui.service.StatisticsCache;
|
|
import com.provectus.kafka.ui.service.StatisticsCache;
|
|
import com.provectus.kafka.ui.service.integration.odd.schema.DataSetFieldsExtractors;
|
|
import com.provectus.kafka.ui.service.integration.odd.schema.DataSetFieldsExtractors;
|
|
|
|
+import com.provectus.kafka.ui.sr.model.SchemaSubject;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -24,6 +25,8 @@ import org.opendatadiscovery.oddrn.model.KafkaPath;
|
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
|
+import reactor.util.function.Tuples;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -98,9 +101,8 @@ class TopicsExporter {
|
|
return Mono.just(List.of());
|
|
return Mono.just(List.of());
|
|
}
|
|
}
|
|
String subject = topic + (isKey ? "-key" : "-value");
|
|
String subject = topic + (isKey ? "-key" : "-value");
|
|
- return cluster.getSchemaRegistryClient()
|
|
|
|
- .mono(client -> client.getSubjectVersion(subject, "latest"))
|
|
|
|
- .map(subj -> DataSetFieldsExtractors.extract(subj, topicOddrn, isKey))
|
|
|
|
|
|
+ return getSubjWithResolvedRefs(cluster, subject)
|
|
|
|
+ .map(t -> DataSetFieldsExtractors.extract(t.getT1(), t.getT2(), topicOddrn, isKey))
|
|
.onErrorResume(WebClientResponseException.NotFound.class, th -> Mono.just(List.of()))
|
|
.onErrorResume(WebClientResponseException.NotFound.class, th -> Mono.just(List.of()))
|
|
.onErrorResume(th -> true, th -> {
|
|
.onErrorResume(th -> true, th -> {
|
|
log.warn("Error retrieving subject {} for cluster {}", subject, cluster.getName(), th);
|
|
log.warn("Error retrieving subject {} for cluster {}", subject, cluster.getName(), th);
|
|
@@ -108,4 +110,13 @@ class TopicsExporter {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Mono<Tuple2<SchemaSubject, ImmutableMap<String, String>>> getSubjWithResolvedRefs(KafkaCluster cluster,
|
|
|
|
+ String subjectName) {
|
|
|
|
+ return cluster.getSchemaRegistryClient()
|
|
|
|
+ .mono(client ->
|
|
|
|
+ client.getSubjectVersion(subjectName, "latest", false)
|
|
|
|
+ .flatMap(subj -> new SchemaReferencesResolver(client).resolve(subj.getReferences())
|
|
|
|
+ .map(resolvedRefs -> Tuples.of(subj, resolvedRefs))));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|