Use the data control tool from a Legacy Groovy worker
Warning
Legacy documentation: This documentation applies to Legacy Deephaven Enterprise only and does not apply to Core+.
The data control tool (dhctl) is a command-line tool that allows you to manage data in Deephaven. This functionality is also available from any Legacy worker with sufficient permissions.
Truncate and delete intraday partitions
A builder, described below, provides full control over parameters. For simplicity, some simple options can be invoked via helper methods. These methods do not allow for dry runs or the selection of which Data Import Servers are included.
Tip
You will want to check the results of these commands.
Options Builder
The options builder can be useful when programmatically constructing complex truncate or delete commands.
Modify the builder with the desired options, much like the dhctl command line options.
Set the partition to be deleted:
For example:
Note
Only one key is permitted at this time. You can call one of the key() methods again, but you must call builder.clearKey() in between.
Dry run options
Change the dry run option:
Authentication
Change the authentication (by default, the command will be run using the default authentication of the worker):
Add a DIS
Add a DIS to the include or exclude list:
Build options
Build the options as configured in the builder. You may call build() multiple times. This allows you to use a builder to check a dry run and then perform the delete, or to change the key in a loop.
You can invoke the truncate or delete methods directly from the builder or options:
You can pass the options to the Intraday Control tool and check the results:
You can display the contents of the builder or options:
Check the results
Truncate and delete commands return result objects containing detailed information about the operation. The intraday operations can be complex, so the result object is also necessarily complex.
The DISCommandUtil.ActionResult object has an overall result that indicates success or failure of the operation as a whole.
It also contains a map of results for each DIS that was involved in the operation.
There is an overall result code for each DIS, and a collection of results for the individual locations that were processed.
The code examples below illustrate how to check the results at various levels of detail. These are intended as examples; adjust the code to suit your needs.
This example executes a truncate dry run, and then executes the truncate only if none of the locations to be truncated are still in use:
This example executes a truncate command and then, if the truncate was successful, delete:
Rescan tables
This command instructs the DIS handling table DbInternal.ProcessEventLog to look for new data:
This command instructs all DISs to look for new data for all tables:
Caveats
- This method makes a best-effort attempt to delete everything on all appropriate Data Import Servers. This cannot be atomic, so the operation might have only partial success. Make sure you check all the results.
- The truncated partitions are marked as permanently truncated, and further ingestion of data will be disallowed. This is to prevent confusion if loggers produce new data for the partition, or if tailers have not finished all existing data files.
- Before logging new data for the truncated partitions, remove any existing data files (bin files), and then delete the partitions with
dhctl intraday delete .... - It is possible to delete data on one Data Import Server and leave it on another (e.g., a backup). Be extremely careful with this, as it can create confusion.