Code Monkey home page Code Monkey logo

cqllock's Introduction

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.

cqllock's People

Contributors

acm1 avatar saulfloresbluetrail avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.