Este conteúdo não está disponível no idioma selecionado.
Chapter 17. Running batch operations
Data Grid Operator provides a Batch CR that lets you create Data Grid resources in bulk. Batch CR uses the Data Grid command line interface (CLI) in batch mode to carry out sequences of operations.
Modifying a Batch CR instance has no effect. Batch operations are "one-time" events that modify Data Grid resources. To update .spec fields for the CR, or when a batch operation fails, you must create a new instance of the Batch CR.
17.1. Running inline batch operations Copiar o linkLink copiado para a área de transferência!
Include your batch operations directly in a Batch CR if they do not require separate configuration artifacts.
Procedure
Create a
BatchCR.-
Specify the name of the Data Grid cluster where you want the batch operations to run as the value of the
spec.clusterfield. Add each CLI command to run on a line in the
spec.configfield.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Specify the name of the Data Grid cluster where you want the batch operations to run as the value of the
Apply your
BatchCR.oc apply -f mybatch.yaml
oc apply -f mybatch.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the
BatchCR to succeed.oc wait --for=jsonpath='{.status.phase}'=Succeeded Batch/mybatchoc wait --for=jsonpath='{.status.phase}'=Succeeded Batch/mybatchCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.2. Creating ConfigMaps for batch operations Copiar o linkLink copiado para a área de transferência!
Create a ConfigMap so that additional files, such as Data Grid cache configuration, are available for batch operations.
Prerequisites
For demonstration purposes, you should add some configuration artifacts to your host filesystem before you start the procedure:
Create a
/tmp/mybatchdirectory where you can add some files.mkdir -p /tmp/mybatch
mkdir -p /tmp/mybatchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Data Grid cache configuration.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Create a
batchfile that contains all commands you want to run.For example, the following
batchfile creates a cache named "mycache" and adds two entries to it:create cache mycache --file=/etc/batch/mycache.xml put --cache=mycache hello world put --cache=mycache hola mundo
create cache mycache --file=/etc/batch/mycache.xml put --cache=mycache hello world put --cache=mycache hola mundoCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe
ConfigMapis mounted in Data Grid pods at/etc/batch. You must prepend all--file=directives in your batch operations with that path.Ensure all configuration artifacts that your batch operations require are in the same directory as the
batchfile.ls /tmp/mybatch batch mycache.xml
ls /tmp/mybatch batch mycache.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
ConfigMapfrom the directory.oc create configmap mybatch-config-map --from-file=/tmp/mybatch
oc create configmap mybatch-config-map --from-file=/tmp/mybatchCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.3. Running batch operations with ConfigMaps Copiar o linkLink copiado para a área de transferência!
Run batch operations that include configuration artifacts.
Prerequisites
-
Create a
ConfigMapthat contains any files your batch operations require.
Procedure
-
Create a
BatchCR that specifies the name of a Data Grid cluster as the value of thespec.clusterfield. Set the name of the
ConfigMapthat contains yourbatchfile and configuration artifacts with thespec.configMapfield.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply your
BatchCR.oc apply -f mybatch.yaml
oc apply -f mybatch.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the
BatchCR to succeed.oc wait --for=jsonpath='{.status.phase}'=Succeeded Batch/mybatchoc wait --for=jsonpath='{.status.phase}'=Succeeded Batch/mybatchCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.4. Batch status messages Copiar o linkLink copiado para a área de transferência!
Verify and troubleshoot batch operations with the status.Phase field in the Batch CR.
| Phase | Description |
|---|---|
|
| All batch operations have completed successfully. |
|
| Batch operations are queued and resources are initializing. |
|
| Batch operations are ready to start. |
|
| Batch operations are in progress. |
|
| One or more batch operations were not successful. |
Failed operations
Batch operations are not atomic. If a command in a batch script fails, it does not affect the other operations or cause them to rollback.
If your batch operations have any server or syntax errors, you can view log messages in the Batch CR in the status.Reason field.
17.5. Example batch operations Copiar o linkLink copiado para a área de transferência!
Use these example batch operations as starting points for creating and modifying Data Grid resources with the Batch CR.
You can pass configuration files to Data Grid Operator only via a ConfigMap.
The ConfigMap is mounted in Data Grid pods at /etc/batch so you must prepend all --file= directives with that path.
17.5.1. Caches Copiar o linkLink copiado para a área de transferência!
- Create multiple caches from configuration files.
- Create a template from a file and then create caches from the template.
17.5.2. Counters Copiar o linkLink copiado para a área de transferência!
Use the Batch CR to create multiple counters that can increment and decrement to record the count of objects.
You can use counters to generate identifiers, act as rate limiters, or track the number of times a resource is accessed.
17.5.3. Protobuf schema Copiar o linkLink copiado para a área de transferência!
Register Protobuf schema to query values in caches. Protobuf schema (.proto files) provide metadata about custom entities and controls field indexing.
17.5.4. Tasks Copiar o linkLink copiado para a área de transferência!
Upload tasks that implement org.infinispan.tasks.ServerTask or scripts that are compatible with the javax.script scripting API.