├── .gitignore ├── README.md ├── cassandra-cdc ├── README.md ├── config │ ├── cassandra-1-cdc-tmp.yaml │ ├── cassandra-2-cdc-tmp.yaml │ ├── reader-1.yml │ └── reader-2.yml ├── docker │ ├── Dockerfile │ └── cassandra.yaml ├── pom.xml └── src │ └── main │ ├── java │ └── io │ │ └── smartcat │ │ └── cassandra │ │ └── cdc │ │ ├── CustomCommitLogReadHandler.java │ │ ├── Reader.java │ │ └── YamlUtils.java │ └── resources │ └── logback.xml └── cassandra-trigger ├── README.md ├── pom.xml └── src └── main └── java └── io └── smartcat └── cassandra └── trigger └── KafkaTrigger.java /.gitignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.project 3 | **/.settings 4 | **/target 5 | **/logs 6 | **/*.iml 7 | **/*.idea 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cassandra-kafka-connector 2 | cassandra-kafka-connector 3 | -------------------------------------------------------------------------------- /cassandra-cdc/README.md: -------------------------------------------------------------------------------- 1 | # Cassandra Capture Data Change (CDC) 2 | 3 | Purpose of this project is to serve as an example for how to implement read Cassandra CDC. 4 | 5 | ## Create a JAR 6 | 7 | This is a common Maven project with shade plugin to include all dependencies into JAR. To build it, just run: 8 | 9 | `mvn clean install` 10 | 11 | ## Use JAR 12 | 13 | In order to start reading CDC commitlogs, run JAR with: 14 | `java -jar cassandra-cdc-0.0.1-SNAPSHOT.jar ` 15 | 16 | create trigger in cassandra, JAR file needs to be places under `$CASSANDRA_CONFIG/triggers` directory on every node which will be used as coordinator. Also, path to `KafkaTrigger.yml` (line 37) needs to be adjusted to location where actuall `KafkaTrigger.yml` file is placed. Content of the file should be: 17 | 18 | ``` 19 | bootstrap.servers: cluster_kafka_1:9092,cluster_kafka_2:9092 20 | topic.name: trigger-topic 21 | ``` 22 | 23 | Note that content matches infrastructure setup which is created using `docker-compose` command from `cluster` directory. Docker compose file used is: 24 | 25 | ``` 26 | version: '3.3' 27 | services: 28 | zookeeper: 29 | image: wurstmeister/zookeeper:3.4.6 30 | ports: 31 | - "2181:2181" 32 | kafka: 33 | image: wurstmeister/kafka:0.10.1.1 34 | ports: 35 | - 9092 36 | environment: 37 | HOSTNAME_COMMAND: "ifconfig | awk '/Bcast:.+/{print $$2}' | awk -F\":\" '{print $$2}'" 38 | KAFKA_ADVERTISED_PORT: 9092 39 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 40 | cassandra-seed: 41 | image: cassandra-cdc 42 | ports: 43 | - 7199 44 | - 9042 45 | environment: 46 | CASSANDRA_CLUSTER_NAME: test-cluster 47 | cassandra: 48 | image: cassandra-cdc 49 | ports: 50 | - 7199 51 | - 9042 52 | environment: 53 | CASSANDRA_CLUSTER_NAME: test-cluster 54 | CASSANDRA_SEEDS: cassandra-seed 55 | ``` 56 | 57 | `cassandra-cdc` docker image is custom built for this usage. It includes changes to configuration file, JAR file of reader application and its configuration files. 58 | Whole setup necessary for building `cassandra-cdc` docker image can be found in [docker](docker) directory. 59 | 60 | ``` 61 | FROM cassandra:3.11.0 62 | COPY KafkaTrigger.yml /etc/cassandra/triggers/KafkaTrigger.yml 63 | COPY cassandra-trigger-0.0.1-SNAPSHOT.jar /etc/cassandra/triggers/trigger.jar 64 | CMD ["cassandra", "-f"] 65 | ``` 66 | 67 | If you intend using JAR file in different infrastructure setup (virtual machines, different docker setup, cloud environment) configuration needs to be changed to match that infrastructure. 68 | 69 | ## Create a trigger 70 | 71 | To add a trigger to a table, just execute `CREATE TRIGGER kafka_trigger ON movies_by_genre USING 'io.smartcat.cassandra.trigger.KafkaTrigger';`. -------------------------------------------------------------------------------- /cassandra-cdc/config/cassandra-1-cdc-tmp.yaml: -------------------------------------------------------------------------------- 1 | # Cassandra storage config YAML 2 | 3 | # NOTE: 4 | # See http://wiki.apache.org/cassandra/StorageConfiguration for 5 | # full explanations of configuration directives 6 | # /NOTE 7 | 8 | # The name of the cluster. This is mainly used to prevent machines in 9 | # one logical cluster from joining another. 10 | cluster_name: 'Test Cluster' 11 | 12 | # This defines the number of tokens randomly assigned to this node on the ring 13 | # The more tokens, relative to other nodes, the larger the proportion of data 14 | # that this node will store. You probably want all nodes to have the same number 15 | # of tokens assuming they have equal hardware capability. 16 | # 17 | # If you leave this unspecified, Cassandra will use the default of 1 token for legacy compatibility, 18 | # and will use the initial_token as described below. 19 | # 20 | # Specifying initial_token will override this setting on the node's initial start, 21 | # on subsequent starts, this setting will apply even if initial token is set. 22 | # 23 | # If you already have a cluster with 1 token per node, and wish to migrate to 24 | # multiple tokens per node, see http://wiki.apache.org/cassandra/Operations 25 | num_tokens: 256 26 | 27 | # Triggers automatic allocation of num_tokens tokens for this node. The allocation 28 | # algorithm attempts to choose tokens in a way that optimizes replicated load over 29 | # the nodes in the datacenter for the replication strategy used by the specified 30 | # keyspace. 31 | # 32 | # The load assigned to each node will be close to proportional to its number of 33 | # vnodes. 34 | # 35 | # Only supported with the Murmur3Partitioner. 36 | # allocate_tokens_for_keyspace: KEYSPACE 37 | 38 | # initial_token allows you to specify tokens manually. While you can use it with 39 | # vnodes (num_tokens > 1, above) -- in which case you should provide a 40 | # comma-separated list -- it's primarily used when adding nodes to legacy clusters 41 | # that do not have vnodes enabled. 42 | # initial_token: 43 | 44 | # See http://wiki.apache.org/cassandra/HintedHandoff 45 | # May either be "true" or "false" to enable globally 46 | hinted_handoff_enabled: true 47 | 48 | # When hinted_handoff_enabled is true, a black list of data centers that will not 49 | # perform hinted handoff 50 | # hinted_handoff_disabled_datacenters: 51 | # - DC1 52 | # - DC2 53 | 54 | # this defines the maximum amount of time a dead host will have hints 55 | # generated. After it has been dead this long, new hints for it will not be 56 | # created until it has been seen alive and gone down again. 57 | max_hint_window_in_ms: 10800000 # 3 hours 58 | 59 | # Maximum throttle in KBs per second, per delivery thread. This will be 60 | # reduced proportionally to the number of nodes in the cluster. (If there 61 | # are two nodes in the cluster, each delivery thread will use the maximum 62 | # rate; if there are three, each will throttle to half of the maximum, 63 | # since we expect two nodes to be delivering hints simultaneously.) 64 | hinted_handoff_throttle_in_kb: 1024 65 | 66 | # Number of threads with which to deliver hints; 67 | # Consider increasing this number when you have multi-dc deployments, since 68 | # cross-dc handoff tends to be slower 69 | max_hints_delivery_threads: 2 70 | 71 | # Directory where Cassandra should store hints. 72 | # If not set, the default directory is $CASSANDRA_HOME/data/hints. 73 | # hints_directory: /var/lib/cassandra/hints 74 | hints_directory: /tmp/cdc/cassandra-1/hints 75 | 76 | # How often hints should be flushed from the internal buffers to disk. 77 | # Will *not* trigger fsync. 78 | hints_flush_period_in_ms: 10000 79 | 80 | # Maximum size for a single hints file, in megabytes. 81 | max_hints_file_size_in_mb: 128 82 | 83 | # Compression to apply to the hint files. If omitted, hints files 84 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 85 | # are supported. 86 | #hints_compression: 87 | # - class_name: LZ4Compressor 88 | # parameters: 89 | # - 90 | 91 | # Maximum throttle in KBs per second, total. This will be 92 | # reduced proportionally to the number of nodes in the cluster. 93 | batchlog_replay_throttle_in_kb: 1024 94 | 95 | # Authentication backend, implementing IAuthenticator; used to identify users 96 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator, 97 | # PasswordAuthenticator}. 98 | # 99 | # - AllowAllAuthenticator performs no checks - set it to disable authentication. 100 | # - PasswordAuthenticator relies on username/password pairs to authenticate 101 | # users. It keeps usernames and hashed passwords in system_auth.roles table. 102 | # Please increase system_auth keyspace replication factor if you use this authenticator. 103 | # If using PasswordAuthenticator, CassandraRoleManager must also be used (see below) 104 | authenticator: AllowAllAuthenticator 105 | 106 | # Authorization backend, implementing IAuthorizer; used to limit access/provide permissions 107 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer, 108 | # CassandraAuthorizer}. 109 | # 110 | # - AllowAllAuthorizer allows any action to any user - set it to disable authorization. 111 | # - CassandraAuthorizer stores permissions in system_auth.role_permissions table. Please 112 | # increase system_auth keyspace replication factor if you use this authorizer. 113 | authorizer: AllowAllAuthorizer 114 | 115 | # Part of the Authentication & Authorization backend, implementing IRoleManager; used 116 | # to maintain grants and memberships between roles. 117 | # Out of the box, Cassandra provides org.apache.cassandra.auth.CassandraRoleManager, 118 | # which stores role information in the system_auth keyspace. Most functions of the 119 | # IRoleManager require an authenticated login, so unless the configured IAuthenticator 120 | # actually implements authentication, most of this functionality will be unavailable. 121 | # 122 | # - CassandraRoleManager stores role data in the system_auth keyspace. Please 123 | # increase system_auth keyspace replication factor if you use this role manager. 124 | role_manager: CassandraRoleManager 125 | 126 | # Validity period for roles cache (fetching granted roles can be an expensive 127 | # operation depending on the role manager, CassandraRoleManager is one example) 128 | # Granted roles are cached for authenticated sessions in AuthenticatedUser and 129 | # after the period specified here, become eligible for (async) reload. 130 | # Defaults to 2000, set to 0 to disable caching entirely. 131 | # Will be disabled automatically for AllowAllAuthenticator. 132 | roles_validity_in_ms: 2000 133 | 134 | # Refresh interval for roles cache (if enabled). 135 | # After this interval, cache entries become eligible for refresh. Upon next 136 | # access, an async reload is scheduled and the old value returned until it 137 | # completes. If roles_validity_in_ms is non-zero, then this must be 138 | # also. 139 | # Defaults to the same value as roles_validity_in_ms. 140 | # roles_update_interval_in_ms: 2000 141 | 142 | # Validity period for permissions cache (fetching permissions can be an 143 | # expensive operation depending on the authorizer, CassandraAuthorizer is 144 | # one example). Defaults to 2000, set to 0 to disable. 145 | # Will be disabled automatically for AllowAllAuthorizer. 146 | permissions_validity_in_ms: 2000 147 | 148 | # Refresh interval for permissions cache (if enabled). 149 | # After this interval, cache entries become eligible for refresh. Upon next 150 | # access, an async reload is scheduled and the old value returned until it 151 | # completes. If permissions_validity_in_ms is non-zero, then this must be 152 | # also. 153 | # Defaults to the same value as permissions_validity_in_ms. 154 | # permissions_update_interval_in_ms: 2000 155 | 156 | # Validity period for credentials cache. This cache is tightly coupled to 157 | # the provided PasswordAuthenticator implementation of IAuthenticator. If 158 | # another IAuthenticator implementation is configured, this cache will not 159 | # be automatically used and so the following settings will have no effect. 160 | # Please note, credentials are cached in their encrypted form, so while 161 | # activating this cache may reduce the number of queries made to the 162 | # underlying table, it may not bring a significant reduction in the 163 | # latency of individual authentication attempts. 164 | # Defaults to 2000, set to 0 to disable credentials caching. 165 | credentials_validity_in_ms: 2000 166 | 167 | # Refresh interval for credentials cache (if enabled). 168 | # After this interval, cache entries become eligible for refresh. Upon next 169 | # access, an async reload is scheduled and the old value returned until it 170 | # completes. If credentials_validity_in_ms is non-zero, then this must be 171 | # also. 172 | # Defaults to the same value as credentials_validity_in_ms. 173 | # credentials_update_interval_in_ms: 2000 174 | 175 | # The partitioner is responsible for distributing groups of rows (by 176 | # partition key) across nodes in the cluster. You should leave this 177 | # alone for new clusters. The partitioner can NOT be changed without 178 | # reloading all data, so when upgrading you should set this to the 179 | # same partitioner you were already using. 180 | # 181 | # Besides Murmur3Partitioner, partitioners included for backwards 182 | # compatibility include RandomPartitioner, ByteOrderedPartitioner, and 183 | # OrderPreservingPartitioner. 184 | # 185 | partitioner: org.apache.cassandra.dht.Murmur3Partitioner 186 | 187 | # Directories where Cassandra should store data on disk. Cassandra 188 | # will spread data evenly across them, subject to the granularity of 189 | # the configured compaction strategy. 190 | # If not set, the default directory is $CASSANDRA_HOME/data/data. 191 | # data_file_directories: 192 | # - /var/lib/cassandra/data 193 | data_file_directories: 194 | - /tmp/cdc/cassandra-1/data 195 | 196 | # commit log. when running on magnetic HDD, this should be a 197 | # separate spindle than the data directories. 198 | # If not set, the default directory is $CASSANDRA_HOME/data/commitlog. 199 | # commitlog_directory: /var/lib/cassandra/commitlog 200 | commitlog_directory: /tmp/cdc/cassandra-1/commitlog 201 | 202 | # Enable / disable CDC functionality on a per-node basis. This modifies the logic used 203 | # for write path allocation rejection (standard: never reject. cdc: reject Mutation 204 | # containing a CDC-enabled table if at space limit in cdc_raw_directory). 205 | cdc_enabled: true 206 | 207 | # CommitLogSegments are moved to this directory on flush if cdc_enabled: true and the 208 | # segment contains mutations for a CDC-enabled table. This should be placed on a 209 | # separate spindle than the data directories. If not set, the default directory is 210 | # $CASSANDRA_HOME/data/cdc_raw. 211 | # cdc_raw_directory: /var/lib/cassandra/cdc_raw 212 | cdc_raw_directory: /tmp/cdc/cassandra-1/cdc_raw 213 | 214 | # Policy for data disk failures: 215 | # 216 | # die 217 | # shut down gossip and client transports and kill the JVM for any fs errors or 218 | # single-sstable errors, so the node can be replaced. 219 | # 220 | # stop_paranoid 221 | # shut down gossip and client transports even for single-sstable errors, 222 | # kill the JVM for errors during startup. 223 | # 224 | # stop 225 | # shut down gossip and client transports, leaving the node effectively dead, but 226 | # can still be inspected via JMX, kill the JVM for errors during startup. 227 | # 228 | # best_effort 229 | # stop using the failed disk and respond to requests based on 230 | # remaining available sstables. This means you WILL see obsolete 231 | # data at CL.ONE! 232 | # 233 | # ignore 234 | # ignore fatal errors and let requests fail, as in pre-1.2 Cassandra 235 | disk_failure_policy: stop 236 | 237 | # Policy for commit disk failures: 238 | # 239 | # die 240 | # shut down gossip and Thrift and kill the JVM, so the node can be replaced. 241 | # 242 | # stop 243 | # shut down gossip and Thrift, leaving the node effectively dead, but 244 | # can still be inspected via JMX. 245 | # 246 | # stop_commit 247 | # shutdown the commit log, letting writes collect but 248 | # continuing to service reads, as in pre-2.0.5 Cassandra 249 | # 250 | # ignore 251 | # ignore fatal errors and let the batches fail 252 | commit_failure_policy: stop 253 | 254 | # Maximum size of the native protocol prepared statement cache 255 | # 256 | # Valid values are either "auto" (omitting the value) or a value greater 0. 257 | # 258 | # Note that specifying a too large value will result in long running GCs and possbily 259 | # out-of-memory errors. Keep the value at a small fraction of the heap. 260 | # 261 | # If you constantly see "prepared statements discarded in the last minute because 262 | # cache limit reached" messages, the first step is to investigate the root cause 263 | # of these messages and check whether prepared statements are used correctly - 264 | # i.e. use bind markers for variable parts. 265 | # 266 | # Do only change the default value, if you really have more prepared statements than 267 | # fit in the cache. In most cases it is not neccessary to change this value. 268 | # Constantly re-preparing statements is a performance penalty. 269 | # 270 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 271 | prepared_statements_cache_size_mb: 272 | 273 | # Maximum size of the Thrift prepared statement cache 274 | # 275 | # If you do not use Thrift at all, it is safe to leave this value at "auto". 276 | # 277 | # See description of 'prepared_statements_cache_size_mb' above for more information. 278 | # 279 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 280 | thrift_prepared_statements_cache_size_mb: 281 | 282 | # Maximum size of the key cache in memory. 283 | # 284 | # Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the 285 | # minimum, sometimes more. The key cache is fairly tiny for the amount of 286 | # time it saves, so it's worthwhile to use it at large numbers. 287 | # The row cache saves even more time, but must contain the entire row, 288 | # so it is extremely space-intensive. It's best to only use the 289 | # row cache if you have hot rows or static rows. 290 | # 291 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 292 | # 293 | # Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache. 294 | key_cache_size_in_mb: 295 | 296 | # Duration in seconds after which Cassandra should 297 | # save the key cache. Caches are saved to saved_caches_directory as 298 | # specified in this configuration file. 299 | # 300 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 301 | # terms of I/O for the key cache. Row cache saving is much more expensive and 302 | # has limited use. 303 | # 304 | # Default is 14400 or 4 hours. 305 | key_cache_save_period: 14400 306 | 307 | # Number of keys from the key cache to save 308 | # Disabled by default, meaning all keys are going to be saved 309 | # key_cache_keys_to_save: 100 310 | 311 | # Row cache implementation class name. Available implementations: 312 | # 313 | # org.apache.cassandra.cache.OHCProvider 314 | # Fully off-heap row cache implementation (default). 315 | # 316 | # org.apache.cassandra.cache.SerializingCacheProvider 317 | # This is the row cache implementation availabile 318 | # in previous releases of Cassandra. 319 | # row_cache_class_name: org.apache.cassandra.cache.OHCProvider 320 | 321 | # Maximum size of the row cache in memory. 322 | # Please note that OHC cache implementation requires some additional off-heap memory to manage 323 | # the map structures and some in-flight memory during operations before/after cache entries can be 324 | # accounted against the cache capacity. This overhead is usually small compared to the whole capacity. 325 | # Do not specify more memory that the system can afford in the worst usual situation and leave some 326 | # headroom for OS block level cache. Do never allow your system to swap. 327 | # 328 | # Default value is 0, to disable row caching. 329 | row_cache_size_in_mb: 0 330 | 331 | # Duration in seconds after which Cassandra should save the row cache. 332 | # Caches are saved to saved_caches_directory as specified in this configuration file. 333 | # 334 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 335 | # terms of I/O for the key cache. Row cache saving is much more expensive and 336 | # has limited use. 337 | # 338 | # Default is 0 to disable saving the row cache. 339 | row_cache_save_period: 0 340 | 341 | # Number of keys from the row cache to save. 342 | # Specify 0 (which is the default), meaning all keys are going to be saved 343 | # row_cache_keys_to_save: 100 344 | 345 | # Maximum size of the counter cache in memory. 346 | # 347 | # Counter cache helps to reduce counter locks' contention for hot counter cells. 348 | # In case of RF = 1 a counter cache hit will cause Cassandra to skip the read before 349 | # write entirely. With RF > 1 a counter cache hit will still help to reduce the duration 350 | # of the lock hold, helping with hot counter cell updates, but will not allow skipping 351 | # the read entirely. Only the local (clock, count) tuple of a counter cell is kept 352 | # in memory, not the whole counter, so it's relatively cheap. 353 | # 354 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 355 | # 356 | # Default value is empty to make it "auto" (min(2.5% of Heap (in MB), 50MB)). Set to 0 to disable counter cache. 357 | # NOTE: if you perform counter deletes and rely on low gcgs, you should disable the counter cache. 358 | counter_cache_size_in_mb: 359 | 360 | # Duration in seconds after which Cassandra should 361 | # save the counter cache (keys only). Caches are saved to saved_caches_directory as 362 | # specified in this configuration file. 363 | # 364 | # Default is 7200 or 2 hours. 365 | counter_cache_save_period: 7200 366 | 367 | # Number of keys from the counter cache to save 368 | # Disabled by default, meaning all keys are going to be saved 369 | # counter_cache_keys_to_save: 100 370 | 371 | # saved caches 372 | # If not set, the default directory is $CASSANDRA_HOME/data/saved_caches. 373 | # saved_caches_directory: /var/lib/cassandra/saved_caches 374 | 375 | # commitlog_sync may be either "periodic" or "batch." 376 | # 377 | # When in batch mode, Cassandra won't ack writes until the commit log 378 | # has been fsynced to disk. It will wait 379 | # commitlog_sync_batch_window_in_ms milliseconds between fsyncs. 380 | # This window should be kept short because the writer threads will 381 | # be unable to do extra work while waiting. (You may need to increase 382 | # concurrent_writes for the same reason.) 383 | # 384 | # commitlog_sync: batch 385 | # commitlog_sync_batch_window_in_ms: 2 386 | # 387 | # the other option is "periodic" where writes may be acked immediately 388 | # and the CommitLog is simply synced every commitlog_sync_period_in_ms 389 | # milliseconds. 390 | commitlog_sync: periodic 391 | commitlog_sync_period_in_ms: 10000 392 | 393 | # The size of the individual commitlog file segments. A commitlog 394 | # segment may be archived, deleted, or recycled once all the data 395 | # in it (potentially from each columnfamily in the system) has been 396 | # flushed to sstables. 397 | # 398 | # The default size is 32, which is almost always fine, but if you are 399 | # archiving commitlog segments (see commitlog_archiving.properties), 400 | # then you probably want a finer granularity of archiving; 8 or 16 MB 401 | # is reasonable. 402 | # Max mutation size is also configurable via max_mutation_size_in_kb setting in 403 | # cassandra.yaml. The default is half the size commitlog_segment_size_in_mb * 1024. 404 | # 405 | # NOTE: If max_mutation_size_in_kb is set explicitly then commitlog_segment_size_in_mb must 406 | # be set to at least twice the size of max_mutation_size_in_kb / 1024 407 | # 408 | commitlog_segment_size_in_mb: 1 409 | 410 | # Compression to apply to the commit log. If omitted, the commit log 411 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 412 | # are supported. 413 | # commitlog_compression: 414 | # - class_name: LZ4Compressor 415 | # parameters: 416 | # - 417 | 418 | # any class that implements the SeedProvider interface and has a 419 | # constructor that takes a Map of parameters will do. 420 | seed_provider: 421 | # Addresses of hosts that are deemed contact points. 422 | # Cassandra nodes use this list of hosts to find each other and learn 423 | # the topology of the ring. You must change this if you are running 424 | # multiple nodes! 425 | - class_name: org.apache.cassandra.locator.SimpleSeedProvider 426 | parameters: 427 | # seeds is actually a comma-delimited list of addresses. 428 | # Ex: ",," 429 | - seeds: "127.0.0.1" 430 | 431 | # For workloads with more data than can fit in memory, Cassandra's 432 | # bottleneck will be reads that need to fetch data from 433 | # disk. "concurrent_reads" should be set to (16 * number_of_drives) in 434 | # order to allow the operations to enqueue low enough in the stack 435 | # that the OS and drives can reorder them. Same applies to 436 | # "concurrent_counter_writes", since counter writes read the current 437 | # values before incrementing and writing them back. 438 | # 439 | # On the other hand, since writes are almost never IO bound, the ideal 440 | # number of "concurrent_writes" is dependent on the number of cores in 441 | # your system; (8 * number_of_cores) is a good rule of thumb. 442 | concurrent_reads: 32 443 | concurrent_writes: 32 444 | concurrent_counter_writes: 32 445 | 446 | # For materialized view writes, as there is a read involved, so this should 447 | # be limited by the less of concurrent reads or concurrent writes. 448 | concurrent_materialized_view_writes: 32 449 | 450 | # Maximum memory to use for sstable chunk cache and buffer pooling. 451 | # 32MB of this are reserved for pooling buffers, the rest is used as an 452 | # cache that holds uncompressed sstable chunks. 453 | # Defaults to the smaller of 1/4 of heap or 512MB. This pool is allocated off-heap, 454 | # so is in addition to the memory allocated for heap. The cache also has on-heap 455 | # overhead which is roughly 128 bytes per chunk (i.e. 0.2% of the reserved size 456 | # if the default 64k chunk size is used). 457 | # Memory is only allocated when needed. 458 | # file_cache_size_in_mb: 512 459 | 460 | # Flag indicating whether to allocate on or off heap when the sstable buffer 461 | # pool is exhausted, that is when it has exceeded the maximum memory 462 | # file_cache_size_in_mb, beyond which it will not cache buffers but allocate on request. 463 | 464 | # buffer_pool_use_heap_if_exhausted: true 465 | 466 | # The strategy for optimizing disk read 467 | # Possible values are: 468 | # ssd (for solid state disks, the default) 469 | # spinning (for spinning disks) 470 | # disk_optimization_strategy: ssd 471 | 472 | # Total permitted memory to use for memtables. Cassandra will stop 473 | # accepting writes when the limit is exceeded until a flush completes, 474 | # and will trigger a flush based on memtable_cleanup_threshold 475 | # If omitted, Cassandra will set both to 1/4 the size of the heap. 476 | # memtable_heap_space_in_mb: 2048 477 | # memtable_offheap_space_in_mb: 2048 478 | 479 | # memtable_cleanup_threshold is deprecated. The default calculation 480 | # is the only reasonable choice. See the comments on memtable_flush_writers 481 | # for more information. 482 | # 483 | # Ratio of occupied non-flushing memtable size to total permitted size 484 | # that will trigger a flush of the largest memtable. Larger mct will 485 | # mean larger flushes and hence less compaction, but also less concurrent 486 | # flush activity which can make it difficult to keep your disks fed 487 | # under heavy write load. 488 | # 489 | # memtable_cleanup_threshold defaults to 1 / (memtable_flush_writers + 1) 490 | # memtable_cleanup_threshold: 0.11 491 | 492 | # Specify the way Cassandra allocates and manages memtable memory. 493 | # Options are: 494 | # 495 | # heap_buffers 496 | # on heap nio buffers 497 | # 498 | # offheap_buffers 499 | # off heap (direct) nio buffers 500 | # 501 | # offheap_objects 502 | # off heap objects 503 | memtable_allocation_type: heap_buffers 504 | 505 | # Total space to use for commit logs on disk. 506 | # 507 | # If space gets above this value, Cassandra will flush every dirty CF 508 | # in the oldest segment and remove it. So a small total commitlog space 509 | # will tend to cause more flush activity on less-active columnfamilies. 510 | # 511 | # The default value is the smaller of 8192, and 1/4 of the total space 512 | # of the commitlog volume. 513 | # 514 | # commitlog_total_space_in_mb: 8192 515 | commitlog_total_space_in_mb: 16 516 | 517 | # This sets the number of memtable flush writer threads per disk 518 | # as well as the total number of memtables that can be flushed concurrently. 519 | # These are generally a combination of compute and IO bound. 520 | # 521 | # Memtable flushing is more CPU efficient than memtable ingest and a single thread 522 | # can keep up with the ingest rate of a whole server on a single fast disk 523 | # until it temporarily becomes IO bound under contention typically with compaction. 524 | # At that point you need multiple flush threads. At some point in the future 525 | # it may become CPU bound all the time. 526 | # 527 | # You can tell if flushing is falling behind using the MemtablePool.BlockedOnAllocation 528 | # metric which should be 0, but will be non-zero if threads are blocked waiting on flushing 529 | # to free memory. 530 | # 531 | # memtable_flush_writers defaults to two for a single data directory. 532 | # This means that two memtables can be flushed concurrently to the single data directory. 533 | # If you have multiple data directories the default is one memtable flushing at a time 534 | # but the flush will use a thread per data directory so you will get two or more writers. 535 | # 536 | # Two is generally enough to flush on a fast disk [array] mounted as a single data directory. 537 | # Adding more flush writers will result in smaller more frequent flushes that introduce more 538 | # compaction overhead. 539 | # 540 | # There is a direct tradeoff between number of memtables that can be flushed concurrently 541 | # and flush size and frequency. More is not better you just need enough flush writers 542 | # to never stall waiting for flushing to free memory. 543 | # 544 | #memtable_flush_writers: 2 545 | 546 | # Total space to use for change-data-capture logs on disk. 547 | # 548 | # If space gets above this value, Cassandra will throw WriteTimeoutException 549 | # on Mutations including tables with CDC enabled. A CDCCompactor is responsible 550 | # for parsing the raw CDC logs and deleting them when parsing is completed. 551 | # 552 | # The default value is the min of 4096 mb and 1/8th of the total space 553 | # of the drive where cdc_raw_directory resides. 554 | # cdc_total_space_in_mb: 4096 555 | cdc_total_space_in_mb: 4096 556 | 557 | # When we hit our cdc_raw limit and the CDCCompactor is either running behind 558 | # or experiencing backpressure, we check at the following interval to see if any 559 | # new space for cdc-tracked tables has been made available. Default to 250ms 560 | # cdc_free_space_check_interval_ms: 250 561 | cdc_free_space_check_interval_ms: 250 562 | 563 | # A fixed memory pool size in MB for for SSTable index summaries. If left 564 | # empty, this will default to 5% of the heap size. If the memory usage of 565 | # all index summaries exceeds this limit, SSTables with low read rates will 566 | # shrink their index summaries in order to meet this limit. However, this 567 | # is a best-effort process. In extreme conditions Cassandra may need to use 568 | # more than this amount of memory. 569 | index_summary_capacity_in_mb: 570 | 571 | # How frequently index summaries should be resampled. This is done 572 | # periodically to redistribute memory from the fixed-size pool to sstables 573 | # proportional their recent read rates. Setting to -1 will disable this 574 | # process, leaving existing index summaries at their current sampling level. 575 | index_summary_resize_interval_in_minutes: 60 576 | 577 | # Whether to, when doing sequential writing, fsync() at intervals in 578 | # order to force the operating system to flush the dirty 579 | # buffers. Enable this to avoid sudden dirty buffer flushing from 580 | # impacting read latencies. Almost always a good idea on SSDs; not 581 | # necessarily on platters. 582 | trickle_fsync: false 583 | trickle_fsync_interval_in_kb: 10240 584 | 585 | # TCP port, for commands and data 586 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 587 | storage_port: 7000 588 | 589 | # SSL port, for encrypted communication. Unused unless enabled in 590 | # encryption_options 591 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 592 | ssl_storage_port: 7001 593 | 594 | # Address or interface to bind to and tell other Cassandra nodes to connect to. 595 | # You _must_ change this if you want multiple nodes to be able to communicate! 596 | # 597 | # Set listen_address OR listen_interface, not both. 598 | # 599 | # Leaving it blank leaves it up to InetAddress.getLocalHost(). This 600 | # will always do the Right Thing _if_ the node is properly configured 601 | # (hostname, name resolution, etc), and the Right Thing is to use the 602 | # address associated with the hostname (it might not be). 603 | # 604 | # Setting listen_address to 0.0.0.0 is always wrong. 605 | # 606 | listen_address: localhost 607 | 608 | # Set listen_address OR listen_interface, not both. Interfaces must correspond 609 | # to a single address, IP aliasing is not supported. 610 | # listen_interface: eth0 611 | 612 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 613 | # you can specify which should be chosen using listen_interface_prefer_ipv6. If false the first ipv4 614 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 615 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 616 | # listen_interface_prefer_ipv6: false 617 | 618 | # Address to broadcast to other Cassandra nodes 619 | # Leaving this blank will set it to the same value as listen_address 620 | # broadcast_address: 1.2.3.4 621 | 622 | # When using multiple physical network interfaces, set this 623 | # to true to listen on broadcast_address in addition to 624 | # the listen_address, allowing nodes to communicate in both 625 | # interfaces. 626 | # Ignore this property if the network configuration automatically 627 | # routes between the public and private networks such as EC2. 628 | # listen_on_broadcast_address: false 629 | 630 | # Internode authentication backend, implementing IInternodeAuthenticator; 631 | # used to allow/disallow connections from peer nodes. 632 | # internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator 633 | 634 | # Whether to start the native transport server. 635 | # Please note that the address on which the native transport is bound is the 636 | # same as the rpc_address. The port however is different and specified below. 637 | start_native_transport: true 638 | # port for the CQL native transport to listen for clients on 639 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 640 | native_transport_port: 9042 641 | # Enabling native transport encryption in client_encryption_options allows you to either use 642 | # encryption for the standard port or to use a dedicated, additional port along with the unencrypted 643 | # standard native_transport_port. 644 | # Enabling client encryption and keeping native_transport_port_ssl disabled will use encryption 645 | # for native_transport_port. Setting native_transport_port_ssl to a different value 646 | # from native_transport_port will use encryption for native_transport_port_ssl while 647 | # keeping native_transport_port unencrypted. 648 | # native_transport_port_ssl: 9142 649 | # The maximum threads for handling requests when the native transport is used. 650 | # This is similar to rpc_max_threads though the default differs slightly (and 651 | # there is no native_transport_min_threads, idle threads will always be stopped 652 | # after 30 seconds). 653 | # native_transport_max_threads: 128 654 | # 655 | # The maximum size of allowed frame. Frame (requests) larger than this will 656 | # be rejected as invalid. The default is 256MB. If you're changing this parameter, 657 | # you may want to adjust max_value_size_in_mb accordingly. 658 | # native_transport_max_frame_size_in_mb: 256 659 | 660 | # The maximum number of concurrent client connections. 661 | # The default is -1, which means unlimited. 662 | # native_transport_max_concurrent_connections: -1 663 | 664 | # The maximum number of concurrent client connections per source ip. 665 | # The default is -1, which means unlimited. 666 | # native_transport_max_concurrent_connections_per_ip: -1 667 | 668 | # Whether to start the thrift rpc server. 669 | start_rpc: false 670 | 671 | # The address or interface to bind the Thrift RPC service and native transport 672 | # server to. 673 | # 674 | # Set rpc_address OR rpc_interface, not both. 675 | # 676 | # Leaving rpc_address blank has the same effect as on listen_address 677 | # (i.e. it will be based on the configured hostname of the node). 678 | # 679 | # Note that unlike listen_address, you can specify 0.0.0.0, but you must also 680 | # set broadcast_rpc_address to a value other than 0.0.0.0. 681 | # 682 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 683 | rpc_address: localhost 684 | 685 | # Set rpc_address OR rpc_interface, not both. Interfaces must correspond 686 | # to a single address, IP aliasing is not supported. 687 | # rpc_interface: eth1 688 | 689 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 690 | # you can specify which should be chosen using rpc_interface_prefer_ipv6. If false the first ipv4 691 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 692 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 693 | # rpc_interface_prefer_ipv6: false 694 | 695 | # port for Thrift to listen for clients on 696 | rpc_port: 9160 697 | 698 | # RPC address to broadcast to drivers and other Cassandra nodes. This cannot 699 | # be set to 0.0.0.0. If left blank, this will be set to the value of 700 | # rpc_address. If rpc_address is set to 0.0.0.0, broadcast_rpc_address must 701 | # be set. 702 | # broadcast_rpc_address: 1.2.3.4 703 | 704 | # enable or disable keepalive on rpc/native connections 705 | rpc_keepalive: true 706 | 707 | # Cassandra provides two out-of-the-box options for the RPC Server: 708 | # 709 | # sync 710 | # One thread per thrift connection. For a very large number of clients, memory 711 | # will be your limiting factor. On a 64 bit JVM, 180KB is the minimum stack size 712 | # per thread, and that will correspond to your use of virtual memory (but physical memory 713 | # may be limited depending on use of stack space). 714 | # 715 | # hsha 716 | # Stands for "half synchronous, half asynchronous." All thrift clients are handled 717 | # asynchronously using a small number of threads that does not vary with the amount 718 | # of thrift clients (and thus scales well to many clients). The rpc requests are still 719 | # synchronous (one thread per active request). If hsha is selected then it is essential 720 | # that rpc_max_threads is changed from the default value of unlimited. 721 | # 722 | # The default is sync because on Windows hsha is about 30% slower. On Linux, 723 | # sync/hsha performance is about the same, with hsha of course using less memory. 724 | # 725 | # Alternatively, can provide your own RPC server by providing the fully-qualified class name 726 | # of an o.a.c.t.TServerFactory that can create an instance of it. 727 | rpc_server_type: sync 728 | 729 | # Uncomment rpc_min|max_thread to set request pool size limits. 730 | # 731 | # Regardless of your choice of RPC server (see above), the number of maximum requests in the 732 | # RPC thread pool dictates how many concurrent requests are possible (but if you are using the sync 733 | # RPC server, it also dictates the number of clients that can be connected at all). 734 | # 735 | # The default is unlimited and thus provides no protection against clients overwhelming the server. You are 736 | # encouraged to set a maximum that makes sense for you in production, but do keep in mind that 737 | # rpc_max_threads represents the maximum number of client requests this server may execute concurrently. 738 | # 739 | # rpc_min_threads: 16 740 | # rpc_max_threads: 2048 741 | 742 | # uncomment to set socket buffer sizes on rpc connections 743 | # rpc_send_buff_size_in_bytes: 744 | # rpc_recv_buff_size_in_bytes: 745 | 746 | # Uncomment to set socket buffer size for internode communication 747 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 748 | # and when not setting it it is defined by net.ipv4.tcp_wmem 749 | # See also: 750 | # /proc/sys/net/core/wmem_max 751 | # /proc/sys/net/core/rmem_max 752 | # /proc/sys/net/ipv4/tcp_wmem 753 | # /proc/sys/net/ipv4/tcp_wmem 754 | # and 'man tcp' 755 | # internode_send_buff_size_in_bytes: 756 | 757 | # Uncomment to set socket buffer size for internode communication 758 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 759 | # and when not setting it it is defined by net.ipv4.tcp_wmem 760 | # internode_recv_buff_size_in_bytes: 761 | 762 | # Frame size for thrift (maximum message length). 763 | thrift_framed_transport_size_in_mb: 15 764 | 765 | # Set to true to have Cassandra create a hard link to each sstable 766 | # flushed or streamed locally in a backups/ subdirectory of the 767 | # keyspace data. Removing these links is the operator's 768 | # responsibility. 769 | incremental_backups: false 770 | 771 | # Whether or not to take a snapshot before each compaction. Be 772 | # careful using this option, since Cassandra won't clean up the 773 | # snapshots for you. Mostly useful if you're paranoid when there 774 | # is a data format change. 775 | snapshot_before_compaction: false 776 | 777 | # Whether or not a snapshot is taken of the data before keyspace truncation 778 | # or dropping of column families. The STRONGLY advised default of true 779 | # should be used to provide data safety. If you set this flag to false, you will 780 | # lose data on truncation or drop. 781 | auto_snapshot: true 782 | 783 | # Granularity of the collation index of rows within a partition. 784 | # Increase if your rows are large, or if you have a very large 785 | # number of rows per partition. The competing goals are these: 786 | # 787 | # - a smaller granularity means more index entries are generated 788 | # and looking up rows withing the partition by collation column 789 | # is faster 790 | # - but, Cassandra will keep the collation index in memory for hot 791 | # rows (as part of the key cache), so a larger granularity means 792 | # you can cache more hot rows 793 | column_index_size_in_kb: 64 794 | 795 | # Per sstable indexed key cache entries (the collation index in memory 796 | # mentioned above) exceeding this size will not be held on heap. 797 | # This means that only partition information is held on heap and the 798 | # index entries are read from disk. 799 | # 800 | # Note that this size refers to the size of the 801 | # serialized index information and not the size of the partition. 802 | column_index_cache_size_in_kb: 2 803 | 804 | # Number of simultaneous compactions to allow, NOT including 805 | # validation "compactions" for anti-entropy repair. Simultaneous 806 | # compactions can help preserve read performance in a mixed read/write 807 | # workload, by mitigating the tendency of small sstables to accumulate 808 | # during a single long running compactions. The default is usually 809 | # fine and if you experience problems with compaction running too 810 | # slowly or too fast, you should look at 811 | # compaction_throughput_mb_per_sec first. 812 | # 813 | # concurrent_compactors defaults to the smaller of (number of disks, 814 | # number of cores), with a minimum of 2 and a maximum of 8. 815 | # 816 | # If your data directories are backed by SSD, you should increase this 817 | # to the number of cores. 818 | #concurrent_compactors: 1 819 | 820 | # Throttles compaction to the given total throughput across the entire 821 | # system. The faster you insert data, the faster you need to compact in 822 | # order to keep the sstable count down, but in general, setting this to 823 | # 16 to 32 times the rate you are inserting data is more than sufficient. 824 | # Setting this to 0 disables throttling. Note that this account for all types 825 | # of compaction, including validation compaction. 826 | compaction_throughput_mb_per_sec: 16 827 | 828 | # When compacting, the replacement sstable(s) can be opened before they 829 | # are completely written, and used in place of the prior sstables for 830 | # any range that has been written. This helps to smoothly transfer reads 831 | # between the sstables, reducing page cache churn and keeping hot rows hot 832 | sstable_preemptive_open_interval_in_mb: 50 833 | 834 | # Throttles all outbound streaming file transfers on this node to the 835 | # given total throughput in Mbps. This is necessary because Cassandra does 836 | # mostly sequential IO when streaming data during bootstrap or repair, which 837 | # can lead to saturating the network connection and degrading rpc performance. 838 | # When unset, the default is 200 Mbps or 25 MB/s. 839 | # stream_throughput_outbound_megabits_per_sec: 200 840 | 841 | # Throttles all streaming file transfer between the datacenters, 842 | # this setting allows users to throttle inter dc stream throughput in addition 843 | # to throttling all network stream traffic as configured with 844 | # stream_throughput_outbound_megabits_per_sec 845 | # When unset, the default is 200 Mbps or 25 MB/s 846 | # inter_dc_stream_throughput_outbound_megabits_per_sec: 200 847 | 848 | # How long the coordinator should wait for read operations to complete 849 | read_request_timeout_in_ms: 5000 850 | # How long the coordinator should wait for seq or index scans to complete 851 | range_request_timeout_in_ms: 10000 852 | # How long the coordinator should wait for writes to complete 853 | write_request_timeout_in_ms: 2000 854 | # How long the coordinator should wait for counter writes to complete 855 | counter_write_request_timeout_in_ms: 5000 856 | # How long a coordinator should continue to retry a CAS operation 857 | # that contends with other proposals for the same row 858 | cas_contention_timeout_in_ms: 1000 859 | # How long the coordinator should wait for truncates to complete 860 | # (This can be much longer, because unless auto_snapshot is disabled 861 | # we need to flush first so we can snapshot before removing the data.) 862 | truncate_request_timeout_in_ms: 60000 863 | # The default timeout for other, miscellaneous operations 864 | request_timeout_in_ms: 10000 865 | 866 | # How long before a node logs slow queries. Select queries that take longer than 867 | # this timeout to execute, will generate an aggregated log message, so that slow queries 868 | # can be identified. Set this value to zero to disable slow query logging. 869 | slow_query_log_timeout_in_ms: 500 870 | 871 | # Enable operation timeout information exchange between nodes to accurately 872 | # measure request timeouts. If disabled, replicas will assume that requests 873 | # were forwarded to them instantly by the coordinator, which means that 874 | # under overload conditions we will waste that much extra time processing 875 | # already-timed-out requests. 876 | # 877 | # Warning: before enabling this property make sure to ntp is installed 878 | # and the times are synchronized between the nodes. 879 | cross_node_timeout: false 880 | 881 | # Set keep-alive period for streaming 882 | # This node will send a keep-alive message periodically with this period. 883 | # If the node does not receive a keep-alive message from the peer for 884 | # 2 keep-alive cycles the stream session times out and fail 885 | # Default value is 300s (5 minutes), which means stalled stream 886 | # times out in 10 minutes by default 887 | # streaming_keep_alive_period_in_secs: 300 888 | 889 | # phi value that must be reached for a host to be marked down. 890 | # most users should never need to adjust this. 891 | # phi_convict_threshold: 8 892 | 893 | # endpoint_snitch -- Set this to a class that implements 894 | # IEndpointSnitch. The snitch has two functions: 895 | # 896 | # - it teaches Cassandra enough about your network topology to route 897 | # requests efficiently 898 | # - it allows Cassandra to spread replicas around your cluster to avoid 899 | # correlated failures. It does this by grouping machines into 900 | # "datacenters" and "racks." Cassandra will do its best not to have 901 | # more than one replica on the same "rack" (which may not actually 902 | # be a physical location) 903 | # 904 | # CASSANDRA WILL NOT ALLOW YOU TO SWITCH TO AN INCOMPATIBLE SNITCH 905 | # ONCE DATA IS INSERTED INTO THE CLUSTER. This would cause data loss. 906 | # This means that if you start with the default SimpleSnitch, which 907 | # locates every node on "rack1" in "datacenter1", your only options 908 | # if you need to add another datacenter are GossipingPropertyFileSnitch 909 | # (and the older PFS). From there, if you want to migrate to an 910 | # incompatible snitch like Ec2Snitch you can do it by adding new nodes 911 | # under Ec2Snitch (which will locate them in a new "datacenter") and 912 | # decommissioning the old ones. 913 | # 914 | # Out of the box, Cassandra provides: 915 | # 916 | # SimpleSnitch: 917 | # Treats Strategy order as proximity. This can improve cache 918 | # locality when disabling read repair. Only appropriate for 919 | # single-datacenter deployments. 920 | # 921 | # GossipingPropertyFileSnitch 922 | # This should be your go-to snitch for production use. The rack 923 | # and datacenter for the local node are defined in 924 | # cassandra-rackdc.properties and propagated to other nodes via 925 | # gossip. If cassandra-topology.properties exists, it is used as a 926 | # fallback, allowing migration from the PropertyFileSnitch. 927 | # 928 | # PropertyFileSnitch: 929 | # Proximity is determined by rack and data center, which are 930 | # explicitly configured in cassandra-topology.properties. 931 | # 932 | # Ec2Snitch: 933 | # Appropriate for EC2 deployments in a single Region. Loads Region 934 | # and Availability Zone information from the EC2 API. The Region is 935 | # treated as the datacenter, and the Availability Zone as the rack. 936 | # Only private IPs are used, so this will not work across multiple 937 | # Regions. 938 | # 939 | # Ec2MultiRegionSnitch: 940 | # Uses public IPs as broadcast_address to allow cross-region 941 | # connectivity. (Thus, you should set seed addresses to the public 942 | # IP as well.) You will need to open the storage_port or 943 | # ssl_storage_port on the public IP firewall. (For intra-Region 944 | # traffic, Cassandra will switch to the private IP after 945 | # establishing a connection.) 946 | # 947 | # RackInferringSnitch: 948 | # Proximity is determined by rack and data center, which are 949 | # assumed to correspond to the 3rd and 2nd octet of each node's IP 950 | # address, respectively. Unless this happens to match your 951 | # deployment conventions, this is best used as an example of 952 | # writing a custom Snitch class and is provided in that spirit. 953 | # 954 | # You can use a custom Snitch by setting this to the full class name 955 | # of the snitch, which will be assumed to be on your classpath. 956 | endpoint_snitch: SimpleSnitch 957 | 958 | # controls how often to perform the more expensive part of host score 959 | # calculation 960 | dynamic_snitch_update_interval_in_ms: 100 961 | # controls how often to reset all host scores, allowing a bad host to 962 | # possibly recover 963 | dynamic_snitch_reset_interval_in_ms: 600000 964 | # if set greater than zero and read_repair_chance is < 1.0, this will allow 965 | # 'pinning' of replicas to hosts in order to increase cache capacity. 966 | # The badness threshold will control how much worse the pinned host has to be 967 | # before the dynamic snitch will prefer other replicas over it. This is 968 | # expressed as a double which represents a percentage. Thus, a value of 969 | # 0.2 means Cassandra would continue to prefer the static snitch values 970 | # until the pinned host was 20% worse than the fastest. 971 | dynamic_snitch_badness_threshold: 0.1 972 | 973 | # request_scheduler -- Set this to a class that implements 974 | # RequestScheduler, which will schedule incoming client requests 975 | # according to the specific policy. This is useful for multi-tenancy 976 | # with a single Cassandra cluster. 977 | # NOTE: This is specifically for requests from the client and does 978 | # not affect inter node communication. 979 | # org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place 980 | # org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of 981 | # client requests to a node with a separate queue for each 982 | # request_scheduler_id. The scheduler is further customized by 983 | # request_scheduler_options as described below. 984 | request_scheduler: org.apache.cassandra.scheduler.NoScheduler 985 | 986 | # Scheduler Options vary based on the type of scheduler 987 | # 988 | # NoScheduler 989 | # Has no options 990 | # 991 | # RoundRobin 992 | # throttle_limit 993 | # The throttle_limit is the number of in-flight 994 | # requests per client. Requests beyond 995 | # that limit are queued up until 996 | # running requests can complete. 997 | # The value of 80 here is twice the number of 998 | # concurrent_reads + concurrent_writes. 999 | # default_weight 1000 | # default_weight is optional and allows for 1001 | # overriding the default which is 1. 1002 | # weights 1003 | # Weights are optional and will default to 1 or the 1004 | # overridden default_weight. The weight translates into how 1005 | # many requests are handled during each turn of the 1006 | # RoundRobin, based on the scheduler id. 1007 | # 1008 | # request_scheduler_options: 1009 | # throttle_limit: 80 1010 | # default_weight: 5 1011 | # weights: 1012 | # Keyspace1: 1 1013 | # Keyspace2: 5 1014 | 1015 | # request_scheduler_id -- An identifier based on which to perform 1016 | # the request scheduling. Currently the only valid option is keyspace. 1017 | # request_scheduler_id: keyspace 1018 | 1019 | # Enable or disable inter-node encryption 1020 | # JVM defaults for supported SSL socket protocols and cipher suites can 1021 | # be replaced using custom encryption options. This is not recommended 1022 | # unless you have policies in place that dictate certain settings, or 1023 | # need to disable vulnerable ciphers or protocols in case the JVM cannot 1024 | # be updated. 1025 | # FIPS compliant settings can be configured at JVM level and should not 1026 | # involve changing encryption settings here: 1027 | # https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/FIPS.html 1028 | # *NOTE* No custom encryption options are enabled at the moment 1029 | # The available internode options are : all, none, dc, rack 1030 | # 1031 | # If set to dc cassandra will encrypt the traffic between the DCs 1032 | # If set to rack cassandra will encrypt the traffic between the racks 1033 | # 1034 | # The passwords used in these options must match the passwords used when generating 1035 | # the keystore and truststore. For instructions on generating these files, see: 1036 | # http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore 1037 | # 1038 | server_encryption_options: 1039 | internode_encryption: none 1040 | keystore: conf/.keystore 1041 | keystore_password: cassandra 1042 | truststore: conf/.truststore 1043 | truststore_password: cassandra 1044 | # More advanced defaults below: 1045 | # protocol: TLS 1046 | # algorithm: SunX509 1047 | # store_type: JKS 1048 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1049 | # require_client_auth: false 1050 | # require_endpoint_verification: false 1051 | 1052 | # enable or disable client/server encryption. 1053 | client_encryption_options: 1054 | enabled: false 1055 | # If enabled and optional is set to true encrypted and unencrypted connections are handled. 1056 | optional: false 1057 | keystore: conf/.keystore 1058 | keystore_password: cassandra 1059 | # require_client_auth: false 1060 | # Set trustore and truststore_password if require_client_auth is true 1061 | # truststore: conf/.truststore 1062 | # truststore_password: cassandra 1063 | # More advanced defaults below: 1064 | # protocol: TLS 1065 | # algorithm: SunX509 1066 | # store_type: JKS 1067 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1068 | 1069 | # internode_compression controls whether traffic between nodes is 1070 | # compressed. 1071 | # Can be: 1072 | # 1073 | # all 1074 | # all traffic is compressed 1075 | # 1076 | # dc 1077 | # traffic between different datacenters is compressed 1078 | # 1079 | # none 1080 | # nothing is compressed. 1081 | internode_compression: dc 1082 | 1083 | # Enable or disable tcp_nodelay for inter-dc communication. 1084 | # Disabling it will result in larger (but fewer) network packets being sent, 1085 | # reducing overhead from the TCP protocol itself, at the cost of increasing 1086 | # latency if you block for cross-datacenter responses. 1087 | inter_dc_tcp_nodelay: false 1088 | 1089 | # TTL for different trace types used during logging of the repair process. 1090 | tracetype_query_ttl: 86400 1091 | tracetype_repair_ttl: 604800 1092 | 1093 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1094 | # This threshold can be adjusted to minimize logging if necessary 1095 | # gc_log_threshold_in_ms: 200 1096 | 1097 | # If unset, all GC Pauses greater than gc_log_threshold_in_ms will log at 1098 | # INFO level 1099 | # UDFs (user defined functions) are disabled by default. 1100 | # As of Cassandra 3.0 there is a sandbox in place that should prevent execution of evil code. 1101 | enable_user_defined_functions: false 1102 | 1103 | # Enables scripted UDFs (JavaScript UDFs). 1104 | # Java UDFs are always enabled, if enable_user_defined_functions is true. 1105 | # Enable this option to be able to use UDFs with "language javascript" or any custom JSR-223 provider. 1106 | # This option has no effect, if enable_user_defined_functions is false. 1107 | enable_scripted_user_defined_functions: false 1108 | 1109 | # The default Windows kernel timer and scheduling resolution is 15.6ms for power conservation. 1110 | # Lowering this value on Windows can provide much tighter latency and better throughput, however 1111 | # some virtualized environments may see a negative performance impact from changing this setting 1112 | # below their system default. The sysinternals 'clockres' tool can confirm your system's default 1113 | # setting. 1114 | windows_timer_interval: 1 1115 | 1116 | 1117 | # Enables encrypting data at-rest (on disk). Different key providers can be plugged in, but the default reads from 1118 | # a JCE-style keystore. A single keystore can hold multiple keys, but the one referenced by 1119 | # the "key_alias" is the only key that will be used for encrypt opertaions; previously used keys 1120 | # can still (and should!) be in the keystore and will be used on decrypt operations 1121 | # (to handle the case of key rotation). 1122 | # 1123 | # It is strongly recommended to download and install Java Cryptography Extension (JCE) 1124 | # Unlimited Strength Jurisdiction Policy Files for your version of the JDK. 1125 | # (current link: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html) 1126 | # 1127 | # Currently, only the following file types are supported for transparent data encryption, although 1128 | # more are coming in future cassandra releases: commitlog, hints 1129 | transparent_data_encryption_options: 1130 | enabled: false 1131 | chunk_length_kb: 64 1132 | cipher: AES/CBC/PKCS5Padding 1133 | key_alias: testing:1 1134 | # CBC IV length for AES needs to be 16 bytes (which is also the default size) 1135 | # iv_length: 16 1136 | key_provider: 1137 | - class_name: org.apache.cassandra.security.JKSKeyProvider 1138 | parameters: 1139 | - keystore: conf/.keystore 1140 | keystore_password: cassandra 1141 | store_type: JCEKS 1142 | key_password: cassandra 1143 | 1144 | 1145 | ##################### 1146 | # SAFETY THRESHOLDS # 1147 | ##################### 1148 | 1149 | # When executing a scan, within or across a partition, we need to keep the 1150 | # tombstones seen in memory so we can return them to the coordinator, which 1151 | # will use them to make sure other replicas also know about the deleted rows. 1152 | # With workloads that generate a lot of tombstones, this can cause performance 1153 | # problems and even exaust the server heap. 1154 | # (http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets) 1155 | # Adjust the thresholds here if you understand the dangers and want to 1156 | # scan more tombstones anyway. These thresholds may also be adjusted at runtime 1157 | # using the StorageService mbean. 1158 | tombstone_warn_threshold: 1000 1159 | tombstone_failure_threshold: 100000 1160 | 1161 | # Log WARN on any multiple-partition batch size exceeding this value. 5kb per batch by default. 1162 | # Caution should be taken on increasing the size of this threshold as it can lead to node instability. 1163 | batch_size_warn_threshold_in_kb: 5 1164 | 1165 | # Fail any multiple-partition batch exceeding this value. 50kb (10x warn threshold) by default. 1166 | batch_size_fail_threshold_in_kb: 50 1167 | 1168 | # Log WARN on any batches not of type LOGGED than span across more partitions than this limit 1169 | unlogged_batch_across_partitions_warn_threshold: 10 1170 | 1171 | # Log a warning when compacting partitions larger than this value 1172 | compaction_large_partition_warning_threshold_mb: 100 1173 | 1174 | # GC Pauses greater than gc_warn_threshold_in_ms will be logged at WARN level 1175 | # Adjust the threshold based on your application throughput requirement 1176 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1177 | gc_warn_threshold_in_ms: 1000 1178 | 1179 | # Maximum size of any value in SSTables. Safety measure to detect SSTable corruption 1180 | # early. Any value size larger than this threshold will result into marking an SSTable 1181 | # as corrupted. 1182 | # max_value_size_in_mb: 256 1183 | 1184 | # Back-pressure settings # 1185 | # If enabled, the coordinator will apply the back-pressure strategy specified below to each mutation 1186 | # sent to replicas, with the aim of reducing pressure on overloaded replicas. 1187 | back_pressure_enabled: false 1188 | # The back-pressure strategy applied. 1189 | # The default implementation, RateBasedBackPressure, takes three arguments: 1190 | # high ratio, factor, and flow type, and uses the ratio between incoming mutation responses and outgoing mutation requests. 1191 | # If below high ratio, outgoing mutations are rate limited according to the incoming rate decreased by the given factor; 1192 | # if above high ratio, the rate limiting is increased by the given factor; 1193 | # such factor is usually best configured between 1 and 10, use larger values for a faster recovery 1194 | # at the expense of potentially more dropped mutations; 1195 | # the rate limiting is applied according to the flow type: if FAST, it's rate limited at the speed of the fastest replica, 1196 | # if SLOW at the speed of the slowest one. 1197 | # New strategies can be added. Implementors need to implement org.apache.cassandra.net.BackpressureStrategy and 1198 | # provide a public constructor accepting a Map. 1199 | back_pressure_strategy: 1200 | - class_name: org.apache.cassandra.net.RateBasedBackPressure 1201 | parameters: 1202 | - high_ratio: 0.90 1203 | factor: 5 1204 | flow: FAST 1205 | 1206 | # Coalescing Strategies # 1207 | # Coalescing multiples messages turns out to significantly boost message processing throughput (think doubling or more). 1208 | # On bare metal, the floor for packet processing throughput is high enough that many applications won't notice, but in 1209 | # virtualized environments, the point at which an application can be bound by network packet processing can be 1210 | # surprisingly low compared to the throughput of task processing that is possible inside a VM. It's not that bare metal 1211 | # doesn't benefit from coalescing messages, it's that the number of packets a bare metal network interface can process 1212 | # is sufficient for many applications such that no load starvation is experienced even without coalescing. 1213 | # There are other benefits to coalescing network messages that are harder to isolate with a simple metric like messages 1214 | # per second. By coalescing multiple tasks together, a network thread can process multiple messages for the cost of one 1215 | # trip to read from a socket, and all the task submission work can be done at the same time reducing context switching 1216 | # and increasing cache friendliness of network message processing. 1217 | # See CASSANDRA-8692 for details. 1218 | 1219 | # Strategy to use for coalescing messages in OutboundTcpConnection. 1220 | # Can be fixed, movingaverage, timehorizon, disabled (default). 1221 | # You can also specify a subclass of CoalescingStrategies.CoalescingStrategy by name. 1222 | # otc_coalescing_strategy: DISABLED 1223 | 1224 | # How many microseconds to wait for coalescing. For fixed strategy this is the amount of time after the first 1225 | # message is received before it will be sent with any accompanying messages. For moving average this is the 1226 | # maximum amount of time that will be waited as well as the interval at which messages must arrive on average 1227 | # for coalescing to be enabled. 1228 | # otc_coalescing_window_us: 200 1229 | 1230 | # Do not try to coalesce messages if we already got that many messages. This should be more than 2 and less than 128. 1231 | # otc_coalescing_enough_coalesced_messages: 8 1232 | 1233 | # How many milliseconds to wait between two expiration runs on the backlog (queue) of the OutboundTcpConnection. 1234 | # Expiration is done if messages are piling up in the backlog. Droppable messages are expired to free the memory 1235 | # taken by expired messages. The interval should be between 0 and 1000, and in most installations the default value 1236 | # will be appropriate. A smaller value could potentially expire messages slightly sooner at the expense of more CPU 1237 | # time and queue contention while iterating the backlog of messages. 1238 | # An interval of 0 disables any wait time, which is the behavior of former Cassandra versions. 1239 | # 1240 | # otc_backlog_expiration_interval_ms: 200 1241 | -------------------------------------------------------------------------------- /cassandra-cdc/config/cassandra-2-cdc-tmp.yaml: -------------------------------------------------------------------------------- 1 | # Cassandra storage config YAML 2 | 3 | # NOTE: 4 | # See http://wiki.apache.org/cassandra/StorageConfiguration for 5 | # full explanations of configuration directives 6 | # /NOTE 7 | 8 | # The name of the cluster. This is mainly used to prevent machines in 9 | # one logical cluster from joining another. 10 | cluster_name: 'Test Cluster' 11 | 12 | # This defines the number of tokens randomly assigned to this node on the ring 13 | # The more tokens, relative to other nodes, the larger the proportion of data 14 | # that this node will store. You probably want all nodes to have the same number 15 | # of tokens assuming they have equal hardware capability. 16 | # 17 | # If you leave this unspecified, Cassandra will use the default of 1 token for legacy compatibility, 18 | # and will use the initial_token as described below. 19 | # 20 | # Specifying initial_token will override this setting on the node's initial start, 21 | # on subsequent starts, this setting will apply even if initial token is set. 22 | # 23 | # If you already have a cluster with 1 token per node, and wish to migrate to 24 | # multiple tokens per node, see http://wiki.apache.org/cassandra/Operations 25 | num_tokens: 256 26 | 27 | # Triggers automatic allocation of num_tokens tokens for this node. The allocation 28 | # algorithm attempts to choose tokens in a way that optimizes replicated load over 29 | # the nodes in the datacenter for the replication strategy used by the specified 30 | # keyspace. 31 | # 32 | # The load assigned to each node will be close to proportional to its number of 33 | # vnodes. 34 | # 35 | # Only supported with the Murmur3Partitioner. 36 | # allocate_tokens_for_keyspace: KEYSPACE 37 | 38 | # initial_token allows you to specify tokens manually. While you can use it with 39 | # vnodes (num_tokens > 1, above) -- in which case you should provide a 40 | # comma-separated list -- it's primarily used when adding nodes to legacy clusters 41 | # that do not have vnodes enabled. 42 | # initial_token: 43 | 44 | # See http://wiki.apache.org/cassandra/HintedHandoff 45 | # May either be "true" or "false" to enable globally 46 | hinted_handoff_enabled: true 47 | 48 | # When hinted_handoff_enabled is true, a black list of data centers that will not 49 | # perform hinted handoff 50 | # hinted_handoff_disabled_datacenters: 51 | # - DC1 52 | # - DC2 53 | 54 | # this defines the maximum amount of time a dead host will have hints 55 | # generated. After it has been dead this long, new hints for it will not be 56 | # created until it has been seen alive and gone down again. 57 | max_hint_window_in_ms: 10800000 # 3 hours 58 | 59 | # Maximum throttle in KBs per second, per delivery thread. This will be 60 | # reduced proportionally to the number of nodes in the cluster. (If there 61 | # are two nodes in the cluster, each delivery thread will use the maximum 62 | # rate; if there are three, each will throttle to half of the maximum, 63 | # since we expect two nodes to be delivering hints simultaneously.) 64 | hinted_handoff_throttle_in_kb: 1024 65 | 66 | # Number of threads with which to deliver hints; 67 | # Consider increasing this number when you have multi-dc deployments, since 68 | # cross-dc handoff tends to be slower 69 | max_hints_delivery_threads: 2 70 | 71 | # Directory where Cassandra should store hints. 72 | # If not set, the default directory is $CASSANDRA_HOME/data/hints. 73 | # hints_directory: /var/lib/cassandra/hints 74 | hints_directory: /tmp/cdc/cassandra-2/hints 75 | 76 | # How often hints should be flushed from the internal buffers to disk. 77 | # Will *not* trigger fsync. 78 | hints_flush_period_in_ms: 10000 79 | 80 | # Maximum size for a single hints file, in megabytes. 81 | max_hints_file_size_in_mb: 128 82 | 83 | # Compression to apply to the hint files. If omitted, hints files 84 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 85 | # are supported. 86 | #hints_compression: 87 | # - class_name: LZ4Compressor 88 | # parameters: 89 | # - 90 | 91 | # Maximum throttle in KBs per second, total. This will be 92 | # reduced proportionally to the number of nodes in the cluster. 93 | batchlog_replay_throttle_in_kb: 1024 94 | 95 | # Authentication backend, implementing IAuthenticator; used to identify users 96 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator, 97 | # PasswordAuthenticator}. 98 | # 99 | # - AllowAllAuthenticator performs no checks - set it to disable authentication. 100 | # - PasswordAuthenticator relies on username/password pairs to authenticate 101 | # users. It keeps usernames and hashed passwords in system_auth.roles table. 102 | # Please increase system_auth keyspace replication factor if you use this authenticator. 103 | # If using PasswordAuthenticator, CassandraRoleManager must also be used (see below) 104 | authenticator: AllowAllAuthenticator 105 | 106 | # Authorization backend, implementing IAuthorizer; used to limit access/provide permissions 107 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer, 108 | # CassandraAuthorizer}. 109 | # 110 | # - AllowAllAuthorizer allows any action to any user - set it to disable authorization. 111 | # - CassandraAuthorizer stores permissions in system_auth.role_permissions table. Please 112 | # increase system_auth keyspace replication factor if you use this authorizer. 113 | authorizer: AllowAllAuthorizer 114 | 115 | # Part of the Authentication & Authorization backend, implementing IRoleManager; used 116 | # to maintain grants and memberships between roles. 117 | # Out of the box, Cassandra provides org.apache.cassandra.auth.CassandraRoleManager, 118 | # which stores role information in the system_auth keyspace. Most functions of the 119 | # IRoleManager require an authenticated login, so unless the configured IAuthenticator 120 | # actually implements authentication, most of this functionality will be unavailable. 121 | # 122 | # - CassandraRoleManager stores role data in the system_auth keyspace. Please 123 | # increase system_auth keyspace replication factor if you use this role manager. 124 | role_manager: CassandraRoleManager 125 | 126 | # Validity period for roles cache (fetching granted roles can be an expensive 127 | # operation depending on the role manager, CassandraRoleManager is one example) 128 | # Granted roles are cached for authenticated sessions in AuthenticatedUser and 129 | # after the period specified here, become eligible for (async) reload. 130 | # Defaults to 2000, set to 0 to disable caching entirely. 131 | # Will be disabled automatically for AllowAllAuthenticator. 132 | roles_validity_in_ms: 2000 133 | 134 | # Refresh interval for roles cache (if enabled). 135 | # After this interval, cache entries become eligible for refresh. Upon next 136 | # access, an async reload is scheduled and the old value returned until it 137 | # completes. If roles_validity_in_ms is non-zero, then this must be 138 | # also. 139 | # Defaults to the same value as roles_validity_in_ms. 140 | # roles_update_interval_in_ms: 2000 141 | 142 | # Validity period for permissions cache (fetching permissions can be an 143 | # expensive operation depending on the authorizer, CassandraAuthorizer is 144 | # one example). Defaults to 2000, set to 0 to disable. 145 | # Will be disabled automatically for AllowAllAuthorizer. 146 | permissions_validity_in_ms: 2000 147 | 148 | # Refresh interval for permissions cache (if enabled). 149 | # After this interval, cache entries become eligible for refresh. Upon next 150 | # access, an async reload is scheduled and the old value returned until it 151 | # completes. If permissions_validity_in_ms is non-zero, then this must be 152 | # also. 153 | # Defaults to the same value as permissions_validity_in_ms. 154 | # permissions_update_interval_in_ms: 2000 155 | 156 | # Validity period for credentials cache. This cache is tightly coupled to 157 | # the provided PasswordAuthenticator implementation of IAuthenticator. If 158 | # another IAuthenticator implementation is configured, this cache will not 159 | # be automatically used and so the following settings will have no effect. 160 | # Please note, credentials are cached in their encrypted form, so while 161 | # activating this cache may reduce the number of queries made to the 162 | # underlying table, it may not bring a significant reduction in the 163 | # latency of individual authentication attempts. 164 | # Defaults to 2000, set to 0 to disable credentials caching. 165 | credentials_validity_in_ms: 2000 166 | 167 | # Refresh interval for credentials cache (if enabled). 168 | # After this interval, cache entries become eligible for refresh. Upon next 169 | # access, an async reload is scheduled and the old value returned until it 170 | # completes. If credentials_validity_in_ms is non-zero, then this must be 171 | # also. 172 | # Defaults to the same value as credentials_validity_in_ms. 173 | # credentials_update_interval_in_ms: 2000 174 | 175 | # The partitioner is responsible for distributing groups of rows (by 176 | # partition key) across nodes in the cluster. You should leave this 177 | # alone for new clusters. The partitioner can NOT be changed without 178 | # reloading all data, so when upgrading you should set this to the 179 | # same partitioner you were already using. 180 | # 181 | # Besides Murmur3Partitioner, partitioners included for backwards 182 | # compatibility include RandomPartitioner, ByteOrderedPartitioner, and 183 | # OrderPreservingPartitioner. 184 | # 185 | partitioner: org.apache.cassandra.dht.Murmur3Partitioner 186 | 187 | # Directories where Cassandra should store data on disk. Cassandra 188 | # will spread data evenly across them, subject to the granularity of 189 | # the configured compaction strategy. 190 | # If not set, the default directory is $CASSANDRA_HOME/data/data. 191 | # data_file_directories: 192 | # - /var/lib/cassandra/data 193 | data_file_directories: 194 | - /tmp/cdc/cassandra-2/data 195 | 196 | # commit log. when running on magnetic HDD, this should be a 197 | # separate spindle than the data directories. 198 | # If not set, the default directory is $CASSANDRA_HOME/data/commitlog. 199 | # commitlog_directory: /var/lib/cassandra/commitlog 200 | commitlog_directory: /tmp/cdc/cassandra-2/commitlog 201 | 202 | # Enable / disable CDC functionality on a per-node basis. This modifies the logic used 203 | # for write path allocation rejection (standard: never reject. cdc: reject Mutation 204 | # containing a CDC-enabled table if at space limit in cdc_raw_directory). 205 | cdc_enabled: true 206 | 207 | # CommitLogSegments are moved to this directory on flush if cdc_enabled: true and the 208 | # segment contains mutations for a CDC-enabled table. This should be placed on a 209 | # separate spindle than the data directories. If not set, the default directory is 210 | # $CASSANDRA_HOME/data/cdc_raw. 211 | # cdc_raw_directory: /var/lib/cassandra/cdc_raw 212 | cdc_raw_directory: /tmp/cdc/cassandra-2/cdc_raw 213 | 214 | # Policy for data disk failures: 215 | # 216 | # die 217 | # shut down gossip and client transports and kill the JVM for any fs errors or 218 | # single-sstable errors, so the node can be replaced. 219 | # 220 | # stop_paranoid 221 | # shut down gossip and client transports even for single-sstable errors, 222 | # kill the JVM for errors during startup. 223 | # 224 | # stop 225 | # shut down gossip and client transports, leaving the node effectively dead, but 226 | # can still be inspected via JMX, kill the JVM for errors during startup. 227 | # 228 | # best_effort 229 | # stop using the failed disk and respond to requests based on 230 | # remaining available sstables. This means you WILL see obsolete 231 | # data at CL.ONE! 232 | # 233 | # ignore 234 | # ignore fatal errors and let requests fail, as in pre-1.2 Cassandra 235 | disk_failure_policy: stop 236 | 237 | # Policy for commit disk failures: 238 | # 239 | # die 240 | # shut down gossip and Thrift and kill the JVM, so the node can be replaced. 241 | # 242 | # stop 243 | # shut down gossip and Thrift, leaving the node effectively dead, but 244 | # can still be inspected via JMX. 245 | # 246 | # stop_commit 247 | # shutdown the commit log, letting writes collect but 248 | # continuing to service reads, as in pre-2.0.5 Cassandra 249 | # 250 | # ignore 251 | # ignore fatal errors and let the batches fail 252 | commit_failure_policy: stop 253 | 254 | # Maximum size of the native protocol prepared statement cache 255 | # 256 | # Valid values are either "auto" (omitting the value) or a value greater 0. 257 | # 258 | # Note that specifying a too large value will result in long running GCs and possbily 259 | # out-of-memory errors. Keep the value at a small fraction of the heap. 260 | # 261 | # If you constantly see "prepared statements discarded in the last minute because 262 | # cache limit reached" messages, the first step is to investigate the root cause 263 | # of these messages and check whether prepared statements are used correctly - 264 | # i.e. use bind markers for variable parts. 265 | # 266 | # Do only change the default value, if you really have more prepared statements than 267 | # fit in the cache. In most cases it is not neccessary to change this value. 268 | # Constantly re-preparing statements is a performance penalty. 269 | # 270 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 271 | prepared_statements_cache_size_mb: 272 | 273 | # Maximum size of the Thrift prepared statement cache 274 | # 275 | # If you do not use Thrift at all, it is safe to leave this value at "auto". 276 | # 277 | # See description of 'prepared_statements_cache_size_mb' above for more information. 278 | # 279 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 280 | thrift_prepared_statements_cache_size_mb: 281 | 282 | # Maximum size of the key cache in memory. 283 | # 284 | # Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the 285 | # minimum, sometimes more. The key cache is fairly tiny for the amount of 286 | # time it saves, so it's worthwhile to use it at large numbers. 287 | # The row cache saves even more time, but must contain the entire row, 288 | # so it is extremely space-intensive. It's best to only use the 289 | # row cache if you have hot rows or static rows. 290 | # 291 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 292 | # 293 | # Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache. 294 | key_cache_size_in_mb: 295 | 296 | # Duration in seconds after which Cassandra should 297 | # save the key cache. Caches are saved to saved_caches_directory as 298 | # specified in this configuration file. 299 | # 300 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 301 | # terms of I/O for the key cache. Row cache saving is much more expensive and 302 | # has limited use. 303 | # 304 | # Default is 14400 or 4 hours. 305 | key_cache_save_period: 14400 306 | 307 | # Number of keys from the key cache to save 308 | # Disabled by default, meaning all keys are going to be saved 309 | # key_cache_keys_to_save: 100 310 | 311 | # Row cache implementation class name. Available implementations: 312 | # 313 | # org.apache.cassandra.cache.OHCProvider 314 | # Fully off-heap row cache implementation (default). 315 | # 316 | # org.apache.cassandra.cache.SerializingCacheProvider 317 | # This is the row cache implementation availabile 318 | # in previous releases of Cassandra. 319 | # row_cache_class_name: org.apache.cassandra.cache.OHCProvider 320 | 321 | # Maximum size of the row cache in memory. 322 | # Please note that OHC cache implementation requires some additional off-heap memory to manage 323 | # the map structures and some in-flight memory during operations before/after cache entries can be 324 | # accounted against the cache capacity. This overhead is usually small compared to the whole capacity. 325 | # Do not specify more memory that the system can afford in the worst usual situation and leave some 326 | # headroom for OS block level cache. Do never allow your system to swap. 327 | # 328 | # Default value is 0, to disable row caching. 329 | row_cache_size_in_mb: 0 330 | 331 | # Duration in seconds after which Cassandra should save the row cache. 332 | # Caches are saved to saved_caches_directory as specified in this configuration file. 333 | # 334 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 335 | # terms of I/O for the key cache. Row cache saving is much more expensive and 336 | # has limited use. 337 | # 338 | # Default is 0 to disable saving the row cache. 339 | row_cache_save_period: 0 340 | 341 | # Number of keys from the row cache to save. 342 | # Specify 0 (which is the default), meaning all keys are going to be saved 343 | # row_cache_keys_to_save: 100 344 | 345 | # Maximum size of the counter cache in memory. 346 | # 347 | # Counter cache helps to reduce counter locks' contention for hot counter cells. 348 | # In case of RF = 1 a counter cache hit will cause Cassandra to skip the read before 349 | # write entirely. With RF > 1 a counter cache hit will still help to reduce the duration 350 | # of the lock hold, helping with hot counter cell updates, but will not allow skipping 351 | # the read entirely. Only the local (clock, count) tuple of a counter cell is kept 352 | # in memory, not the whole counter, so it's relatively cheap. 353 | # 354 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 355 | # 356 | # Default value is empty to make it "auto" (min(2.5% of Heap (in MB), 50MB)). Set to 0 to disable counter cache. 357 | # NOTE: if you perform counter deletes and rely on low gcgs, you should disable the counter cache. 358 | counter_cache_size_in_mb: 359 | 360 | # Duration in seconds after which Cassandra should 361 | # save the counter cache (keys only). Caches are saved to saved_caches_directory as 362 | # specified in this configuration file. 363 | # 364 | # Default is 7200 or 2 hours. 365 | counter_cache_save_period: 7200 366 | 367 | # Number of keys from the counter cache to save 368 | # Disabled by default, meaning all keys are going to be saved 369 | # counter_cache_keys_to_save: 100 370 | 371 | # saved caches 372 | # If not set, the default directory is $CASSANDRA_HOME/data/saved_caches. 373 | # saved_caches_directory: /var/lib/cassandra/saved_caches 374 | 375 | # commitlog_sync may be either "periodic" or "batch." 376 | # 377 | # When in batch mode, Cassandra won't ack writes until the commit log 378 | # has been fsynced to disk. It will wait 379 | # commitlog_sync_batch_window_in_ms milliseconds between fsyncs. 380 | # This window should be kept short because the writer threads will 381 | # be unable to do extra work while waiting. (You may need to increase 382 | # concurrent_writes for the same reason.) 383 | # 384 | # commitlog_sync: batch 385 | # commitlog_sync_batch_window_in_ms: 2 386 | # 387 | # the other option is "periodic" where writes may be acked immediately 388 | # and the CommitLog is simply synced every commitlog_sync_period_in_ms 389 | # milliseconds. 390 | commitlog_sync: periodic 391 | commitlog_sync_period_in_ms: 10000 392 | 393 | # The size of the individual commitlog file segments. A commitlog 394 | # segment may be archived, deleted, or recycled once all the data 395 | # in it (potentially from each columnfamily in the system) has been 396 | # flushed to sstables. 397 | # 398 | # The default size is 32, which is almost always fine, but if you are 399 | # archiving commitlog segments (see commitlog_archiving.properties), 400 | # then you probably want a finer granularity of archiving; 8 or 16 MB 401 | # is reasonable. 402 | # Max mutation size is also configurable via max_mutation_size_in_kb setting in 403 | # cassandra.yaml. The default is half the size commitlog_segment_size_in_mb * 1024. 404 | # 405 | # NOTE: If max_mutation_size_in_kb is set explicitly then commitlog_segment_size_in_mb must 406 | # be set to at least twice the size of max_mutation_size_in_kb / 1024 407 | # 408 | commitlog_segment_size_in_mb: 1 409 | 410 | # Compression to apply to the commit log. If omitted, the commit log 411 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 412 | # are supported. 413 | # commitlog_compression: 414 | # - class_name: LZ4Compressor 415 | # parameters: 416 | # - 417 | 418 | # any class that implements the SeedProvider interface and has a 419 | # constructor that takes a Map of parameters will do. 420 | seed_provider: 421 | # Addresses of hosts that are deemed contact points. 422 | # Cassandra nodes use this list of hosts to find each other and learn 423 | # the topology of the ring. You must change this if you are running 424 | # multiple nodes! 425 | - class_name: org.apache.cassandra.locator.SimpleSeedProvider 426 | parameters: 427 | # seeds is actually a comma-delimited list of addresses. 428 | # Ex: ",," 429 | - seeds: "127.0.0.1" 430 | 431 | # For workloads with more data than can fit in memory, Cassandra's 432 | # bottleneck will be reads that need to fetch data from 433 | # disk. "concurrent_reads" should be set to (16 * number_of_drives) in 434 | # order to allow the operations to enqueue low enough in the stack 435 | # that the OS and drives can reorder them. Same applies to 436 | # "concurrent_counter_writes", since counter writes read the current 437 | # values before incrementing and writing them back. 438 | # 439 | # On the other hand, since writes are almost never IO bound, the ideal 440 | # number of "concurrent_writes" is dependent on the number of cores in 441 | # your system; (8 * number_of_cores) is a good rule of thumb. 442 | concurrent_reads: 32 443 | concurrent_writes: 32 444 | concurrent_counter_writes: 32 445 | 446 | # For materialized view writes, as there is a read involved, so this should 447 | # be limited by the less of concurrent reads or concurrent writes. 448 | concurrent_materialized_view_writes: 32 449 | 450 | # Maximum memory to use for sstable chunk cache and buffer pooling. 451 | # 32MB of this are reserved for pooling buffers, the rest is used as an 452 | # cache that holds uncompressed sstable chunks. 453 | # Defaults to the smaller of 1/4 of heap or 512MB. This pool is allocated off-heap, 454 | # so is in addition to the memory allocated for heap. The cache also has on-heap 455 | # overhead which is roughly 128 bytes per chunk (i.e. 0.2% of the reserved size 456 | # if the default 64k chunk size is used). 457 | # Memory is only allocated when needed. 458 | # file_cache_size_in_mb: 512 459 | 460 | # Flag indicating whether to allocate on or off heap when the sstable buffer 461 | # pool is exhausted, that is when it has exceeded the maximum memory 462 | # file_cache_size_in_mb, beyond which it will not cache buffers but allocate on request. 463 | 464 | # buffer_pool_use_heap_if_exhausted: true 465 | 466 | # The strategy for optimizing disk read 467 | # Possible values are: 468 | # ssd (for solid state disks, the default) 469 | # spinning (for spinning disks) 470 | # disk_optimization_strategy: ssd 471 | 472 | # Total permitted memory to use for memtables. Cassandra will stop 473 | # accepting writes when the limit is exceeded until a flush completes, 474 | # and will trigger a flush based on memtable_cleanup_threshold 475 | # If omitted, Cassandra will set both to 1/4 the size of the heap. 476 | # memtable_heap_space_in_mb: 2048 477 | # memtable_offheap_space_in_mb: 2048 478 | 479 | # memtable_cleanup_threshold is deprecated. The default calculation 480 | # is the only reasonable choice. See the comments on memtable_flush_writers 481 | # for more information. 482 | # 483 | # Ratio of occupied non-flushing memtable size to total permitted size 484 | # that will trigger a flush of the largest memtable. Larger mct will 485 | # mean larger flushes and hence less compaction, but also less concurrent 486 | # flush activity which can make it difficult to keep your disks fed 487 | # under heavy write load. 488 | # 489 | # memtable_cleanup_threshold defaults to 1 / (memtable_flush_writers + 1) 490 | # memtable_cleanup_threshold: 0.11 491 | 492 | # Specify the way Cassandra allocates and manages memtable memory. 493 | # Options are: 494 | # 495 | # heap_buffers 496 | # on heap nio buffers 497 | # 498 | # offheap_buffers 499 | # off heap (direct) nio buffers 500 | # 501 | # offheap_objects 502 | # off heap objects 503 | memtable_allocation_type: heap_buffers 504 | 505 | # Total space to use for commit logs on disk. 506 | # 507 | # If space gets above this value, Cassandra will flush every dirty CF 508 | # in the oldest segment and remove it. So a small total commitlog space 509 | # will tend to cause more flush activity on less-active columnfamilies. 510 | # 511 | # The default value is the smaller of 8192, and 1/4 of the total space 512 | # of the commitlog volume. 513 | # 514 | # commitlog_total_space_in_mb: 8192 515 | commitlog_total_space_in_mb: 16 516 | 517 | # This sets the number of memtable flush writer threads per disk 518 | # as well as the total number of memtables that can be flushed concurrently. 519 | # These are generally a combination of compute and IO bound. 520 | # 521 | # Memtable flushing is more CPU efficient than memtable ingest and a single thread 522 | # can keep up with the ingest rate of a whole server on a single fast disk 523 | # until it temporarily becomes IO bound under contention typically with compaction. 524 | # At that point you need multiple flush threads. At some point in the future 525 | # it may become CPU bound all the time. 526 | # 527 | # You can tell if flushing is falling behind using the MemtablePool.BlockedOnAllocation 528 | # metric which should be 0, but will be non-zero if threads are blocked waiting on flushing 529 | # to free memory. 530 | # 531 | # memtable_flush_writers defaults to two for a single data directory. 532 | # This means that two memtables can be flushed concurrently to the single data directory. 533 | # If you have multiple data directories the default is one memtable flushing at a time 534 | # but the flush will use a thread per data directory so you will get two or more writers. 535 | # 536 | # Two is generally enough to flush on a fast disk [array] mounted as a single data directory. 537 | # Adding more flush writers will result in smaller more frequent flushes that introduce more 538 | # compaction overhead. 539 | # 540 | # There is a direct tradeoff between number of memtables that can be flushed concurrently 541 | # and flush size and frequency. More is not better you just need enough flush writers 542 | # to never stall waiting for flushing to free memory. 543 | # 544 | #memtable_flush_writers: 2 545 | 546 | # Total space to use for change-data-capture logs on disk. 547 | # 548 | # If space gets above this value, Cassandra will throw WriteTimeoutException 549 | # on Mutations including tables with CDC enabled. A CDCCompactor is responsible 550 | # for parsing the raw CDC logs and deleting them when parsing is completed. 551 | # 552 | # The default value is the min of 4096 mb and 1/8th of the total space 553 | # of the drive where cdc_raw_directory resides. 554 | # cdc_total_space_in_mb: 4096 555 | cdc_total_space_in_mb: 4096 556 | 557 | # When we hit our cdc_raw limit and the CDCCompactor is either running behind 558 | # or experiencing backpressure, we check at the following interval to see if any 559 | # new space for cdc-tracked tables has been made available. Default to 250ms 560 | # cdc_free_space_check_interval_ms: 250 561 | cdc_free_space_check_interval_ms: 250 562 | 563 | # A fixed memory pool size in MB for for SSTable index summaries. If left 564 | # empty, this will default to 5% of the heap size. If the memory usage of 565 | # all index summaries exceeds this limit, SSTables with low read rates will 566 | # shrink their index summaries in order to meet this limit. However, this 567 | # is a best-effort process. In extreme conditions Cassandra may need to use 568 | # more than this amount of memory. 569 | index_summary_capacity_in_mb: 570 | 571 | # How frequently index summaries should be resampled. This is done 572 | # periodically to redistribute memory from the fixed-size pool to sstables 573 | # proportional their recent read rates. Setting to -1 will disable this 574 | # process, leaving existing index summaries at their current sampling level. 575 | index_summary_resize_interval_in_minutes: 60 576 | 577 | # Whether to, when doing sequential writing, fsync() at intervals in 578 | # order to force the operating system to flush the dirty 579 | # buffers. Enable this to avoid sudden dirty buffer flushing from 580 | # impacting read latencies. Almost always a good idea on SSDs; not 581 | # necessarily on platters. 582 | trickle_fsync: false 583 | trickle_fsync_interval_in_kb: 10240 584 | 585 | # TCP port, for commands and data 586 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 587 | storage_port: 7000 588 | 589 | # SSL port, for encrypted communication. Unused unless enabled in 590 | # encryption_options 591 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 592 | ssl_storage_port: 7001 593 | 594 | # Address or interface to bind to and tell other Cassandra nodes to connect to. 595 | # You _must_ change this if you want multiple nodes to be able to communicate! 596 | # 597 | # Set listen_address OR listen_interface, not both. 598 | # 599 | # Leaving it blank leaves it up to InetAddress.getLocalHost(). This 600 | # will always do the Right Thing _if_ the node is properly configured 601 | # (hostname, name resolution, etc), and the Right Thing is to use the 602 | # address associated with the hostname (it might not be). 603 | # 604 | # Setting listen_address to 0.0.0.0 is always wrong. 605 | # 606 | listen_address: localhost 607 | 608 | # Set listen_address OR listen_interface, not both. Interfaces must correspond 609 | # to a single address, IP aliasing is not supported. 610 | # listen_interface: eth0 611 | 612 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 613 | # you can specify which should be chosen using listen_interface_prefer_ipv6. If false the first ipv4 614 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 615 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 616 | # listen_interface_prefer_ipv6: false 617 | 618 | # Address to broadcast to other Cassandra nodes 619 | # Leaving this blank will set it to the same value as listen_address 620 | # broadcast_address: 1.2.3.4 621 | 622 | # When using multiple physical network interfaces, set this 623 | # to true to listen on broadcast_address in addition to 624 | # the listen_address, allowing nodes to communicate in both 625 | # interfaces. 626 | # Ignore this property if the network configuration automatically 627 | # routes between the public and private networks such as EC2. 628 | # listen_on_broadcast_address: false 629 | 630 | # Internode authentication backend, implementing IInternodeAuthenticator; 631 | # used to allow/disallow connections from peer nodes. 632 | # internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator 633 | 634 | # Whether to start the native transport server. 635 | # Please note that the address on which the native transport is bound is the 636 | # same as the rpc_address. The port however is different and specified below. 637 | start_native_transport: true 638 | # port for the CQL native transport to listen for clients on 639 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 640 | native_transport_port: 9042 641 | # Enabling native transport encryption in client_encryption_options allows you to either use 642 | # encryption for the standard port or to use a dedicated, additional port along with the unencrypted 643 | # standard native_transport_port. 644 | # Enabling client encryption and keeping native_transport_port_ssl disabled will use encryption 645 | # for native_transport_port. Setting native_transport_port_ssl to a different value 646 | # from native_transport_port will use encryption for native_transport_port_ssl while 647 | # keeping native_transport_port unencrypted. 648 | # native_transport_port_ssl: 9142 649 | # The maximum threads for handling requests when the native transport is used. 650 | # This is similar to rpc_max_threads though the default differs slightly (and 651 | # there is no native_transport_min_threads, idle threads will always be stopped 652 | # after 30 seconds). 653 | # native_transport_max_threads: 128 654 | # 655 | # The maximum size of allowed frame. Frame (requests) larger than this will 656 | # be rejected as invalid. The default is 256MB. If you're changing this parameter, 657 | # you may want to adjust max_value_size_in_mb accordingly. 658 | # native_transport_max_frame_size_in_mb: 256 659 | 660 | # The maximum number of concurrent client connections. 661 | # The default is -1, which means unlimited. 662 | # native_transport_max_concurrent_connections: -1 663 | 664 | # The maximum number of concurrent client connections per source ip. 665 | # The default is -1, which means unlimited. 666 | # native_transport_max_concurrent_connections_per_ip: -1 667 | 668 | # Whether to start the thrift rpc server. 669 | start_rpc: false 670 | 671 | # The address or interface to bind the Thrift RPC service and native transport 672 | # server to. 673 | # 674 | # Set rpc_address OR rpc_interface, not both. 675 | # 676 | # Leaving rpc_address blank has the same effect as on listen_address 677 | # (i.e. it will be based on the configured hostname of the node). 678 | # 679 | # Note that unlike listen_address, you can specify 0.0.0.0, but you must also 680 | # set broadcast_rpc_address to a value other than 0.0.0.0. 681 | # 682 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 683 | rpc_address: localhost 684 | 685 | # Set rpc_address OR rpc_interface, not both. Interfaces must correspond 686 | # to a single address, IP aliasing is not supported. 687 | # rpc_interface: eth1 688 | 689 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 690 | # you can specify which should be chosen using rpc_interface_prefer_ipv6. If false the first ipv4 691 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 692 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 693 | # rpc_interface_prefer_ipv6: false 694 | 695 | # port for Thrift to listen for clients on 696 | rpc_port: 9160 697 | 698 | # RPC address to broadcast to drivers and other Cassandra nodes. This cannot 699 | # be set to 0.0.0.0. If left blank, this will be set to the value of 700 | # rpc_address. If rpc_address is set to 0.0.0.0, broadcast_rpc_address must 701 | # be set. 702 | # broadcast_rpc_address: 1.2.3.4 703 | 704 | # enable or disable keepalive on rpc/native connections 705 | rpc_keepalive: true 706 | 707 | # Cassandra provides two out-of-the-box options for the RPC Server: 708 | # 709 | # sync 710 | # One thread per thrift connection. For a very large number of clients, memory 711 | # will be your limiting factor. On a 64 bit JVM, 180KB is the minimum stack size 712 | # per thread, and that will correspond to your use of virtual memory (but physical memory 713 | # may be limited depending on use of stack space). 714 | # 715 | # hsha 716 | # Stands for "half synchronous, half asynchronous." All thrift clients are handled 717 | # asynchronously using a small number of threads that does not vary with the amount 718 | # of thrift clients (and thus scales well to many clients). The rpc requests are still 719 | # synchronous (one thread per active request). If hsha is selected then it is essential 720 | # that rpc_max_threads is changed from the default value of unlimited. 721 | # 722 | # The default is sync because on Windows hsha is about 30% slower. On Linux, 723 | # sync/hsha performance is about the same, with hsha of course using less memory. 724 | # 725 | # Alternatively, can provide your own RPC server by providing the fully-qualified class name 726 | # of an o.a.c.t.TServerFactory that can create an instance of it. 727 | rpc_server_type: sync 728 | 729 | # Uncomment rpc_min|max_thread to set request pool size limits. 730 | # 731 | # Regardless of your choice of RPC server (see above), the number of maximum requests in the 732 | # RPC thread pool dictates how many concurrent requests are possible (but if you are using the sync 733 | # RPC server, it also dictates the number of clients that can be connected at all). 734 | # 735 | # The default is unlimited and thus provides no protection against clients overwhelming the server. You are 736 | # encouraged to set a maximum that makes sense for you in production, but do keep in mind that 737 | # rpc_max_threads represents the maximum number of client requests this server may execute concurrently. 738 | # 739 | # rpc_min_threads: 16 740 | # rpc_max_threads: 2048 741 | 742 | # uncomment to set socket buffer sizes on rpc connections 743 | # rpc_send_buff_size_in_bytes: 744 | # rpc_recv_buff_size_in_bytes: 745 | 746 | # Uncomment to set socket buffer size for internode communication 747 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 748 | # and when not setting it it is defined by net.ipv4.tcp_wmem 749 | # See also: 750 | # /proc/sys/net/core/wmem_max 751 | # /proc/sys/net/core/rmem_max 752 | # /proc/sys/net/ipv4/tcp_wmem 753 | # /proc/sys/net/ipv4/tcp_wmem 754 | # and 'man tcp' 755 | # internode_send_buff_size_in_bytes: 756 | 757 | # Uncomment to set socket buffer size for internode communication 758 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 759 | # and when not setting it it is defined by net.ipv4.tcp_wmem 760 | # internode_recv_buff_size_in_bytes: 761 | 762 | # Frame size for thrift (maximum message length). 763 | thrift_framed_transport_size_in_mb: 15 764 | 765 | # Set to true to have Cassandra create a hard link to each sstable 766 | # flushed or streamed locally in a backups/ subdirectory of the 767 | # keyspace data. Removing these links is the operator's 768 | # responsibility. 769 | incremental_backups: false 770 | 771 | # Whether or not to take a snapshot before each compaction. Be 772 | # careful using this option, since Cassandra won't clean up the 773 | # snapshots for you. Mostly useful if you're paranoid when there 774 | # is a data format change. 775 | snapshot_before_compaction: false 776 | 777 | # Whether or not a snapshot is taken of the data before keyspace truncation 778 | # or dropping of column families. The STRONGLY advised default of true 779 | # should be used to provide data safety. If you set this flag to false, you will 780 | # lose data on truncation or drop. 781 | auto_snapshot: true 782 | 783 | # Granularity of the collation index of rows within a partition. 784 | # Increase if your rows are large, or if you have a very large 785 | # number of rows per partition. The competing goals are these: 786 | # 787 | # - a smaller granularity means more index entries are generated 788 | # and looking up rows withing the partition by collation column 789 | # is faster 790 | # - but, Cassandra will keep the collation index in memory for hot 791 | # rows (as part of the key cache), so a larger granularity means 792 | # you can cache more hot rows 793 | column_index_size_in_kb: 64 794 | 795 | # Per sstable indexed key cache entries (the collation index in memory 796 | # mentioned above) exceeding this size will not be held on heap. 797 | # This means that only partition information is held on heap and the 798 | # index entries are read from disk. 799 | # 800 | # Note that this size refers to the size of the 801 | # serialized index information and not the size of the partition. 802 | column_index_cache_size_in_kb: 2 803 | 804 | # Number of simultaneous compactions to allow, NOT including 805 | # validation "compactions" for anti-entropy repair. Simultaneous 806 | # compactions can help preserve read performance in a mixed read/write 807 | # workload, by mitigating the tendency of small sstables to accumulate 808 | # during a single long running compactions. The default is usually 809 | # fine and if you experience problems with compaction running too 810 | # slowly or too fast, you should look at 811 | # compaction_throughput_mb_per_sec first. 812 | # 813 | # concurrent_compactors defaults to the smaller of (number of disks, 814 | # number of cores), with a minimum of 2 and a maximum of 8. 815 | # 816 | # If your data directories are backed by SSD, you should increase this 817 | # to the number of cores. 818 | #concurrent_compactors: 1 819 | 820 | # Throttles compaction to the given total throughput across the entire 821 | # system. The faster you insert data, the faster you need to compact in 822 | # order to keep the sstable count down, but in general, setting this to 823 | # 16 to 32 times the rate you are inserting data is more than sufficient. 824 | # Setting this to 0 disables throttling. Note that this account for all types 825 | # of compaction, including validation compaction. 826 | compaction_throughput_mb_per_sec: 16 827 | 828 | # When compacting, the replacement sstable(s) can be opened before they 829 | # are completely written, and used in place of the prior sstables for 830 | # any range that has been written. This helps to smoothly transfer reads 831 | # between the sstables, reducing page cache churn and keeping hot rows hot 832 | sstable_preemptive_open_interval_in_mb: 50 833 | 834 | # Throttles all outbound streaming file transfers on this node to the 835 | # given total throughput in Mbps. This is necessary because Cassandra does 836 | # mostly sequential IO when streaming data during bootstrap or repair, which 837 | # can lead to saturating the network connection and degrading rpc performance. 838 | # When unset, the default is 200 Mbps or 25 MB/s. 839 | # stream_throughput_outbound_megabits_per_sec: 200 840 | 841 | # Throttles all streaming file transfer between the datacenters, 842 | # this setting allows users to throttle inter dc stream throughput in addition 843 | # to throttling all network stream traffic as configured with 844 | # stream_throughput_outbound_megabits_per_sec 845 | # When unset, the default is 200 Mbps or 25 MB/s 846 | # inter_dc_stream_throughput_outbound_megabits_per_sec: 200 847 | 848 | # How long the coordinator should wait for read operations to complete 849 | read_request_timeout_in_ms: 5000 850 | # How long the coordinator should wait for seq or index scans to complete 851 | range_request_timeout_in_ms: 10000 852 | # How long the coordinator should wait for writes to complete 853 | write_request_timeout_in_ms: 2000 854 | # How long the coordinator should wait for counter writes to complete 855 | counter_write_request_timeout_in_ms: 5000 856 | # How long a coordinator should continue to retry a CAS operation 857 | # that contends with other proposals for the same row 858 | cas_contention_timeout_in_ms: 1000 859 | # How long the coordinator should wait for truncates to complete 860 | # (This can be much longer, because unless auto_snapshot is disabled 861 | # we need to flush first so we can snapshot before removing the data.) 862 | truncate_request_timeout_in_ms: 60000 863 | # The default timeout for other, miscellaneous operations 864 | request_timeout_in_ms: 10000 865 | 866 | # How long before a node logs slow queries. Select queries that take longer than 867 | # this timeout to execute, will generate an aggregated log message, so that slow queries 868 | # can be identified. Set this value to zero to disable slow query logging. 869 | slow_query_log_timeout_in_ms: 500 870 | 871 | # Enable operation timeout information exchange between nodes to accurately 872 | # measure request timeouts. If disabled, replicas will assume that requests 873 | # were forwarded to them instantly by the coordinator, which means that 874 | # under overload conditions we will waste that much extra time processing 875 | # already-timed-out requests. 876 | # 877 | # Warning: before enabling this property make sure to ntp is installed 878 | # and the times are synchronized between the nodes. 879 | cross_node_timeout: false 880 | 881 | # Set keep-alive period for streaming 882 | # This node will send a keep-alive message periodically with this period. 883 | # If the node does not receive a keep-alive message from the peer for 884 | # 2 keep-alive cycles the stream session times out and fail 885 | # Default value is 300s (5 minutes), which means stalled stream 886 | # times out in 10 minutes by default 887 | # streaming_keep_alive_period_in_secs: 300 888 | 889 | # phi value that must be reached for a host to be marked down. 890 | # most users should never need to adjust this. 891 | # phi_convict_threshold: 8 892 | 893 | # endpoint_snitch -- Set this to a class that implements 894 | # IEndpointSnitch. The snitch has two functions: 895 | # 896 | # - it teaches Cassandra enough about your network topology to route 897 | # requests efficiently 898 | # - it allows Cassandra to spread replicas around your cluster to avoid 899 | # correlated failures. It does this by grouping machines into 900 | # "datacenters" and "racks." Cassandra will do its best not to have 901 | # more than one replica on the same "rack" (which may not actually 902 | # be a physical location) 903 | # 904 | # CASSANDRA WILL NOT ALLOW YOU TO SWITCH TO AN INCOMPATIBLE SNITCH 905 | # ONCE DATA IS INSERTED INTO THE CLUSTER. This would cause data loss. 906 | # This means that if you start with the default SimpleSnitch, which 907 | # locates every node on "rack1" in "datacenter1", your only options 908 | # if you need to add another datacenter are GossipingPropertyFileSnitch 909 | # (and the older PFS). From there, if you want to migrate to an 910 | # incompatible snitch like Ec2Snitch you can do it by adding new nodes 911 | # under Ec2Snitch (which will locate them in a new "datacenter") and 912 | # decommissioning the old ones. 913 | # 914 | # Out of the box, Cassandra provides: 915 | # 916 | # SimpleSnitch: 917 | # Treats Strategy order as proximity. This can improve cache 918 | # locality when disabling read repair. Only appropriate for 919 | # single-datacenter deployments. 920 | # 921 | # GossipingPropertyFileSnitch 922 | # This should be your go-to snitch for production use. The rack 923 | # and datacenter for the local node are defined in 924 | # cassandra-rackdc.properties and propagated to other nodes via 925 | # gossip. If cassandra-topology.properties exists, it is used as a 926 | # fallback, allowing migration from the PropertyFileSnitch. 927 | # 928 | # PropertyFileSnitch: 929 | # Proximity is determined by rack and data center, which are 930 | # explicitly configured in cassandra-topology.properties. 931 | # 932 | # Ec2Snitch: 933 | # Appropriate for EC2 deployments in a single Region. Loads Region 934 | # and Availability Zone information from the EC2 API. The Region is 935 | # treated as the datacenter, and the Availability Zone as the rack. 936 | # Only private IPs are used, so this will not work across multiple 937 | # Regions. 938 | # 939 | # Ec2MultiRegionSnitch: 940 | # Uses public IPs as broadcast_address to allow cross-region 941 | # connectivity. (Thus, you should set seed addresses to the public 942 | # IP as well.) You will need to open the storage_port or 943 | # ssl_storage_port on the public IP firewall. (For intra-Region 944 | # traffic, Cassandra will switch to the private IP after 945 | # establishing a connection.) 946 | # 947 | # RackInferringSnitch: 948 | # Proximity is determined by rack and data center, which are 949 | # assumed to correspond to the 3rd and 2nd octet of each node's IP 950 | # address, respectively. Unless this happens to match your 951 | # deployment conventions, this is best used as an example of 952 | # writing a custom Snitch class and is provided in that spirit. 953 | # 954 | # You can use a custom Snitch by setting this to the full class name 955 | # of the snitch, which will be assumed to be on your classpath. 956 | endpoint_snitch: SimpleSnitch 957 | 958 | # controls how often to perform the more expensive part of host score 959 | # calculation 960 | dynamic_snitch_update_interval_in_ms: 100 961 | # controls how often to reset all host scores, allowing a bad host to 962 | # possibly recover 963 | dynamic_snitch_reset_interval_in_ms: 600000 964 | # if set greater than zero and read_repair_chance is < 1.0, this will allow 965 | # 'pinning' of replicas to hosts in order to increase cache capacity. 966 | # The badness threshold will control how much worse the pinned host has to be 967 | # before the dynamic snitch will prefer other replicas over it. This is 968 | # expressed as a double which represents a percentage. Thus, a value of 969 | # 0.2 means Cassandra would continue to prefer the static snitch values 970 | # until the pinned host was 20% worse than the fastest. 971 | dynamic_snitch_badness_threshold: 0.1 972 | 973 | # request_scheduler -- Set this to a class that implements 974 | # RequestScheduler, which will schedule incoming client requests 975 | # according to the specific policy. This is useful for multi-tenancy 976 | # with a single Cassandra cluster. 977 | # NOTE: This is specifically for requests from the client and does 978 | # not affect inter node communication. 979 | # org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place 980 | # org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of 981 | # client requests to a node with a separate queue for each 982 | # request_scheduler_id. The scheduler is further customized by 983 | # request_scheduler_options as described below. 984 | request_scheduler: org.apache.cassandra.scheduler.NoScheduler 985 | 986 | # Scheduler Options vary based on the type of scheduler 987 | # 988 | # NoScheduler 989 | # Has no options 990 | # 991 | # RoundRobin 992 | # throttle_limit 993 | # The throttle_limit is the number of in-flight 994 | # requests per client. Requests beyond 995 | # that limit are queued up until 996 | # running requests can complete. 997 | # The value of 80 here is twice the number of 998 | # concurrent_reads + concurrent_writes. 999 | # default_weight 1000 | # default_weight is optional and allows for 1001 | # overriding the default which is 1. 1002 | # weights 1003 | # Weights are optional and will default to 1 or the 1004 | # overridden default_weight. The weight translates into how 1005 | # many requests are handled during each turn of the 1006 | # RoundRobin, based on the scheduler id. 1007 | # 1008 | # request_scheduler_options: 1009 | # throttle_limit: 80 1010 | # default_weight: 5 1011 | # weights: 1012 | # Keyspace1: 1 1013 | # Keyspace2: 5 1014 | 1015 | # request_scheduler_id -- An identifier based on which to perform 1016 | # the request scheduling. Currently the only valid option is keyspace. 1017 | # request_scheduler_id: keyspace 1018 | 1019 | # Enable or disable inter-node encryption 1020 | # JVM defaults for supported SSL socket protocols and cipher suites can 1021 | # be replaced using custom encryption options. This is not recommended 1022 | # unless you have policies in place that dictate certain settings, or 1023 | # need to disable vulnerable ciphers or protocols in case the JVM cannot 1024 | # be updated. 1025 | # FIPS compliant settings can be configured at JVM level and should not 1026 | # involve changing encryption settings here: 1027 | # https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/FIPS.html 1028 | # *NOTE* No custom encryption options are enabled at the moment 1029 | # The available internode options are : all, none, dc, rack 1030 | # 1031 | # If set to dc cassandra will encrypt the traffic between the DCs 1032 | # If set to rack cassandra will encrypt the traffic between the racks 1033 | # 1034 | # The passwords used in these options must match the passwords used when generating 1035 | # the keystore and truststore. For instructions on generating these files, see: 1036 | # http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore 1037 | # 1038 | server_encryption_options: 1039 | internode_encryption: none 1040 | keystore: conf/.keystore 1041 | keystore_password: cassandra 1042 | truststore: conf/.truststore 1043 | truststore_password: cassandra 1044 | # More advanced defaults below: 1045 | # protocol: TLS 1046 | # algorithm: SunX509 1047 | # store_type: JKS 1048 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1049 | # require_client_auth: false 1050 | # require_endpoint_verification: false 1051 | 1052 | # enable or disable client/server encryption. 1053 | client_encryption_options: 1054 | enabled: false 1055 | # If enabled and optional is set to true encrypted and unencrypted connections are handled. 1056 | optional: false 1057 | keystore: conf/.keystore 1058 | keystore_password: cassandra 1059 | # require_client_auth: false 1060 | # Set trustore and truststore_password if require_client_auth is true 1061 | # truststore: conf/.truststore 1062 | # truststore_password: cassandra 1063 | # More advanced defaults below: 1064 | # protocol: TLS 1065 | # algorithm: SunX509 1066 | # store_type: JKS 1067 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1068 | 1069 | # internode_compression controls whether traffic between nodes is 1070 | # compressed. 1071 | # Can be: 1072 | # 1073 | # all 1074 | # all traffic is compressed 1075 | # 1076 | # dc 1077 | # traffic between different datacenters is compressed 1078 | # 1079 | # none 1080 | # nothing is compressed. 1081 | internode_compression: dc 1082 | 1083 | # Enable or disable tcp_nodelay for inter-dc communication. 1084 | # Disabling it will result in larger (but fewer) network packets being sent, 1085 | # reducing overhead from the TCP protocol itself, at the cost of increasing 1086 | # latency if you block for cross-datacenter responses. 1087 | inter_dc_tcp_nodelay: false 1088 | 1089 | # TTL for different trace types used during logging of the repair process. 1090 | tracetype_query_ttl: 86400 1091 | tracetype_repair_ttl: 604800 1092 | 1093 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1094 | # This threshold can be adjusted to minimize logging if necessary 1095 | # gc_log_threshold_in_ms: 200 1096 | 1097 | # If unset, all GC Pauses greater than gc_log_threshold_in_ms will log at 1098 | # INFO level 1099 | # UDFs (user defined functions) are disabled by default. 1100 | # As of Cassandra 3.0 there is a sandbox in place that should prevent execution of evil code. 1101 | enable_user_defined_functions: false 1102 | 1103 | # Enables scripted UDFs (JavaScript UDFs). 1104 | # Java UDFs are always enabled, if enable_user_defined_functions is true. 1105 | # Enable this option to be able to use UDFs with "language javascript" or any custom JSR-223 provider. 1106 | # This option has no effect, if enable_user_defined_functions is false. 1107 | enable_scripted_user_defined_functions: false 1108 | 1109 | # The default Windows kernel timer and scheduling resolution is 15.6ms for power conservation. 1110 | # Lowering this value on Windows can provide much tighter latency and better throughput, however 1111 | # some virtualized environments may see a negative performance impact from changing this setting 1112 | # below their system default. The sysinternals 'clockres' tool can confirm your system's default 1113 | # setting. 1114 | windows_timer_interval: 1 1115 | 1116 | 1117 | # Enables encrypting data at-rest (on disk). Different key providers can be plugged in, but the default reads from 1118 | # a JCE-style keystore. A single keystore can hold multiple keys, but the one referenced by 1119 | # the "key_alias" is the only key that will be used for encrypt opertaions; previously used keys 1120 | # can still (and should!) be in the keystore and will be used on decrypt operations 1121 | # (to handle the case of key rotation). 1122 | # 1123 | # It is strongly recommended to download and install Java Cryptography Extension (JCE) 1124 | # Unlimited Strength Jurisdiction Policy Files for your version of the JDK. 1125 | # (current link: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html) 1126 | # 1127 | # Currently, only the following file types are supported for transparent data encryption, although 1128 | # more are coming in future cassandra releases: commitlog, hints 1129 | transparent_data_encryption_options: 1130 | enabled: false 1131 | chunk_length_kb: 64 1132 | cipher: AES/CBC/PKCS5Padding 1133 | key_alias: testing:1 1134 | # CBC IV length for AES needs to be 16 bytes (which is also the default size) 1135 | # iv_length: 16 1136 | key_provider: 1137 | - class_name: org.apache.cassandra.security.JKSKeyProvider 1138 | parameters: 1139 | - keystore: conf/.keystore 1140 | keystore_password: cassandra 1141 | store_type: JCEKS 1142 | key_password: cassandra 1143 | 1144 | 1145 | ##################### 1146 | # SAFETY THRESHOLDS # 1147 | ##################### 1148 | 1149 | # When executing a scan, within or across a partition, we need to keep the 1150 | # tombstones seen in memory so we can return them to the coordinator, which 1151 | # will use them to make sure other replicas also know about the deleted rows. 1152 | # With workloads that generate a lot of tombstones, this can cause performance 1153 | # problems and even exaust the server heap. 1154 | # (http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets) 1155 | # Adjust the thresholds here if you understand the dangers and want to 1156 | # scan more tombstones anyway. These thresholds may also be adjusted at runtime 1157 | # using the StorageService mbean. 1158 | tombstone_warn_threshold: 1000 1159 | tombstone_failure_threshold: 100000 1160 | 1161 | # Log WARN on any multiple-partition batch size exceeding this value. 5kb per batch by default. 1162 | # Caution should be taken on increasing the size of this threshold as it can lead to node instability. 1163 | batch_size_warn_threshold_in_kb: 5 1164 | 1165 | # Fail any multiple-partition batch exceeding this value. 50kb (10x warn threshold) by default. 1166 | batch_size_fail_threshold_in_kb: 50 1167 | 1168 | # Log WARN on any batches not of type LOGGED than span across more partitions than this limit 1169 | unlogged_batch_across_partitions_warn_threshold: 10 1170 | 1171 | # Log a warning when compacting partitions larger than this value 1172 | compaction_large_partition_warning_threshold_mb: 100 1173 | 1174 | # GC Pauses greater than gc_warn_threshold_in_ms will be logged at WARN level 1175 | # Adjust the threshold based on your application throughput requirement 1176 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1177 | gc_warn_threshold_in_ms: 1000 1178 | 1179 | # Maximum size of any value in SSTables. Safety measure to detect SSTable corruption 1180 | # early. Any value size larger than this threshold will result into marking an SSTable 1181 | # as corrupted. 1182 | # max_value_size_in_mb: 256 1183 | 1184 | # Back-pressure settings # 1185 | # If enabled, the coordinator will apply the back-pressure strategy specified below to each mutation 1186 | # sent to replicas, with the aim of reducing pressure on overloaded replicas. 1187 | back_pressure_enabled: false 1188 | # The back-pressure strategy applied. 1189 | # The default implementation, RateBasedBackPressure, takes three arguments: 1190 | # high ratio, factor, and flow type, and uses the ratio between incoming mutation responses and outgoing mutation requests. 1191 | # If below high ratio, outgoing mutations are rate limited according to the incoming rate decreased by the given factor; 1192 | # if above high ratio, the rate limiting is increased by the given factor; 1193 | # such factor is usually best configured between 1 and 10, use larger values for a faster recovery 1194 | # at the expense of potentially more dropped mutations; 1195 | # the rate limiting is applied according to the flow type: if FAST, it's rate limited at the speed of the fastest replica, 1196 | # if SLOW at the speed of the slowest one. 1197 | # New strategies can be added. Implementors need to implement org.apache.cassandra.net.BackpressureStrategy and 1198 | # provide a public constructor accepting a Map. 1199 | back_pressure_strategy: 1200 | - class_name: org.apache.cassandra.net.RateBasedBackPressure 1201 | parameters: 1202 | - high_ratio: 0.90 1203 | factor: 5 1204 | flow: FAST 1205 | 1206 | # Coalescing Strategies # 1207 | # Coalescing multiples messages turns out to significantly boost message processing throughput (think doubling or more). 1208 | # On bare metal, the floor for packet processing throughput is high enough that many applications won't notice, but in 1209 | # virtualized environments, the point at which an application can be bound by network packet processing can be 1210 | # surprisingly low compared to the throughput of task processing that is possible inside a VM. It's not that bare metal 1211 | # doesn't benefit from coalescing messages, it's that the number of packets a bare metal network interface can process 1212 | # is sufficient for many applications such that no load starvation is experienced even without coalescing. 1213 | # There are other benefits to coalescing network messages that are harder to isolate with a simple metric like messages 1214 | # per second. By coalescing multiple tasks together, a network thread can process multiple messages for the cost of one 1215 | # trip to read from a socket, and all the task submission work can be done at the same time reducing context switching 1216 | # and increasing cache friendliness of network message processing. 1217 | # See CASSANDRA-8692 for details. 1218 | 1219 | # Strategy to use for coalescing messages in OutboundTcpConnection. 1220 | # Can be fixed, movingaverage, timehorizon, disabled (default). 1221 | # You can also specify a subclass of CoalescingStrategies.CoalescingStrategy by name. 1222 | # otc_coalescing_strategy: DISABLED 1223 | 1224 | # How many microseconds to wait for coalescing. For fixed strategy this is the amount of time after the first 1225 | # message is received before it will be sent with any accompanying messages. For moving average this is the 1226 | # maximum amount of time that will be waited as well as the interval at which messages must arrive on average 1227 | # for coalescing to be enabled. 1228 | # otc_coalescing_window_us: 200 1229 | 1230 | # Do not try to coalesce messages if we already got that many messages. This should be more than 2 and less than 128. 1231 | # otc_coalescing_enough_coalesced_messages: 8 1232 | 1233 | # How many milliseconds to wait between two expiration runs on the backlog (queue) of the OutboundTcpConnection. 1234 | # Expiration is done if messages are piling up in the backlog. Droppable messages are expired to free the memory 1235 | # taken by expired messages. The interval should be between 0 and 1000, and in most installations the default value 1236 | # will be appropriate. A smaller value could potentially expire messages slightly sooner at the expense of more CPU 1237 | # time and queue contention while iterating the backlog of messages. 1238 | # An interval of 0 disables any wait time, which is the behavior of former Cassandra versions. 1239 | # 1240 | # otc_backlog_expiration_interval_ms: 200 1241 | -------------------------------------------------------------------------------- /cassandra-cdc/config/reader-1.yml: -------------------------------------------------------------------------------- 1 | cassandra: 2 | keyspace: custom 3 | table: movies_by_genre 4 | cdc_raw_directory: /tmp/cdc/cassandra-1/cdc_raw 5 | kafka: 6 | topic: cdc-topic 7 | configuration: 8 | bootstrap.servers: 0.0.0.0:33028, 0.0.0.0:33029 9 | key.serializer: org.apache.kafka.common.serialization.StringSerializer 10 | value.serializer: org.apache.kafka.common.serialization.StringSerializer 11 | -------------------------------------------------------------------------------- /cassandra-cdc/config/reader-2.yml: -------------------------------------------------------------------------------- 1 | cassandra: 2 | keyspace: custom 3 | table: movies_by_genre 4 | cdc_raw_directory: /tmp/cdc/cassandra-2/cdc_raw 5 | kafka: 6 | topic: cdc-topic 7 | configuration: 8 | bootstrap.servers: 0.0.0.0:33028, 0.0.0.0:33029 9 | key.serializer: org.apache.kafka.common.serialization.StringSerializer 10 | value.serializer: org.apache.kafka.common.serialization.StringSerializer 11 | -------------------------------------------------------------------------------- /cassandra-cdc/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cassandra:3.11.0 2 | COPY cassandra.yaml /etc/cassandra/cassandra.yaml 3 | CMD ["cassandra", "-f"] 4 | -------------------------------------------------------------------------------- /cassandra-cdc/docker/cassandra.yaml: -------------------------------------------------------------------------------- 1 | # Cassandra storage config YAML 2 | 3 | # NOTE: 4 | # See http://wiki.apache.org/cassandra/StorageConfiguration for 5 | # full explanations of configuration directives 6 | # /NOTE 7 | 8 | # The name of the cluster. This is mainly used to prevent machines in 9 | # one logical cluster from joining another. 10 | cluster_name: 'Test Cluster' 11 | 12 | # This defines the number of tokens randomly assigned to this node on the ring 13 | # The more tokens, relative to other nodes, the larger the proportion of data 14 | # that this node will store. You probably want all nodes to have the same number 15 | # of tokens assuming they have equal hardware capability. 16 | # 17 | # If you leave this unspecified, Cassandra will use the default of 1 token for legacy compatibility, 18 | # and will use the initial_token as described below. 19 | # 20 | # Specifying initial_token will override this setting on the node's initial start, 21 | # on subsequent starts, this setting will apply even if initial token is set. 22 | # 23 | # If you already have a cluster with 1 token per node, and wish to migrate to 24 | # multiple tokens per node, see http://wiki.apache.org/cassandra/Operations 25 | num_tokens: 256 26 | 27 | # Triggers automatic allocation of num_tokens tokens for this node. The allocation 28 | # algorithm attempts to choose tokens in a way that optimizes replicated load over 29 | # the nodes in the datacenter for the replication strategy used by the specified 30 | # keyspace. 31 | # 32 | # The load assigned to each node will be close to proportional to its number of 33 | # vnodes. 34 | # 35 | # Only supported with the Murmur3Partitioner. 36 | # allocate_tokens_for_keyspace: KEYSPACE 37 | 38 | # initial_token allows you to specify tokens manually. While you can use it with 39 | # vnodes (num_tokens > 1, above) -- in which case you should provide a 40 | # comma-separated list -- it's primarily used when adding nodes to legacy clusters 41 | # that do not have vnodes enabled. 42 | # initial_token: 43 | 44 | # See http://wiki.apache.org/cassandra/HintedHandoff 45 | # May either be "true" or "false" to enable globally 46 | hinted_handoff_enabled: true 47 | 48 | # When hinted_handoff_enabled is true, a black list of data centers that will not 49 | # perform hinted handoff 50 | # hinted_handoff_disabled_datacenters: 51 | # - DC1 52 | # - DC2 53 | 54 | # this defines the maximum amount of time a dead host will have hints 55 | # generated. After it has been dead this long, new hints for it will not be 56 | # created until it has been seen alive and gone down again. 57 | max_hint_window_in_ms: 10800000 # 3 hours 58 | 59 | # Maximum throttle in KBs per second, per delivery thread. This will be 60 | # reduced proportionally to the number of nodes in the cluster. (If there 61 | # are two nodes in the cluster, each delivery thread will use the maximum 62 | # rate; if there are three, each will throttle to half of the maximum, 63 | # since we expect two nodes to be delivering hints simultaneously.) 64 | hinted_handoff_throttle_in_kb: 1024 65 | 66 | # Number of threads with which to deliver hints; 67 | # Consider increasing this number when you have multi-dc deployments, since 68 | # cross-dc handoff tends to be slower 69 | max_hints_delivery_threads: 2 70 | 71 | # Directory where Cassandra should store hints. 72 | # If not set, the default directory is $CASSANDRA_HOME/data/hints. 73 | # hints_directory: /var/lib/cassandra/hints 74 | hints_directory: /var/lib/cassandra/hints 75 | 76 | # How often hints should be flushed from the internal buffers to disk. 77 | # Will *not* trigger fsync. 78 | hints_flush_period_in_ms: 10000 79 | 80 | # Maximum size for a single hints file, in megabytes. 81 | max_hints_file_size_in_mb: 128 82 | 83 | # Compression to apply to the hint files. If omitted, hints files 84 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 85 | # are supported. 86 | #hints_compression: 87 | # - class_name: LZ4Compressor 88 | # parameters: 89 | # - 90 | 91 | # Maximum throttle in KBs per second, total. This will be 92 | # reduced proportionally to the number of nodes in the cluster. 93 | batchlog_replay_throttle_in_kb: 1024 94 | 95 | # Authentication backend, implementing IAuthenticator; used to identify users 96 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator, 97 | # PasswordAuthenticator}. 98 | # 99 | # - AllowAllAuthenticator performs no checks - set it to disable authentication. 100 | # - PasswordAuthenticator relies on username/password pairs to authenticate 101 | # users. It keeps usernames and hashed passwords in system_auth.roles table. 102 | # Please increase system_auth keyspace replication factor if you use this authenticator. 103 | # If using PasswordAuthenticator, CassandraRoleManager must also be used (see below) 104 | authenticator: AllowAllAuthenticator 105 | 106 | # Authorization backend, implementing IAuthorizer; used to limit access/provide permissions 107 | # Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer, 108 | # CassandraAuthorizer}. 109 | # 110 | # - AllowAllAuthorizer allows any action to any user - set it to disable authorization. 111 | # - CassandraAuthorizer stores permissions in system_auth.role_permissions table. Please 112 | # increase system_auth keyspace replication factor if you use this authorizer. 113 | authorizer: AllowAllAuthorizer 114 | 115 | # Part of the Authentication & Authorization backend, implementing IRoleManager; used 116 | # to maintain grants and memberships between roles. 117 | # Out of the box, Cassandra provides org.apache.cassandra.auth.CassandraRoleManager, 118 | # which stores role information in the system_auth keyspace. Most functions of the 119 | # IRoleManager require an authenticated login, so unless the configured IAuthenticator 120 | # actually implements authentication, most of this functionality will be unavailable. 121 | # 122 | # - CassandraRoleManager stores role data in the system_auth keyspace. Please 123 | # increase system_auth keyspace replication factor if you use this role manager. 124 | role_manager: CassandraRoleManager 125 | 126 | # Validity period for roles cache (fetching granted roles can be an expensive 127 | # operation depending on the role manager, CassandraRoleManager is one example) 128 | # Granted roles are cached for authenticated sessions in AuthenticatedUser and 129 | # after the period specified here, become eligible for (async) reload. 130 | # Defaults to 2000, set to 0 to disable caching entirely. 131 | # Will be disabled automatically for AllowAllAuthenticator. 132 | roles_validity_in_ms: 2000 133 | 134 | # Refresh interval for roles cache (if enabled). 135 | # After this interval, cache entries become eligible for refresh. Upon next 136 | # access, an async reload is scheduled and the old value returned until it 137 | # completes. If roles_validity_in_ms is non-zero, then this must be 138 | # also. 139 | # Defaults to the same value as roles_validity_in_ms. 140 | # roles_update_interval_in_ms: 2000 141 | 142 | # Validity period for permissions cache (fetching permissions can be an 143 | # expensive operation depending on the authorizer, CassandraAuthorizer is 144 | # one example). Defaults to 2000, set to 0 to disable. 145 | # Will be disabled automatically for AllowAllAuthorizer. 146 | permissions_validity_in_ms: 2000 147 | 148 | # Refresh interval for permissions cache (if enabled). 149 | # After this interval, cache entries become eligible for refresh. Upon next 150 | # access, an async reload is scheduled and the old value returned until it 151 | # completes. If permissions_validity_in_ms is non-zero, then this must be 152 | # also. 153 | # Defaults to the same value as permissions_validity_in_ms. 154 | # permissions_update_interval_in_ms: 2000 155 | 156 | # Validity period for credentials cache. This cache is tightly coupled to 157 | # the provided PasswordAuthenticator implementation of IAuthenticator. If 158 | # another IAuthenticator implementation is configured, this cache will not 159 | # be automatically used and so the following settings will have no effect. 160 | # Please note, credentials are cached in their encrypted form, so while 161 | # activating this cache may reduce the number of queries made to the 162 | # underlying table, it may not bring a significant reduction in the 163 | # latency of individual authentication attempts. 164 | # Defaults to 2000, set to 0 to disable credentials caching. 165 | credentials_validity_in_ms: 2000 166 | 167 | # Refresh interval for credentials cache (if enabled). 168 | # After this interval, cache entries become eligible for refresh. Upon next 169 | # access, an async reload is scheduled and the old value returned until it 170 | # completes. If credentials_validity_in_ms is non-zero, then this must be 171 | # also. 172 | # Defaults to the same value as credentials_validity_in_ms. 173 | # credentials_update_interval_in_ms: 2000 174 | 175 | # The partitioner is responsible for distributing groups of rows (by 176 | # partition key) across nodes in the cluster. You should leave this 177 | # alone for new clusters. The partitioner can NOT be changed without 178 | # reloading all data, so when upgrading you should set this to the 179 | # same partitioner you were already using. 180 | # 181 | # Besides Murmur3Partitioner, partitioners included for backwards 182 | # compatibility include RandomPartitioner, ByteOrderedPartitioner, and 183 | # OrderPreservingPartitioner. 184 | # 185 | partitioner: org.apache.cassandra.dht.Murmur3Partitioner 186 | 187 | # Directories where Cassandra should store data on disk. Cassandra 188 | # will spread data evenly across them, subject to the granularity of 189 | # the configured compaction strategy. 190 | # If not set, the default directory is $CASSANDRA_HOME/data/data. 191 | # data_file_directories: 192 | # - /var/lib/cassandra/data 193 | data_file_directories: 194 | - /var/lib/cassandra/data 195 | 196 | # commit log. when running on magnetic HDD, this should be a 197 | # separate spindle than the data directories. 198 | # If not set, the default directory is $CASSANDRA_HOME/data/commitlog. 199 | # commitlog_directory: /var/lib/cassandra/commitlog 200 | commitlog_directory: /var/lib/cassandra/commitlog 201 | 202 | # Enable / disable CDC functionality on a per-node basis. This modifies the logic used 203 | # for write path allocation rejection (standard: never reject. cdc: reject Mutation 204 | # containing a CDC-enabled table if at space limit in cdc_raw_directory). 205 | cdc_enabled: true 206 | 207 | # CommitLogSegments are moved to this directory on flush if cdc_enabled: true and the 208 | # segment contains mutations for a CDC-enabled table. This should be placed on a 209 | # separate spindle than the data directories. If not set, the default directory is 210 | # $CASSANDRA_HOME/data/cdc_raw. 211 | # cdc_raw_directory: /var/lib/cassandra/cdc_raw 212 | cdc_raw_directory: /var/lib/cassandra/cdc_raw 213 | 214 | # Policy for data disk failures: 215 | # 216 | # die 217 | # shut down gossip and client transports and kill the JVM for any fs errors or 218 | # single-sstable errors, so the node can be replaced. 219 | # 220 | # stop_paranoid 221 | # shut down gossip and client transports even for single-sstable errors, 222 | # kill the JVM for errors during startup. 223 | # 224 | # stop 225 | # shut down gossip and client transports, leaving the node effectively dead, but 226 | # can still be inspected via JMX, kill the JVM for errors during startup. 227 | # 228 | # best_effort 229 | # stop using the failed disk and respond to requests based on 230 | # remaining available sstables. This means you WILL see obsolete 231 | # data at CL.ONE! 232 | # 233 | # ignore 234 | # ignore fatal errors and let requests fail, as in pre-1.2 Cassandra 235 | disk_failure_policy: stop 236 | 237 | # Policy for commit disk failures: 238 | # 239 | # die 240 | # shut down gossip and Thrift and kill the JVM, so the node can be replaced. 241 | # 242 | # stop 243 | # shut down gossip and Thrift, leaving the node effectively dead, but 244 | # can still be inspected via JMX. 245 | # 246 | # stop_commit 247 | # shutdown the commit log, letting writes collect but 248 | # continuing to service reads, as in pre-2.0.5 Cassandra 249 | # 250 | # ignore 251 | # ignore fatal errors and let the batches fail 252 | commit_failure_policy: stop 253 | 254 | # Maximum size of the native protocol prepared statement cache 255 | # 256 | # Valid values are either "auto" (omitting the value) or a value greater 0. 257 | # 258 | # Note that specifying a too large value will result in long running GCs and possbily 259 | # out-of-memory errors. Keep the value at a small fraction of the heap. 260 | # 261 | # If you constantly see "prepared statements discarded in the last minute because 262 | # cache limit reached" messages, the first step is to investigate the root cause 263 | # of these messages and check whether prepared statements are used correctly - 264 | # i.e. use bind markers for variable parts. 265 | # 266 | # Do only change the default value, if you really have more prepared statements than 267 | # fit in the cache. In most cases it is not neccessary to change this value. 268 | # Constantly re-preparing statements is a performance penalty. 269 | # 270 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 271 | prepared_statements_cache_size_mb: 272 | 273 | # Maximum size of the Thrift prepared statement cache 274 | # 275 | # If you do not use Thrift at all, it is safe to leave this value at "auto". 276 | # 277 | # See description of 'prepared_statements_cache_size_mb' above for more information. 278 | # 279 | # Default value ("auto") is 1/256th of the heap or 10MB, whichever is greater 280 | thrift_prepared_statements_cache_size_mb: 281 | 282 | # Maximum size of the key cache in memory. 283 | # 284 | # Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the 285 | # minimum, sometimes more. The key cache is fairly tiny for the amount of 286 | # time it saves, so it's worthwhile to use it at large numbers. 287 | # The row cache saves even more time, but must contain the entire row, 288 | # so it is extremely space-intensive. It's best to only use the 289 | # row cache if you have hot rows or static rows. 290 | # 291 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 292 | # 293 | # Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache. 294 | key_cache_size_in_mb: 295 | 296 | # Duration in seconds after which Cassandra should 297 | # save the key cache. Caches are saved to saved_caches_directory as 298 | # specified in this configuration file. 299 | # 300 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 301 | # terms of I/O for the key cache. Row cache saving is much more expensive and 302 | # has limited use. 303 | # 304 | # Default is 14400 or 4 hours. 305 | key_cache_save_period: 14400 306 | 307 | # Number of keys from the key cache to save 308 | # Disabled by default, meaning all keys are going to be saved 309 | # key_cache_keys_to_save: 100 310 | 311 | # Row cache implementation class name. Available implementations: 312 | # 313 | # org.apache.cassandra.cache.OHCProvider 314 | # Fully off-heap row cache implementation (default). 315 | # 316 | # org.apache.cassandra.cache.SerializingCacheProvider 317 | # This is the row cache implementation availabile 318 | # in previous releases of Cassandra. 319 | # row_cache_class_name: org.apache.cassandra.cache.OHCProvider 320 | 321 | # Maximum size of the row cache in memory. 322 | # Please note that OHC cache implementation requires some additional off-heap memory to manage 323 | # the map structures and some in-flight memory during operations before/after cache entries can be 324 | # accounted against the cache capacity. This overhead is usually small compared to the whole capacity. 325 | # Do not specify more memory that the system can afford in the worst usual situation and leave some 326 | # headroom for OS block level cache. Do never allow your system to swap. 327 | # 328 | # Default value is 0, to disable row caching. 329 | row_cache_size_in_mb: 0 330 | 331 | # Duration in seconds after which Cassandra should save the row cache. 332 | # Caches are saved to saved_caches_directory as specified in this configuration file. 333 | # 334 | # Saved caches greatly improve cold-start speeds, and is relatively cheap in 335 | # terms of I/O for the key cache. Row cache saving is much more expensive and 336 | # has limited use. 337 | # 338 | # Default is 0 to disable saving the row cache. 339 | row_cache_save_period: 0 340 | 341 | # Number of keys from the row cache to save. 342 | # Specify 0 (which is the default), meaning all keys are going to be saved 343 | # row_cache_keys_to_save: 100 344 | 345 | # Maximum size of the counter cache in memory. 346 | # 347 | # Counter cache helps to reduce counter locks' contention for hot counter cells. 348 | # In case of RF = 1 a counter cache hit will cause Cassandra to skip the read before 349 | # write entirely. With RF > 1 a counter cache hit will still help to reduce the duration 350 | # of the lock hold, helping with hot counter cell updates, but will not allow skipping 351 | # the read entirely. Only the local (clock, count) tuple of a counter cell is kept 352 | # in memory, not the whole counter, so it's relatively cheap. 353 | # 354 | # NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. 355 | # 356 | # Default value is empty to make it "auto" (min(2.5% of Heap (in MB), 50MB)). Set to 0 to disable counter cache. 357 | # NOTE: if you perform counter deletes and rely on low gcgs, you should disable the counter cache. 358 | counter_cache_size_in_mb: 359 | 360 | # Duration in seconds after which Cassandra should 361 | # save the counter cache (keys only). Caches are saved to saved_caches_directory as 362 | # specified in this configuration file. 363 | # 364 | # Default is 7200 or 2 hours. 365 | counter_cache_save_period: 7200 366 | 367 | # Number of keys from the counter cache to save 368 | # Disabled by default, meaning all keys are going to be saved 369 | # counter_cache_keys_to_save: 100 370 | 371 | # saved caches 372 | # If not set, the default directory is $CASSANDRA_HOME/data/saved_caches. 373 | # saved_caches_directory: /var/lib/cassandra/saved_caches 374 | 375 | # commitlog_sync may be either "periodic" or "batch." 376 | # 377 | # When in batch mode, Cassandra won't ack writes until the commit log 378 | # has been fsynced to disk. It will wait 379 | # commitlog_sync_batch_window_in_ms milliseconds between fsyncs. 380 | # This window should be kept short because the writer threads will 381 | # be unable to do extra work while waiting. (You may need to increase 382 | # concurrent_writes for the same reason.) 383 | # 384 | # commitlog_sync: batch 385 | # commitlog_sync_batch_window_in_ms: 2 386 | # 387 | # the other option is "periodic" where writes may be acked immediately 388 | # and the CommitLog is simply synced every commitlog_sync_period_in_ms 389 | # milliseconds. 390 | commitlog_sync: periodic 391 | commitlog_sync_period_in_ms: 10000 392 | 393 | # The size of the individual commitlog file segments. A commitlog 394 | # segment may be archived, deleted, or recycled once all the data 395 | # in it (potentially from each columnfamily in the system) has been 396 | # flushed to sstables. 397 | # 398 | # The default size is 32, which is almost always fine, but if you are 399 | # archiving commitlog segments (see commitlog_archiving.properties), 400 | # then you probably want a finer granularity of archiving; 8 or 16 MB 401 | # is reasonable. 402 | # Max mutation size is also configurable via max_mutation_size_in_kb setting in 403 | # cassandra.yaml. The default is half the size commitlog_segment_size_in_mb * 1024. 404 | # 405 | # NOTE: If max_mutation_size_in_kb is set explicitly then commitlog_segment_size_in_mb must 406 | # be set to at least twice the size of max_mutation_size_in_kb / 1024 407 | # 408 | commitlog_segment_size_in_mb: 1 409 | 410 | # Compression to apply to the commit log. If omitted, the commit log 411 | # will be written uncompressed. LZ4, Snappy, and Deflate compressors 412 | # are supported. 413 | # commitlog_compression: 414 | # - class_name: LZ4Compressor 415 | # parameters: 416 | # - 417 | 418 | # any class that implements the SeedProvider interface and has a 419 | # constructor that takes a Map of parameters will do. 420 | seed_provider: 421 | # Addresses of hosts that are deemed contact points. 422 | # Cassandra nodes use this list of hosts to find each other and learn 423 | # the topology of the ring. You must change this if you are running 424 | # multiple nodes! 425 | - class_name: org.apache.cassandra.locator.SimpleSeedProvider 426 | parameters: 427 | # seeds is actually a comma-delimited list of addresses. 428 | # Ex: ",," 429 | - seeds: "127.0.0.1" 430 | 431 | # For workloads with more data than can fit in memory, Cassandra's 432 | # bottleneck will be reads that need to fetch data from 433 | # disk. "concurrent_reads" should be set to (16 * number_of_drives) in 434 | # order to allow the operations to enqueue low enough in the stack 435 | # that the OS and drives can reorder them. Same applies to 436 | # "concurrent_counter_writes", since counter writes read the current 437 | # values before incrementing and writing them back. 438 | # 439 | # On the other hand, since writes are almost never IO bound, the ideal 440 | # number of "concurrent_writes" is dependent on the number of cores in 441 | # your system; (8 * number_of_cores) is a good rule of thumb. 442 | concurrent_reads: 32 443 | concurrent_writes: 32 444 | concurrent_counter_writes: 32 445 | 446 | # For materialized view writes, as there is a read involved, so this should 447 | # be limited by the less of concurrent reads or concurrent writes. 448 | concurrent_materialized_view_writes: 32 449 | 450 | # Maximum memory to use for sstable chunk cache and buffer pooling. 451 | # 32MB of this are reserved for pooling buffers, the rest is used as an 452 | # cache that holds uncompressed sstable chunks. 453 | # Defaults to the smaller of 1/4 of heap or 512MB. This pool is allocated off-heap, 454 | # so is in addition to the memory allocated for heap. The cache also has on-heap 455 | # overhead which is roughly 128 bytes per chunk (i.e. 0.2% of the reserved size 456 | # if the default 64k chunk size is used). 457 | # Memory is only allocated when needed. 458 | # file_cache_size_in_mb: 512 459 | 460 | # Flag indicating whether to allocate on or off heap when the sstable buffer 461 | # pool is exhausted, that is when it has exceeded the maximum memory 462 | # file_cache_size_in_mb, beyond which it will not cache buffers but allocate on request. 463 | 464 | # buffer_pool_use_heap_if_exhausted: true 465 | 466 | # The strategy for optimizing disk read 467 | # Possible values are: 468 | # ssd (for solid state disks, the default) 469 | # spinning (for spinning disks) 470 | # disk_optimization_strategy: ssd 471 | 472 | # Total permitted memory to use for memtables. Cassandra will stop 473 | # accepting writes when the limit is exceeded until a flush completes, 474 | # and will trigger a flush based on memtable_cleanup_threshold 475 | # If omitted, Cassandra will set both to 1/4 the size of the heap. 476 | # memtable_heap_space_in_mb: 2048 477 | # memtable_offheap_space_in_mb: 2048 478 | 479 | # memtable_cleanup_threshold is deprecated. The default calculation 480 | # is the only reasonable choice. See the comments on memtable_flush_writers 481 | # for more information. 482 | # 483 | # Ratio of occupied non-flushing memtable size to total permitted size 484 | # that will trigger a flush of the largest memtable. Larger mct will 485 | # mean larger flushes and hence less compaction, but also less concurrent 486 | # flush activity which can make it difficult to keep your disks fed 487 | # under heavy write load. 488 | # 489 | # memtable_cleanup_threshold defaults to 1 / (memtable_flush_writers + 1) 490 | # memtable_cleanup_threshold: 0.11 491 | 492 | # Specify the way Cassandra allocates and manages memtable memory. 493 | # Options are: 494 | # 495 | # heap_buffers 496 | # on heap nio buffers 497 | # 498 | # offheap_buffers 499 | # off heap (direct) nio buffers 500 | # 501 | # offheap_objects 502 | # off heap objects 503 | memtable_allocation_type: heap_buffers 504 | 505 | # Total space to use for commit logs on disk. 506 | # 507 | # If space gets above this value, Cassandra will flush every dirty CF 508 | # in the oldest segment and remove it. So a small total commitlog space 509 | # will tend to cause more flush activity on less-active columnfamilies. 510 | # 511 | # The default value is the smaller of 8192, and 1/4 of the total space 512 | # of the commitlog volume. 513 | # 514 | # commitlog_total_space_in_mb: 8192 515 | commitlog_total_space_in_mb: 16 516 | 517 | # This sets the number of memtable flush writer threads per disk 518 | # as well as the total number of memtables that can be flushed concurrently. 519 | # These are generally a combination of compute and IO bound. 520 | # 521 | # Memtable flushing is more CPU efficient than memtable ingest and a single thread 522 | # can keep up with the ingest rate of a whole server on a single fast disk 523 | # until it temporarily becomes IO bound under contention typically with compaction. 524 | # At that point you need multiple flush threads. At some point in the future 525 | # it may become CPU bound all the time. 526 | # 527 | # You can tell if flushing is falling behind using the MemtablePool.BlockedOnAllocation 528 | # metric which should be 0, but will be non-zero if threads are blocked waiting on flushing 529 | # to free memory. 530 | # 531 | # memtable_flush_writers defaults to two for a single data directory. 532 | # This means that two memtables can be flushed concurrently to the single data directory. 533 | # If you have multiple data directories the default is one memtable flushing at a time 534 | # but the flush will use a thread per data directory so you will get two or more writers. 535 | # 536 | # Two is generally enough to flush on a fast disk [array] mounted as a single data directory. 537 | # Adding more flush writers will result in smaller more frequent flushes that introduce more 538 | # compaction overhead. 539 | # 540 | # There is a direct tradeoff between number of memtables that can be flushed concurrently 541 | # and flush size and frequency. More is not better you just need enough flush writers 542 | # to never stall waiting for flushing to free memory. 543 | # 544 | #memtable_flush_writers: 2 545 | 546 | # Total space to use for change-data-capture logs on disk. 547 | # 548 | # If space gets above this value, Cassandra will throw WriteTimeoutException 549 | # on Mutations including tables with CDC enabled. A CDCCompactor is responsible 550 | # for parsing the raw CDC logs and deleting them when parsing is completed. 551 | # 552 | # The default value is the min of 4096 mb and 1/8th of the total space 553 | # of the drive where cdc_raw_directory resides. 554 | # cdc_total_space_in_mb: 4096 555 | cdc_total_space_in_mb: 4096 556 | 557 | # When we hit our cdc_raw limit and the CDCCompactor is either running behind 558 | # or experiencing backpressure, we check at the following interval to see if any 559 | # new space for cdc-tracked tables has been made available. Default to 250ms 560 | # cdc_free_space_check_interval_ms: 250 561 | cdc_free_space_check_interval_ms: 250 562 | 563 | # A fixed memory pool size in MB for for SSTable index summaries. If left 564 | # empty, this will default to 5% of the heap size. If the memory usage of 565 | # all index summaries exceeds this limit, SSTables with low read rates will 566 | # shrink their index summaries in order to meet this limit. However, this 567 | # is a best-effort process. In extreme conditions Cassandra may need to use 568 | # more than this amount of memory. 569 | index_summary_capacity_in_mb: 570 | 571 | # How frequently index summaries should be resampled. This is done 572 | # periodically to redistribute memory from the fixed-size pool to sstables 573 | # proportional their recent read rates. Setting to -1 will disable this 574 | # process, leaving existing index summaries at their current sampling level. 575 | index_summary_resize_interval_in_minutes: 60 576 | 577 | # Whether to, when doing sequential writing, fsync() at intervals in 578 | # order to force the operating system to flush the dirty 579 | # buffers. Enable this to avoid sudden dirty buffer flushing from 580 | # impacting read latencies. Almost always a good idea on SSDs; not 581 | # necessarily on platters. 582 | trickle_fsync: false 583 | trickle_fsync_interval_in_kb: 10240 584 | 585 | # TCP port, for commands and data 586 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 587 | storage_port: 7000 588 | 589 | # SSL port, for encrypted communication. Unused unless enabled in 590 | # encryption_options 591 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 592 | ssl_storage_port: 7001 593 | 594 | # Address or interface to bind to and tell other Cassandra nodes to connect to. 595 | # You _must_ change this if you want multiple nodes to be able to communicate! 596 | # 597 | # Set listen_address OR listen_interface, not both. 598 | # 599 | # Leaving it blank leaves it up to InetAddress.getLocalHost(). This 600 | # will always do the Right Thing _if_ the node is properly configured 601 | # (hostname, name resolution, etc), and the Right Thing is to use the 602 | # address associated with the hostname (it might not be). 603 | # 604 | # Setting listen_address to 0.0.0.0 is always wrong. 605 | # 606 | listen_address: localhost 607 | 608 | # Set listen_address OR listen_interface, not both. Interfaces must correspond 609 | # to a single address, IP aliasing is not supported. 610 | # listen_interface: eth0 611 | 612 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 613 | # you can specify which should be chosen using listen_interface_prefer_ipv6. If false the first ipv4 614 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 615 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 616 | # listen_interface_prefer_ipv6: false 617 | 618 | # Address to broadcast to other Cassandra nodes 619 | # Leaving this blank will set it to the same value as listen_address 620 | # broadcast_address: 1.2.3.4 621 | 622 | # When using multiple physical network interfaces, set this 623 | # to true to listen on broadcast_address in addition to 624 | # the listen_address, allowing nodes to communicate in both 625 | # interfaces. 626 | # Ignore this property if the network configuration automatically 627 | # routes between the public and private networks such as EC2. 628 | # listen_on_broadcast_address: false 629 | 630 | # Internode authentication backend, implementing IInternodeAuthenticator; 631 | # used to allow/disallow connections from peer nodes. 632 | # internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator 633 | 634 | # Whether to start the native transport server. 635 | # Please note that the address on which the native transport is bound is the 636 | # same as the rpc_address. The port however is different and specified below. 637 | start_native_transport: true 638 | # port for the CQL native transport to listen for clients on 639 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 640 | native_transport_port: 9042 641 | # Enabling native transport encryption in client_encryption_options allows you to either use 642 | # encryption for the standard port or to use a dedicated, additional port along with the unencrypted 643 | # standard native_transport_port. 644 | # Enabling client encryption and keeping native_transport_port_ssl disabled will use encryption 645 | # for native_transport_port. Setting native_transport_port_ssl to a different value 646 | # from native_transport_port will use encryption for native_transport_port_ssl while 647 | # keeping native_transport_port unencrypted. 648 | # native_transport_port_ssl: 9142 649 | # The maximum threads for handling requests when the native transport is used. 650 | # This is similar to rpc_max_threads though the default differs slightly (and 651 | # there is no native_transport_min_threads, idle threads will always be stopped 652 | # after 30 seconds). 653 | # native_transport_max_threads: 128 654 | # 655 | # The maximum size of allowed frame. Frame (requests) larger than this will 656 | # be rejected as invalid. The default is 256MB. If you're changing this parameter, 657 | # you may want to adjust max_value_size_in_mb accordingly. 658 | # native_transport_max_frame_size_in_mb: 256 659 | 660 | # The maximum number of concurrent client connections. 661 | # The default is -1, which means unlimited. 662 | # native_transport_max_concurrent_connections: -1 663 | 664 | # The maximum number of concurrent client connections per source ip. 665 | # The default is -1, which means unlimited. 666 | # native_transport_max_concurrent_connections_per_ip: -1 667 | 668 | # Whether to start the thrift rpc server. 669 | start_rpc: false 670 | 671 | # The address or interface to bind the Thrift RPC service and native transport 672 | # server to. 673 | # 674 | # Set rpc_address OR rpc_interface, not both. 675 | # 676 | # Leaving rpc_address blank has the same effect as on listen_address 677 | # (i.e. it will be based on the configured hostname of the node). 678 | # 679 | # Note that unlike listen_address, you can specify 0.0.0.0, but you must also 680 | # set broadcast_rpc_address to a value other than 0.0.0.0. 681 | # 682 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 683 | rpc_address: localhost 684 | 685 | # Set rpc_address OR rpc_interface, not both. Interfaces must correspond 686 | # to a single address, IP aliasing is not supported. 687 | # rpc_interface: eth1 688 | 689 | # If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address 690 | # you can specify which should be chosen using rpc_interface_prefer_ipv6. If false the first ipv4 691 | # address will be used. If true the first ipv6 address will be used. Defaults to false preferring 692 | # ipv4. If there is only one address it will be selected regardless of ipv4/ipv6. 693 | # rpc_interface_prefer_ipv6: false 694 | 695 | # port for Thrift to listen for clients on 696 | rpc_port: 9160 697 | 698 | # RPC address to broadcast to drivers and other Cassandra nodes. This cannot 699 | # be set to 0.0.0.0. If left blank, this will be set to the value of 700 | # rpc_address. If rpc_address is set to 0.0.0.0, broadcast_rpc_address must 701 | # be set. 702 | # broadcast_rpc_address: 1.2.3.4 703 | 704 | # enable or disable keepalive on rpc/native connections 705 | rpc_keepalive: true 706 | 707 | # Cassandra provides two out-of-the-box options for the RPC Server: 708 | # 709 | # sync 710 | # One thread per thrift connection. For a very large number of clients, memory 711 | # will be your limiting factor. On a 64 bit JVM, 180KB is the minimum stack size 712 | # per thread, and that will correspond to your use of virtual memory (but physical memory 713 | # may be limited depending on use of stack space). 714 | # 715 | # hsha 716 | # Stands for "half synchronous, half asynchronous." All thrift clients are handled 717 | # asynchronously using a small number of threads that does not vary with the amount 718 | # of thrift clients (and thus scales well to many clients). The rpc requests are still 719 | # synchronous (one thread per active request). If hsha is selected then it is essential 720 | # that rpc_max_threads is changed from the default value of unlimited. 721 | # 722 | # The default is sync because on Windows hsha is about 30% slower. On Linux, 723 | # sync/hsha performance is about the same, with hsha of course using less memory. 724 | # 725 | # Alternatively, can provide your own RPC server by providing the fully-qualified class name 726 | # of an o.a.c.t.TServerFactory that can create an instance of it. 727 | rpc_server_type: sync 728 | 729 | # Uncomment rpc_min|max_thread to set request pool size limits. 730 | # 731 | # Regardless of your choice of RPC server (see above), the number of maximum requests in the 732 | # RPC thread pool dictates how many concurrent requests are possible (but if you are using the sync 733 | # RPC server, it also dictates the number of clients that can be connected at all). 734 | # 735 | # The default is unlimited and thus provides no protection against clients overwhelming the server. You are 736 | # encouraged to set a maximum that makes sense for you in production, but do keep in mind that 737 | # rpc_max_threads represents the maximum number of client requests this server may execute concurrently. 738 | # 739 | # rpc_min_threads: 16 740 | # rpc_max_threads: 2048 741 | 742 | # uncomment to set socket buffer sizes on rpc connections 743 | # rpc_send_buff_size_in_bytes: 744 | # rpc_recv_buff_size_in_bytes: 745 | 746 | # Uncomment to set socket buffer size for internode communication 747 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 748 | # and when not setting it it is defined by net.ipv4.tcp_wmem 749 | # See also: 750 | # /proc/sys/net/core/wmem_max 751 | # /proc/sys/net/core/rmem_max 752 | # /proc/sys/net/ipv4/tcp_wmem 753 | # /proc/sys/net/ipv4/tcp_wmem 754 | # and 'man tcp' 755 | # internode_send_buff_size_in_bytes: 756 | 757 | # Uncomment to set socket buffer size for internode communication 758 | # Note that when setting this, the buffer size is limited by net.core.wmem_max 759 | # and when not setting it it is defined by net.ipv4.tcp_wmem 760 | # internode_recv_buff_size_in_bytes: 761 | 762 | # Frame size for thrift (maximum message length). 763 | thrift_framed_transport_size_in_mb: 15 764 | 765 | # Set to true to have Cassandra create a hard link to each sstable 766 | # flushed or streamed locally in a backups/ subdirectory of the 767 | # keyspace data. Removing these links is the operator's 768 | # responsibility. 769 | incremental_backups: false 770 | 771 | # Whether or not to take a snapshot before each compaction. Be 772 | # careful using this option, since Cassandra won't clean up the 773 | # snapshots for you. Mostly useful if you're paranoid when there 774 | # is a data format change. 775 | snapshot_before_compaction: false 776 | 777 | # Whether or not a snapshot is taken of the data before keyspace truncation 778 | # or dropping of column families. The STRONGLY advised default of true 779 | # should be used to provide data safety. If you set this flag to false, you will 780 | # lose data on truncation or drop. 781 | auto_snapshot: true 782 | 783 | # Granularity of the collation index of rows within a partition. 784 | # Increase if your rows are large, or if you have a very large 785 | # number of rows per partition. The competing goals are these: 786 | # 787 | # - a smaller granularity means more index entries are generated 788 | # and looking up rows withing the partition by collation column 789 | # is faster 790 | # - but, Cassandra will keep the collation index in memory for hot 791 | # rows (as part of the key cache), so a larger granularity means 792 | # you can cache more hot rows 793 | column_index_size_in_kb: 64 794 | 795 | # Per sstable indexed key cache entries (the collation index in memory 796 | # mentioned above) exceeding this size will not be held on heap. 797 | # This means that only partition information is held on heap and the 798 | # index entries are read from disk. 799 | # 800 | # Note that this size refers to the size of the 801 | # serialized index information and not the size of the partition. 802 | column_index_cache_size_in_kb: 2 803 | 804 | # Number of simultaneous compactions to allow, NOT including 805 | # validation "compactions" for anti-entropy repair. Simultaneous 806 | # compactions can help preserve read performance in a mixed read/write 807 | # workload, by mitigating the tendency of small sstables to accumulate 808 | # during a single long running compactions. The default is usually 809 | # fine and if you experience problems with compaction running too 810 | # slowly or too fast, you should look at 811 | # compaction_throughput_mb_per_sec first. 812 | # 813 | # concurrent_compactors defaults to the smaller of (number of disks, 814 | # number of cores), with a minimum of 2 and a maximum of 8. 815 | # 816 | # If your data directories are backed by SSD, you should increase this 817 | # to the number of cores. 818 | #concurrent_compactors: 1 819 | 820 | # Throttles compaction to the given total throughput across the entire 821 | # system. The faster you insert data, the faster you need to compact in 822 | # order to keep the sstable count down, but in general, setting this to 823 | # 16 to 32 times the rate you are inserting data is more than sufficient. 824 | # Setting this to 0 disables throttling. Note that this account for all types 825 | # of compaction, including validation compaction. 826 | compaction_throughput_mb_per_sec: 16 827 | 828 | # When compacting, the replacement sstable(s) can be opened before they 829 | # are completely written, and used in place of the prior sstables for 830 | # any range that has been written. This helps to smoothly transfer reads 831 | # between the sstables, reducing page cache churn and keeping hot rows hot 832 | sstable_preemptive_open_interval_in_mb: 50 833 | 834 | # Throttles all outbound streaming file transfers on this node to the 835 | # given total throughput in Mbps. This is necessary because Cassandra does 836 | # mostly sequential IO when streaming data during bootstrap or repair, which 837 | # can lead to saturating the network connection and degrading rpc performance. 838 | # When unset, the default is 200 Mbps or 25 MB/s. 839 | # stream_throughput_outbound_megabits_per_sec: 200 840 | 841 | # Throttles all streaming file transfer between the datacenters, 842 | # this setting allows users to throttle inter dc stream throughput in addition 843 | # to throttling all network stream traffic as configured with 844 | # stream_throughput_outbound_megabits_per_sec 845 | # When unset, the default is 200 Mbps or 25 MB/s 846 | # inter_dc_stream_throughput_outbound_megabits_per_sec: 200 847 | 848 | # How long the coordinator should wait for read operations to complete 849 | read_request_timeout_in_ms: 5000 850 | # How long the coordinator should wait for seq or index scans to complete 851 | range_request_timeout_in_ms: 10000 852 | # How long the coordinator should wait for writes to complete 853 | write_request_timeout_in_ms: 2000 854 | # How long the coordinator should wait for counter writes to complete 855 | counter_write_request_timeout_in_ms: 5000 856 | # How long a coordinator should continue to retry a CAS operation 857 | # that contends with other proposals for the same row 858 | cas_contention_timeout_in_ms: 1000 859 | # How long the coordinator should wait for truncates to complete 860 | # (This can be much longer, because unless auto_snapshot is disabled 861 | # we need to flush first so we can snapshot before removing the data.) 862 | truncate_request_timeout_in_ms: 60000 863 | # The default timeout for other, miscellaneous operations 864 | request_timeout_in_ms: 10000 865 | 866 | # How long before a node logs slow queries. Select queries that take longer than 867 | # this timeout to execute, will generate an aggregated log message, so that slow queries 868 | # can be identified. Set this value to zero to disable slow query logging. 869 | slow_query_log_timeout_in_ms: 500 870 | 871 | # Enable operation timeout information exchange between nodes to accurately 872 | # measure request timeouts. If disabled, replicas will assume that requests 873 | # were forwarded to them instantly by the coordinator, which means that 874 | # under overload conditions we will waste that much extra time processing 875 | # already-timed-out requests. 876 | # 877 | # Warning: before enabling this property make sure to ntp is installed 878 | # and the times are synchronized between the nodes. 879 | cross_node_timeout: false 880 | 881 | # Set keep-alive period for streaming 882 | # This node will send a keep-alive message periodically with this period. 883 | # If the node does not receive a keep-alive message from the peer for 884 | # 2 keep-alive cycles the stream session times out and fail 885 | # Default value is 300s (5 minutes), which means stalled stream 886 | # times out in 10 minutes by default 887 | # streaming_keep_alive_period_in_secs: 300 888 | 889 | # phi value that must be reached for a host to be marked down. 890 | # most users should never need to adjust this. 891 | # phi_convict_threshold: 8 892 | 893 | # endpoint_snitch -- Set this to a class that implements 894 | # IEndpointSnitch. The snitch has two functions: 895 | # 896 | # - it teaches Cassandra enough about your network topology to route 897 | # requests efficiently 898 | # - it allows Cassandra to spread replicas around your cluster to avoid 899 | # correlated failures. It does this by grouping machines into 900 | # "datacenters" and "racks." Cassandra will do its best not to have 901 | # more than one replica on the same "rack" (which may not actually 902 | # be a physical location) 903 | # 904 | # CASSANDRA WILL NOT ALLOW YOU TO SWITCH TO AN INCOMPATIBLE SNITCH 905 | # ONCE DATA IS INSERTED INTO THE CLUSTER. This would cause data loss. 906 | # This means that if you start with the default SimpleSnitch, which 907 | # locates every node on "rack1" in "datacenter1", your only options 908 | # if you need to add another datacenter are GossipingPropertyFileSnitch 909 | # (and the older PFS). From there, if you want to migrate to an 910 | # incompatible snitch like Ec2Snitch you can do it by adding new nodes 911 | # under Ec2Snitch (which will locate them in a new "datacenter") and 912 | # decommissioning the old ones. 913 | # 914 | # Out of the box, Cassandra provides: 915 | # 916 | # SimpleSnitch: 917 | # Treats Strategy order as proximity. This can improve cache 918 | # locality when disabling read repair. Only appropriate for 919 | # single-datacenter deployments. 920 | # 921 | # GossipingPropertyFileSnitch 922 | # This should be your go-to snitch for production use. The rack 923 | # and datacenter for the local node are defined in 924 | # cassandra-rackdc.properties and propagated to other nodes via 925 | # gossip. If cassandra-topology.properties exists, it is used as a 926 | # fallback, allowing migration from the PropertyFileSnitch. 927 | # 928 | # PropertyFileSnitch: 929 | # Proximity is determined by rack and data center, which are 930 | # explicitly configured in cassandra-topology.properties. 931 | # 932 | # Ec2Snitch: 933 | # Appropriate for EC2 deployments in a single Region. Loads Region 934 | # and Availability Zone information from the EC2 API. The Region is 935 | # treated as the datacenter, and the Availability Zone as the rack. 936 | # Only private IPs are used, so this will not work across multiple 937 | # Regions. 938 | # 939 | # Ec2MultiRegionSnitch: 940 | # Uses public IPs as broadcast_address to allow cross-region 941 | # connectivity. (Thus, you should set seed addresses to the public 942 | # IP as well.) You will need to open the storage_port or 943 | # ssl_storage_port on the public IP firewall. (For intra-Region 944 | # traffic, Cassandra will switch to the private IP after 945 | # establishing a connection.) 946 | # 947 | # RackInferringSnitch: 948 | # Proximity is determined by rack and data center, which are 949 | # assumed to correspond to the 3rd and 2nd octet of each node's IP 950 | # address, respectively. Unless this happens to match your 951 | # deployment conventions, this is best used as an example of 952 | # writing a custom Snitch class and is provided in that spirit. 953 | # 954 | # You can use a custom Snitch by setting this to the full class name 955 | # of the snitch, which will be assumed to be on your classpath. 956 | endpoint_snitch: SimpleSnitch 957 | 958 | # controls how often to perform the more expensive part of host score 959 | # calculation 960 | dynamic_snitch_update_interval_in_ms: 100 961 | # controls how often to reset all host scores, allowing a bad host to 962 | # possibly recover 963 | dynamic_snitch_reset_interval_in_ms: 600000 964 | # if set greater than zero and read_repair_chance is < 1.0, this will allow 965 | # 'pinning' of replicas to hosts in order to increase cache capacity. 966 | # The badness threshold will control how much worse the pinned host has to be 967 | # before the dynamic snitch will prefer other replicas over it. This is 968 | # expressed as a double which represents a percentage. Thus, a value of 969 | # 0.2 means Cassandra would continue to prefer the static snitch values 970 | # until the pinned host was 20% worse than the fastest. 971 | dynamic_snitch_badness_threshold: 0.1 972 | 973 | # request_scheduler -- Set this to a class that implements 974 | # RequestScheduler, which will schedule incoming client requests 975 | # according to the specific policy. This is useful for multi-tenancy 976 | # with a single Cassandra cluster. 977 | # NOTE: This is specifically for requests from the client and does 978 | # not affect inter node communication. 979 | # org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place 980 | # org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of 981 | # client requests to a node with a separate queue for each 982 | # request_scheduler_id. The scheduler is further customized by 983 | # request_scheduler_options as described below. 984 | request_scheduler: org.apache.cassandra.scheduler.NoScheduler 985 | 986 | # Scheduler Options vary based on the type of scheduler 987 | # 988 | # NoScheduler 989 | # Has no options 990 | # 991 | # RoundRobin 992 | # throttle_limit 993 | # The throttle_limit is the number of in-flight 994 | # requests per client. Requests beyond 995 | # that limit are queued up until 996 | # running requests can complete. 997 | # The value of 80 here is twice the number of 998 | # concurrent_reads + concurrent_writes. 999 | # default_weight 1000 | # default_weight is optional and allows for 1001 | # overriding the default which is 1. 1002 | # weights 1003 | # Weights are optional and will default to 1 or the 1004 | # overridden default_weight. The weight translates into how 1005 | # many requests are handled during each turn of the 1006 | # RoundRobin, based on the scheduler id. 1007 | # 1008 | # request_scheduler_options: 1009 | # throttle_limit: 80 1010 | # default_weight: 5 1011 | # weights: 1012 | # Keyspace1: 1 1013 | # Keyspace2: 5 1014 | 1015 | # request_scheduler_id -- An identifier based on which to perform 1016 | # the request scheduling. Currently the only valid option is keyspace. 1017 | # request_scheduler_id: keyspace 1018 | 1019 | # Enable or disable inter-node encryption 1020 | # JVM defaults for supported SSL socket protocols and cipher suites can 1021 | # be replaced using custom encryption options. This is not recommended 1022 | # unless you have policies in place that dictate certain settings, or 1023 | # need to disable vulnerable ciphers or protocols in case the JVM cannot 1024 | # be updated. 1025 | # FIPS compliant settings can be configured at JVM level and should not 1026 | # involve changing encryption settings here: 1027 | # https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/FIPS.html 1028 | # *NOTE* No custom encryption options are enabled at the moment 1029 | # The available internode options are : all, none, dc, rack 1030 | # 1031 | # If set to dc cassandra will encrypt the traffic between the DCs 1032 | # If set to rack cassandra will encrypt the traffic between the racks 1033 | # 1034 | # The passwords used in these options must match the passwords used when generating 1035 | # the keystore and truststore. For instructions on generating these files, see: 1036 | # http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore 1037 | # 1038 | server_encryption_options: 1039 | internode_encryption: none 1040 | keystore: conf/.keystore 1041 | keystore_password: cassandra 1042 | truststore: conf/.truststore 1043 | truststore_password: cassandra 1044 | # More advanced defaults below: 1045 | # protocol: TLS 1046 | # algorithm: SunX509 1047 | # store_type: JKS 1048 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1049 | # require_client_auth: false 1050 | # require_endpoint_verification: false 1051 | 1052 | # enable or disable client/server encryption. 1053 | client_encryption_options: 1054 | enabled: false 1055 | # If enabled and optional is set to true encrypted and unencrypted connections are handled. 1056 | optional: false 1057 | keystore: conf/.keystore 1058 | keystore_password: cassandra 1059 | # require_client_auth: false 1060 | # Set trustore and truststore_password if require_client_auth is true 1061 | # truststore: conf/.truststore 1062 | # truststore_password: cassandra 1063 | # More advanced defaults below: 1064 | # protocol: TLS 1065 | # algorithm: SunX509 1066 | # store_type: JKS 1067 | # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] 1068 | 1069 | # internode_compression controls whether traffic between nodes is 1070 | # compressed. 1071 | # Can be: 1072 | # 1073 | # all 1074 | # all traffic is compressed 1075 | # 1076 | # dc 1077 | # traffic between different datacenters is compressed 1078 | # 1079 | # none 1080 | # nothing is compressed. 1081 | internode_compression: dc 1082 | 1083 | # Enable or disable tcp_nodelay for inter-dc communication. 1084 | # Disabling it will result in larger (but fewer) network packets being sent, 1085 | # reducing overhead from the TCP protocol itself, at the cost of increasing 1086 | # latency if you block for cross-datacenter responses. 1087 | inter_dc_tcp_nodelay: false 1088 | 1089 | # TTL for different trace types used during logging of the repair process. 1090 | tracetype_query_ttl: 86400 1091 | tracetype_repair_ttl: 604800 1092 | 1093 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1094 | # This threshold can be adjusted to minimize logging if necessary 1095 | # gc_log_threshold_in_ms: 200 1096 | 1097 | # If unset, all GC Pauses greater than gc_log_threshold_in_ms will log at 1098 | # INFO level 1099 | # UDFs (user defined functions) are disabled by default. 1100 | # As of Cassandra 3.0 there is a sandbox in place that should prevent execution of evil code. 1101 | enable_user_defined_functions: false 1102 | 1103 | # Enables scripted UDFs (JavaScript UDFs). 1104 | # Java UDFs are always enabled, if enable_user_defined_functions is true. 1105 | # Enable this option to be able to use UDFs with "language javascript" or any custom JSR-223 provider. 1106 | # This option has no effect, if enable_user_defined_functions is false. 1107 | enable_scripted_user_defined_functions: false 1108 | 1109 | # The default Windows kernel timer and scheduling resolution is 15.6ms for power conservation. 1110 | # Lowering this value on Windows can provide much tighter latency and better throughput, however 1111 | # some virtualized environments may see a negative performance impact from changing this setting 1112 | # below their system default. The sysinternals 'clockres' tool can confirm your system's default 1113 | # setting. 1114 | windows_timer_interval: 1 1115 | 1116 | 1117 | # Enables encrypting data at-rest (on disk). Different key providers can be plugged in, but the default reads from 1118 | # a JCE-style keystore. A single keystore can hold multiple keys, but the one referenced by 1119 | # the "key_alias" is the only key that will be used for encrypt opertaions; previously used keys 1120 | # can still (and should!) be in the keystore and will be used on decrypt operations 1121 | # (to handle the case of key rotation). 1122 | # 1123 | # It is strongly recommended to download and install Java Cryptography Extension (JCE) 1124 | # Unlimited Strength Jurisdiction Policy Files for your version of the JDK. 1125 | # (current link: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html) 1126 | # 1127 | # Currently, only the following file types are supported for transparent data encryption, although 1128 | # more are coming in future cassandra releases: commitlog, hints 1129 | transparent_data_encryption_options: 1130 | enabled: false 1131 | chunk_length_kb: 64 1132 | cipher: AES/CBC/PKCS5Padding 1133 | key_alias: testing:1 1134 | # CBC IV length for AES needs to be 16 bytes (which is also the default size) 1135 | # iv_length: 16 1136 | key_provider: 1137 | - class_name: org.apache.cassandra.security.JKSKeyProvider 1138 | parameters: 1139 | - keystore: conf/.keystore 1140 | keystore_password: cassandra 1141 | store_type: JCEKS 1142 | key_password: cassandra 1143 | 1144 | 1145 | ##################### 1146 | # SAFETY THRESHOLDS # 1147 | ##################### 1148 | 1149 | # When executing a scan, within or across a partition, we need to keep the 1150 | # tombstones seen in memory so we can return them to the coordinator, which 1151 | # will use them to make sure other replicas also know about the deleted rows. 1152 | # With workloads that generate a lot of tombstones, this can cause performance 1153 | # problems and even exaust the server heap. 1154 | # (http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets) 1155 | # Adjust the thresholds here if you understand the dangers and want to 1156 | # scan more tombstones anyway. These thresholds may also be adjusted at runtime 1157 | # using the StorageService mbean. 1158 | tombstone_warn_threshold: 1000 1159 | tombstone_failure_threshold: 100000 1160 | 1161 | # Log WARN on any multiple-partition batch size exceeding this value. 5kb per batch by default. 1162 | # Caution should be taken on increasing the size of this threshold as it can lead to node instability. 1163 | batch_size_warn_threshold_in_kb: 5 1164 | 1165 | # Fail any multiple-partition batch exceeding this value. 50kb (10x warn threshold) by default. 1166 | batch_size_fail_threshold_in_kb: 50 1167 | 1168 | # Log WARN on any batches not of type LOGGED than span across more partitions than this limit 1169 | unlogged_batch_across_partitions_warn_threshold: 10 1170 | 1171 | # Log a warning when compacting partitions larger than this value 1172 | compaction_large_partition_warning_threshold_mb: 100 1173 | 1174 | # GC Pauses greater than gc_warn_threshold_in_ms will be logged at WARN level 1175 | # Adjust the threshold based on your application throughput requirement 1176 | # By default, Cassandra logs GC Pauses greater than 200 ms at INFO level 1177 | gc_warn_threshold_in_ms: 1000 1178 | 1179 | # Maximum size of any value in SSTables. Safety measure to detect SSTable corruption 1180 | # early. Any value size larger than this threshold will result into marking an SSTable 1181 | # as corrupted. 1182 | # max_value_size_in_mb: 256 1183 | 1184 | # Back-pressure settings # 1185 | # If enabled, the coordinator will apply the back-pressure strategy specified below to each mutation 1186 | # sent to replicas, with the aim of reducing pressure on overloaded replicas. 1187 | back_pressure_enabled: false 1188 | # The back-pressure strategy applied. 1189 | # The default implementation, RateBasedBackPressure, takes three arguments: 1190 | # high ratio, factor, and flow type, and uses the ratio between incoming mutation responses and outgoing mutation requests. 1191 | # If below high ratio, outgoing mutations are rate limited according to the incoming rate decreased by the given factor; 1192 | # if above high ratio, the rate limiting is increased by the given factor; 1193 | # such factor is usually best configured between 1 and 10, use larger values for a faster recovery 1194 | # at the expense of potentially more dropped mutations; 1195 | # the rate limiting is applied according to the flow type: if FAST, it's rate limited at the speed of the fastest replica, 1196 | # if SLOW at the speed of the slowest one. 1197 | # New strategies can be added. Implementors need to implement org.apache.cassandra.net.BackpressureStrategy and 1198 | # provide a public constructor accepting a Map. 1199 | back_pressure_strategy: 1200 | - class_name: org.apache.cassandra.net.RateBasedBackPressure 1201 | parameters: 1202 | - high_ratio: 0.90 1203 | factor: 5 1204 | flow: FAST 1205 | 1206 | # Coalescing Strategies # 1207 | # Coalescing multiples messages turns out to significantly boost message processing throughput (think doubling or more). 1208 | # On bare metal, the floor for packet processing throughput is high enough that many applications won't notice, but in 1209 | # virtualized environments, the point at which an application can be bound by network packet processing can be 1210 | # surprisingly low compared to the throughput of task processing that is possible inside a VM. It's not that bare metal 1211 | # doesn't benefit from coalescing messages, it's that the number of packets a bare metal network interface can process 1212 | # is sufficient for many applications such that no load starvation is experienced even without coalescing. 1213 | # There are other benefits to coalescing network messages that are harder to isolate with a simple metric like messages 1214 | # per second. By coalescing multiple tasks together, a network thread can process multiple messages for the cost of one 1215 | # trip to read from a socket, and all the task submission work can be done at the same time reducing context switching 1216 | # and increasing cache friendliness of network message processing. 1217 | # See CASSANDRA-8692 for details. 1218 | 1219 | # Strategy to use for coalescing messages in OutboundTcpConnection. 1220 | # Can be fixed, movingaverage, timehorizon, disabled (default). 1221 | # You can also specify a subclass of CoalescingStrategies.CoalescingStrategy by name. 1222 | # otc_coalescing_strategy: DISABLED 1223 | 1224 | # How many microseconds to wait for coalescing. For fixed strategy this is the amount of time after the first 1225 | # message is received before it will be sent with any accompanying messages. For moving average this is the 1226 | # maximum amount of time that will be waited as well as the interval at which messages must arrive on average 1227 | # for coalescing to be enabled. 1228 | # otc_coalescing_window_us: 200 1229 | 1230 | # Do not try to coalesce messages if we already got that many messages. This should be more than 2 and less than 128. 1231 | # otc_coalescing_enough_coalesced_messages: 8 1232 | 1233 | # How many milliseconds to wait between two expiration runs on the backlog (queue) of the OutboundTcpConnection. 1234 | # Expiration is done if messages are piling up in the backlog. Droppable messages are expired to free the memory 1235 | # taken by expired messages. The interval should be between 0 and 1000, and in most installations the default value 1236 | # will be appropriate. A smaller value could potentially expire messages slightly sooner at the expense of more CPU 1237 | # time and queue contention while iterating the backlog of messages. 1238 | # An interval of 0 disables any wait time, which is the behavior of former Cassandra versions. 1239 | # 1240 | # otc_backlog_expiration_interval_ms: 200 1241 | -------------------------------------------------------------------------------- /cassandra-cdc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.smartcat 7 | cassandra-cdc 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | CassandraCDC 12 | Custom Cassandra CDC Reader 13 | 14 | 15 | 16 | UTF-8 17 | UTF-8 18 | 1.8 19 | 1.8 20 | 3.11.0 21 | 0.10.2.0 22 | 3.5.1 23 | 2.5.2 24 | 2.8.2 25 | 2.4.3 26 | 2.6 27 | 2.7 28 | 29 | 30 | 31 | 32 | org.apache.cassandra 33 | cassandra-all 34 | ${version.cassandra-all} 35 | 36 | 37 | org.apache.kafka 38 | connect-api 39 | ${version.kafka} 40 | 41 | 42 | org.apache.kafka 43 | connect-runtime 44 | ${version.kafka} 45 | 46 | 47 | org.slf4j 48 | slf4j-log4j12 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-jar-plugin 60 | ${version.plugin.jar} 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-resources-plugin 65 | ${version.plugin.resources} 66 | 67 | 68 | 69 | org.apache.maven.plugins 70 | maven-install-plugin 71 | ${version.plugin.install} 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-shade-plugin 76 | ${version.plugin.shade} 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-deploy-plugin 81 | ${version.plugin.deploy} 82 | 83 | true 84 | 85 | 86 | 87 | org.apache.maven.plugins 88 | maven-compiler-plugin 89 | ${version.plugin.compiler} 90 | true 91 | 92 | ${source.level} 93 | ${code.level} 94 | ${project.build.sourceEncoding} 95 | 96 | 97 | 98 | 99 | 100 | 101 | org.apache.maven.plugins 102 | maven-shade-plugin 103 | 104 | 105 | package 106 | 107 | shade 108 | 109 | 110 | false 111 | false 112 | 113 | 114 | classworlds:classworlds 115 | junit:junit 116 | org.apache.maven:lib:tests 117 | 118 | 119 | 120 | 122 | io.smartcat.cassandra.cdc.Reader 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /cassandra-cdc/src/main/java/io/smartcat/cassandra/cdc/CustomCommitLogReadHandler.java: -------------------------------------------------------------------------------- 1 | package io.smartcat.cassandra.cdc; 2 | 3 | import org.apache.cassandra.config.ColumnDefinition; 4 | import org.apache.cassandra.db.Clustering; 5 | import org.apache.cassandra.db.ClusteringBound; 6 | import org.apache.cassandra.db.ClusteringPrefix; 7 | import org.apache.cassandra.db.Mutation; 8 | import org.apache.cassandra.db.commitlog.CommitLogDescriptor; 9 | import org.apache.cassandra.db.commitlog.CommitLogReadHandler; 10 | import org.apache.cassandra.db.partitions.Partition; 11 | import org.apache.cassandra.db.partitions.PartitionUpdate; 12 | import org.apache.cassandra.db.rows.Cell; 13 | import org.apache.cassandra.db.rows.Row; 14 | import org.apache.cassandra.db.rows.Unfiltered; 15 | import org.apache.cassandra.db.rows.UnfilteredRowIterator; 16 | import org.apache.kafka.clients.producer.KafkaProducer; 17 | import org.apache.kafka.clients.producer.Producer; 18 | import org.apache.kafka.clients.producer.ProducerRecord; 19 | import org.json.simple.JSONObject; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import java.io.IOException; 24 | import java.util.ArrayList; 25 | import java.util.Iterator; 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | public class CustomCommitLogReadHandler implements CommitLogReadHandler { 30 | 31 | private static final Logger LOGGER = LoggerFactory.getLogger(CustomCommitLogReadHandler.class); 32 | 33 | private final String keyspace; 34 | private final String table; 35 | private final String topic; 36 | private final Producer producer; 37 | 38 | public CustomCommitLogReadHandler(Map configuration) { 39 | keyspace = (String) YamlUtils.select(configuration, "cassandra.keyspace"); 40 | table = (String) YamlUtils.select(configuration, "cassandra.table"); 41 | topic = (String) YamlUtils.select(configuration, "kafka.topic"); 42 | producer = new KafkaProducer<>((Map) YamlUtils.select(configuration, "kafka.configuration")); 43 | } 44 | 45 | @Override 46 | public void handleMutation(Mutation mutation, int size, int entryLocation, CommitLogDescriptor descriptor) { 47 | LOGGER.debug("Handle mutation started..."); 48 | for (PartitionUpdate partitionUpdate : mutation.getPartitionUpdates()) { 49 | process(partitionUpdate); 50 | } 51 | LOGGER.debug("Handle mutation finished..."); 52 | } 53 | 54 | @Override 55 | public void handleUnrecoverableError(CommitLogReadException exception) throws IOException { 56 | LOGGER.debug("Handle unrecoverable error called."); 57 | throw new RuntimeException(exception); 58 | } 59 | 60 | @Override 61 | public boolean shouldSkipSegmentOnError(CommitLogReadException exception) throws IOException { 62 | LOGGER.debug("Should skip segment on error."); 63 | exception.printStackTrace(); 64 | return true; 65 | } 66 | 67 | 68 | @SuppressWarnings("unchecked") 69 | private void process(Partition partition) { 70 | LOGGER.debug("Process method started..."); 71 | if (!partition.metadata().ksName.equals(keyspace)) { 72 | LOGGER.debug("Keyspace should be '{}' but is '{}'.", keyspace, partition.metadata().ksName); 73 | return; 74 | } 75 | if (!partition.metadata().cfName.equals(table)) { 76 | LOGGER.debug("Table should be '{} but is '{}'.", table, partition.metadata().cfName); 77 | return; 78 | } 79 | String key = getKey(partition); 80 | JSONObject obj = new JSONObject(); 81 | obj.put("key", key); 82 | if (partitionIsDeleted(partition)) { 83 | obj.put("partitionDeleted", true); 84 | } else { 85 | UnfilteredRowIterator it = partition.unfilteredIterator(); 86 | List rows = new ArrayList<>(); 87 | while (it.hasNext()) { 88 | Unfiltered un = it.next(); 89 | if (un.isRow()) { 90 | JSONObject jsonRow = new JSONObject(); 91 | Clustering clustering = (Clustering) un.clustering(); 92 | String clusteringKey = clustering.toCQLString(partition.metadata()); 93 | jsonRow.put("clusteringKey", clusteringKey); 94 | Row row = partition.getRow(clustering); 95 | 96 | if (rowIsDeleted(row)) { 97 | obj.put("rowDeleted", true); 98 | } else { 99 | Iterator cells = row.cells().iterator(); 100 | Iterator columns = row.columns().iterator(); 101 | List cellObjects = new ArrayList<>(); 102 | while (cells.hasNext() && columns.hasNext()) { 103 | JSONObject jsonCell = new JSONObject(); 104 | ColumnDefinition columnDef = columns.next(); 105 | Cell cell = cells.next(); 106 | jsonCell.put("name", columnDef.name.toString()); 107 | if (cell.isTombstone()) { 108 | jsonCell.put("deleted", true); 109 | } else { 110 | String data = columnDef.type.getString(cell.value()); 111 | jsonCell.put("value", data); 112 | } 113 | cellObjects.add(jsonCell); 114 | } 115 | jsonRow.put("cells", cellObjects); 116 | } 117 | rows.add(jsonRow); 118 | } else if (un.isRangeTombstoneMarker()) { 119 | obj.put("rowRangeDeleted", true); 120 | ClusteringBound bound = (ClusteringBound) un.clustering(); 121 | List bounds = new ArrayList<>(); 122 | for (int i = 0; i < bound.size(); i++) { 123 | String clusteringBound = partition.metadata().comparator.subtype(i).getString(bound.get(i)); 124 | JSONObject boundObject = new JSONObject(); 125 | boundObject.put("clusteringKey", clusteringBound); 126 | if (i == bound.size() - 1) { 127 | if (bound.kind().isStart()) { 128 | boundObject.put("inclusive", 129 | bound.kind() == ClusteringPrefix.Kind.INCL_START_BOUND ? true : false); 130 | } 131 | if (bound.kind().isEnd()) { 132 | boundObject.put("inclusive", 133 | bound.kind() == ClusteringPrefix.Kind.INCL_END_BOUND ? true : false); 134 | } 135 | } 136 | bounds.add(boundObject); 137 | } 138 | obj.put((bound.kind().isStart() ? "start" : "end"), bounds); 139 | } 140 | } 141 | obj.put("rows", rows); 142 | } 143 | LOGGER.debug("Creating json value..."); 144 | String value = obj.toJSONString(); 145 | LOGGER.debug("Created json value '{}'", value); 146 | ProducerRecord record = new ProducerRecord<>(topic, key, value); 147 | LOGGER.debug("Created producer record with topic {}, key {}, value {}", topic, key, value); 148 | producer.send(record); 149 | LOGGER.debug("Sent record to kafka."); 150 | } 151 | 152 | private boolean partitionIsDeleted(Partition partition) { 153 | return partition.partitionLevelDeletion().markedForDeleteAt() > Long.MIN_VALUE; 154 | } 155 | 156 | private boolean rowIsDeleted(Row row) { 157 | return row.deletion().time().markedForDeleteAt() > Long.MIN_VALUE; 158 | } 159 | 160 | private String getKey(Partition partition) { 161 | return partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey()); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /cassandra-cdc/src/main/java/io/smartcat/cassandra/cdc/Reader.java: -------------------------------------------------------------------------------- 1 | package io.smartcat.cassandra.cdc; 2 | 3 | import org.apache.cassandra.config.DatabaseDescriptor; 4 | import org.apache.cassandra.config.Schema; 5 | import org.apache.cassandra.db.commitlog.CommitLogReader; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.IOException; 10 | import java.nio.file.*; 11 | import java.util.Map; 12 | 13 | import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; 14 | 15 | public class Reader { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(CustomCommitLogReadHandler.class); 18 | 19 | private final WatchService watcher; 20 | private final Path dir; 21 | private final WatchKey key; 22 | private final CommitLogReader commitLogReader; 23 | private final CustomCommitLogReadHandler commitLogReadHander; 24 | 25 | /** 26 | * Creates a WatchService and registers the given directory 27 | */ 28 | public Reader(Map configuration) throws IOException { 29 | this.dir = Paths.get((String) YamlUtils.select(configuration, "cassandra.cdc_raw_directory")); 30 | watcher = FileSystems.getDefault().newWatchService(); 31 | key = dir.register(watcher, ENTRY_CREATE); 32 | commitLogReader = new CommitLogReader(); 33 | commitLogReadHander = new CustomCommitLogReadHandler(configuration); 34 | DatabaseDescriptor.toolInitialization(); 35 | Schema.instance.loadFromDisk(false); 36 | } 37 | 38 | /** 39 | * Process all events for keys queued to the watcher 40 | * 41 | * @throws InterruptedException 42 | * @throws IOException 43 | */ 44 | public void processEvents() throws InterruptedException, IOException { 45 | while (true) { 46 | WatchKey aKey = watcher.take(); 47 | if (!key.equals(aKey)) { 48 | LOGGER.error("WatchKey not recognized."); 49 | continue; 50 | } 51 | for (WatchEvent event : key.pollEvents()) { 52 | WatchEvent.Kind kind = event.kind(); 53 | if (kind != ENTRY_CREATE) { 54 | continue; 55 | } 56 | 57 | // Context for directory entry event is the file name of entry 58 | WatchEvent ev = (WatchEvent) event; 59 | Path relativePath = ev.context(); 60 | Path absolutePath = dir.resolve(relativePath); 61 | processCommitLogSegment(absolutePath); 62 | Files.delete(absolutePath); 63 | 64 | // print out event 65 | LOGGER.debug("{}: {}", event.kind().name(), absolutePath); 66 | } 67 | key.reset(); 68 | } 69 | } 70 | 71 | public static void main(String[] args) throws IOException, InterruptedException { 72 | Map configuration = YamlUtils.load(args[0]); 73 | new Reader(configuration).processEvents(); 74 | } 75 | 76 | private void processCommitLogSegment(Path path) throws IOException { 77 | LOGGER.debug("Processing commitlog segment..."); 78 | commitLogReader.readCommitLogSegment(commitLogReadHander, path.toFile(), false); 79 | LOGGER.debug("Commitlog segment processed."); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /cassandra-cdc/src/main/java/io/smartcat/cassandra/cdc/YamlUtils.java: -------------------------------------------------------------------------------- 1 | package io.smartcat.cassandra.cdc; 2 | 3 | import org.apache.cassandra.io.util.FileUtils; 4 | import org.yaml.snakeyaml.Yaml; 5 | 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.InputStream; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.regex.Matcher; 13 | import java.util.regex.Pattern; 14 | 15 | public class YamlUtils { 16 | 17 | private static final Pattern PATH_INDEX = Pattern.compile("^(.+)\\[([0-9]+)\\]$"); 18 | 19 | @SuppressWarnings("unchecked") 20 | public static Map load(String filePath) { 21 | InputStream stream = null; 22 | try { 23 | stream = new FileInputStream(new File(filePath)); 24 | Yaml yaml = new Yaml(); 25 | return (Map) yaml.load(stream); 26 | } catch (Exception e) { 27 | throw new RuntimeException(e); 28 | } finally { 29 | FileUtils.closeQuietly(stream); 30 | } 31 | } 32 | 33 | public static Object select(Map configuration, String path) { 34 | List pathComponents = toPathList(path); 35 | if (pathComponents.isEmpty()) { 36 | throw new IllegalArgumentException( 37 | String.format("Given path expression %s has to have at least one component.", pathComponents)); 38 | } 39 | return extractPathRecursive(configuration, pathComponents); 40 | } 41 | 42 | private static Object extractPathRecursive(Object input, List path) { 43 | if (path.isEmpty()) { 44 | return input; 45 | } else { 46 | Object obj; 47 | Object firstElement = path.get(0); 48 | if (firstElement instanceof Integer) { 49 | Integer childIndex = (Integer) firstElement; 50 | obj = ((List) input).get(childIndex); 51 | } else { 52 | String childName = (String) firstElement; 53 | obj = ((Map) input).get(childName); 54 | } 55 | return extractPathRecursive(obj, path.subList(1, path.size())); 56 | } 57 | } 58 | 59 | private static List toPathList(String jsonPath) { 60 | String[] pathComponents = jsonPath.split("\\."); 61 | List pathList = new ArrayList<>(); 62 | for (String component : pathComponents) { 63 | Matcher m = PATH_INDEX.matcher(component); 64 | if (m.matches()) { 65 | pathList.add(m.group(1)); 66 | pathList.add(Integer.valueOf(m.group(2))); 67 | } else { 68 | pathList.add(component); 69 | } 70 | } 71 | return pathList; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cassandra-cdc/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] %logger{1} - %msg%n 8 | 9 | 10 | 11 | 12 | ${LOG_DIR}/berserker.log 13 | 14 | %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] %logger{1} - %msg%n 15 | 16 | 17 | 18 | ${LOG_DIR}/archived/berserker.%d{yyyy-MM-dd}.%i.log 19 | 20 | 10MB 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /cassandra-trigger/README.md: -------------------------------------------------------------------------------- 1 | # Cassandra Trigger 2 | 3 | Purpose of this project is to serve as an example for how to implement triggers in cassandra. 4 | 5 | ## Create a JAR 6 | 7 | This is a common Maven project with shade plugin to include all dependencies into JAR. To build it, just run: 8 | 9 | `mvn clean install` 10 | 11 | ## Use JAR in Cassandra 12 | 13 | In order to create trigger in cassandra, JAR file needs to be places under `$CASSANDRA_CONFIG/triggers` directory on every node which will be used as coordinator. Also, path to `KafkaTrigger.yml` (line 37) needs to be adjusted to location where actuall `KafkaTrigger.yml` file is placed. Content of the file should be: 14 | 15 | ``` 16 | bootstrap.servers: cluster_kafka_1:9092,cluster_kafka_2:9092 17 | topic.name: trigger-topic 18 | ``` 19 | 20 | Note that content matches infrastcurture setup which is created using `docker-compose` command from `cluster` directory. Docker compose file used is: 21 | 22 | ``` 23 | version: '3.3' 24 | services: 25 | zookeeper: 26 | image: wurstmeister/zookeeper:3.4.6 27 | ports: 28 | - "2181:2181" 29 | kafka: 30 | image: wurstmeister/kafka:0.10.1.1 31 | ports: 32 | - 9092 33 | environment: 34 | HOSTNAME_COMMAND: "ifconfig | awk '/Bcast:.+/{print $$2}' | awk -F\":\" '{print $$2}'" 35 | KAFKA_ADVERTISED_PORT: 9092 36 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 37 | cassandra-seed: 38 | image: trigger-cassandra 39 | ports: 40 | - 7199 41 | - 9042 42 | environment: 43 | CASSANDRA_CLUSTER_NAME: test-cluster 44 | cassandra: 45 | image: trigger-cassandra 46 | ports: 47 | - 7199 48 | - 9042 49 | environment: 50 | CASSANDRA_CLUSTER_NAME: test-cluster 51 | CASSANDRA_SEEDS: cassandra-seed 52 | ``` 53 | 54 | `trigger-cassandra` docker image is custom built for this usage. It includes `KafkaTrigger.yml` and JAR file: 55 | 56 | ``` 57 | FROM cassandra:3.11.0 58 | COPY KafkaTrigger.yml /etc/cassandra/triggers/KafkaTrigger.yml 59 | COPY cassandra-trigger-0.0.1-SNAPSHOT.jar /etc/cassandra/triggers/trigger.jar 60 | CMD ["cassandra", "-f"] 61 | ``` 62 | 63 | If you intend using JAR file in different infrastructure setup (virtual machines, different docker setup, cloud environment) configuration needs to be changed to match that infrastructure. 64 | 65 | ## Create a trigger 66 | 67 | To add a trigger to a table, just execute `CREATE TRIGGER kafka_trigger ON movies_by_genre USING 'io.smartcat.cassandra.trigger.KafkaTrigger';`. 68 | 69 | -------------------------------------------------------------------------------- /cassandra-trigger/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.smartcat 7 | cassandra-trigger 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | CassandraTrigger 12 | Custom Cassandra trigger 13 | 14 | 15 | 16 | UTF-8 17 | UTF-8 18 | 1.8 19 | 1.8 20 | 3.11.0 21 | 0.10.2.0 22 | 3.5.1 23 | 2.5.2 24 | 2.8.2 25 | 2.4.3 26 | 2.6 27 | 2.7 28 | 29 | 30 | 31 | 32 | org.apache.cassandra 33 | cassandra-all 34 | ${version.cassandra-all} 35 | 36 | 37 | org.apache.kafka 38 | connect-api 39 | ${version.kafka} 40 | 41 | 42 | org.apache.kafka 43 | connect-runtime 44 | ${version.kafka} 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-jar-plugin 54 | ${version.plugin.jar} 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-resources-plugin 59 | ${version.plugin.resources} 60 | 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-install-plugin 65 | ${version.plugin.install} 66 | 67 | 68 | org.apache.maven.plugins 69 | maven-shade-plugin 70 | ${version.plugin.shade} 71 | 72 | 73 | org.apache.maven.plugins 74 | maven-deploy-plugin 75 | ${version.plugin.deploy} 76 | 77 | true 78 | 79 | 80 | 81 | org.apache.maven.plugins 82 | maven-compiler-plugin 83 | ${version.plugin.compiler} 84 | true 85 | 86 | ${source.level} 87 | ${code.level} 88 | ${project.build.sourceEncoding} 89 | 90 | 91 | 92 | 93 | 94 | 95 | org.apache.maven.plugins 96 | maven-shade-plugin 97 | 98 | 99 | package 100 | 101 | shade 102 | 103 | 104 | false 105 | false 106 | 107 | 108 | classworlds:classworlds 109 | junit:junit 110 | org.apache.maven:lib:tests 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /cassandra-trigger/src/main/java/io/smartcat/cassandra/trigger/KafkaTrigger.java: -------------------------------------------------------------------------------- 1 | package io.smartcat.cassandra.trigger; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.InputStream; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.concurrent.LinkedBlockingDeque; 13 | import java.util.concurrent.ThreadPoolExecutor; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | import org.apache.cassandra.config.ColumnDefinition; 17 | import org.apache.cassandra.db.Clustering; 18 | import org.apache.cassandra.db.ClusteringBound; 19 | import org.apache.cassandra.db.ClusteringPrefix; 20 | import org.apache.cassandra.db.Mutation; 21 | import org.apache.cassandra.db.partitions.Partition; 22 | import org.apache.cassandra.db.rows.Cell; 23 | import org.apache.cassandra.db.rows.Row; 24 | import org.apache.cassandra.db.rows.Unfiltered; 25 | import org.apache.cassandra.db.rows.UnfilteredRowIterator; 26 | import org.apache.cassandra.io.util.FileUtils; 27 | import org.apache.cassandra.triggers.ITrigger; 28 | import org.apache.kafka.clients.producer.KafkaProducer; 29 | import org.apache.kafka.clients.producer.Producer; 30 | import org.apache.kafka.clients.producer.ProducerRecord; 31 | import org.apache.kafka.common.serialization.StringSerializer; 32 | import org.json.simple.JSONObject; 33 | import org.yaml.snakeyaml.Yaml; 34 | 35 | public class KafkaTrigger implements ITrigger { 36 | 37 | private static final String FILE_PATH = "/etc/cassandra/triggers/KafkaTrigger.yml"; 38 | private static final String TOPIC_NAME = "topic.name"; 39 | 40 | private final String topic; 41 | private final Producer producer; 42 | private final ThreadPoolExecutor threadPoolExecutor; 43 | 44 | public KafkaTrigger() { 45 | Map configuration = loadConfiguration(); 46 | topic = (String) getProperty(TOPIC_NAME, configuration); 47 | StringSerializer keySerializer = getSerializer(configuration, true); 48 | StringSerializer valueSerializer = getSerializer(configuration, false); 49 | producer = new KafkaProducer<>(configuration, keySerializer, valueSerializer); 50 | threadPoolExecutor = new ThreadPoolExecutor(4, 20, 30, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); 51 | } 52 | 53 | @Override 54 | public Collection augment(Partition partition) { 55 | threadPoolExecutor.execute(() -> readPartition(partition)); 56 | return Collections.emptyList(); 57 | } 58 | 59 | @SuppressWarnings("unchecked") 60 | private void readPartition(Partition partition) { 61 | String key = getKey(partition); 62 | JSONObject obj = new JSONObject(); 63 | obj.put("key", key); 64 | if (partitionIsDeleted(partition)) { 65 | obj.put("partitionDeleted", true); 66 | } else { 67 | UnfilteredRowIterator it = partition.unfilteredIterator(); 68 | List rows = new ArrayList<>(); 69 | while (it.hasNext()) { 70 | Unfiltered un = it.next(); 71 | if (un.isRow()) { 72 | JSONObject jsonRow = new JSONObject(); 73 | Clustering clustering = (Clustering) un.clustering(); 74 | String clusteringKey = clustering.toCQLString(partition.metadata()); 75 | jsonRow.put("clusteringKey", clusteringKey); 76 | Row row = partition.getRow(clustering); 77 | 78 | if (rowIsDeleted(row)) { 79 | obj.put("rowDeleted", true); 80 | } else { 81 | Iterator cells = row.cells().iterator(); 82 | Iterator columns = row.columns().iterator(); 83 | List cellObjects = new ArrayList<>(); 84 | while (cells.hasNext() && columns.hasNext()) { 85 | JSONObject jsonCell = new JSONObject(); 86 | ColumnDefinition columnDef = columns.next(); 87 | Cell cell = cells.next(); 88 | jsonCell.put("name", columnDef.name.toString()); 89 | if (cell.isTombstone()) { 90 | jsonCell.put("deleted", true); 91 | } else { 92 | String data = columnDef.type.getString(cell.value()); 93 | jsonCell.put("value", data); 94 | } 95 | cellObjects.add(jsonCell); 96 | } 97 | jsonRow.put("cells", cellObjects); 98 | } 99 | rows.add(jsonRow); 100 | } else if (un.isRangeTombstoneMarker()) { 101 | obj.put("rowRangeDeleted", true); 102 | ClusteringBound bound = (ClusteringBound) un.clustering(); 103 | List bounds = new ArrayList<>(); 104 | for (int i = 0; i < bound.size(); i++) { 105 | String clusteringBound = partition.metadata().comparator.subtype(i).getString(bound.get(i)); 106 | JSONObject boundObject = new JSONObject(); 107 | boundObject.put("clusteringKey", clusteringBound); 108 | if (i == bound.size() - 1) { 109 | if (bound.kind().isStart()) { 110 | boundObject.put("inclusive", 111 | bound.kind() == ClusteringPrefix.Kind.INCL_START_BOUND ? true : false); 112 | } 113 | if (bound.kind().isEnd()) { 114 | boundObject.put("inclusive", 115 | bound.kind() == ClusteringPrefix.Kind.INCL_END_BOUND ? true : false); 116 | } 117 | } 118 | bounds.add(boundObject); 119 | } 120 | obj.put((bound.kind().isStart() ? "start" : "end"), bounds); 121 | } 122 | } 123 | obj.put("rows", rows); 124 | } 125 | String value = obj.toJSONString(); 126 | ProducerRecord record = new ProducerRecord<>(topic, key, value); 127 | producer.send(record); 128 | } 129 | 130 | private boolean partitionIsDeleted(Partition partition) { 131 | return partition.partitionLevelDeletion().markedForDeleteAt() > Long.MIN_VALUE; 132 | } 133 | 134 | private boolean rowIsDeleted(Row row) { 135 | return row.deletion().time().markedForDeleteAt() > Long.MIN_VALUE; 136 | } 137 | 138 | private String getKey(Partition partition) { 139 | return partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey()); 140 | } 141 | 142 | @SuppressWarnings("unchecked") 143 | private Map loadConfiguration() { 144 | InputStream stream = null; 145 | try { 146 | stream = new FileInputStream(new File(FILE_PATH)); 147 | Yaml yaml = new Yaml(); 148 | return (Map) yaml.load(stream); 149 | } catch (Exception e) { 150 | throw new RuntimeException(e); 151 | } finally { 152 | FileUtils.closeQuietly(stream); 153 | } 154 | } 155 | 156 | private Object getProperty(String key, Map configuration) { 157 | if (!configuration.containsKey(key)) { 158 | throw new RuntimeException("Property: " + key + " not found in configuration."); 159 | } 160 | return configuration.get(key); 161 | } 162 | 163 | private StringSerializer getSerializer(Map configuration, boolean isKey) { 164 | StringSerializer serializer = new StringSerializer(); 165 | serializer.configure(configuration, isKey); 166 | return serializer; 167 | } 168 | } 169 | --------------------------------------------------------------------------------