JC

##Erlang, Distributable, In-Memory Cache

Featruing: Pub/Sub, JSON-query, consistency support, and a simple, TCP interop. protocol.

Build Statushex.pm version

###Features

###Cache Functions (jc)

Consistency Support Functions (jc_s)

Identical to the Create and Evict family of functions of the jc module (see above), except:

###Eviction Manager Functions (jc_eviction_manager)

###Pub/Sub Functions (jc_psub)

###Indexing Functions (jc_store)

###Interoperability: Bridge (jc_bridge)

Interoperability: Socket Protocol

Binary-encoded, string protocol used to provide socket-based interoperability with JC.

All messages to JC are string representations of a tuple. All messages form the caching system to the client are JSON

The protocol defines three message types: CONNECT, CLOSE and COMMAND all of which are binary strings consisting of an 8-byte size followed by the actual command messages.

Responses are also binary strings with an 8-byte size prefix.

The CONNECT command initiates a session,

M = <<"{connect,{version,\"1.0\"}}">> 

Size is 25, so the CONNECT message is:

<<25:8, M/binary>> = 
<<25,40,58,99,111,110,110,101,99,116,32,123,58,118,101,
  114,115,105,111,110,32,49,46,48,125,41>> 

The server will respond to a CONNECT command with either an error or the encoded version of {"version":" "1.0"}

<<15:8, <<"{\"version\":\"1.0\"}">> = 
<<15,123,34,118,101,114,115,105,111,110,34,58,49,46,48,125>>

The CLOSE command closes the socket, ending the session

M = <<"{close}">>

 Size is 7 so the CLOSE message is:
 <<7,123,99,108,111,115,101,125>>

COMMAND messages are string versions of the tuple-messages, which jc_bridge uses, without the self() parameter. For example

{self(), {put, Map, Key, Value}} becomes 
{put, Map, Key, Value}

The return will be an encoded version of a JSON string. A client session might look as follows:

client:send("{put, evs, \"1\", \"{\\\"value:\\\":true}\"}")
<<"{\"ok\":\"1\"}">>

client:send("{get, evs, \"1\"}"),
<<"{\"ok\":"{\\\"value\\\":true}\"}">>

client:send("{put, evs, 1, \"{\\\"value:\\\":true}\"}")
<<"{\"ok\":1}">>

client:send("{get, evs, 1}"),
<<"{\"ok\":"{\\\"value\\\":true}\"}">>

###Configuration

###Application Modules

###Net Split/Join Strategy Mnesia does not merge on its own when a node joins (returns) to a mesh of nodes. There are two situations where this is relevant:

To handle these situations, whenever a cluster is created by a Node (node@123.45.67, for example), it creates a ClusterId - its Node name (node@123.45.67), for that cluster.

Given this ClusterId, we have the following strategy:

  1. Cluster Creation: creates an initial ClusterId;
  2. Nodedown: If the Node that created the cluster dissapears, a surviving Node changes the ClusterId such that ClusterId is now this new Node's name. In the case of a disconnected newtwork, one of the islands will have the original ClusterId Node dissapear, and it will create a new one as described.
  3. Nodeup Whenever a Node appears, an arbitary Node ensures that any Nodes that report a different ClusterId (different than the arbitrary Node's ClusterId) are killed to be restarted by the hearbeat application. If any Nodes required restarting, the entire cache is flushed.

###Build Instructions

###Documentation

[root@dbo1] ./rebar3 edoc

Component and Sequence Diagrams

Components

Sequence Diagrams