Skip to content

Commit

Permalink
add Node.get_sstables_via_sstableutil
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy authored and ptnapoleon committed Aug 30, 2017
1 parent cc30d8d commit 0b1af9f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ccmlib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,34 @@ def get_sstables_per_data_directory(self, keyspace, column_family):
def get_sstables(self, keyspace, column_family):
return [f for sublist in self.get_sstables_per_data_directory(keyspace, column_family) for f in sublist]

def get_sstables_via_sstableutil(self, keyspace, table, sstabletype='all', oplogs=False, cleanup=False, match='-Data.db'):
env = common.make_cassandra_env(self.get_install_cassandra_root(), self.get_node_cassandra_root())
tool_bin = self.get_tool('sstableutil')

args = [tool_bin, '--type', sstabletype]

if oplogs:
args.extend(['--oplog'])
if cleanup:
args.extend(['--cleanup'])

args.extend([keyspace, table])

p = subprocess.Popen(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

stdout, stderr = p.communicate()

if p.returncode != 0:
common.error("""Error invoking sstableutil; returned {code}; args={args}; env={env}
stdout:
{stdout}
stderr:
{stderr}
""".format(code=p.returncode, args=args, env=env, stdout=stdout, stderr=stderr))
raise Exception("Error invoking sstableutil; returned {code}".format(code=p.returncode))

return sorted(filter(lambda s: match in s, stdout.splitlines()))

def stress_process(self, stress_options=None, whitelist=False):
if stress_options is None:
stress_options = []
Expand Down

0 comments on commit 0b1af9f

Please sign in to comment.