Skip to content

Commit fd5fb82

Browse files
committed
allow setting arbitrary jmx args
1 parent 81cca17 commit fd5fb82

File tree

7 files changed

+24
-2
lines changed

7 files changed

+24
-2
lines changed

cstar/args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ def add_cstar_arguments(parser, commands, execute_command, execute_continue, exe
103103
_add_cstar_arguments_without_command(continue_parser)
104104
_add_ssh_arguments(continue_parser)
105105
_add_jmx_auth_arguments(continue_parser)
106+
_add_raw_jmx_args(continue_parser)
106107

107108
cleanup_parser = subparsers.add_parser('cleanup-jobs', help='Cleanup old finished jobs and exit (*)')
108109
cleanup_parser.set_defaults(func=execute_cleanup)
109110
_add_common_arguments(cleanup_parser)
110111
_add_cstar_arguments_without_command(cleanup_parser)
111112
_add_ssh_arguments(cleanup_parser)
112113
_add_jmx_auth_arguments(cleanup_parser)
114+
_add_raw_jmx_args(cleanup_parser)
113115

114116
for (name, command) in commands.items():
115117
command_parser = subparsers.add_parser(name, help=command.description)
@@ -120,6 +122,7 @@ def add_cstar_arguments(parser, commands, execute_command, execute_continue, exe
120122
_add_common_arguments(command_parser)
121123
_add_ssh_arguments(command_parser)
122124
_add_jmx_auth_arguments(command_parser)
125+
_add_raw_jmx_args(command_parser)
123126
command_parser.set_defaults(func=lambda args: execute_command(args), command=command)
124127

125128

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

135139
def _add_ssh_arguments(parser):
@@ -140,3 +144,6 @@ def _add_ssh_arguments(parser):
140144
def _add_jmx_auth_arguments(parser):
141145
parser.add_argument('--jmx-username', help='JMX username', default=None)
142146
parser.add_argument('--jmx-passwordfile', help='JMX passwordfile', default=None)
147+
148+
def _add_raw_jmx_args(parser):
149+
parser.add_argument('--jmx-addlargs', help='Any additional JMX args', default=None)

cstar/cstarcli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def execute_command(args):
142142
jmx_username=args.jmx_username,
143143
jmx_password=args.jmx_password,
144144
jmx_passwordfile=args.jmx_passwordfile,
145+
jmx_addlargs=args.jmx_addlargs,
145146
resolve_hostnames=args.resolve_hostnames,
146147
hosts_variables=hosts_variables)
147148
job.run()
@@ -224,6 +225,9 @@ def main():
224225
else:
225226
namespace.jmx_password = None
226227

228+
if namespace.jmx_addlargs:
229+
namespace.jmx_addlargs = namespace.jmx_addlargs.strip('\\')
230+
227231
cstar.output.configure(namespace.verbose)
228232
namespace.func(namespace)
229233

cstar/cstarparcli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def main():
5555
else:
5656
namespace.jmx_password = None
5757

58+
if namespace.jmx_addlargs:
59+
namespace.jmx_addlargs = namespace.jmx_addlargs.strip('\\')
60+
5861
if bool(namespace.seed_host) + bool(namespace.host) + bool(namespace.host_file) != 1:
5962
error("Exactly one of --seed-host, --host and --host-file must be used", print_traceback=False)
6063

@@ -110,6 +113,7 @@ def main():
110113
jmx_username=namespace.jmx_username,
111114
jmx_password=namespace.jmx_password,
112115
jmx_passwordfile=namespace.jmx_passwordfile,
116+
jmx_addlargs=namespace.jmx_addlargs,
113117
resolve_hostnames=namespace.resolve_hostnames,
114118
hosts_variables=hosts_variables)
115119
job.run()

cstar/job.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(self):
7676
self.jmx_username = None
7777
self.jmx_password = None
7878
self.jmx_passwordfile = None
79+
self.jmx_addlargs = None
7980
self.hosts_variables = dict()
8081
self.returned_jobs = list()
8182
self.schema_versions = list()
@@ -106,7 +107,6 @@ def get_cluster_topology(self, seed_nodes):
106107
for host in seed_nodes:
107108
tried_hosts.append(host)
108109
conn = self._connection(host)
109-
110110
describe_res = self.run_nodetool(conn, "describecluster")
111111
status_res = self.run_nodetool(conn, "status")
112112
if (describe_res.status == 0) and (status_res.status == 0):
@@ -240,6 +240,9 @@ def run_nodetool(self, conn, *cmds):
240240
jmx_args.extend(["-pw", self.jmx_password])
241241
if self.jmx_passwordfile:
242242
jmx_args.extend(["-pwf", self.jmx_passwordfile])
243+
if self.jmx_addlargs:
244+
split_jmx_addlargs=self.jmx_addlargs.split()
245+
jmx_args.extend(split_jmx_addlargs)
243246

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

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

253256
msg("Starting setup")
254257

@@ -275,6 +278,7 @@ def setup(self, hosts, seeds, command, job_id, strategy, cluster_parallel, dc_pa
275278
self.jmx_username = jmx_username
276279
self.jmx_password = jmx_password
277280
self.jmx_passwordfile = jmx_passwordfile
281+
self.jmx_addlargs = jmx_addlargs
278282
self.resolve_hostnames = resolve_hostnames
279283
self.hosts_variables = hosts_variables
280284
if not os.path.exists(self.output_directory):

cstar/jobreader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _parse(input, file, output_directory, job, job_id, stop_after, max_days, end
6969
job.sudo_args = data['sudo_args']
7070
job.jmx_username = data['jmx_username']
7171
job.jmx_passwordfile = data['jmx_passwordfile']
72+
job.addl_jmx_args = data['addl_jmx_args']
7273
job.hosts_variables = data['hosts_variables']
7374

7475
strategy = cstar.strategy.parse(state['strategy'])

tests/jobreader_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def get_example_file():
140140
"timeout": null,
141141
"jmx_username": null,
142142
"jmx_passwordfile": null,
143+
"addl_jmx_args": null,
143144
"use_sudo": "false",
144145
"version": 8,
145146
"hosts_variables": null

tests/resources/failed_job.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"timeout": null,
106106
"jmx_username": null,
107107
"jmx_passwordfile": null,
108+
"jmx_addlargs": null,
108109
"use_sudo": false,
109110
"version": 8,
110111
"hosts_variables": null

0 commit comments

Comments
 (0)