o3project / odenos

ODENOS(O3 Orchestrator Suite) is a network orchestration framework for controlling multi-layer, multi-domain or multi-vendor networks.
Apache License 2.0
22 stars 18 forks source link

In-memory state persistence #90

Closed araobp closed 9 years ago

araobp commented 9 years ago

In-memory state persistence

A very simple proprietary data base will be implemented for in-memory state persistency as a tentative solution (You could make them stateless and use SQL, Cassandra or Hazelcast instead).

The enhancement:

Since ODENOS runs in multiple threads, you might think that the sequence can be different between the logging time and a restarting time.

However, every RemoteObject runs in a single thread (Actor model) and every request is triggered by an incoming event (Request and Event, i.e., event-driven), so the sequence is always consistent.

While resuming the in-memory state, every RemoteObject instance as an actor is completely isolated from the others.

The only message that is not initiated by an incoming event is "PUT /systemmanager/component_managers/...".

MessageDispatcher instantiates OdenCookBook for each target RemoteObject instance for the resume process:

[OdenCookBook 1] <-----> [RemoteObject instance 1]
[OdenCookBook 2] <-----> [RemoteObject instance 2]
[OdenCookBook 3] <-----> [RemoteObject instance 3]
   :

The Oden cook makes delicious Oden for the guests.

That is something like RANCID using "expect" on Redis to configure ODENOS... OdenCookBook uses Java Iterator.next() (a list of Oden recipes) to make a next action (to make delicious Oden!).

"expect"-like method in OdenCookBook.java

"expect"-like method is used for synchronization between OdenCookBook and a target RemoteObject instance:

OdenCookBook can resume the state if the target RemoteObject instance follows the rule above.

Synchronization with other RemoteObjects (local or remote)

Use ZooKeeper for global locking: while restarting RemoteObject, the other RemoteObject instances cannot send a request or an event to the restarting one. Maybe, all the incoming requests from drivers or RESTTranslator must be blocked while restarting.

Future direction

[Idea 1]

Make all RemoteObject instances stateless and store all states in open source data bases.

[Idea 2]

araobp commented 9 years ago

I have almost completed the coding, but found a problem. Some of ODENOS REST APIs are not transactional: returns 200 OK even if the request has not been confirmed yet.

All the REST APIs and internal APIs should be transactional to keep state consistency among distributed objects.

And it may not be a good idea to keep state of a distributed object in another distributed object. Use a data base supporting HA and Ephemeral mode instead, if it is for a data caching purpose.

Use asynchronous events for state update only.

araobp commented 9 years ago

This feature is very hard to implement, because it is impossible to prove that reconstructing in-memory state from log works for any kinds of ODENOS RemoteObject.

For example, Aggregator behaves very differently from Logic components.

So I stop implementing this.

araobp commented 9 years ago

I have come up with a different method, so I reopen this issue.

araobp commented 9 years ago

It has turned out that a request sending sequence of "operator component" such as Aggregator is inconsistent, so this tool (expect-like tool) does not work very well.

This issue is closed.