Commit b611329
authored
Daemonize snapshot-converter (#1887)
# Description
This PR add the feature for snapshot-converter to run as a daemon. See
the help text of
```console
$ cabal run snapshot-converter -- --help
Utility for converting snapshots among the different snapshot formats used by
cardano-node.
Usage: snapshot-converter (
(--monitor-lsm-snapshots-in ARG --lsm-database ARG |
--monitor-lmdb-snapshots-in ARG)
--output-mem-snapshots-in ARG |
(--input-lsm-snapshot ARG --input-lsm-database ARG |
--input-mem ARG | --input-lmdb ARG)
(--output-lsm-snapshot ARG
--output-lsm-database ARG |
--output-mem ARG | --output-lmdb ARG))
--config PATH [--threshold THRESHOLD]
# Running in oneshot mode
`snapshot-converter` can be invoked to convert a single snapshot to a different
format. The three formats supported at the moment are: Mem, LMDB and LSM.
As snapshots in Mem and LMDB are fully contained in one directory, providing
that one is enough. On the other hand, converting an LSM snapshot requires a
reference to the snapshot directory as well as the LSM database directory.
To run in oneshot mode, you have to provide input and output parameters as in:
```
# mem to lsm
$ snapshot-converter --input-mem <PATH> --output-lsm-snapshot <PATH> --output-lsm-database <PATH> --config <PATH>
# mem to lmdb
$ snapshot-converter --input-mem <PATH> --output-lmdb <PATH> --config <PATH>
# lmdb to lsm
$ snapshot-converter --input-lmdb <PATH> --output-lsm-snapshot <PATH> --output-lsm-database --config <PATH>
# lmdb to mem
$ snapshot-converter --input-lmdb <PATH> --output-mem <PATH> --config <PATH>
# lsm to mem
$ snapshot-converter --input-lsm-snapshot <PATH> --input-lsm-database <PATH> --output-mem <PATH> --config <PATH>
# lsm to mem
$ snapshot-converter --input-lsm-snapshot <PATH> --input-lsm-database <PATH> --output-lmdb <PATH> --config <PATH>
```
Note that the input and output paths need to be named after the slot number
of the contained ledger state, this means for example that a snapshot for
slot 100 has to be contained in a directory `100[_suffix]` and has to be
written to a directory `100[_some_other_suffix]`. Providing a wrong slot
number will throw an error.
This naming convention is the same expected by `cardano-node`.
# Running in daemon mode
`snapshot-converter` can be invoked as a daemon to monitor and convert
snapshots produced by a `cardano-node` into Mem format as they are
written by the node. This is only meaningful to run if your node
produces LMDB or LSM snapshots:
```
# lsm to mem
$ snapshot-converter --monitor-lsm-snapshots-in <PATH> --lsm-database <PATH> --output-mem-snapshots-in <PATH> --config <PATH>
# lmdb to mem
$ snapshot-converter --monitor-lmdb-snapshots-in <PATH> --output-mem-snapshots-in <PATH> --config <PATH>
```
Available options:
--config PATH Path to config file
--threshold THRESHOLD PBftSignatureThreshold
-h,--help Show this help text
```File tree
10 files changed
+836
-631
lines changed- ouroboros-consensus-cardano
- app
- changelog.d
- src/unstable-snapshot-conversion/Ouroboros/Consensus/Cardano
- ouroboros-consensus
- changelog.d
- src
- ouroboros-consensus-lmdb/Ouroboros/Consensus/Storage/LedgerDB/V1/BackingStore/Impl
- ouroboros-consensus-lsm/Ouroboros/Consensus/Storage/LedgerDB/V2
- ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2
10 files changed
+836
-631
lines changedLarge diffs are not rendered by default.
Whitespace-only changes.
Lines changed: 39 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
182 | 215 | | |
183 | 216 | | |
184 | 217 | | |
| |||
692 | 725 | | |
693 | 726 | | |
694 | 727 | | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | 728 | | |
699 | 729 | | |
700 | | - | |
701 | 730 | | |
702 | 731 | | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | 732 | | |
709 | | - | |
710 | | - | |
| 733 | + | |
711 | 734 | | |
712 | 735 | | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
| 736 | + | |
| 737 | + | |
724 | 738 | | |
725 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
726 | 743 | | |
727 | 744 | | |
728 | 745 | | |
| |||
0 commit comments