Skip to content

avalanche123/cassandra-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cassandra Web

A web interface to Apache Cassandra with AngularJS and server-sent events.

Installation

gem install cassandra-web

Usage

Run cassandra-web -h for help.

Quick Start

cassandra-web

Connect to a Cassandra Cluster requiring authentication

cassandra-web --hosts '10.0.2.2' --port '9042' --username 'cassweb' --password 'myPassword'

How it works

Cassandra web consists of an HTTP API powered by Sinatra and a thin HTML5/JavaScript frontend powered by AngularJS.

When you run cassandra-web script, it starts a Thin web server on a specified address, which defaults to localhost:3000. Openning http://localhost:3000, or whatever address you've specified in the browser, loads the AngularJS application and it starts interacting with the HTTP API of cassandra-web. This api uses the Ruby Driver to communicate with an Apache Cassandra cluster.

When the frontend has fully loaded, it subscribes to /events API endpoint, and begins receiving Server Sent Events. The API uses an event listener, which is registered with the Cluster instance created by the Ruby Driver, to stream events such as schema and node status changes to update the user interface without having to refresh the page.

You can see this feature in action by creating a keyspace using the execute button in the top-right corner of the UI and executing the following statement:

CREATE KEYSPACE example WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}

If the statement executed successfully, you should see a new keyspace show up on the left side of the UI.

Alt text

The web server, Thin, used by cassandra-web is asynchronous and uses only a single thread to handle requests. This enables efficient handling multiple of long running connections, which is a requirement for streaming and Server Sent Events, but also means that the application cannot perform blocking operations during request handling, since it would hang up all connections for the duration of the blocking operation. cassandra-web therefore uses Asynchronous Execution feature of the Ruby Driver to not block on statements execution. The application executes statements asynchronously, receiving a future from the Ruby Driver. It then registers future completion listeners to send a response (or error) whenever it becomes available.

Credits

Cassandra web is possible because of the following awesome technologies (in no particular order):