forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema registry documentation (apache#1457)
* add basic notes for schema registry * more notes on schema registry in C&A doc * add java interfaces to concepts doc * add theoretical docs * add schema storage cookbook * add schema storage cookbook to sidebar * remove schema storage cookbook for now * remove unused notes * add java examples * add schema components * add user config * add examples of user-defined props * finish draft of java client docs * add custom schema storage document * more sections in custom doc * add schemaRegistryStorageClassName to conf/broker.conf file * change sentence in getting started guide
- Loading branch information
1 parent
faa107b
commit 7056384
Showing
6 changed files
with
217 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Custom schema storage | ||
tags: [schema, schema registry] | ||
--- | ||
|
||
By default, Pulsar stores data type [schemas](../../getting-started/ConceptsAndArchitecture#schema-registry) in [Apache BookKeeper](https://bookkeeper.apache.org) (which is deployed alongside Pulsar). You can, however, use another storage system if you wish. This doc walks you through creating your own schema storage implementation. | ||
|
||
## Interface | ||
|
||
In order to use a non-default (i.e. non-BookKeeper) storage system for Pulsar schemas, you need to implement two Java interfaces: [`SchemaStorage`](#schema-storage) and [`SchemaStorageFactory`](#schema-storage-factory). | ||
|
||
### The `SchemaStorage` interface {#schema-storage} | ||
|
||
The `SchemaStorage` interface has the following methods: | ||
|
||
```java | ||
public interface SchemaStorage { | ||
// How schemas are updated | ||
CompletableFuture<SchemaVersion> put(String key, byte[] value, byte[] hash); | ||
|
||
// How schemas are fetched from storage | ||
CompletableFuture<StoredSchema> get(String key, SchemaVersion version); | ||
|
||
// How schemas are deleted | ||
CompletableFuture<SchemaVersion> delete(String key); | ||
|
||
// Utility method for converting a schema version byte array to a SchemaVersion object | ||
SchemaVersion versionFromBytes(byte[] version); | ||
|
||
// Startup behavior for the schema storage client | ||
void start() throws Exception; | ||
|
||
// Shutdown behavior for the schema storage client | ||
void close() throws Exception; | ||
} | ||
``` | ||
|
||
{% include admonition.html type="info" title="Example implementation" content="For a full-fledged example schema storage implementation, see the [`BookKeeperSchemaStorage`](https://github.com/apache/incubator-pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java) class." %} | ||
|
||
### The `SchemaStorageFactory` interface {#schema-storage-factory} | ||
|
||
```java | ||
public interface SchemaStorageFactory { | ||
@NotNull | ||
SchemaStorage create(PulsarService pulsar) throws Exception; | ||
} | ||
``` | ||
|
||
{% include admonition.html type="info" title="Example implementation" content="For a full-fledged example schema storage factory implementation, see the [`BookKeeperSchemaStorageFactory`](https://github.com/apache/incubator-pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorageFactory.java) class." %} | ||
|
||
## Deployment | ||
|
||
In order to use your custom schema storage implementation, you'll need to: | ||
|
||
1. Package the implementation in a [JAR](https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html) file. | ||
1. Add that jar to the `lib` folder in your Pulsar [binary or source distribution](../../getting-started/LocalCluster#installing-pulsar). | ||
1. Change the `schemaRegistryStorageClassName` configuration in [`broker.conf`](../../reference/Configuration#broker) to your custom factory class (i.e. the `SchemaStorageFactory` implementation, not the `SchemaStorage` implementation). | ||
1. Start up Pulsar. |