codelipenghui commented on a change in pull request #5227: [PIP-44] Separate
schema compatibility checker for producer and consumer
URL: https://github.com/apache/pulsar/pull/5227#discussion_r333423003
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
##########
@@ -109,61 +110,55 @@
@Override
@NotNull
public CompletableFuture<SchemaVersion> putSchemaIfAbsent(String schemaId,
SchemaData schema,
-
SchemaCompatibilityStrategy strategy) {
- return getSchema(schemaId, SchemaVersion.Latest)
- .thenCompose(
- (existingSchema) ->
- {
- CompletableFuture<Long> maxDeleteVersionFuture;
- if (existingSchema == null) {
- maxDeleteVersionFuture =
completedFuture(NO_DELETED_VERSION);
- } else if (existingSchema.schema.isDeleted()) {
- maxDeleteVersionFuture =
completedFuture(((LongSchemaVersion)schemaStorage
-
.versionFromBytes(existingSchema.version.bytes())).getVersion());
+
SchemaCompatibilityStrategy strategy, boolean isAllowAutoUpdateSchema) {
+ return
trimDeletedSchemaAndGetList(schemaId).thenCompose(schemaAndMetadataList -> {
+ final CompletableFuture<SchemaVersion> completableFuture = new
CompletableFuture<>();
+ SchemaVersion schemaVersion;
+ for (SchemaAndMetadata schemaAndMetadata : schemaAndMetadataList) {
+ if
(Arrays.equals(hashFunction.hashBytes(schemaAndMetadata.schema.getData()).asBytes(),
+ hashFunction.hashBytes(schema.getData()).asBytes())) {
+ schemaVersion = schemaAndMetadata.version;
+ completableFuture.complete(schemaVersion);
+ return completableFuture;
+ }
+ }
+ if (isAllowAutoUpdateSchema) {
+ CompletableFuture<Void> isCompatibility = new
CompletableFuture<>();
Review comment:
it's better to rename to checkCompatibilityFurture
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services