[GitHub] [pulsar] codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema.
codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema. URL: https://github.com/apache/pulsar/pull/5782#discussion_r353522311 ## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java ## @@ -185,13 +185,19 @@ public String getReplicatorPrefix() { String base = TopicName.get(getName()).getPartitionedTopicName(); String id = TopicName.get(base).getSchemaName(); -if (isAllowAutoUpdateSchema) { -return brokerService.pulsar() -.getSchemaRegistryService() -.putSchemaIfAbsent(id, schema, schemaCompatibilityStrategy); -} else { -return FutureUtil.failedFuture(new IncompatibleSchemaException("Don't allow auto update schema.")); -} +SchemaRegistryService schemaRegistryService = brokerService.pulsar().getSchemaRegistryService(); +return isAllowAutoUpdateSchema ? schemaRegistryService +.putSchemaIfAbsent(id, schema, schemaCompatibilityStrategy) +: schemaRegistryService.trimDeletedSchemaAndGetList(id).thenCompose(schemaAndMetadataList -> + schemaRegistryService.getSchemaVersionBySchemaData(schemaAndMetadataList, schema) +.thenCompose(schemaVersion -> { +if (schemaVersion == null) { +return FutureUtil +.failedFuture(new IncompatibleSchemaException("Don't allow auto update schema.")); Review comment: ```suggestion .failedFuture(new IncompatibleSchemaException("Schema not found and schema auto updating is disabled")); ``` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [pulsar] codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema.
codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema. URL: https://github.com/apache/pulsar/pull/5782#discussion_r353524616 ## File path: pulsar-broker/src/test/java/org/apache/pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java ## @@ -267,6 +269,23 @@ public void testIsAutoUpdateSchema(SchemaCompatibilityStrategy schemaCompatibili assertEquals(personTwo.id, 2); assertEquals(personTwo.name, "Lucy"); +producer.close(); +consumerTwo.close(); + +producer = producerThreeBuilder.create(); +consumerTwo = comsumerBuilder.subscribe(); + + admin.namespaces().setIsAllowAutoUpdateSchema(namespaceName.toString(), false); Review comment: Set schema auto update strategy need before producer creation, because we do the schema compatibility check when create a new producer or consumer. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [pulsar] codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema.
codelipenghui commented on a change in pull request #5782: Modify the logical in producer carry a schema to connect broker with isAllowAutoUpdateSchema. URL: https://github.com/apache/pulsar/pull/5782#discussion_r352604737 ## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java ## @@ -111,7 +111,8 @@ @Override @NotNull public CompletableFuture putSchemaIfAbsent(String schemaId, SchemaData schema, - SchemaCompatibilityStrategy strategy) { + SchemaCompatibilityStrategy strategy, + boolean isAllowCreateSchema) { Review comment: Looks weird here, i think we'd better add a method to get schema version by schemaData which producer carried, if the the exists schemas contains the schema that producer carried, producer can connect success, otherwise if not allow schema auto update, reject the producer. 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: us...@infra.apache.org With regards, Apache Git Services