2017-08-17 21:36:58 +08:00
|
|
|
|
2017-08-09 20:45:23 +08:00
|
|
|
# distributed memgraph
|
|
|
|
|
|
|
|
This subdirectory structure implements distributed infrastructure of Memgraph.
|
|
|
|
|
2017-08-24 16:29:21 +08:00
|
|
|
## Terminology
|
2017-08-17 21:36:58 +08:00
|
|
|
|
|
|
|
* Memgraph Node Id (mnid): a machine (processs) that runs a (distributed) Memgraph program.
|
|
|
|
* Node: a computer that performs (distributed) work.
|
|
|
|
* Vertex: an abstract graph concept.
|
|
|
|
* Reactor: a unit of concurrent execution, lives on its own thread.
|
2017-08-23 21:16:26 +08:00
|
|
|
* Channel: a (one-way) communication abstraction between Reactors. The reactors can be on the same machine or on different processes.
|
2017-08-24 16:29:21 +08:00
|
|
|
* Message: gets sent through channels. Must be serializable if sent via network layer (library: cereal).
|
|
|
|
* Event: arrival of a (subclass of) Message. You can register callbacks. Register exact callbacks (not for derivated/subclasses).
|
2017-08-23 21:16:26 +08:00
|
|
|
* EventStream: read-end of a channel, is owned by exactly one Reactor/thread.
|
|
|
|
* ChannelWriter: write-end of a channel, can be owned (wrote into) by multiple threads.
|
2017-08-17 21:36:58 +08:00
|
|
|
|
2017-08-24 16:29:21 +08:00
|
|
|
## Ownership:
|
2017-08-09 20:45:23 +08:00
|
|
|
|
2017-08-24 16:29:21 +08:00
|
|
|
* System, Distributed are singletons. They should be always alive.
|
|
|
|
* ChannelWriter (write-end) should be lightweight and can be copied arbitrarily.
|
|
|
|
* EventStream (read-end) should never be written by anyone except the owner (the reactor that created it).
|
2017-08-25 21:25:49 +08:00
|
|
|
* In general: always think about who owns an object. Preferably write it in its comment block.
|
2017-08-09 20:45:23 +08:00
|
|
|
|
2017-08-24 16:29:21 +08:00
|
|
|
## Code Conventions
|
|
|
|
|
2017-08-25 21:25:49 +08:00
|
|
|
* Locked: A method having a "Locked..." prefix indicates that you
|
2017-08-24 16:29:21 +08:00
|
|
|
have to lock the appropriate mutex before calling this function.
|
|
|
|
* ALWAYS close channels. You will memory leak if you don't.
|
|
|
|
Reactor::CloseChannel or Subscription::Close will do the trick.
|
|
|
|
|
|
|
|
## Dependencies
|
2017-08-09 20:45:23 +08:00
|
|
|
|
|
|
|
* cereal
|
|
|
|
* <other memgraph dependencies>
|