cqllock

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

README

cqllock

Command-line tool to create and delete distributed locks using Cassandra and lightweight transactions. These tools are useful for managing distributed jobs on multiple hosts.

Usage

Set up a config file at ~/.cqllockrc or /etc/cqllock.yaml in the following YAML format:

seeds:
- cassandra-seed1.domain.com
- optional-cassandra-seed2.domain.com
- etc
keyspace: keyspace_containing_lock_table
table: lock_table_name
username: optional-username-if-using-auth
password: optional-password-if-using-auth
certpath: /path/to/optional/client/cert/if/using/SSL.pem
keypath: /path/to/optional/client/key/if/using/SSL.key
timeout: 10  # This is the Cassandra connectiont timeout in seconds
retries: 3   # This is the number of times to retry failed Cassandra queries
Possible scenarios
Ensure a process only runs once ever, regardless of how many times or on what host it's attempted:
cqllock ProcessLock && ./myProcess.sh

The first call to cqllock that successfully acquires the lock will hold it forever. Further calls to cqllock will return non-zero, so ./myProcess.sh won't run again. This command can be run on multiple hosts.

Multiple hosts run a job, but only allow one at a time:
cqllock -t 1d -r 5m jobLock && ./myJob.sh ; cqllock -u jobLock

The first host to acquire the lock will hold it until ./myJob.sh finishes. Other hosts will attempt to acquire the lock every five minutes and will wait up to one day trying to reaquire the lock.

There are likely other useful scenarios.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL