Skip to content

Commit

Permalink
Add option to switch to batch commit log
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Lebresne committed May 13, 2011
1 parent 049d522 commit e0dad11
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ccm_lib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ def update_configuration(self, cassandra_dir):
def set_configuration_option(self, name, value):
for node in self.nodes.values():
node.set_configuration_option(name, value)

def unset_configuration_option(self, name):
for node in self.nodes.values():
node.unset_configuration_option(name)
14 changes: 11 additions & 3 deletions ccm_lib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def update_yaml(self):
data['partitioner'] = self.cluster.partitioner

for name in self.config_options:
data[name] = self.config_options[name]
value = self.config_options[name]
if value is None:
del data[name]
else:
data[name] = self.config_options[name]

with open(conf_file, 'w') as f:
yaml.dump(data, f, default_flow_style=False)
Expand All @@ -132,6 +136,10 @@ def set_configuration_option(self, name, value):
self.config_options[name] = value
self.update_yaml()

def unset_configuration_option(self, name):
self.config_options[name] = None
self.update_yaml()

def update_log4j(self):
append_pattern='log4j.appender.R.File=';
conf_file = os.path.join(self.get_conf_dir(), common.LOG4J_CONF)
Expand Down Expand Up @@ -254,8 +262,8 @@ def run_cli(self, cassandra_dir, cmds=None, show_output=False):
i = 0
for log in p.stdout:
# first four lines are not intersting
if i >= 4
print log
if i >= 4:
print log,
i = i + 1


Expand Down
6 changes: 6 additions & 0 deletions cmds/cluster_cass_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ def get_parser(self):
parser = self._get_default_parser(usage, self.description(), cassandra_dir=True)
parser.add_option('--no-hh', '--no-hinted-handoff', action="store_false",
dest="hinted_handoff", default=True, help="Disable hinted handoff")
parser.add_option('--batch-cl', '--batch-commit-log', action="store_true",
dest="cl_batch", default=True, help="Set commit log to batch mode")
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, load_cluster=True)

def run(self):
self.cluster.set_configuration_option("hinted_handoff_enabled", self.options.hinted_handoff)
if self.options.cl_batch:
self.cluster.set_configuration_option("commitlog_sync", "batch")
self.cluster.set_configuration_option("commitlog_sync_batch_window_in_ms", 5)
self.cluster.unset_configuration_option("commitlog_sync_period_in_ms")
self.cluster.update_configuration(self.options.cassandra_dir)
6 changes: 6 additions & 0 deletions cmds/node_cass_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,19 @@ def get_parser(self):
parser = self._get_default_parser(usage, self.description(), cassandra_dir=True)
parser.add_option('--no-hh', '--no-hinted-handoff', action="store_false",
dest="hinted_handoff", default=True, help="Disable hinted handoff")
parser.add_option('--batch-cl', '--batch-commit-log', action="store_true",
dest="cl_batch", default=False, help="Set commit log to batch mode")
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)

def run(self):
self.node.set_configuration_option("hinted_handoff_enabled", self.options.hinted_handoff)
if self.options.cl_batch:
self.node.set_configuration_option("commitlog_sync", "batch")
self.node.set_configuration_option("commitlog_sync_batch_window_in_ms", 5)
self.node.unset_configuration_option("commitlog_sync_period_in_ms")
self.node.update_configuration(self.options.cassandra_dir)

class NodeStressCmd(Cmd):
Expand Down

0 comments on commit e0dad11

Please sign in to comment.