Clio
develop
The XRP Ledger API server.
|
Clio maintains the off-chain data of XRPL and multiple indexes tables to powering complex queries. To simplify the creation of index tables, this migration framework handles the process of database change and facilitates the migration of historical data seamlessly.
Clio provides a migration command-line tool to migrate data in database.
./clio_server --migrate status ~/config/migrator.json
This command returns the current migration status of each migrator. The example output:
Current Migration Status: Migrator: ExampleMigrator - Feature v1, Clio v3 - not migrated
./clio_server --migrate ExampleMigrator ~/config/migrator.json
Migration will run if the migrator has not been migrated. The migrator will be marked as migrated after the migration is completed.
Note If you'd like to add new index table in Clio and old historical data needs to be migrated into new table, you'd need to write a migrator.
A migrator satisfies the MigratorSpec(impl/Spec.hpp) concept.
It contains:
Note Each migrator is designed to work with a specific database.
Sometimes migrator isn't able to query the historical data by table's partition key. For example, migrator of transactions needs the historical transaction data without knowing each transaction hash. Full table scanner can help to get all the rows in parallel.
Most indexes are based on either ledger states or transactions. We provide the objects and transactions scanner. Developers only need to implement the callback function to receive the historical data. Please find the examples in tests/integration/migration/cassandra/ExampleTransactionsMigrator.cpp and tests/integration/migration/cassandra/ExampleObjectsMigrator.cpp.
If you need to do full scan against other table, you can follow below steps:
Please take ObjectsAdapter/TransactionsAdapter as example.
We have some example migrators under tests/integration/migration/cassandra folder.
ExampleDropTableMigrator
This migrator drops diff table.
ExampleLedgerMigrator
This migrator shows how to migrate data when we don't need to do full table scan. This migrator creates an index table ledger_example which maintains the map of ledger sequence and its account hash.
ExampleObjectsMigrator
This migrator shows how to migrate ledger states related data. It uses ObjectsScanner to proceed the full scan in parallel. It counts the number of ACCOUNT_ROOT.
ExampleTransactionsMigrator
This migrator shows how to migrate transactions related data. It uses TransactionsScanner to proceed the transactions table full scan in parallel. It creates an index table tx_index_example which tracks the transaction hash and its according transaction type.