-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
yamcs rocksdb | ||
============= | ||
|
||
.. program:: yamcs rocksdb | ||
|
||
Synopsis | ||
-------- | ||
|
||
.. rst-class:: synopsis | ||
|
||
| **yamcs rocksdb** tablespaces | ||
| **yamcs rocksdb** compact [--dbpath <*DBPATH*>] <*TABLESPACE*> <*CF*> | ||
|
||
Description | ||
----------- | ||
|
||
Manage RocksDB storage engine. | ||
|
||
|
||
Commands | ||
-------- | ||
|
||
.. describe:: tablespaces | ||
|
||
List processors | ||
|
||
.. describe:: compact [--dbpath <DBPATH>] <TABLESPACE> <CF> | ||
|
||
Delete a processor | ||
|
||
|
||
Options | ||
------- | ||
|
||
.. option:: --dbpath <DBPATH> | ||
|
||
With ``compact``, specify a path within the tablespace. Leave unspecified for the root database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import sys | ||
from typing import Any, List | ||
|
||
from yamcs.client import YamcsClient | ||
|
||
from yamcs.cli import utils | ||
|
||
|
||
class RocksDBCommand(utils.Command): | ||
def __init__(self, parent): | ||
super(RocksDBCommand, self).__init__( | ||
parent, "rocksdb", "Manage RocksDB storage engine" | ||
) | ||
|
||
subparsers = self.parser.add_subparsers(title="Commands", metavar="COMMAND") | ||
subparsers.required = True | ||
|
||
subparser = self.create_subparser(subparsers, "tablespaces", "List tablespaces") | ||
subparser.set_defaults(func=self.tablespaces) | ||
|
||
subparser = self.create_subparser( | ||
subparsers, "compact", "Compact column family" | ||
) | ||
subparser.set_defaults(func=self.compact) | ||
subparser.add_argument( | ||
"tablespace", | ||
metavar="TABLESPACE", | ||
type=str, | ||
help="RocksDB tablespace", | ||
) | ||
subparser.add_argument( | ||
"cf", | ||
metavar="CF", | ||
type=str, | ||
help="RocksDB column family", | ||
) | ||
subparser.add_argument( | ||
"--dbpath", | ||
metavar="PATH", | ||
type=str, | ||
help="Path within the tablespace", | ||
) | ||
|
||
def tablespaces(self, args): | ||
opts = utils.CommandOptions(args) | ||
client = YamcsClient(**opts.client_kwargs) | ||
|
||
rows: List[List[Any]] = [["NAME", "DATA DIR"]] | ||
for tablespace in client.list_rdb_tablespaces(): | ||
rows.append([tablespace.name, tablespace.data_dir]) | ||
utils.print_table(rows) | ||
|
||
def compact(self, args): | ||
opts = utils.CommandOptions(args) | ||
client = YamcsClient(**opts.client_kwargs) | ||
|
||
sys.stderr.write("Compacting... ") | ||
sys.stderr.flush() | ||
client.compact_rdb_column_family( | ||
tablespace=args.tablespace, | ||
cf=args.cf, | ||
dbpath=args.dbpath or "", | ||
) | ||
sys.stderr.write("done\n") | ||
sys.stderr.flush() |