Module jc_cluster
Either Joins an existing Mnesia cluster, copying tables over to this
replica; or create the first node of the cluster and creates relevant
tables.
Copyright © (C) 2015, Jim Rosenblum
Authors: Jim Rosenblum (jrosenblum@jims-mbp.jhs.local).
Either Joins an existing Mnesia cluster, copying tables over to this
replica; or create the first node of the cluster and creates relevant
tables. Created tables:
- Table key_to_value stores the Map, Key, Value, Create Time Last Update
and a unique record reference. Time-stamps are unix-style,
time-since-epoch, millisecond granularity.
- Table ttl maps the unique record reference to a timer_ref so that,
when the timer goes off, it can find the record that needs to be
deleted - used by the jc_eviction_manager process.
- Table max_ttl holds {map_name, Secs} defining how long items in a
given map are allowed to live before being evicted. The eviction is
done via a process that runs at a configured interval.
- Table stats holds (currently) the datetime of application start.
and a ClusterId - the name of the Node that started the cluster -
that is used to recognize net joins after a split.
- Table ps_sub is a local table and uses a subscription pattern as a key
that is associated to a set of process ids (PIDs) subscribed to the
pattern.
- Table ps_client is a local table and has an entry for each subscribing
PID and stores what mechansim is being used to monitor that node - link
or monitor.
- Table seq stores the highest, per Map sequence number seen. Used by
jc_s api that dissalows put and evict opperation with a sequence
number less than the greatest one seen -- helps with consistency.
- Tables to_index and auto_index support indexing in support of the _match
operations which search by json.path.criteria. auto_index tracks
the frequency of particular json.path.search.criteria and if that use
is sufficient, an index is initiated. The details of the index
are stored in the to_index table.
Desiged to create a diskless cluster (schema is RAM and all tables in RAM)
therefore sys.config MUST CONTAIN {schema_location, ram}.
cluster_id() = node()
change_cluster_id/0 | Change the cluster_id: used when a Node that had been the ClusterId
Node of record dies. |
check/1 | If this node doesn't have the same ClusterId as the supplied one,
its an indciation of a net-join of a orphaned or island node. |
get_cluster_id/0 | Return the current cluster_id or no_exists if this Node hasn't made
it through mnesia cluster creation / join. |
init/0 | Either join an existing Mnesia cluster or start one, creating the tables
as appropriate. |
change_cluster_id() -> ok
Change the cluster_id: used when a Node that had been the ClusterId
Node of record dies.
If this node doesn't have the same ClusterId as the supplied one,
its an indciation of a net-join of a orphaned or island node. Likey to have
consistancy issues. Kill oneself and be restarted by the heartbeat.
Return the current cluster_id or no_exists if this Node hasn't made
it through mnesia cluster creation / join.
Either join an existing Mnesia cluster or start one, creating the tables
as appropriate. Notice that sys.config MUST contain {schema_location, ram}.
Generated by EDoc, Sep 7 2016, 09:32:13.