Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add addl jmx args option to nodetool #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cstar/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ def add_cstar_arguments(parser, commands, execute_command, execute_continue, exe
_add_cstar_arguments_without_command(continue_parser)
_add_ssh_arguments(continue_parser)
_add_jmx_auth_arguments(continue_parser)
_add_raw_jmx_args(continue_parser)

cleanup_parser = subparsers.add_parser('cleanup-jobs', help='Cleanup old finished jobs and exit (*)')
cleanup_parser.set_defaults(func=execute_cleanup)
_add_common_arguments(cleanup_parser)
_add_cstar_arguments_without_command(cleanup_parser)
_add_ssh_arguments(cleanup_parser)
_add_jmx_auth_arguments(cleanup_parser)
_add_raw_jmx_args(cleanup_parser)

for (name, command) in commands.items():
command_parser = subparsers.add_parser(name, help=command.description)
Expand All @@ -120,6 +122,7 @@ def add_cstar_arguments(parser, commands, execute_command, execute_continue, exe
_add_common_arguments(command_parser)
_add_ssh_arguments(command_parser)
_add_jmx_auth_arguments(command_parser)
_add_raw_jmx_args(command_parser)
command_parser.set_defaults(func=lambda args: execute_command(args), command=command)


Expand All @@ -130,6 +133,7 @@ def add_cstarpar_arguments(parser):
_add_strategy_arguments(parser)
_add_ssh_arguments(parser)
_add_jmx_auth_arguments(parser)
_add_raw_jmx_args(parser)
parser.add_argument('command', help='Command to run once for each Cassandra host')

def _add_ssh_arguments(parser):
Expand All @@ -140,3 +144,6 @@ def _add_ssh_arguments(parser):
def _add_jmx_auth_arguments(parser):
parser.add_argument('--jmx-username', help='JMX username', default=None)
parser.add_argument('--jmx-passwordfile', help='JMX passwordfile', default=None)

def _add_raw_jmx_args(parser):
parser.add_argument('--jmx-addlargs', help='Any additional JMX args', default=None)
4 changes: 4 additions & 0 deletions cstar/cstarcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def execute_command(args):
jmx_username=args.jmx_username,
jmx_password=args.jmx_password,
jmx_passwordfile=args.jmx_passwordfile,
jmx_addlargs=args.jmx_addlargs,
resolve_hostnames=args.resolve_hostnames,
hosts_variables=hosts_variables)
job.run()
Expand Down Expand Up @@ -224,6 +225,9 @@ def main():
else:
namespace.jmx_password = None

if namespace.jmx_addlargs:
namespace.jmx_addlargs = namespace.jmx_addlargs.strip('\\')

cstar.output.configure(namespace.verbose)
namespace.func(namespace)

Expand Down
4 changes: 4 additions & 0 deletions cstar/cstarparcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def main():
else:
namespace.jmx_password = None

if namespace.jmx_addlargs:
namespace.jmx_addlargs = namespace.jmx_addlargs.strip('\\')

if bool(namespace.seed_host) + bool(namespace.host) + bool(namespace.host_file) != 1:
error("Exactly one of --seed-host, --host and --host-file must be used", print_traceback=False)

Expand Down Expand Up @@ -110,6 +113,7 @@ def main():
jmx_username=namespace.jmx_username,
jmx_password=namespace.jmx_password,
jmx_passwordfile=namespace.jmx_passwordfile,
jmx_addlargs=namespace.jmx_addlargs,
resolve_hostnames=namespace.resolve_hostnames,
hosts_variables=hosts_variables)
job.run()
Expand Down
8 changes: 6 additions & 2 deletions cstar/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self):
self.jmx_username = None
self.jmx_password = None
self.jmx_passwordfile = None
self.jmx_addlargs = None
self.hosts_variables = dict()
self.returned_jobs = list()
self.schema_versions = list()
Expand Down Expand Up @@ -106,7 +107,6 @@ def get_cluster_topology(self, seed_nodes):
for host in seed_nodes:
tried_hosts.append(host)
conn = self._connection(host)

describe_res = self.run_nodetool(conn, "describecluster")
status_res = self.run_nodetool(conn, "status")
if (describe_res.status == 0) and (status_res.status == 0):
Expand Down Expand Up @@ -240,6 +240,9 @@ def run_nodetool(self, conn, *cmds):
jmx_args.extend(["-pw", self.jmx_password])
if self.jmx_passwordfile:
jmx_args.extend(["-pwf", self.jmx_passwordfile])
if self.jmx_addlargs:
split_jmx_addlargs=self.jmx_addlargs.split()
jmx_args.extend(split_jmx_addlargs)

return conn.run((*sudo, "nodetool", *jmx_args, *cmds))

Expand All @@ -248,7 +251,7 @@ def setup(self, hosts, seeds, command, job_id, strategy, cluster_parallel, dc_pa
ignore_down_nodes, dc_filter,
sleep_on_new_runner, sleep_after_done,
ssh_username, ssh_password, ssh_identity_file, ssh_lib,
jmx_username, jmx_password, jmx_passwordfile, resolve_hostnames, hosts_variables):
jmx_username, jmx_password, jmx_passwordfile, jmx_addlargs, resolve_hostnames, hosts_variables):

msg("Starting setup")

Expand All @@ -275,6 +278,7 @@ def setup(self, hosts, seeds, command, job_id, strategy, cluster_parallel, dc_pa
self.jmx_username = jmx_username
self.jmx_password = jmx_password
self.jmx_passwordfile = jmx_passwordfile
self.jmx_addlargs = jmx_addlargs
self.resolve_hostnames = resolve_hostnames
self.hosts_variables = hosts_variables
if not os.path.exists(self.output_directory):
Expand Down
1 change: 1 addition & 0 deletions cstar/jobreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _parse(input, file, output_directory, job, job_id, stop_after, max_days, end
job.sudo_args = data['sudo_args']
job.jmx_username = data['jmx_username']
job.jmx_passwordfile = data['jmx_passwordfile']
job.addl_jmx_args = data['addl_jmx_args']
job.hosts_variables = data['hosts_variables']

strategy = cstar.strategy.parse(state['strategy'])
Expand Down
1 change: 1 addition & 0 deletions tests/jobreader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def get_example_file():
"timeout": null,
"jmx_username": null,
"jmx_passwordfile": null,
"addl_jmx_args": null,
"use_sudo": "false",
"version": 8,
"hosts_variables": null
Expand Down
1 change: 1 addition & 0 deletions tests/resources/failed_job.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"timeout": null,
"jmx_username": null,
"jmx_passwordfile": null,
"jmx_addlargs": null,
"use_sudo": false,
"version": 8,
"hosts_variables": null
Expand Down