Merge ~barryprice/cassandra-charm/+git/cassandra-charm:master into cassandra-charm:master

Proposed by Barry Price
Status: Merged
Merge reported by: Stuart Bishop
Merged at revision: 13f11d0fb280fbfcb9468e704a107c0b0cee9351
Proposed branch: ~barryprice/cassandra-charm/+git/cassandra-charm:master
Merge into: cassandra-charm:master
Diff against target: 225 lines (+55/-29)
4 files modified
config.yaml (+21/-9)
hooks/actions.py (+16/-15)
hooks/helpers.py (+12/-5)
tests/test_helpers.py (+6/-0)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+343480@code.launchpad.net

Commit message

Add file_cache_size_in_mb option, alphabetise keys for readability in a couple of places

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks good!

review: Approve
13f11d0... by Barry Price

More pythonic value check, Flake8 fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 5ed5cf3..380b68c 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -125,7 +125,7 @@ options:
6 description: >
7 Set kernel io scheduler for persistent storage.
8 https://www.kernel.org/doc/Documentation/block/switching-sched.txt
9-
10+
11 ## units-to-update:
12 ## type: string
13 ## default: "all"
14@@ -162,12 +162,12 @@ options:
15 description: >
16 The pct of heap used to trigger a nagios critcal alert
17 nagios_disk_warn_pct:
18- default: 50
19+ default: 50
20 type: int
21 description: >
22 The pct of data disk used to trigger a nagios warning
23 nagios_disk_crit_pct:
24- default: 25
25+ default: 25
26 type: int
27 description: >
28 The pct of data disk used to trigger a nagios critcal alert
29@@ -202,6 +202,18 @@ options:
30 another. All Cassandra services you wish to cluster together
31 must have the same cluster_name. This setting cannot be changed
32 after service deployment.
33+ file_cache_size_in_mb:
34+ type: int
35+ default: 0
36+ description: >
37+ Maximum memory to use for sstable chunk cache and buffer pooling.
38+ 32MB of this are reserved for pooling buffers, the rest is used as
39+ an cache that holds uncompressed sstable chunks. Defaults to the
40+ smaller of 1/4 of heap or 512MB. This pool is allocated off-heap,
41+ so is in addition to the memory allocated for heap. The cache also
42+ has on-heap overhead which is roughly 128 bytes per chunk (i.e.
43+ 0.2% of the reserved size if the default 64k chunk size is used).
44+ Memory is only allocated when needed.
45 partitioner:
46 default: Murmur3Partitioner
47 type: string
48@@ -212,7 +224,7 @@ options:
49 type: int
50 default: 256
51 description: Number of tokens per node.
52-
53+
54 # Topology of the service in the cluster.
55 datacenter:
56 type: string
57@@ -220,7 +232,7 @@ options:
58 description: >
59 The node's datacenter used by the endpoint_snitch. e.g. "DC1".
60 It cannot be changed after service deployment.
61- rack:
62+ rack:
63 type: string
64 default: ""
65 description: >
66@@ -229,7 +241,7 @@ options:
67 It defaults to the service name. Cassandra will store replicated
68 data in different racks whenever possible.
69
70-
71+
72 # Networking options.
73 native_transport_port:
74 type: int
75@@ -282,7 +294,7 @@ options:
76 - CassandraAuthorizer stores permissions in
77 system_auth.permissions table.
78
79-
80+
81 # Tuning options.
82 compaction_throughput_mb_per_sec:
83 type: int
84@@ -301,8 +313,8 @@ options:
85 description: >
86 Throttles all outbound streaming file transfers on nodes to the
87 given total throughput in Mbps. This is necessary because Cassandra
88- does mostly sequential IO when streaming data during bootstrap or
89- repair, which can lead to saturating the network connection and
90+ does mostly sequential IO when streaming data during bootstrap or
91+ repair, which can lead to saturating the network connection and
92 degrading rpc performance. When unset, the default is 200 Mbps
93 or 25 MB/s. 0 to disable throttling.
94
95diff --git a/hooks/actions.py b/hooks/actions.py
96index 3625d9a..5be6325 100644
97--- a/hooks/actions.py
98+++ b/hooks/actions.py
99@@ -48,27 +48,28 @@ UNCHANGEABLE_KEYS = set(['cluster_name', 'datacenter', 'rack', 'edition'])
100 # If any of these config items are changed, Cassandra needs to be
101 # restarted and maybe remounted.
102 RESTART_REQUIRED_KEYS = set([
103- 'data_file_directories',
104+ 'authenticator',
105+ 'authorizer',
106 'commitlog_directory',
107- 'saved_caches_directory',
108- 'storage_port',
109- 'ssl_storage_port',
110+ 'compaction_throughput_mb_per_sec',
111+ 'data_file_directories',
112+ 'file_cache_size_in_mb',
113+ 'heap_newsize',
114+ 'jre',
115 'listen_interface',
116- 'rpc_port',
117+ 'max_heap_size',
118 'native_transport_port',
119- 'rpc_interface',
120- 'partitioner',
121 'num_tokens',
122- 'max_heap_size',
123- 'heap_newsize',
124- 'authenticator',
125- 'authorizer',
126- 'compaction_throughput_mb_per_sec',
127+ 'partitioner',
128+ 'private_jre_url',
129+ 'rpc_interface',
130+ 'rpc_port',
131+ 'saved_caches_directory',
132+ 'ssl_storage_port',
133+ 'storage_port',
134 'stream_throughput_outbound_megabits_per_sec',
135- 'tombstone_warn_threshold',
136 'tombstone_failure_threshold',
137- 'jre',
138- 'private_jre_url'])
139+ 'tombstone_warn_threshold',])
140
141 ALL_CONFIG_KEYS = UNCHANGEABLE_KEYS.union(RESTART_REQUIRED_KEYS)
142
143diff --git a/hooks/helpers.py b/hooks/helpers.py
144index c71f9f7..1e666f3 100644
145--- a/hooks/helpers.py
146+++ b/hooks/helpers.py
147@@ -877,14 +877,21 @@ def configure_cassandra_yaml(overrides={}, seeds=None):
148 # Most options just copy from config.yaml keys with the same name.
149 # Using the same name is preferred to match the actual Cassandra
150 # documentation.
151- simple_config_keys = ['cluster_name', 'num_tokens',
152- 'partitioner', 'authorizer', 'authenticator',
153+ simple_config_keys = ['authenticator', 'authorizer', 'cluster_name',
154 'compaction_throughput_mb_per_sec',
155+ 'file_cache_size_in_mb', 'native_transport_port',
156+ 'num_tokens', 'partitioner', 'rpc_port',
157+ 'ssl_storage_port' 'storage_port',
158 'stream_throughput_outbound_megabits_per_sec',
159- 'tombstone_warn_threshold',
160 'tombstone_failure_threshold',
161- 'native_transport_port', 'rpc_port',
162- 'storage_port', 'ssl_storage_port']
163+ 'tombstone_warn_threshold']
164+
165+ # file_cache_size_in_mb defaults to 0 in YAML, because int values need
166+ # an int default - but if left as default, let cassandra figure it out
167+ if (config.get('file_cache_size_in_mb') is None
168+ or config.get('file_cache_size_in_mb') <= 0):
169+ simple_config_keys.remove('file_cache_size_in_mb')
170+
171 cassandra_yaml.update((k, config[k]) for k in simple_config_keys)
172
173 seeds = ','.join(seeds or get_seed_ips()) # Don't include whitespace!
174diff --git a/tests/test_helpers.py b/tests/test_helpers.py
175index 0d78568..f52a021 100755
176--- a/tests/test_helpers.py
177+++ b/tests/test_helpers.py
178@@ -1016,6 +1016,7 @@ class TestHelpers(TestCaseBase):
179 get_cassandra_version.return_value = '2.0'
180 hookenv.config().update(dict(num_tokens=128,
181 cluster_name='test_cluster_name',
182+ file_cache_size_in_mb=768,
183 partitioner='test_partitioner'))
184
185 seed_ips.return_value = ['10.20.0.1', '10.20.0.2', '10.20.0.3']
186@@ -1042,6 +1043,7 @@ class TestHelpers(TestCaseBase):
187 cluster_name: test_cluster_name
188 authenticator: PasswordAuthenticator
189 num_tokens: 128
190+ file_cache_size_in_mb: 768
191 partitioner: test_partitioner
192 listen_address: 10.20.0.1
193 rpc_address: 0.0.0.0
194@@ -1087,6 +1089,7 @@ class TestHelpers(TestCaseBase):
195 get_cassandra_version.return_value = '2.0'
196 hookenv.config().update(dict(num_tokens=128,
197 cluster_name='test_cluster_name',
198+ file_cache_size_in_mb=768,
199 partitioner='test_partitioner'))
200
201 seed_ips.return_value = ['10.20.0.1', '10.20.0.2', '10.20.0.3']
202@@ -1115,6 +1118,7 @@ class TestHelpers(TestCaseBase):
203 cluster_name: test_cluster_name
204 authenticator: PasswordAuthenticator
205 num_tokens: 128
206+ file_cache_size_in_mb: 768
207 partitioner: test_partitioner
208 listen_address: 10.20.0.1
209 rpc_address: 0.0.0.0
210@@ -1158,6 +1162,7 @@ class TestHelpers(TestCaseBase):
211 yaml_file, get_cassandra_version):
212 get_cassandra_version.return_value = '2.1'
213 hookenv.config().update(dict(num_tokens=128,
214+ file_cache_size_in_mb=768,
215 cluster_name='test_cluster_name',
216 partitioner='test_partitioner'))
217
218@@ -1185,6 +1190,7 @@ class TestHelpers(TestCaseBase):
219 cluster_name: test_cluster_name
220 authenticator: PasswordAuthenticator
221 num_tokens: 128
222+ file_cache_size_in_mb: 768
223 partitioner: test_partitioner
224 listen_address: 10.20.0.1
225 rpc_address: 0.0.0.0

Subscribers

People subscribed via source and target branches