You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/08/01 02:33:55 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #4845: [Doc] Add *Manage Schema* Section

sijie commented on a change in pull request #4845: [Doc] Add *Manage Schema* Section
URL: https://github.com/apache/pulsar/pull/4845#discussion_r309502556
 
 

 ##########
 File path: site2/docs/schema-manage.md
 ##########
 @@ -0,0 +1,497 @@
+---
+id: schema-manage
+title: Manage schema
+sidebar_label: Manage schema
+---
+
+## Schema AutoUpdate
+
+If a schema passes the schema compatibility check, Pulsar producer automatically updates this schema to the topic it produces by default. 
+
+### AutoUpdate for producer
+
+For a producer, the `AutoUpdate` happens in the following cases:
+
+* If a **topic doesn’t have a schema**, Pulsar registers a schema automatically.
+
+* If a **topic has a schema**:
+
+  * If a **producer doesn’t carry a schema**:
+
+    * If `isSchemaValidationEnforced` or `schemaValidationEnforced` is **disabled** in the namespace to which the topic belongs, the producer is allowed to connect to the topic and produce data. 
+    
+    * If `isSchemaValidationEnforced` or `schemaValidationEnforced` is **enabled** in the namespace to which the topic belongs, the producer is rejected and disconnected.
+
+  * If a **producer carries a schema**:
+  
+    A broker performs the compatibility check based on the configured compatibility check strategy of the namespace to which the topic belongs. 
+    
+    * If it is a new schema and it passes the compatibility check, the broker registers a new schema automatically for the topic.
+
+    * If the schema does not pass the compatibility check, the broker does not register a schema.
+
+![AutoUpdate Producer](assets/schema-autoupdate-producer.png)
+
+### AutoUpdate for consumer
+
+For a consumer, the `AutoUpdate` happens in the following cases:
+
+* If a **consumer connects to a topic without a schema** (which means the consumer receiving raw bytes), the consumer can connect to the topic successfully without doing any compatibility check.
+
+* If a **consumer connects to a topic with a schema**:
+
+  * If the **topic is idle** (no producers, no entries, no other consumers and no registered schemas), the broker registers the schema for the topic automatically.
+
+  * If the **topic is not idle**, the broker verifies if the schema provided by the consumer is compatible with the registered schema of the topic. 
+    
+    * If the **schema passes the compatibility check**, the consumer can connect to the topic and receive messages. 
+    
+    * If the **schema does not pass the compatibility check**, the consumer is rejected and disconnected.
+
+### Manage AutoUpdate strategy
+
+You can use the `pulsar-admin` command to manage the `AutoUpdate` strategy as below:
+
+* Disable AutoUpdate
+
+* Adjust compatibility
+
+#### Disable AutoUpdate 
+
+To disable `AutoUpdate` on a namespace, you can use the `pulsar-admin` command.
+
+```
+bin/pulsar-admin namespaces set-schema-autoupdate-strategy --disabled tenant/namespace
+```
+
+Once the `AutoUpdate` is disabled, you can only register a new schema using the `pulsar-admin` command.
+
+#### Adjust compatibility
+
+To adjust the schema compatibility level on a namespace, you can use the `pulsar-admin` command.
+
+```
+bin/pulsar-admin namespaces set-schema-autoupdate-strategy --compatibility <compatibility-level> tenant/namespace
+```
+
+### Schema validation
+
+By default, `schemaValidationEnforced` is **disabled** for producers:
+
+* This means a producer without a schema can produce any kind of messages to a topic with schemas, which may result in producing trash data to the topic. 
+
+* This allows non-java language clients that don’t support schema can produce messages to a topic with schemas.
+
+However, if you want a stronger guarantee on the topics with schemas, you can enable `schemaValidationEnforced` across the whole cluster or on a per-namespace basis.
+
+#### Enable schema validation
+
+To enable `schemaValidationEnforced` on a namespace, you can use the `pulsar-admin` command.
+
+```
+bin/pulsar-admin namespaces set-schema-validation-enforce --enable tenant/namespace
+```
+
+#### Disable schema validation
+
+To disable `schemaValidationEnforced` on a namespace, you can use the `pulsar-admin` command.
+
+```
+bin/pulsar-admin namespaces set-schema-validation-enforce --disable tenant/namespace
+```
+
+## Schema manual management
+
+To manage schemas, you can use one of the following methods:
+
+* **Admin CLI** (`pulsar-admin` CLI)
+  
+* **REST API** (Pulsar exposes schema related management API in Pulsar’s admin RESTful API. You can access the admin RESTful endpoint directly to manage schemas)
+
+* **Java Admin API** (use Java admin library provided by Pulsar)
+
+### Upload a schema
 
 Review comment:
   Can we organize the `admin-cli`, `restful-api` and `java-admin` in the multi-tab way?
   
   for example: http://pulsar.apache.org/docs/en/next/functions-develop/

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services