Este conteúdo não está disponível no idioma selecionado.
Chapter 5. Managing schemas in Data Grid
This documentation explains how to create, register, and manage Protostream schemas in Data Grid. Schemas are registered in the Data Grid server and/or client so that ProtoStream knows how to interpret data in the caches.
5.1. Hotrod Java Client management API Copiar o linkLink copiado para a área de transferência!
The RemoteSchemasAdmin interface provides methods to manage Protostream schemas in a remote Data Grid server. It allows you to create, update, retrieve, and delete schemas, as well as check for validation errors. This API is marked as @Experimental and may change in future releases.
5.1.1. Overview Copiar o linkLink copiado para a área de transferência!
Schemas define how objects are serialized and deserialized using Protostream. With RemoteSchemasAdmin, you can perform schema operations programmatically through the Hot Rod client.
5.1.2. Key Operations Copiar o linkLink copiado para a área de transferência!
Get a schema Retrieve a schema by name.
-
get(String schemaName) -
getAsync(String schemaName)
-
Retrieve schema errors Check if a schema has validation or parsing errors.
-
retrieveError(String schemaName) -
retrieveAllSchemaErrors()
-
Create a schema Add a new schema from a
Schemaobject orFileDescriptorSource.-
create(Schema schema) -
create(FileDescriptorSource fileDescriptorSource)
-
Update a schema Update an existing schema safely or force the update.
-
update(Schema schema, boolean force) -
update(FileDescriptorSource fileDescriptorSource)
-
Create or update a schema Create the schema if it does not exist, or update it if it does.
-
createOrUpdate(Schema schema, boolean force) -
createOrUpdate(FileDescriptorSource fileDescriptorSource)
-
Delete a schema Remove a schema by name, with optional force to bypass cache dependencies. If a cache uses one of the schema messages for indexing, the remove operation fails unless force is set to
true.-
remove(String schemaName, boolean force)
-
Check schema existence Verify if a schema is already registered.
-
exists(String schemaName)
-
5.1.3. Async Support Copiar o linkLink copiado para a área de transferência!
All operations have asynchronous variants that return CompletionStage<T> for non-blocking execution.
5.1.4. Result Objects Copiar o linkLink copiado para a área de transferência!
-
SchemaOpResult— Holds the operation result type (CREATED,UPDATED,DELETED,NONE,ERROR) and any validation errors. -
SchemaErrors— Contains multiple schema errors mapped by schema name.
Schema management API example
- Schema updates are version-safe unless forced.
- For large deployments, use asynchronous methods to avoid blocking client threads.
- Forced operations (force=true) should be used cautiously to prevent errors.
5.2. Schema Management in the Console Copiar o linkLink copiado para a área de transferência!
From the Data Grid web console, you can list, create, update, and manage schemas, and reindex the related caches. The web interface is simple and easy to use.
Figure 5.1. Schemas management interface
5.2.1. Creating Protobuf Schemas Copiar o linkLink copiado para a área de transferência!
Create Protobuf schemas across Data Grid clusters with POST requests that include the content of a protobuf file in the payload.
POST /rest/v2/schemas/{schemaName}
POST /rest/v2/schemas/{schemaName}
If the schema already exists, Data Grid returns HTTP 409 (Conflict). If the schema is not valid, either because of syntax errors, or because some of its dependencies are missing, Data Grid stores the schema and returns the error in the response body.
Data Grid responds with the schema name and any errors.
-
nameis the name of the Protobuf schema. -
errorisnullfor valid Protobuf schemas. If Data Grid cannot successfully validate the schema, it returns errors.
If the operation successfully completes, the service returns 201 (Created).
5.2.2. Reading Protobuf Schemas Copiar o linkLink copiado para a área de transferência!
Retrieve Protobuf schema from Data Grid with GET requests.
GET /rest/v2/schemas/{schemaName}
GET /rest/v2/schemas/{schemaName}
5.2.3. Updating Protobuf Schemas Copiar o linkLink copiado para a área de transferência!
Modify Protobuf schemas with PUT requests that include the content of a protobuf file in the payload.
When you make changes to the existing Protobuf schema definition, you must either update or rebuild the index schema. If the changes involve modifying the existing fields, then you must rebuild the index. When you add new fields without touching existing schema, you can update the index schema instead of rebuilding it.
PUT /rest/v2/schemas/{schemaName}
PUT /rest/v2/schemas/{schemaName}
If the schema is not valid, either because of syntax errors, or because some of its dependencies are missing, Data Grid updates the schema and returns the error in the response body.
-
nameis the name of the Protobuf schema. -
errorisnullfor valid Protobuf schemas. If Data Grid cannot successfully validate the schema, it returns errors.
5.2.4. Deleting Protobuf Schemas Copiar o linkLink copiado para a área de transferência!
Remove Protobuf schemas from Data Grid clusters with DELETE requests.
DELETE /rest/v2/schemas/{schemaName}
DELETE /rest/v2/schemas/{schemaName}
If the operation successfully completes, the service returns 204 (No Content).
5.2.5. Listing Protobuf Schemas Copiar o linkLink copiado para a área de transferência!
List all available Protobuf schemas with GET requests.
GET /rest/v2/schemas/
GET /rest/v2/schemas/
Data Grid responds with a list of all schemas available on the cluster.
-
nameis the name of the Protobuf schema. -
errorisnullfor valid Protobuf schemas. If Data Grid cannot successfully validate the schema, it returns errors.
5.2.6. Listing Protobuf Types Copiar o linkLink copiado para a área de transferência!
List all available Protobuf types with GET requests.
GET /rest/v2/schemas?action=types
GET /rest/v2/schemas?action=types
Data Grid responds with a list of all types available on the cluster.
["org.infinispan.Person", "org.infinispan.Phone"]
["org.infinispan.Person", "org.infinispan.Phone"]