Managing a Processing Application
Installing and using the management CLI
A management service command-line interface (CLI) is provided for you to manage Processing Applications. The CLI can be used also to send events, start a Kafka consumer or producer for development purposed. In production, the CLI must only be used to management Processing Applications configuration and lifecycle.
Installing the command line interface
- Make sure that you have Java™ 17, bash 3.2, curl 7, and jq 1.5, or later versions, installed.
- Retrieve the URL, username, and password of the management service as instructed in Accessing Business Automation Insights services.
- Download the
archive:
curl -k https://${MANAGEMENT_URL}/cli --header 'Authorization: Basic X' -o ${DESTINATION_DIR}/bai-command.tar.gz - Unpack the archive.
tar xvf <file> -
If you want to be able to run the
management-clicommands from any directory, remember to update yourPATHenvironment variable.
Using the command line interface
- Login to the management service in order to use the
CLI.
management-cli env login --management-url=${MANAGEMENT_URL} - Use the help function to display available
commands.
management-cli --help
Creating and restarting from savepoints
The management CLI offer the capability to create flink savepoints for your Processing Application and restart them.
- Login into the management service using the management
cli.
management-cli env login --management-url=${MANAGEMENT_URL} --management-username=${MANAGEMENT_USERNAME} --management-password=${MANAGEMENT_PASSWORD} - List the job and note the id of jobs to which you want to create a
savepoint.
management-cli processing-jobs list - Cancel a job and create a savepoint using the following command. Take note of the savepoint-path
under
result.operation.locationdisplayed after running the command.management-cli processing-jobs cancel --job-id=<jobid> --create-savepoint - When deploying a processing-application you can specify the savepoint-path noted in the previous
step.
management-cli processing-app deploy --savepoint-path=<savepoint-path>
savepoints for all the running jobs using the
create-savepoints command:
management-cli processing-jobs create-savepoints --cancelCleaning up the Processing Application
When you deploy a Processing Application, the management service takes care of creating or updating various resources declared in the processing configuration such as OpenSearch indices and Kafka topics. However, during the development phase, you must regularly clean up your environment to avoid a proliferation of resources and Processing Applications.
- Stop the processing of the application. See How to stop the processing.
- Delete the topic. See How to delete a topic.
- Delete the OpenSearch configuration of the index. See How to delete an index configuration.
- Delete the Processing Application along with its configuration:
management-cli processing-app delete --name=<app_name>
How to stop the processing
When you deploy an application, a processing job (Flink job) starts. Follow this procedure to stop it.
- List the jobs to identify the one that matches your application name and whose state is
running.management-cli processing-jobs list - If you find a match, use the job ID to cancel the
job.
management-cli processing-jobs cancel --job-id=<job-id>The cancel operation is synchronous.
- Run the command in step 1 again to verify that the stats of the job is now
CANCELED.
How to delete a topic
- Stop the processing of the application.
- List the topics to confirm the name of the topic that you want to
delete.
management-cli kafka list-topics - Delete the topic. See Adding and removing topics
] from Kafka documentation.
How to delete an index configuration
export NAMESPACE=<namespace>
OPENSEARCH_URL="https://$(oc get routes opensearch-route -o jsonpath="{.spec.host}" -n "$NAMESPACE")"
OPENSEARCH_USERNAME=$(oc get secret/opensearch-admin-user -o json -n "$NAMESPACE" | jq -r '.data|keys[0]')
OPENSEARCH_PASSWORD=$(oc extract secret/opensearch-admin-user --keys="$OPENSEARCH_USERNAME" --to=- -n "$NAMESPACE" 2>/dev/nullDeleting an index configuration consists of deleting the indices, aliases, and the index template that is related to the index name declared in the processing configuration.
- Stop the processing of the application.
- Set the variable
paIndexNamewith the name of the index declared in the processing configuration. - Identify one or more indexes instance names to delete.
curl -sku ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} ${OPENSEARCH_URL}/_cat/indices/${paIndexName}-idx-*?h=index - Delete each index.
indexInstanceName=<index_instance_name> curl -sku ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} -XDELETE ${OPENSEARCH_URL}/${indexInstanceName} - Identify the index template name.
curl -sku ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} ${OPENSEARCH_URL}/_cat/templates | grep ${paIndexName} | awk '{print $1;}' - Delete the template.
templateName=<template_name> curl -sku ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} -XDELETE ${OPENSEARCH_URL}/_template/${templateName}